AbilityResourceDictionary - jimdroberts/FishMMO GitHub Wiki

Description

Serializable dictionary mapping character attribute templates to integer values for ability resources. Used to associate specific resource values (such as mana, stamina, etc.) with character attributes in the FishMMO infrastructure.


Basic Usage

Setup

  1. Ensure you have defined CharacterAttributeTemplate assets for all attributes you wish to use as keys.
  2. Reference or instantiate AbilityResourceDictionary where you need to map attribute templates to resource values (e.g., in ability or character scripts).
  3. No special configuration is required; values can be set and retrieved like a standard dictionary.
  4. Initialization occurs automatically when the class is instantiated.

Example

// Example 1: Creating and using an AbilityResourceDictionary

// Create a new AbilityResourceDictionary instance
var resourceDict = new AbilityResourceDictionary();

// Assume 'healthTemplate' and 'manaTemplate' are CharacterAttributeTemplate instances
resourceDict[healthTemplate] = 100; // Set health resource
resourceDict[manaTemplate] = 50;    // Set mana resource

// Retrieve a resource value
int health = resourceDict[healthTemplate];

// Example 2: Iterating over all resources
foreach (var kvp in resourceDict)
{
    var attribute = kvp.Key;
    int value = kvp.Value;
    // Use attribute and value as needed
}

Best Practices

  • Use CharacterAttributeTemplate assets as keys to ensure consistency and avoid duplication.
  • Use this dictionary for any system that needs to map attributes to resource values (e.g., abilities, effects, character stats).
  • Avoid modifying the dictionary during iteration to prevent runtime exceptions.
⚠️ **GitHub.com Fallback** ⚠️