Skip to content

Instantly share code, notes, and snippets.

@Kryzarel
Created November 30, 2017 23:19
Show Gist options
  • Save Kryzarel/fbd1ff66480a79bda17b6bdfec505239 to your computer and use it in GitHub Desktop.
Save Kryzarel/fbd1ff66480a79bda17b6bdfec505239 to your computer and use it in GitHub Desktop.
Added sorting to statModifiers
// 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