WorldSceneDetailsCache - jimdroberts/FishMMO GitHub Wiki
ScriptableObject cache for storing and managing all world scene details in the game. Provides centralized access and rebuild functionality for scene configuration data.
-
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.
-
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.)
- Create a
WorldSceneDetailsCache
asset via the Unity Editor (Assets > Create > FishMMO > World Scene Details). - Assign one or more
WorldSceneDetailsCacheReader
instances to theWorldSceneDetailsReaders
list. - Populate or update the
Scenes
dictionary as needed.
// 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
}
- 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.