コード例 #1
0
        // Public Methods

        protected override void Update(long timePassed)
        {
            if (BoonStack.Count > 0)
            {
                var toAdd = new BoonSimulationItemDuration(BoonStack[0]);
                if (GenerationSimulation.Count > 0)
                {
                    var last = GenerationSimulation.Last();
                    if (last.End > toAdd.Start)
                    {
                        last.SetEnd(toAdd.Start);
                    }
                }
                GenerationSimulation.Add(toAdd);
                BoonStack[0] = new BoonStackItem(BoonStack[0], timePassed, timePassed);
                long diff = timePassed - Math.Abs(Math.Min(BoonStack[0].BoonDuration, 0));
                for (int i = 1; i < BoonStack.Count; i++)
                {
                    BoonStack[i] = new BoonStackItem(BoonStack[i], diff, 0);
                }
                if (BoonStack[0].BoonDuration <= 0)
                {
                    // Spend leftover time
                    long leftover = Math.Abs(BoonStack[0].BoonDuration);
                    BoonStack.RemoveAt(0);
                    Update(leftover);
                }
            }
        }
コード例 #2
0
        // Public Methods

        protected override void Update(long timePassed)
        {
            if (BoonStack.Count > 0 && timePassed > 0)
            {
                _lastSrcRemoves.Clear();
                var toAdd = new BoonSimulationItemIntensity(BoonStack);
                if (GenerationSimulation.Count > 0)
                {
                    BoonSimulationItem last = GenerationSimulation.Last();
                    if (last.End > toAdd.Start)
                    {
                        last.SetEnd(toAdd.Start);
                    }
                }
                GenerationSimulation.Add(toAdd);
                long diff     = Math.Min(BoonStack.Min(x => x.BoonDuration), timePassed);
                long leftOver = timePassed - diff;
                // Subtract from each
                for (int i = BoonStack.Count - 1; i >= 0; i--)
                {
                    var item = new BoonStackItem(BoonStack[i], diff, diff);
                    BoonStack[i] = item;
                    if (item.BoonDuration == 0)
                    {
                        _lastSrcRemoves.Add(item.SeedSrc);
                    }
                }
                BoonStack.RemoveAll(x => x.BoonDuration == 0);
                Update(leftOver);
            }
        }
コード例 #3
0
        // Public Methods

        protected override void Update(long timePassed)
        {
            if (BoonStack.Count > 0 && timePassed > 0)
            {
                _lastSrcRemove = 0;
                var toAdd = new BoonSimulationItemDuration(BoonStack[0]);
                if (GenerationSimulation.Count > 0)
                {
                    var last = GenerationSimulation.Last();
                    if (last.End > toAdd.Start)
                    {
                        last.SetEnd(toAdd.Start);
                    }
                }
                GenerationSimulation.Add(toAdd);
                long timeDiff = BoonStack[0].BoonDuration - timePassed;
                long diff     = 0;
                long leftOver = 0;
                if (timeDiff < 0)
                {
                    diff     = BoonStack[0].BoonDuration;
                    leftOver = timePassed - diff;
                }
                else
                {
                    diff = timePassed;
                }
                BoonStack[0] = new BoonStackItem(BoonStack[0], diff, diff);
                for (int i = 1; i < BoonStack.Count; i++)
                {
                    BoonStack[i] = new BoonStackItem(BoonStack[i], diff, 0);
                }
                if (BoonStack[0].BoonDuration == 0)
                {
                    _lastSrcRemove = BoonStack[0].SeedSrc;
                    BoonStack.RemoveAt(0);
                }
                Update(leftOver);
            }
        }
コード例 #4
0
        // Public Methods

        protected override void Update(long timePassed)
        {
            if (BoonStack.Count > 0)
            {
                var toAdd = new BoonSimulationItemIntensity(BoonStack);
                if (GenerationSimulation.Count > 0)
                {
                    BoonSimulationItem last = GenerationSimulation.Last();
                    if (last.End > toAdd.Start)
                    {
                        last.SetEnd(toAdd.Start);
                    }
                }
                GenerationSimulation.Add(toAdd);
                // Subtract from each
                for (int i = BoonStack.Count - 1; i >= 0; i--)
                {
                    var item = new BoonStackItem(BoonStack[i], timePassed, timePassed);
                    BoonStack[i] = item;
                }
                BoonStack.RemoveAll(x => x.BoonDuration < 1);
            }
        }
コード例 #5
0
 public override void Extend(long extension, long oldValue, ushort src, long start)
 {
     if ((BoonStack.Count > 0 && oldValue > 0) || BoonStack.Count == Capacity)
     {
         BoonStackItem minItem = BoonStack.MinBy(x => Math.Abs(x.TotalBoonDuration() - oldValue));
         if (minItem != null)
         {
             minItem.Extend(extension, src, start);
         }
     }
     else
     {
         if (_lastSrcRemoves.Count > 0)
         {
             Add(oldValue + extension, src, _lastSrcRemoves.First(), start);
             _lastSrcRemoves.RemoveAt(0);
         }
         else
         {
             Add(oldValue + extension, src, src, start);
         }
     }
 }