3 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
14 private IEnumerable<PowerContainer> batteryList;
17 : base(character, objectiveManager, priorityModifier, option) { }
21 if (battery ==
null) {
return false; }
23 var item = battery.
Item;
24 if (item.IgnoreByAI(character)) {
return false; }
25 if (!item.IsInteractable(character)) {
return false; }
26 if (item.Submarine ==
null) {
return false; }
27 if (item.CurrentHull ==
null) {
return false; }
28 if (item.Submarine.TeamID != character.TeamID) {
return false; }
29 if (character.Submarine !=
null)
31 if (!character.Submarine.IsConnectedTo(item.Submarine)) {
return false; }
33 if (item.ConditionPercentage <= 0) {
return false; }
34 if (item.IsClaimedByBallastFlora) {
return false; }
36 if (IsReady(battery)) {
return false; }
42 if (
Targets.None()) {
return 0; }
43 if (Option ==
"charge")
50 return Targets.Max(t => MathHelper.Lerp(0, 100, t.RechargeRatio));
54 protected override IEnumerable<PowerContainer>
GetList()
56 if (batteryList ==
null)
58 if (character ==
null || character.Submarine ==
null)
62 batteryList = character.Submarine.GetItems(
true).
Select(i => i.GetComponent<
PowerContainer>()).Where(b => b !=
null);
69 if (battery.
HasBeenTuned && character.IsDismissed) {
return true; }
70 if (Option ==
"charge")
81 new AIObjectiveOperateItem(battery, character, objectiveManager, Option,
false, priorityModifier: PriorityModifier)
83 Override = !character.IsDismissed,
84 completionCondition = () => IsReady(battery)
override float GetTargetPriority()
Returns a priority value based on the current targets (e.g. high prio when there's lots of severe fir...
override void OnObjectiveCompleted(AIObjective objective, PowerContainer target)
override Identifier Identifier
override bool AllowAutomaticItemUnequipping
override IEnumerable< PowerContainer > GetList()
List of all possible items of the specified type. Used for filtering the removed objectives.
AIObjectiveChargeBatteries(Character character, AIObjectiveManager objectiveManager, Identifier option, float priorityModifier)
override AIObjective ObjectiveConstructor(PowerContainer battery)
override bool IsValidTarget(PowerContainer battery)
An objective that creates specific kinds of subobjectives for specific types of targets,...
static readonly List< Character > CharacterList
static bool IsActive(Character c)
static bool IsFriendly(Character me, Character other, bool onlySameTeam=false)
virtual bool Select(Character character)
const float aiRechargeTargetRatio