public void AddEffect(ITemporaryEffect effect) { ITemporaryEffect oldeffects = effects.FirstOrDefault(e => e.GetType() == effect.GetType()); if (oldeffects != null) { context.GetModule <EffectModule>().RemoveEffect(oldeffects); } context.GetModule <EffectModule>().AddMonsterEffect(effect); effects.Add(effect); }
/// <summary> /// adds an active player effect /// </summary> /// <param name="playerid">id of player</param> /// <param name="effect">effect to add</param> public void AddPlayerEffect(long playerid, ITemporaryEffect effect) { lock (effectlock) { List <ITemporaryEffect> effects; if (!playereffects.TryGetValue(playerid, out effects)) { playereffects[playerid] = effects = new List <ITemporaryEffect>(); } effects.RemoveAll(e => e.GetType() == effect.GetType()); effects.Add(effect); effect.Initialize(); } }