public override void Tick() { base.Tick(); // once in a while, update the list of comps, and history thingcounts + theoretical maxes (where known). if (Find.TickManager.TicksGame % 2000 == 0) { #if DEBUG_POWER Log.Message(string.Join(", ", _traderDefs.Select(d => d.LabelCap).ToArray())); #endif // get all existing comps for all building defs that have power related comps (in essence, get all powertraders) RefreshCompLists(); // update these counts in the history tracker + reset maxes if count changed. tradingHistory.UpdateThingCountAndMax(_traders.Select(list => list.Count).ToArray(), _traders.Select(list => 0).ToArray()); // update theoretical max for batteries, and reset observed max. overallHistory.UpdateMax(0, 0, (int) _batteries.Sum( list => list.Sum(battery => battery.Props.storedEnergyMax))); } // update the history tracker. int[] trade = GetCurrentTrade(); tradingHistory.Update(trade); overallHistory.Update(trade.Where(i => i > 0).Sum(), trade.Where(i => i < 0).Sum(Math.Abs), GetCurrentBatteries().Sum()); }