ItemAttribute - jimdroberts/FishMMO GitHub Wiki
Represents an attribute instance for an item, such as strength, durability, or custom stat. Holds a reference to the attribute template and its current value.
-
public int value
The current value of this attribute instance.
-
public ItemAttributeTemplate Template { get; private set; }
The template that defines the type and metadata of this attribute.
-
public ItemAttribute(int templateID, int value)
Constructs an ItemAttribute from a template ID and value. Looks up the template using the provided ID. Parameters: - int templateID: The ID of the attribute template. - int value: The initial value for this attribute.*
- Create an ItemAttribute by providing a template ID and initial value.
- The Template property will reference the corresponding ItemAttributeTemplate.
- Use the value field to store and update the attribute's current value as needed.
// Example 1: Creating an item attribute instance
int templateID = 1; // Example template ID
int initialValue = 10;
ItemAttribute attr = new ItemAttribute(templateID, initialValue);
// Example 2: Accessing the template and value
ItemAttributeTemplate template = attr.Template;
int currentValue = attr.value;
- Use the Template property to access metadata and configuration for the attribute.
- Update the value field as the attribute changes during gameplay.
- Ensure template IDs are valid and correspond to existing ItemAttributeTemplate assets.
- Document the purpose and usage of each attribute in the template asset for clarity.