I was wondering whether there was any particular reason why we don’t use tuples within the GetStat function? Currently, we’re retrieving a list of IModifierProvider twice. While this may be pre-optimization (which may not be relevant later), wouldn’t it be better to do something like:
public float GetStat(Stat stat)
{
(float addMod, float perMod) = GetModifiers(stat);
return (GetBaseStat(stat) + addMod) * (1 + perMod / 100);
}
private (float, float) GetModifiers(Stat stat)
{
float addMod = 0.0f;
float perMod = 0.0f;
if (!shouldUseModifiers) return (addMod, perMod);
foreach (IModifierProvider provider in GetComponents<IModifierProvider>())
{
foreach (float modifier in provider.GetAdditiveModifiers(stat))
{
addMod += modifier;
}
foreach (float modifier in provider.GetPercentageModifiers(stat))
{
perMod += modifier;
}
}
return (addMod, perMod);
}