public bool AddModifier(CRModifier newModifier) { if (newModifier == null) { Debug.LogError ("Unable to add null modifier"); return false; } if (_modifiers.Contains(newModifier)) { Debug.LogError ("Modifier has already been added"); return false; } //note: the array is kept ordered by enum value int i = 0; foreach (CRModifier modifier in _modifiers) { if (newModifier.modifierType < modifier.modifierType) break; i++; } _modifiers.Insert(i, newModifier); if (null != OnAddModifier) OnAddModifier(this, newModifier); return true; }
void HandleMaxOnRemoveModifier(CRValue sender, CRModifier modifier) { //maintain the same percentage when the max value changes currentValue = max.activeValue * _percent; }
public bool RemoveModifier(CRModifier modifier) { _modifiers.Remove(modifier); if (null != OnRemoveModifier) OnRemoveModifier(this, modifier); return true; }