/// <summary> /// Removes a Stat Modifier to the Target stat. /// </summary> public void RemoveStatModifier(string targetId, RPGStatModifier mod) { if (mod == null) { return; } _core.RemoveStatModifier(targetId, mod); }
/// <summary> /// Removes a Stat Modifier to the Target stat and then updates the stat's value. /// </summary> public void RemoveStatModifier(string targetId, RPGStatModifier mod, bool update) { if (ContainStat(targetId)) { var modStat = GetStat(targetId) as IStatModifiable; if (modStat != null) { modStat.RemoveModifier(mod); mod.OnModifierRemove(); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStats] Trying to remove Stat Modifier from non modifiable stat \"" + targetId.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to remove Stat Modifier from \"" + targetId.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Adds a Stat Modifier to the Target stat and then updates the stat's value. /// </summary> public void AddStatModifier(string targetId, RPGStatModifier mod, bool update) { if (ContainStat(targetId)) { var modStat = GetStat(targetId) as IStatModifiable; if (modStat != null) { modStat.AddModifier(mod); mod.OnModifierApply(this, targetId); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStats] Trying to add Stat Modifier to non modifiable stat \"" + targetId.ToString() + "\""); } } else { Debug.Log("[RPGStats] Trying to add Stat Modifier to \"" + targetId.ToString() + "\", but RPGStats does not contain that stat"); } }
/// <summary> /// Removes modifier from stat and stops listening to value change event /// </summary> public void RemoveModifier(RPGStatModifier mod) { mod.RemoveValueListener(OnModValueChange); _statMods.Remove(mod); }
/// <summary> /// Adds Modifier to stat and listens to the mod's value change event /// </summary> public void AddModifier(RPGStatModifier mod) { _statMods.Add(mod); mod.AddValueListener(OnModValueChange); }
/// <summary> /// Used to listen to the applied stat modifier OnValueChange events /// </summary> private void OnModValueChange(RPGStatModifier mod) { UpdateModifiers(); }
/// <summary> /// Removes a Stat Modifier to the Target stat and then updates the stat's value. /// </summary> public void RemoveStatModifier(string targetId, RPGStatModifier mod, bool update) { _core.RemoveStatModifier(targetId, mod, update); }
/// <summary> /// Removes a Stat Modifier to the Target stat. /// </summary> public void RemoveStatModifier(string targetId, RPGStatModifier mod) { RemoveStatModifier(targetId, mod, true); }
/// <summary> /// Adds a Stat Modifier to the Target stat. /// </summary> public void AddStatModifier(string targetId, RPGStatModifier mod) { AddStatModifier(targetId, mod, true); }