AbilityResourceDictionary - jimdroberts/FishMMO GitHub Wiki
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.
- Ensure you have defined
CharacterAttributeTemplate
assets for all attributes you wish to use as keys. - Reference or instantiate
AbilityResourceDictionary
where you need to map attribute templates to resource values (e.g., in ability or character scripts). - No special configuration is required; values can be set and retrieved like a standard dictionary.
- Initialization occurs automatically when the class is instantiated.
// 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
}
- 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.