/// <summary> /// End an active effect /// </summary> /// <param name="effect"></param> public void EndEffect(StatEffect effect) { StatValue stat; List <DamageModifier> modifiers; // Find modifier targets foreach (StatModifier mod in effect.modifiers) { stat = FindStat(mod.affectedStat); if (stat != null) { stat.RemoveModifier(mod); } modifiers = FindDamageModifiers(mod.affectedStat); foreach (DamageModifier dm in modifiers) { dm.RemoveModifier(mod); } } if (effect.effectParticles != null) { Destroy(effect.effectParticles); } Effects.Remove(effect); onEffectEnded?.Invoke(effect); effect.onEnd?.Invoke(); }
// updates internal static void Update() { FrameworkDispatcher.Update(); // to let sound update List <int> toKill = new List <int>(); foreach (var sound in ActiveSounds) { if (sound.Value == null || sound.Value.Instance.State == SoundState.Stopped) { toKill.Add(sound.Key); EffectEnded?.Invoke(null, new SoundEventArgs(sound.Key)); } else if (UsePostionalSound && NeedListenerUpdate) { if (sound.Value.Emitter != null) { sound.Value.Instance.Apply3D(Listener, sound.Value.Emitter); } } } NeedListenerUpdate = false; foreach (var sound in toKill) { ActiveSounds.Remove(sound); } }
public static void StopSound(int index) { if (ActiveSounds.ContainsKey(index)) { ActiveSounds[index].Instance.Stop(); ActiveSounds.Remove(index); EffectEnded?.Invoke(null, new SoundEventArgs(index)); } }
internal void SendEffectEnd() { EffectEnded?.Invoke(this, EventArgs.Empty); }