/// <summary> /// Removes a modifier from the System Component. /// </summary> /// <param name="modifier">The ISystemModifier to remove. Uses Equals().</param> public virtual void RemoveModifier(SystemModifier modifier) { if (_modifiers.Remove(modifier) && _isActive) { RecalculateStat(modifier.stat); } }
/// <summary> /// Removes a modifier from the System Component. /// </summary> /// <param name="modifier">The ISystemModifier to remove. Uses Equals().</param> public void RemoveModifier(SystemModifier modifier) { if (_modifiers.Remove(modifier)) { RecalculateStat(modifier.stat); } }
/// <summary> /// Replaces an existing modifier with a new one, or adds a new one if it doesn't exist yet. /// </summary> /// <param name="modifier">The SystemModifier to add or replace.</param> public virtual void ReplaceModifier(SystemModifier modifier) { _modifiers.Replace(modifier); if (_isActive) { RecalculateStat(modifier.stat); } }
/// <summary> /// Adds a modifier to the System Component. /// </summary> /// <param name="modifier">The SystemModifier to add.</param> public virtual void AddModifier(SystemModifier modifier) { _modifiers.Add(modifier); if (_isActive) { RecalculateStat(modifier.stat); } }
/// <summary> /// Get the index of a SystemModifier in the list. /// </summary> /// <returns>The index of the modifier or -1 if not found.</returns> public int IndexOf(SystemModifier modifier) { int index = 0; foreach (SystemModifier mod in _modifiers) { if (mod.id == modifier.id) { return(index); } ++index; } return(-1); }
/// <summary> /// Remove an existing modifier from the list. Uses the /// <c>Equals()</c> method of the ISystemModifier. /// </summary> /// <returns>True if a modifier was found and removed.</returns> public bool Remove(SystemModifier modifier) { if (_modifiers.Count == 0) { return(false); } int index = IndexOf(modifier); if (index != -1) { ResetCache(modifier.stat); _modifiers.RemoveAt(index); return(true); } return(false); }
/// <summary> /// Either replaces an existing modifier, or adds a new one if it doesn't exist yet. /// </summary> /// <returns>True if a modifier was replaced, false if a new one was added.</returns> public bool Replace(SystemModifier modifier) { ResetCache(modifier.stat); if (_modifiers.Count > 0) { // try and find the modifier to replace. int index = IndexOf(modifier); if (index != -1) { _modifiers[index] = modifier; return(true); } } // Otherwise, just add the modifier. _modifiers.Add(modifier); return(false); }
/// <summary> /// Adds a new ISystemModifier to the list. /// </summary> public void Add(SystemModifier modifier) { ResetCache(modifier.stat); _modifiers.Add(modifier); }
/// <summary> /// Replaces an existing modifier with a new one, or adds a new one if it doesn't exist yet. /// </summary> /// <param name="modifier">The SystemModifier to add or replace.</param> public void ReplaceModifier(SystemModifier modifier) { _modifiers.Replace(modifier); RecalculateStat(modifier.stat); }
/// <summary> /// Adds a modifier to the System Component. /// </summary> /// <param name="modifier">The SystemModifier to add.</param> public void AddModifier(SystemModifier modifier) { _modifiers.Add(modifier); RecalculateStat(modifier.stat); }