Last active
November 30, 2017 22:50
-
-
Save Kryzarel/2f3aa1c9ab1685493daea46a874fc9ab to your computer and use it in GitHub Desktop.
Added isDirty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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