internal void NotifyEffectDestroy(EffectOverTime a_effect) { List <IntModifierFromEffect> modifiersToRemove = new List <IntModifierFromEffect>(); foreach (IntModifierFromEffect each in _bonusList) { if (each.source == a_effect) { modifiersToRemove.Add(each); } } List <IntModifierFromEffect> reductionsToRemove = new List <IntModifierFromEffect>(); foreach (IntModifierFromEffect each in _malusList) { if (each.source == a_effect) { reductionsToRemove.Add(each); } } foreach (IntModifierFromEffect each in modifiersToRemove) { _bonusList.Remove(each); _needsToBeCompute = true; } foreach (IntModifierFromEffect each in reductionsToRemove) { _malusList.Remove(each); _needsToBeCompute = true; } }
internal EffectOverTimeReport TryApplyEffect(EffectOverTime a_effect) { EffectOverTimeReport report; if (a_effect.conf.stackMethod == EUnitEffectStackMethod.OnePerUnit) { EffectOverTime previousEffect = GetEffectOfType(a_effect); if (previousEffect != null) { ReplaceEffect(previousEffect, a_effect); report = a_effect.Refresh(); } else { AddNewEffect(a_effect); report = a_effect.Apply(); } } else { report = new EffectOverTimeReport(); report.successfullyApplied = false; } return(report); }
/// <summary> /// Will apply a new effect to this unit. The unit will manage it from here. /// </summary> protected void AddNewEffect(EffectOverTime a_effect) { _effects.Add(a_effect); if (!a_effect.IsPrepared) { a_effect.Prepare(_unit); } }
internal void ReplaceEffect(EffectOverTime a_previous, EffectOverTime a_new) { if (!a_new.IsPrepared) { a_new.Prepare(_unit, a_previous.CurrentStackCount); } a_new.timeElapsed = a_previous.timeElapsed; RemoveEffect(a_previous); AddNewEffect(a_new); }
internal void Add(EffectOverTime newEffect) { var sameEffect = effects.Find(eff => eff.type == newEffect.type); if (sameEffect != null) { sameEffect.AddStackElement(newEffect); } else { effects.Add(newEffect); } }
/// <summary> /// Returns null if no effect with the same conf & source is found in the active effects. /// Returns the matching effect otherwise. /// </summary> internal EffectOverTime GetEffectOfType(EffectOverTime a_effect) { foreach (EffectOverTime each in _effects) { if (each.conf == a_effect.conf && each.attackInfos.source == a_effect.attackInfos.source) { return(each); } } return(null); }
/// <summary> /// Returns an EffectOverTime /// </summary> internal virtual EffectOverTime Compute(AttackInfos a_attackInfos) { EffectOverTime effect = new EffectOverTime(); effect.attackInfos = a_attackInfos; effect.conf = this; foreach (EffectConfWrapper each in effects) { effect.effects.Add(each.Compute(a_attackInfos)); } return(effect); }
internal EffectStackElement(EffectOverTime effect) { delay = effect.type.delay; duration = effect.type.duration; value = effect.type.value; }
internal void AddStackElement(EffectOverTime effect) { stack.Add(new EffectStackElement(effect)); UpdateStack(); }
internal void RemoveEffect(EffectOverTime a_effect) { _effects.Remove(a_effect); a_effect.Destroy(); }