protected override void Update(long timePassed)
 {
     if (BuffStack.Any() && timePassed > 0)
     {
         List <BuffStackItemID> BuffStackToUse = BuffStack;
         long diff = Math.Min(BuffStackToUse.Min(x => x.Duration), timePassed);
         if (diff == 0)
         {
             BuffStackToUse = BuffStack.Where(x => x.Duration > 0).ToList();
             if (!BuffStackToUse.Any())
             {
                 return;
             }
             diff = Math.Min(BuffStackToUse.Min(x => x.Duration), timePassed);
         }
         var toAdd = new BuffSimulationItemIntensity(BuffStackToUse);
         GenerationSimulation.Add(toAdd);
         long leftOver = timePassed - diff;
         if (toAdd.End > toAdd.Start + diff)
         {
             toAdd.OverrideEnd(toAdd.Start + diff);
         }
         // Subtract from each from the original stack so that everyone's time start are shifted
         foreach (BuffStackItemID buffStackItem in BuffStack)
         {
             buffStackItem.Shift(diff, diff);
         }
         Update(leftOver);
     }
 }
コード例 #2
0
 protected override void Update(long timePassed)
 {
     if (BuffStack.Count > 0 && timePassed > 0)
     {
         var toAdd = new BuffSimulationItemIntensity(BuffStack);
         GenerationSimulation.Add(toAdd);
         long diff     = Math.Min(BuffStack.Min(x => x.Duration), timePassed);
         long leftOver = timePassed - diff;
         if (toAdd.End > toAdd.Start + diff)
         {
             toAdd.OverrideEnd(toAdd.Start + diff);
         }
         // Subtract from each
         for (int i = BuffStack.Count - 1; i >= 0; i--)
         {
             BuffStack[i].Shift(diff, diff);
         }
         for (int i = BuffStack.Count - 1; i >= 0; i--)
         {
             if (BuffStack[i].Duration == 0)
             {
                 BuffStack[i].Shift(0, -leftOver);
             }
         }
         Update(leftOver);
     }
 }
 protected override void Update(long timePassed)
 {
     if (BuffStack.Any() && timePassed > 0)
     {
         long diff         = timePassed;
         long leftOver     = 0;
         var  activeStacks = BuffStack.Where(x => x.Active && x.Duration > 0).Take(_capacity).ToList();
         if (activeStacks.Any())
         {
             var toAdd = new BuffSimulationItemIntensity(activeStacks);
             GenerationSimulation.Add(toAdd);
             long currentDur = activeStacks.Min(x => x.Duration);
             long timeDiff   = currentDur - timePassed;
             if (timeDiff < 0)
             {
                 diff     = currentDur;
                 leftOver = timePassed - diff;
             }
             if (toAdd.End > toAdd.Start + diff)
             {
                 toAdd.OverrideEnd(toAdd.Start + diff);
             }
             foreach (BuffStackItemID buffStackItem in activeStacks)
             {
                 buffStackItem.Shift(0, diff);
             }
         }
         foreach (BuffStackItemID buffStackItem in BuffStack)
         {
             buffStackItem.Shift(diff, 0);
         }
         Update(leftOver);
     }
 }