4 using System.Collections.Generic;
5 using System.Collections.Immutable;
16 private ImmutableArray<Identifier> TargetContainerTags {
get; }
17 private List<Item> TargetContainers {
get; } =
new List<Item>();
27 : base(character, objectiveManager, priorityModifier, option)
29 if ((containerTags ==
null || containerTags.None()) && targetContainer ==
null)
36 TargetContainerTags = containerTags.ToImmutableArray();
38 if (targetContainer !=
null)
40 TargetContainers.Add(targetContainer);
47 TargetContainers.Add(item);
56 if (!
IsValidTarget(target, character,
null, TargetCondition)) {
return false; }
64 if (item ==
null || item.
Removed) {
return false; }
67 if (container.Inventory ==
null) {
return false; }
68 if (targetCondition.HasValue && container.Inventory.IsFull() && container.Inventory.AllItems.None(i =>
ItemMatchesTargetCondition(i, targetCondition.Value))) {
return false; }
72 if (!item.
HasAccess(character)) {
return false; }
74 if (item.GetComponent<
Powered>() is { PowerConsumption: > 0, HasPower: false }) {
return false; }
80 if(item ==
null) {
return false; }
83 return targetCondition
switch
87 _ =>
throw new NotImplementedException(),
90 catch (NotImplementedException)
93 DebugConsole.LogError($
"Unexpected target condition \"{targetCondition}\" in AIObjectiveLoadItems.ItemMatchesTargetCondition");
99 protected override IEnumerable<Item>
GetList() => TargetContainers;
102 =>
new AIObjectiveLoadItem(target, TargetContainerTags, TargetCondition, Option, character, objectiveManager, PriorityModifier);
109 if (
Targets.None()) {
return 0; }
110 if (objectiveManager.IsOrder(
this))
112 float prio = objectiveManager.GetOrderPriority(
this);
113 if (subObjectives.All(so => so.SubObjectives.None() || so.Priority <= 0))
static bool IsItemInsideValidSubmarine(Item item, Character character)
static bool ItemMatchesTargetCondition(Item item, ItemCondition targetCondition)
override IEnumerable< Item > GetList()
List of all possible items of the specified type. Used for filtering the removed objectives.
static bool IsValidTarget(Item item, Character character, ImmutableArray< Identifier >? targetContainerTags=null, ItemCondition? targetCondition=null)
override float GetTargetPriority()
Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fir...
override float IgnoreListClearInterval
override AIObjective ObjectiveConstructor(Item target)
override bool IsValidTarget(Item target)
override Identifier Identifier
AIObjectiveLoadItems(Character character, AIObjectiveManager objectiveManager, Identifier option, ImmutableArray< Identifier > containerTags, Item targetContainer=null, float priorityModifier=1)
override bool ResetWhenClearingIgnoreList
override void OnObjectiveCompleted(AIObjective objective, Item target)
An objective that creates specific kinds of subobjectives for specific types of targets,...
const float RunPriority
Objectives with a priority equal to or higher than this make the character run.
static readonly List< Character > CharacterList
List< FireSource > FireSources
static bool IsActive(Character c)
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
bool? IsClaimedByBallastFlora
static readonly List< Item > ItemList
Entity GetRootInventoryOwner()
bool HasAccess(Character character)
Used by the AI to check whether they can (in principle) and are allowed (in practice) to interact wit...
bool TargetItemsMatchItem(Item item, Identifier option=default)