BuffTemplateDatabase - jimdroberts/FishMMO GitHub Wiki
ScriptableObject database for storing and retrieving buff templates by name. Used to manage and access all buff templates in the FishMMO system.
-
private BuffDictionary buffs
The backing field for the buffs dictionary.
-
public BuffDictionary Buffs { get; }
Public accessor for the buffs dictionary.
-
public BaseBuffTemplate GetBuff(string name)
Retrieves a buff template by name, or null if not found. name (string): The name of the buff to retrieve. Returns the BaseBuffTemplate if found, otherwise null.
- Create a new BuffTemplateDatabase ScriptableObject via the Unity editor (Assets > Create > FishMMO > Character > Buff > Database).
- Add buff templates to the database using the Inspector or via code.
- Use the GetBuff method to retrieve buff templates by name at runtime.
// Example 1: Retrieving a buff template by name
BaseBuffTemplate buff = buffDatabase.GetBuff("PowerBuff");
if (buff != null) {
// Apply buff to character
}
// Example 2: Accessing all buffs in the database
foreach (var kvp in buffDatabase.Buffs) {
string buffName = kvp.Key;
BaseBuffTemplate template = kvp.Value;
// Use buff template
}
- Use unique, descriptive names for each buff template in the database.
- Keep the database organized for easy management and retrieval.
- Use the BuffDictionary for efficient lookups and serialization.
- Reference the database as a singleton or via dependency injection for global access.