NebulaGameMode
Server-side game hooks, the equivalent of subclassing Mirror's NetworkManager.
Nebula · Packages/com.1by3.nebula/Runtime/Core/NebulaGameMode.cspublic abstract class NebulaGameMode : MonoBehaviourServer-side game hooks, the equivalent of subclassing Mirror's NetworkManager. Put exactly one subclass in the game scene. Called on whichever worker the gateway picked for the player.
Methods
OnSpawnPlayer
public virtual NetworkIdentity OnSpawnPlayer(NebulaWorker worker, ulong clientId, string playerName, Container container);
public virtual NetworkIdentity OnSpawnPlayer(NebulaWorker worker, in PlayerInfo player, Container container);Create and spawn the player's entity inside container. Return the spawned identity. Override this or the PlayerInfo overload (which also gets the player's identity across sessions).
BeginSpawnPlayer
public virtual void BeginSpawnPlayer(NebulaWorker worker, PlayerInfo player, Container container, System.Action<System.Func<NetworkIdentity>> complete);Begin creating a player, optionally waiting for game-owned storage or content loading. Call complete on the Unity main thread with a factory that creates the pawn. Nebula invokes the factory only if this join is still current and connected, at most once. The default completes synchronously through OnSpawnPlayer.
OnPlayerDespawn
public virtual void OnPlayerDespawn(NebulaWorker worker, NetworkIdentity player);The player is gone for good: the reclaim grace ran out, or the player left on purpose (NebulaClient.Leave) or was kicked. The worker despawns the entity after this returns; a persistent pawn keeps its record for the player's next session.
OnPlayerDisconnected
public virtual void OnPlayerDisconnected(NebulaWorker worker, NetworkIdentity player);The player's link dropped, or the gateway's link to this worker did, and the reclaim grace has started: the worker keeps player for NebulaConfig.SessionReclaimSeconds in case the player comes back. Act on the drop here: drop what the pawn holds, get it out of a seat, save a checkpoint. NetworkIdentity.IsOwnerConnected is already false. Called on the worker that owns the pawn, once per drop: a pawn handed to another worker during the grace carries the fact with it, and the new owner does not call it again. Followed by OnPlayerReconnected if the player comes back in time, or by OnPlayerDespawn when the grace runs out. Not called when the player leaves on purpose or is kicked (straight to OnPlayerDespawn), nor with a grace of 0. The default does nothing.
OnPlayerReconnected
public virtual void OnPlayerReconnected(NebulaWorker worker, NetworkIdentity player);The player came back within the reclaim grace and has player again: the session was reclaimed, through any gateway of the mesh, or the gateway whose link to this worker dropped is back. NetworkIdentity.IsOwnerConnected is already true. Called on the worker that owns the pawn; NebulaGameMode.OnSpawnPlayer is not called again. The default does nothing.
OnWorkerStarted
public virtual void OnWorkerStarted(NebulaWorker worker);Called once the worker is listening and registered with the control plane.
PrepareSpatialFrame
public virtual void PrepareSpatialFrame(NetworkIdentity entity);Called for each authoritative entity before worker container membership queries. Procedural worlds may shift their origin here so distant regions resolve container boundaries precisely. The default does nothing. Keep this per-entity simulation callback inexpensive.