(d16942d30) Simplify.

This commit is contained in:
Joonas Rikkonen
2019-05-16 05:16:13 +03:00
parent bbce41fab0
commit 5b3696f7e4
10 changed files with 134 additions and 976 deletions
@@ -9,17 +9,6 @@ namespace Barotrauma
{
public override string DebugTag => "charge batteries";
private IEnumerable<PowerContainer> batteryList;
private IEnumerable<PowerContainer> BatteryList
{
get
{
if (batteryList == null)
{
batteryList = Item.ItemList.Select(i => i.GetComponent<PowerContainer>()).Where(b => b != null);
}
return batteryList;
}
}
public AIObjectiveChargeBatteries(Character character, AIObjectiveManager objectiveManager, string option, float priorityModifier)
: base(character, objectiveManager, priorityModifier, option) { }
@@ -48,7 +37,14 @@ namespace Barotrauma
}
protected override float TargetEvaluation() => targets.Max(t => 100 - t.ChargePercentage);
protected override IEnumerable<PowerContainer> GetList() => BatteryList;
protected override IEnumerable<PowerContainer> GetList()
{
if (batteryList == null)
{
batteryList = Item.ItemList.Select(i => i.GetComponent<PowerContainer>()).Where(b => b != null);
}
return batteryList;
}
protected override AIObjective ObjectiveConstructor(PowerContainer battery)
=> new AIObjectiveOperateItem(battery, character, objectiveManager, Option, false, priorityModifier: PriorityModifier) { IsLoop = true };
@@ -10,17 +10,6 @@ namespace Barotrauma
public override string DebugTag => "pump water";
public override bool KeepDivingGearOn => true;
private IEnumerable<Pump> pumpList;
private IEnumerable<Pump> PumpList
{
get
{
if (pumpList == null)
{
pumpList = character.Submarine.GetItems(true).Select(i => i.GetComponent<Pump>()).Where(p => p != null);
}
return pumpList;
}
}
public AIObjectivePumpWater(Character character, AIObjectiveManager objectiveManager, string option, float priorityModifier = 1)
: base(character, objectiveManager, priorityModifier, option) { }
@@ -52,8 +41,15 @@ namespace Barotrauma
}
return true;
}
protected override IEnumerable<Pump> GetList() => PumpList;
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));
protected override IEnumerable<Pump> GetList()
{
if (pumpList == null)
{
pumpList = character.Submarine.GetItems(true).Select(i => i.GetComponent<Pump>()).Where(p => p != null);
}
return pumpList;
}
}
}