Client LuaCsForBarotrauma
ShipIssueWorkerRepairSystems.cs
1 using System.Collections.Generic;
2 using System.Linq;
3 
4 namespace Barotrauma
5 {
7  {
8  readonly List<Item> itemsNeedingRepair = new List<Item>();
9 
11 
12  public override void CalculateGlobalIssue()
13  {
14  itemsNeedingRepair.Clear();
15 
16  foreach (Item item in shipCommandManager.CommandedSubmarine.GetItems(true))
17  {
19  if (AIObjectiveRepairItems.NearlyFullCondition(item)) { continue; }
20  itemsNeedingRepair.Add(item);
21  // merged this logic with AIObjectiveRepairItems
22  }
23 
24  if (itemsNeedingRepair.Any())
25  {
26  itemsNeedingRepair.Sort((x, y) => y.ConditionPercentage.CompareTo(x.ConditionPercentage));
27  float modifiedPercentage = itemsNeedingRepair.TakeLast(3).Average(x => x.ConditionPercentage) * 0.6f + itemsNeedingRepair.TakeLast(10).Average(x => x.ConditionPercentage) * 0.4f;
28  // calculate a modified percentage with the most damaged items, with 60% the weight given to the top 3 damaged and the remaining given to top 10
29  GlobalImportance = 100 - modifiedPercentage;
30  }
31  // this system works reasonably well, though it could give extra importance to repairing critical items like reactors and junction boxes
32  }
33  }
34 
35  class ShipIssueWorkerRepairSystems : ShipIssueWorkerGlobal // this class could be removed, but it might need special behavior later
36  {
37  public ShipIssueWorkerRepairSystems(ShipCommandManager shipCommandManager, Order order, ShipGlobalIssueRepairSystems shipGlobalIssueRepairSystems) : base(shipCommandManager, order, shipGlobalIssueRepairSystems)
38  {
39  }
40  }
41 }
static bool NearlyFullCondition(Item item)
static bool ViableForRepair(Item item, Character character, HumanAIController humanAIController)
ShipCommandManager shipCommandManager
ShipGlobalIssueRepairSystems(ShipCommandManager shipCommandManager)
readonly ShipCommandManager shipCommandManager
ShipIssueWorkerRepairSystems(ShipCommandManager shipCommandManager, Order order, ShipGlobalIssueRepairSystems shipGlobalIssueRepairSystems)
List< Item > GetItems(bool alsoFromConnectedSubs)