FluffyManager.History.UpdateThingCountAndMax C# (CSharp) Method

UpdateThingCountAndMax() public method

public UpdateThingCountAndMax ( int counts, int maxes ) : void
counts int
maxes int
return void
        public void UpdateThingCountAndMax( int[] counts, int[] maxes)
        {
            if( maxes.Length != _chapters.Count || maxes.Length != _chapters.Count )
            {
                Log.Warning( "History updated with incorrect number of chapters" );
            }

            for( int i = 0; i < maxes.Length; i++ )
            {
                if ( _chapters[i].ThingCount.count != counts[i] )
                {
                    _chapters[i].TrueMax = maxes[i];
                    _chapters[i].ThingCount.count = counts[i];
                }
            }
        }

Usage Example

Ejemplo n.º 1
0
        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());
        }