Created
November 30, 2017 23:19
-
-
Save Kryzarel/fbd1ff66480a79bda17b6bdfec505239 to your computer and use it in GitHub Desktop.
Added sorting to statModifiers
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
// Change the AddModifiers method to this | |
public void AddModifier(StatModifier mod) | |
{ | |
isDirty = true; | |
statModifiers.Add(mod); | |
statModifiers.Sort(CompareModifierOrder); | |
} | |
// Add this method to the CharacterStat class | |
private int CompareModifierOrder(StatModifier a, StatModifier b) | |
{ | |
if (a.Order < b.Order) | |
return -1; | |
else if (a.Order > b.Order) | |
return 1; | |
return 0; // if (a.Order == b.Order) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment