SceneInstanceDetails - jimdroberts/FishMMO GitHub Wiki

Description

The SceneInstanceDetails class stores details about a scene instance managed by the server, including server IDs, scene name, handle, type, character count, and last exit time. It is used to track the state and lifecycle of scene instances, including detection of stale (empty) scenes for cleanup or management purposes.


API Access

Fields

  • public long WorldServerID

    The world server ID associated with this scene instance.

  • public long SceneServerID

    The scene server ID associated with this scene instance.

  • public string Name

    The name of the scene instance.

  • public int Handle

    The handle (unique identifier) for this scene instance.

  • public SceneType SceneType

    The type of scene (OpenWorld, Group, PvP, etc.).

  • public int CharacterCount

    The current number of characters in this scene instance.

  • public DateTime LastExit

    The time when the last character exited the scene.

Properties

  • public bool StalePulse

    Indicates whether the scene is stale (no characters present).

Methods

  • public void AddCharacterCount(int count)

    Adds or subtracts from the character count, updating LastExit if the scene becomes empty. count (int): Amount to add or subtract from the character count.


Basic Usage

Setup

  1. Create and initialize a SceneInstanceDetails object for each scene instance managed by the server.
  2. Set the appropriate server IDs, scene name, handle, and type when creating the instance.
  3. Use the AddCharacterCount method to update the character count as players enter or exit the scene.
  4. Monitor the StalePulse property and LastExit field to detect and manage stale (empty) scenes.

Example

// Example 1: Creating and updating a scene instance
var details = new SceneInstanceDetails {
    WorldServerID = 1,
    SceneServerID = 2,
    Name = "Dungeon01",
    Handle = 1001,
    SceneType = SceneType.Group
};

// Add a character to the scene
details.AddCharacterCount(1);

// Remove a character from the scene
details.AddCharacterCount(-1);

// Check if the scene is stale
if (details.StalePulse) {
    // Perform cleanup or unload the scene
}

Best Practices

  • Always update the character count using AddCharacterCount to ensure LastExit is accurate.
  • Use the StalePulse property to trigger scene cleanup or unloading when no characters are present.
  • Store and manage all scene instance details centrally for efficient server management.
  • Avoid direct manipulation of CharacterCount or LastExit outside of the provided methods and logic.
⚠️ **GitHub.com Fallback** ⚠️