Server Object Model
Summary
The server-side data structures a developer works with: the Room, its Players, and its Entities, and how they relate. It is part of the Reactor Technical Overview.
Room
The Room (ksIServerRoom) is the container for one running game. It owns the players and entities, runs the simulation, and holds room-wide state. Key surfaces:
Collections:
Players,Entities(withDynamicEntitiesandPermanentEntities), plus counts likeConnectedPlayerCountandVirtualPlayerCount.State and services:
State(starting, running, stopping),Time,Physics,Cluster, and aPropertiesmap synced to clients.Lifecycle events:
OnPlayerJoin,OnPlayerLeave,OnSpawnEntity,OnDestroyEntity,OnShutDown, and theOnAuthenticatehook that runs before a player joins.Entity control:
SpawnEntity(from spawn parameters or convenience overloads),SpawnCollection,GetEntity, andDestroyon the entity itself.Messaging:
CallRPCandCallBatchRPC, covered in Messaging and RPCs.
Room scripts (ksServerRoomScript) attach to the room and hold its logic.
Player
A Player (ksIServerPlayer) represents a connected client or a virtual player, which is a server-controlled bot. Key surfaces:
Identity and state:
Id,ConnectionState,IsConnected,IsVirtual,Address, and the latestFrameand time reported by the client.Data: a
Propertiesmap synced to clients, andVirtualInputfor driving bots.Ownership:
OwnedEntities, plusRemoveOwnedEntitiesandDestroyOwnedEntities.Visibility:
AddToSyncGroup,RemoveFromSyncGroup, andGetSyncGroups, covered in Automatic Client Data Syncing.Control:
DisconnectandUpdateControllers.Lifecycle: the
OnLeaveevent, raised when the player leaves the room.
Player scripts (ksServerPlayerScript) attach to a player.
Entity
An Entity (ksIServerEntity) is a networked object in the room. Key surfaces:
Identity:
Id,Room,Type, and itsOwnerandOwnerPermissions.Transform:
Transform(3D) andTransform2D, synced to clients.Data: a
Propertiesmap, aSyncGroupfor visibility, andDestroyOnOwnerDisconnect.Physics: a physics actor, collision filter, material, and events like
OnCollision,OnOverlapStart,OnWake, andOnSleep.Control:
SetOwner,PlayerController, and the owner-update validators, covered in Ownership and Authority.Lifecycle and messaging:
Destroy,OnDestroy,CallRPC.
Entity scripts (ksServerEntityScript) attach to an entity.
How They Relate
A room contains many players and many entities. A player can own zero or more entities, and each entity has at most one owner. Entities carry the game state that syncs to clients; players carry per-client state and input; the room carries shared state and the simulation that ties them together.
Rooms, players, and entities each expose a
Propertiesmap. Properties are the primary way state reaches clients. See Automatic Client Data Syncing.
Where to Go Next
Ownership and Authority: owners, controllers, and permissions on entities.
Automatic Client Data Syncing: how room, player, and entity state reaches clients.
The Server Update Loop: when your scripts run against these objects each frame.
Last updated

