SceneInstanceDetails - jimdroberts/FishMMO GitHub Wiki
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.
-
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.
-
public bool StalePulse
Indicates whether the scene is stale (no characters present).
-
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.
- Create and initialize a
SceneInstanceDetails
object for each scene instance managed by the server. - Set the appropriate server IDs, scene name, handle, and type when creating the instance.
- Use the
AddCharacterCount
method to update the character count as players enter or exit the scene. - Monitor the
StalePulse
property andLastExit
field to detect and manage stale (empty) scenes.
// 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
}
- Always update the character count using
AddCharacterCount
to ensureLastExit
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
orLastExit
outside of the provided methods and logic.