CharacterAttributeTemplate - jimdroberts/FishMMO GitHub Wiki

Description

Defines a character attribute template, including value ranges, relationships, and formulas for attribute interactions. Used to configure and describe character attributes in the FishMMO system.


API Access

Fields

  • public string Description

    A description of the attribute, used for tooltips and UI.

  • public int InitialValue

    The initial (base) value for this attribute when a character is created.

  • public int MinValue

    The minimum value this attribute can have (used for clamping).

  • public int MaxValue

    The maximum value this attribute can have (used for clamping).

  • public bool IsPercentage

    If true, this attribute is treated as a percentage (e.g., 0-100%).

  • public bool IsResourceAttribute

    If true, this attribute is a resource (e.g., health, mana) that can be consumed or regenerated.

  • public bool ClampFinalValue

    If true, the final value of this attribute is clamped between MinValue and MaxValue.

  • public CharacterAttributeSet ParentTypes

    Set of parent attribute types (attributes that depend on this one).

  • public CharacterAttributeSet ChildTypes

    Set of child attribute types (attributes this one depends on for formulas).

  • public CharacterAttributeSet DependantTypes

    Set of dependant attribute types (additional dependencies for complex relationships).

  • public CharacterAttributeFormulaDictionary Formulas

    Dictionary of formulas defining how each child attribute affects this attribute.

Properties

  • public string Name { get; }

    The display name of the attribute (from the ScriptableObject's name).

  • public float InitialValueAsPct { get; }

    Returns the initial value as a percentage (InitialValue * 0.01f).

Methods

  • public string Tooltip()

    Builds a rich text tooltip string describing this attribute, including name, description, and value ranges. Returns a formatted tooltip string for UI display (string).


Basic Usage

Setup

  1. Create a CharacterAttributeTemplate ScriptableObject via the Unity editor (Assets > Create > FishMMO > Character > Attribute > Character Attribute).
  2. Set Description, InitialValue, MinValue, MaxValue, and other fields in the Inspector.
  3. Define relationships and formulas using ParentTypes, ChildTypes, DependantTypes, and Formulas.

Example

// Example 1: Accessing attribute information
string tooltip = attributeTemplate.Tooltip();

// Example 2: Setting up relationships and formulas
attributeTemplate.ChildTypes.Add(otherAttributeTemplate);
attributeTemplate.Formulas[otherAttributeTemplate] = formulaTemplate;

Best Practices

  • Use clear descriptions and value ranges for each attribute.
  • Define attribute relationships and formulas for complex interactions.
  • Use ScriptableObjects for easy data management and editor integration.
  • Keep attribute templates organized for maintainability.
⚠️ **GitHub.com Fallback** ⚠️