SceneTeleporterDictionary - jimdroberts/FishMMO GitHub Wiki

Description

Serializable dictionary mapping string keys to scene teleporter details. Used to store and retrieve teleporter destinations and settings for scenes.


Basic Usage

Setup

  1. Use this class to store mappings from teleporter names (string) to SceneTeleporterDetails objects.
  2. Ensure SceneTeleporterDetails is properly defined and serializable.
  3. Integrate this dictionary into your scene or game manager as needed.

Example

// Example 1: Creating and populating a SceneTeleporterDictionary
SceneTeleporterDictionary teleporterDict = new SceneTeleporterDictionary();
teleporterDict["Start"] = new SceneTeleporterDetails {
    ToScene = "MainTown",
    ToPosition = new Vector3(0, 0, 0),
    ToRotation = Quaternion.identity
};

// Example 2: Retrieving a teleporter destination
if (teleporterDict.TryGetValue("Start", out SceneTeleporterDetails details)) {
    // Use details.ToScene, details.ToPosition, details.ToRotation
}

Best Practices

  • Use clear, unique string keys for each teleporter to avoid conflicts.
  • Always check for key existence before accessing dictionary values.
  • Ensure all SceneTeleporterDetails entries are valid and initialized before use.
  • Leverage the inherited methods from SerializableDictionary for safe access and manipulation.
⚠️ **GitHub.com Fallback** ⚠️