WorldSceneDetailsCache - jimdroberts/FishMMO GitHub Wiki

Description

ScriptableObject cache for storing and managing all world scene details in the game. Provides centralized access and rebuild functionality for scene configuration data.


API Access

Fields

  • public const string CACHE_PATH

    Path to the folder where the cache asset is stored.

  • public const string CACHE_FILE_NAME

    File name of the cache asset.

  • public const string CACHE_FULL_PATH

    Full path to the cache asset file.

  • public List WorldSceneDetailsReaders

    List of readers responsible for loading and rebuilding scene details from various sources.

  • public WorldSceneDetailsDictionary Scenes

    Dictionary containing all scene details, keyed by scene identifier.

Methods

  • public bool Rebuild()

    Rebuilds the scene details cache by invoking all registered readers. Returns true if any reader successfully rebuilt the cache. Returns: bool (True if the cache was rebuilt by any reader; otherwise, false.)


Basic Usage

Setup

  1. Create a WorldSceneDetailsCache asset via the Unity Editor (Assets > Create > FishMMO > World Scene Details).
  2. Assign one or more WorldSceneDetailsCacheReader instances to the WorldSceneDetailsReaders list.
  3. Populate or update the Scenes dictionary as needed.

Example

// Example 1: Rebuilding the scene details cache
if (worldSceneDetailsCache.Rebuild()) {
    // Cache was successfully rebuilt
}

// Example 2: Accessing scene details
WorldSceneDetails details;
if (worldSceneDetailsCache.Scenes.TryGetValue("MainTown", out details)) {
    // Use details as needed
}

Best Practices

  • Always assign at least one valid WorldSceneDetailsCacheReader to ensure the cache can be rebuilt.
  • Use the Rebuild method after making changes to scene configuration sources.
  • Keep the cache asset in a well-known location for easy reference and version control.
  • Regularly update the Scenes dictionary to reflect the latest scene configurations.
⚠️ **GitHub.com Fallback** ⚠️