Пример #1
0
        void RemovePlayerEffect(Player player, ITemporaryEffect activeeffect)
        {
            ITemporaryEffect effect = playereffects[player.UserID].FirstOrDefault(e => e == activeeffect);

            if (effect == null)
            {
                return;
            }

            effect.WearOff();
            playereffects[player.UserID].Remove(effect);
        }
Пример #2
0
        void ITimerService.Process(double time)
        {
            lock (effectlock) {
                for (int i = monstereffects.Count - 1; i >= 0; --i)
                {
                    ITemporaryEffect effect = monstereffects[i];
                    effect.Time -= time;
                    if (effect.Time <= 0.0)
                    {
                        effect.WearOff();
                        monstereffects.RemoveAt(i);
                    }
                    else
                    {
                        (effect as IStatusEffect)?.ProcessStatusEffect(time);
                    }
                }

                foreach (long player in playereffects.Keys.ToArray())
                {
                    List <ITemporaryEffect> effects = playereffects[player];
                    for (int i = effects.Count - 1; i >= 0; --i)
                    {
                        ITemporaryEffect effect = effects[i];
                        effect.Time -= time;
                        if (effect.Time <= 0.0)
                        {
                            effect.WearOff();
                            effects.RemoveAt(i);
                        }
                        else
                        {
                            (effect as IStatusEffect)?.ProcessStatusEffect(time);
                        }
                    }
                    if (effects.Count == 0)
                    {
                        playereffects.Remove(player);
                    }
                }
            }
        }