FlatBonusFormulaTemplate - jimdroberts/FishMMO GitHub Wiki

Description

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.


API Access

Methods

  • 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).


Basic Usage

Setup

  1. Create a FlatBonusFormulaTemplate ScriptableObject via the Unity editor (Assets > Create > FishMMO > Character > Attribute > Formula > Flat Bonus Formula).
  2. Assign the formula to a character attribute template as needed.

Example

// 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;

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️