From 406562f5229ae8eed45e2e994e9007295e6beb1c Mon Sep 17 00:00:00 2001 From: Regalis11 Date: Thu, 15 Jun 2023 16:50:39 +0300 Subject: [PATCH] Removed a duplicate class --- .../EventActions/CheckSelectedItemAction.cs | 94 ------------------- 1 file changed, 94 deletions(-) delete mode 100644 Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/CheckSelectedItemAction.cs diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/CheckSelectedItemAction.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/CheckSelectedItemAction.cs deleted file mode 100644 index 6de01c0e8..000000000 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/CheckSelectedItemAction.cs +++ /dev/null @@ -1,94 +0,0 @@ -using Barotrauma.Extensions; -using System.Collections.Generic; - -namespace Barotrauma -{ - class CheckSelectedAction : BinaryOptionAction - { - public enum SelectedItemType { Primary, Secondary, Any }; - - [Serialize("", IsPropertySaveable.Yes)] - public Identifier CharacterTag { get; set; } - - [Serialize("", IsPropertySaveable.Yes)] - public Identifier TargetTag { get; set; } - - [Serialize(SelectedItemType.Any, IsPropertySaveable.Yes)] - public SelectedItemType ItemType { get; set; } - - public CheckSelectedAction(ScriptedEvent parentEvent, ContentXElement element) : base(parentEvent, element) { } - - protected override bool? DetermineSuccess() - { - Character character = null; - if (!CharacterTag.IsEmpty) - { - foreach (var t in ParentEvent.GetTargets(CharacterTag)) - { - if (t is Character c) - { - character = c; - break; - } - } - } - if (character == null) - { - DebugConsole.LogError($"CheckSelectedItemAction error: {GetEventName()} uses a CheckSelectedItemAction but no valid character was found for tag \"{CharacterTag}\"! This will cause the check to automatically fail."); - return false; - } - if (!TargetTag.IsEmpty) - { - IEnumerable targets = ParentEvent.GetTargets(TargetTag); - if (targets.None()) - { - DebugConsole.LogError($"CheckSelectedItemAction error: {GetEventName()} uses a CheckSelectedItemAction but no valid targets were found for tag \"{TargetTag}\"! This will cause the check to automatically fail."); - return false; - } - foreach (var target in targets) - { - if (target is Character targetCharacter) - { - if (ItemType == SelectedItemType.Any && character.SelectedCharacter == targetCharacter) { return true; } - continue; - } - if (target is not Item targetItem) - { - continue; - } - if (IsSelected(targetItem)) - { - return true; - } - } - return false; - - bool IsSelected(Item item) - { - return ItemType switch - { - SelectedItemType.Any => character.IsAnySelectedItem(item), - SelectedItemType.Primary => character.SelectedItem == item, - SelectedItemType.Secondary => character.SelectedSecondaryItem == item, - _ => false - }; - } - } - else - { - return ItemType switch - { - SelectedItemType.Any => !character.HasSelectedAnyItem, - SelectedItemType.Primary => character.SelectedItem == null, - SelectedItemType.Secondary => character.SelectedSecondaryItem == null, - _ => false - }; - } - } - - private string GetEventName() - { - return ParentEvent?.Prefab?.Identifier is { IsEmpty: false } identifier ? $"the event \"{identifier}\"" : "an unknown event"; - } - } -} \ No newline at end of file