BuffTemplateDatabase - jimdroberts/FishMMO GitHub Wiki

Description

ScriptableObject database for storing and retrieving buff templates by name. Used to manage and access all buff templates in the FishMMO system.


API Access

Fields

  • private BuffDictionary buffs

    The backing field for the buffs dictionary.

Properties

  • public BuffDictionary Buffs { get; }

    Public accessor for the buffs dictionary.

Methods

  • 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.


Basic Usage

Setup

  1. Create a new BuffTemplateDatabase ScriptableObject via the Unity editor (Assets > Create > FishMMO > Character > Buff > Database).
  2. Add buff templates to the database using the Inspector or via code.
  3. Use the GetBuff method to retrieve buff templates by name at runtime.

Example

// 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
}

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️