/// <summary> /// Removes the stat modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> /// <param name="update">If set to <c>true</c> update.</param> public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod, bool update) { if (ContainStat(target)) { var modStat = GetStat(target) as IStatModifiable; if (modStat != null) { modStat.RemoveModifier(mod); if (update == true) { modStat.UpdateModifiers(); } } else { Debug.Log("[RPGStatCollection] Trying to remove Stat Modifier to non modifiable stat\"" + target.ToString() + "\""); } } else { Debug.Log("[RPGStatCollection] Trying to remove Stat Modifier to \"" + target.ToString() + "\", but RPGStatCollection does not contain that stat"); } }
/// <summary> /// Removes a Stat Modifier to the Target stat and then updates the stat's value. /// </summary> public void RemoveStatModifier(int 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(int 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 the stat modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> public void RemoveStatModifier(RPGStatType target, RPGStatModifier mod) { RemoveStatModifier(target, mod, false); }
/// <summary> /// Adds the modifier. /// </summary> /// <param name="target">Target.</param> /// <param name="mod">Mod.</param> public void AddModifier(RPGStatType target, RPGStatModifier mod) { AddModifier(target, mod, false); }
/// <summary> /// Removes the modifier. /// </summary> /// <param name="mod">Mod.</param> public void RemoveModifier(RPGStatModifier mod) { _statMods.Remove(mod); mod.OnValueChange -= OnModValueChange; }
/// <summary> /// Adds the modifier. /// </summary> /// <param name="mod">Mod.</param> public void AddModifier(RPGStatModifier mod) { _statMods.Add(mod); mod.OnValueChange += OnModValueChange; }
/// <summary> /// Removes a Stat Modifier to the Target stat. /// </summary> public void RemoveStatModifier(int targetId, RPGStatModifier mod) { RemoveStatModifier(targetId, mod, false); }
/// <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 a Stat Modifier to the Target stat. /// </summary> public void AddStatModifier(int targetId, RPGStatModifier mod) { AddStatModifier(targetId, mod, false); }
/// <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(); }
public RPGStatModifierContext(int assignedStatId, RPGStatModifier modifier) { this.AssignedStatId = assignedStatId; this.StatModifier = modifier; }
static public void RemoveStatModifier(this RPGStatCollection collection, RPGStatType statType, RPGStatModifier mod, bool update) { collection.RemoveStatModifier((int)statType, mod, update); }
static public void AddStatModifier(this RPGStatCollection collection, RPGStatType statType, RPGStatModifier mod) { collection.AddStatModifier((int)statType, mod); }