ItemAttributeTemplate - jimdroberts/FishMMO GitHub Wiki

Description

ScriptableObject template for item attributes, defining min/max values and associated character attribute. Used to configure item attribute ranges and their effect on character stats.


API Access

Fields

  • public int MinValue

    The minimum value for this item attribute.

  • public int MaxValue

    The maximum value for this item attribute.

  • public CharacterAttributeTemplate CharacterAttribute

    The character attribute this item attribute affects or is associated with.

Properties

  • public string Name { get; }

    Gets the name of this item attribute template (defaults to the asset name).


Basic Usage

Setup

  1. Create a new ItemAttributeTemplate asset via the Unity Editor (Assets > Create > FishMMO > Item > Item Attribute > Attribute).
  2. Set the MinValue and MaxValue fields to define the attribute's value range.
  3. Assign the CharacterAttribute field to link this attribute to a character stat.
  4. Reference the ItemAttributeTemplate in item templates or scripts as needed.

Example

// Example 1: Accessing attribute values from a template
ItemAttributeTemplate attrTemplate = ...; // Reference to the template
int min = attrTemplate.MinValue;
int max = attrTemplate.MaxValue;
CharacterAttributeTemplate charAttr = attrTemplate.CharacterAttribute;

// Example 2: Using the Name property
string attrName = attrTemplate.Name;

Best Practices

  • Use descriptive names for each ItemAttributeTemplate asset for clarity.
  • Set appropriate min/max values to ensure balanced gameplay.
  • Link each item attribute to the correct CharacterAttributeTemplate for intended effects.
  • Document the purpose of each attribute in the asset's Inspector description.
⚠️ **GitHub.com Fallback** ⚠️