ItemAttributeTemplateDatabase - jimdroberts/FishMMO GitHub Wiki
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.
-
private ItemAttributeDictionary attributes
Internal dictionary of item attribute templates, serialized for inspector access.
-
public ItemAttributeDictionary Attributes { get; }
Gets the dictionary of item attribute templates.
-
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.*
- Create a new ItemAttributeTemplateDatabase asset via the Unity Editor (Assets > Create > FishMMO > Item > Item Attribute > Database).
- Add ItemAttributeTemplate assets to the database and assign unique names as keys.
- Reference the database in scripts or item systems as needed.
// 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
}
- 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.