ItemAttributeTemplateDatabase - jimdroberts/FishMMO GitHub Wiki

Description

ScriptableObject database for item attribute templates, providing lookup and storage by name. Used to manage and retrieve item attribute templates for items in the game.


API Access

Fields

  • private ItemAttributeDictionary attributes

    Internal dictionary of item attribute templates, serialized for inspector access.

Properties

  • public ItemAttributeDictionary Attributes { get; }

    Gets the dictionary of item attribute templates.

Methods

  • public ItemAttributeTemplate GetItemAttribute(string name)

    Retrieves an item attribute template by name. Returns null if not found. Parameters: - string name: The name of the attribute template to retrieve. Returns: - ItemAttributeTemplate: The item attribute template, or null if not found.*


Basic Usage

Setup

  1. Create a new ItemAttributeTemplateDatabase asset via the Unity Editor (Assets > Create > FishMMO > Item > Item Attribute > Database).
  2. Add ItemAttributeTemplate assets to the database and assign unique names as keys.
  3. Reference the database in scripts or item systems as needed.

Example

// Example 1: Retrieving an attribute template by name
ItemAttributeTemplateDatabase db = ...; // Reference to the database
ItemAttributeTemplate attr = db.GetItemAttribute("Strength");
if (attr != null) {
    // Use the attribute template
}

// Example 2: Accessing all attributes
foreach (var pair in db.Attributes) {
    string attrName = pair.Key;
    ItemAttributeTemplate template = pair.Value;
    // Process each attribute
}

Best Practices

  • Use unique and descriptive names for each attribute template key.
  • Keep the database asset organized for easy lookup and maintenance.
  • Reference the database in item systems to ensure consistent attribute retrieval.
  • Document the purpose of each attribute in the asset's Inspector description.
⚠️ **GitHub.com Fallback** ⚠️