2 using System.Collections.Generic;
6 using Microsoft.Xna.Framework;
26 public override bool IsDuplicate<T>(T otherObjective) => otherObjective is
AIObjectiveRepairItems repairObjective && objectiveManager.IsOrder(repairObjective) == objectiveManager.IsOrder(
this);
29 : base(character, objectiveManager, priorityModifier)
38 foreach (
Repairable repairable
in item.Repairables)
44 if (!subObjectives.Contains(objective))
46 subObjectives.Add(objective);
48 objective.Completed += () =>
53 objective.Abandoned += () =>
70 if (item != character.SelectedItem)
94 return item.
Repairables.All(r => !r.IsBelowRepairThreshold);
99 var selectedItem = character.SelectedItem;
100 if (selectedItem !=
null &&
AIObjectiveRepairItem.IsRepairing(character, selectedItem) && selectedItem.ConditionPercentage < 100)
111 bool anyFixers = otherFixers > 0;
112 float ratio = anyFixers ? items / (float)otherFixers : 1;
113 if (objectiveManager.IsOrder(
this))
115 return Targets.Sum(t => 100 - t.ConditionPercentage);
131 float successFactor = MathHelper.Lerp(0, 1, item.
Repairables.Average(r => r.DegreeOfSuccess(character)));
132 if (successFactor < requiredSuccessFactor)
136 return MathHelper.Lerp(0, 100, MathHelper.Clamp(damagePriority * successFactor, 0, 1));
149 if (item ==
null) {
return false; }
150 if (item.
IgnoreByAI(character)) {
return false; }
160 System.Diagnostics.Debug.Assert(item.
Repairables.Any(),
"Invalid target in AIObjectiveRepairItems - the objective should only be checking items that have a Repairable component (Item.RepairableItems)");
An objective that creates specific kinds of subobjectives for specific types of targets,...
Dictionary< T, AIObjective > Objectives
const float RequiredSuccessFactor
static float GetTargetPriority(Item item, Character character, float requiredSuccessFactor=0)
override bool IsDuplicate< T >(T otherObjective)
override Identifier Identifier
AIObjectiveRepairItems(Character character, AIObjectiveManager objectiveManager, float priorityModifier=1, Item prioritizedItem=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 bool AllowInFriendlySubs
static bool NearlyFullCondition(Item item)
override bool IsValidTarget(Item item)
override void CreateObjectives()
static bool IsValidTarget(Item item, Character character)
override bool AllowMultipleInstances
override void OnObjectiveCompleted(AIObjective objective, Item target)
override AIObjective ObjectiveConstructor(Item item)
override IEnumerable< Item > GetList()
List of all possible items of the specified type. Used for filtering the removed objectives.
static bool ViableForRepair(Item item, Character character, HumanAIController humanAIController)
Identifier RelevantSkill
If set, only fix items where required skill matches this.
static readonly List< Character > CharacterList
List< FireSource > FireSources
static int CountBotsInTheCrew(Character character, Func< HumanAIController, bool > predicate=null)
static bool IsActive(Character c)
bool IsItemRepairedByAnother(Item target, out Character other)
AIObjectiveManager ObjectiveManager
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
List< Repairable > Repairables
bool IsInteractable(Character character)
Returns interactibility based on whether the character is on a player team
bool IgnoreByAI(Character character)
static IReadOnlyCollection< Item > RepairableItems
Items that have one more more Repairable component
bool? IsClaimedByBallastFlora
bool IsEntityFoundOnThisSub(MapEntity entity, bool includingConnectedSubs, bool allowDifferentTeam=false, bool allowDifferentType=false)