Skip to content

Instantly share code, notes, and snippets.

@Kryzarel
Last active November 30, 2017 22:50
Show Gist options
  • Save Kryzarel/2f3aa1c9ab1685493daea46a874fc9ab to your computer and use it in GitHub Desktop.
Save Kryzarel/2f3aa1c9ab1685493daea46a874fc9ab to your computer and use it in GitHub Desktop.
Added isDirty
// Add these variables
private bool isDirty = true;
private float _value;
// Change the Value property to this
public float Value {
get {
if(isDirty) {
_value = CalculateFinalValue();
isDirty = false;
}
return _value;
}
}
// Change the AddModifier method
public void AddModifier(StatModifier mod)
{
isDirty = true;
statModifiers.Add(mod);
}
// And change the RemoveModifier method
public bool RemoveModifier(StatModifier mod)
{
isDirty = true;
return statModifiers.Remove(mod);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment