4 using System.Collections.Immutable;
20 private readonly
Item targetItem;
54 this.targetItem = targetItem;
55 this.sourceContainer = sourceContainer;
56 this.targetContainer = targetContainer;
65 this.itemIdentifiers = itemIdentifiers;
66 for (
int i = 0; i < itemIdentifiers.Length; i++)
68 itemIdentifiers[i] = itemIdentifiers[i];
70 this.sourceContainer = sourceContainer;
71 this.targetContainer = targetContainer;
76 protected override void Act(
float deltaTime)
78 Item itemToDecontain =
80 sourceContainer.Inventory.FindItem(i => itemIdentifiers.Any(
id => i.Prefab.Identifier ==
id || i.HasTag(
id) && !i.IgnoreByAI(
character)), recursive:
false);
82 if (itemToDecontain ==
null)
92 if (targetContainer ==
null)
94 if (sourceContainer ==
null)
106 else if (targetContainer.Inventory.Contains(itemToDecontain))
113 TryAddSubObjective(ref getItemObjective,
121 onAbandon: () =>
Abandon =
true);
124 if (targetContainer !=
null)
126 TryAddSubObjective(ref containObjective,
136 ignoredContainerIdentifiers = sourceContainer?.Item.Prefab.Identifier.ToEnumerable().ToImmutableHashSet()
139 onAbandon: () =>
Abandon =
true);
151 getItemObjective =
null;
152 containObjective =
null;
override bool AllowWhileHandcuffed
override Identifier Identifier
Func< bool > AbandonGetItemDialogueCondition
AIObjectiveDecontainItem(Character character, Identifier itemIdentifier, AIObjectiveManager objectiveManager, ItemContainer sourceContainer, ItemContainer targetContainer=null, float priorityModifier=1)
override bool CheckObjectiveState()
Should return whether the objective is completed or not.
AIObjectiveDecontainItem(Character character, Identifier[] itemIdentifiers, AIObjectiveManager objectiveManager, ItemContainer sourceContainer, ItemContainer targetContainer=null, float priorityModifier=1)
string AbandonGetItemDialogueIdentifier
ItemContainer TargetContainer
bool RemoveExistingWhenNecessary
Should existing item(s) be removed from the targetContainer if the targetItem won't fit otherwise?
AIObjectiveGetItem GetItemObjective
AIObjectiveContainItem ContainObjective
Func< Item, bool > RemoveExistingPredicate
AIObjectiveDecontainItem(Character character, Item targetItem, AIObjectiveManager objectiveManager, ItemContainer sourceContainer=null, ItemContainer targetContainer=null, float priorityModifier=1)
bool DropIfFails
If true drops the item when containing the item fails. In both cases abandons the objective....
override void OnAbandon()
Func< Item, float > GetItemPriority
override void Act(float deltaTime)
readonly Character character
readonly AIObjectiveManager objectiveManager
void Drop(Character dropper, bool createNetworkEvent=true, bool setTransform=true)
bool IgnoreByAI(Character character)
bool IsOwnedBy(Entity entity)
Item(ItemPrefab itemPrefab, Vector2 position, Submarine submarine, ushort id=Entity.NullEntityID, bool callOnItemLoaded=true)