(ac7ab10b0) Pass AIObjectiveManager reference in the constructors instead of methods so that we can always access it.
This commit is contained in:
@@ -11,7 +11,8 @@ namespace Barotrauma
|
||||
public override bool KeepDivingGearOn => true;
|
||||
private readonly IEnumerable<Pump> pumpList;
|
||||
|
||||
public AIObjectivePumpWater(Character character, string option, float priorityModifier = 1) : base(character, option, priorityModifier)
|
||||
public AIObjectivePumpWater(Character character, AIObjectiveManager objectiveManager, string option, float priorityModifier = 1)
|
||||
: base(character, objectiveManager, priorityModifier, option)
|
||||
{
|
||||
pumpList = character.Submarine.GetItems(true).Select(i => i.GetComponent<Pump>()).Where(p => p != null);
|
||||
}
|
||||
@@ -21,8 +22,9 @@ namespace Barotrauma
|
||||
//availablePumps = allPumps.Where(p => !p.Item.HasTag("ballast") && p.Item.Connections.None(c => c.IsPower && p.Item.GetConnectedComponentsRecursive<Steering>(c).None())).ToList();
|
||||
protected override void FindTargets()
|
||||
{
|
||||
if (option == null) { return; }
|
||||
if (Option == null) { return; }
|
||||
base.FindTargets();
|
||||
// TODO: add dialog when no targets found and the objective is an order
|
||||
}
|
||||
|
||||
protected override bool Filter(Pump pump)
|
||||
@@ -31,7 +33,7 @@ namespace Barotrauma
|
||||
if (pump.Item.Submarine == null) { return false; }
|
||||
if (pump.Item.Submarine.TeamID != character.TeamID) { return false; }
|
||||
if (character.Submarine != null && !character.Submarine.IsEntityFoundOnThisSub(pump.Item, true)) { return false; }
|
||||
if (option == "stoppumping")
|
||||
if (Option == "stoppumping")
|
||||
{
|
||||
if (!pump.IsActive || pump.FlowPercentage == 0.0f) { return false; }
|
||||
}
|
||||
@@ -43,7 +45,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
protected override IEnumerable<Pump> GetList() => pumpList;
|
||||
protected override AIObjective ObjectiveConstructor(Pump pump) => new AIObjectiveOperateItem(pump, character, Option, false) { IsLoop = true };
|
||||
protected override AIObjective ObjectiveConstructor(Pump pump) => new AIObjectiveOperateItem(pump, character, objectiveManager, Option, false) { IsLoop = true };
|
||||
protected override float TargetEvaluation() => targets.Max(t => MathHelper.Lerp(100, 0, t.CurrFlow / t.MaxFlow));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user