public void RemoveModifier(string id) { for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { FloatModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; BaseValue = BaseValue; break; } } }
public void ClearModifier(string id) { modifiers = modifiers ?? new List <FloatModifier>(); for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { FloatModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; modifiers.RemoveAt(i); break; } } }
public void SetModifier(string id, FloatModifier modifier) { modifiers = modifiers ?? new List <FloatModifier>(); modifier = new FloatModifier(id, modifier); for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { FloatModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; break; } } modifiers.Add(modifier); flatBonus += modifier.flatBonus; percentBonus += modifier.percentBonus; }
public void SetModifier(string id, FloatModifier modifier) { modifier = new FloatModifier(id, modifier); for (int i = 0; i < modifiers.Count; i++) { if (modifiers[i].id == id) { FloatModifier prev = modifiers[i]; flatBonus -= prev.flatBonus; percentBonus -= prev.percentBonus; break; } } modifiers.Add(modifier); flatBonus += modifier.flatBonus; percentBonus += modifier.percentBonus; BaseValue = BaseValue; //weird but works }