FlatBonusFormulaTemplate - jimdroberts/FishMMO GitHub Wiki
Defines a formula template for calculating a flat bonus to a character attribute. Used to apply a simple additive bonus in the FishMMO attribute system.
-
public override int CalculateBonus(CharacterAttribute self, CharacterAttribute bonusAttribute)
Calculates the flat bonus to apply to the attribute. self (CharacterAttribute): The attribute being modified. bonusAttribute (CharacterAttribute): The attribute providing the bonus. Returns the sum of bonusAttribute.FinalValue + bonusAttribute.FinalValue (int).
- Create a FlatBonusFormulaTemplate ScriptableObject via the Unity editor (Assets > Create > FishMMO > Character > Attribute > Formula > Flat Bonus Formula).
- Assign the formula to a character attribute template as needed.
// Example 1: Using the flat bonus formula
int bonus = flatBonusFormula.CalculateBonus(attribute, bonusSource);
// Example 2: Assigning the formula to an attribute template
attributeTemplate.Formula = flatBonusFormula;
- Use this formula for simple additive bonuses where no scaling or complex logic is needed.
- Assign formulas via ScriptableObjects for easy editor integration and reuse.
- Extend CharacterAttributeFormulaTemplate for more advanced bonus calculations.