Static
FixedHow often a FixedUpdate should be called.
The client IDs of every acting host in the room.
Player that the server is waiting to finish joining before resetting all acting hosts back.
Whether or not acting hosts are enabled on this room.
A list of perspectives that are currently active in the room, see createPerspective
All IP addresses banned from this room.
The chat command handler in the room.
The code of the room.
Readonly
configThe config for the room, the worker uses the worker's rooms config to initialise it as.
All connections in the room, mapped by client ID to connection object.
The current start counter for the room.
The unix (milliseconds) timestamp. that the room was created.
Readonly
createdA packet decoder for the room to decode and handle incoming packets.
Every end game intent that should happen in a queue to be or not to be canceled.
The first item of each element being the name of the end game intent and the second being metadata passed with it.
See RoomEndGameIntentEvent to cancel an end game intent, or see registerEndGameIntent to register your own.
See RoomGameEndEvent to listen for a game actually ending.
An instance of the game data in the room. Contains information about players such as their name, colour, hat etc.
It is possible for more than one game data to be spawned, however this property is set and cleared for simplicity.
See objectList if you're looking to find all game data objects that have been spawned.
The state that the game is currently in.
The ID of the host of the room.
All plugins loaded and scoped to the room, mapped by plugin id to room plugin object.
An instance of the lobby behaviour in the room. Spawned when the room is currently in the lobby waiting for a game to start.
It is possible for more than one lobby behaviour to be spawned, however this property is set and cleared for simplicity.
See objectList if you're looking to find all lobby behaviour objects that have been spawned.
This room's console logger.
An instance of the meeting hud in the room. Spawned when a meeting is started.
It is possible for more than one meeting hud to be spawned, however this property is set and cleared for simplicity.
See objectList if you're looking to find all meeting hud objects that have been spawned.
The current message stream to be sent to the server on fixed update.
The networkable components in the room.
A list of all objects in the room.
A map of objects to their respective perspective owner.
A map of player client IDs to active perspectives in the room. Used as a short-hand, as well as being faster than searching each active perspective.
The players in the room.
The privacy state of the room.
A map of spawn type -> objects used in the protocol. Useful to register custom INO (inner net objects) such as replicating behaviour from a client mod, see registerPrefab.
All roles that can be assigned to players. See registerRole.
The settings of the room.
An instance of the ship status in the room. Spawned when a game is started and represents the current map.
It is possible for more than one ship status to be spawned, however this property is set and cleared for simplicity.
See objectList if you're looking to find all ship status objects that have been spawned.
An instance of the voting ban system in the room. Used as a utility object for handling kick and ban votes.
It is possible for more than one vote ban system to be spawned, however this property is set and cleared for simplicity.
See objectList if you're looking to find all vote ban system objects that have been spawned.
The connections/players that are waiting for the host to join back.
Readonly
workerThe worker that instantiated this object.
All plugins loaded and scoped to the worker when this room was created, mapped by plugin id to worker plugin object.
Add another acting host to a Server-As-A-Host room.
The player to make host.
Ban player from a room
The connection or the player that should be banned.
Optional
message: stringOptional
include: PlayerDataResolvable[]Optional
exclude: PlayerDataResolvable[]Broadcast GameData messages and root messages to all or some connections.
Sends GameDataTo if a filter is applied with the include parameter.
A promise that resolves when all packets have been sent.
// Broadcast a scenechange message.
await room.broadcastMessages([
new SceneChangeMessage(0, "OnlineGame")
]);
The GameData messages to send.
The Root messages to send.
Optional
include: Connection[]The connections to include in the broadcast.
Optional
exclude: Connection[]The connections to exclude in the broadcast.
Whether or not this client/room is able to manage an object, i.e. perform host actions on it.
Whether or not the object can be managed by this client/room.
The object to manage.
Clear a room name override made with setRoomNameOverride.
Creates a fake dummy player without a connected client.
The created player.
const player = room.createFakePlayer();
...
room.removeFakePlayer(player);
Whether or not this player should be considered as "joining" the room, i.e. whether they should hop off their seat in the lobby.
Whether or not default cosmetics should be set for this player, i.e. whether they should be immediately visible as a player.
Whether or not the player should appear in GameData. If not, they won't count as an actual player and will live (mostly) off-the-grid.
Create a Perspective object for this room.
This function is relatively slow as it needs to clone the entire room. It shouldn't really be used in loops or any events that get fired a lot.
The created perspective.
The player, or players, to create this perspective for.
Despawn a component.
room.despawnComponent(room.meetinghud);
The component being despawned.
Destroy this room.
Reason for the destroying the room.
Disable acting hosts on the room, leaving either no hosts if the server is in SaaH mode, or leaving 1 host otherwise. It doesn't clear the list of acting hosts, just disables them from being in use.
This function will prevent any acting hosts from being assigned at any point until enabled again with enableActingHosts.
Disable SaaH (Server-as-a-Host) on this room, assigning a new host (the first acting host if available), and tell clients the new host (unless they are an acting host.).
Does nothing particularly special except tell clients that the server is now the host.
Unknown an object so that all rooms can make changes to it.
The object to disown
Optional
intent: EndGameIntent<{}>An array of all acting hosts in the room.
Get the client-server connection of a player.
The connection of the player, or undefined if they only exist on the server.
Get all client-server connections for a list of players. If a player only exists ont he server,
i.e. they are being controlled by a remote client/real player, their place in the list will be undefined
.
A list of connections for the players, in the same order.
The players to get connections for.
Get the owner of an object.
The object to disown
Get a player by one of their components' netIds.
The player that was found, or null if they do not exist.
const player = room.getPlayerByNetId(34);
The net ID of the component of the player to search.
Get a player by their player ID.
The player that was found, or null if they do not exist.
const player = room.getPlayerByPlayerId(1);
The player ID of the player.
Get all real client-server connections for a list of players. That is, connections for all players that are being controlled by a remote client/real player.
See getConnections to get connections for a list of players and
returned in the same order & place as the players provided, although some connections
may not exist, resulting in undefined
s.
All real connections for the players provided.
The list of players to get connections for.
Guard an object so that no other room (or perspective) can make changes to it.
This is useful when perspectives create conflicts and state becomes unmanageable; just assign its logic to one room.
Note that this is only a nominal change; plugins can still make changes freely - the only change is that packets won't be managed by rooms that the object does not belong to.
The object to own
Handle when the game is ended.
The reason for why the game ended.
Optional
intent: EndGameIntent<{}>Handle when a client joins the game.
Handle when a client leaves the game.
The client that left the game.
Handle a client readying up.
The client that readied.
Register an intent to end the game.
The intention to end the game.
Register a custom INO spawn object by its spawn type. Can also override built-in objects.
The spawn type of the component as an integer.
The components in the object. The first component should be the main object which will inherit the rest of the components.
Remove an acting host from a Server-As-A-Host room.
The player to remove as host.
Short-hand for removing a fake player created with createFakePlayer. This will despawn the player immediately.
const player = room.createFakePlayer();
...
room.removeFakePlayer(player);
The fake player to remove from the game.
Resolve a player by some identifier.
The resolved player.
// Resolve a player by their client id.
const player = room.resolvePlayer(11013);
The identifier to resolve to a player.
Resolve a client id by some identifier.
The resolved client ID.
The identifier to resolve to a client ID.
Resolve a player ID by some identifier.
The resolved player ID.
The identifier to resolve to a player ID.
Send a message into the chat as the server. Requries game data to be spawned, can only send messages on the left side of the chat room if there is at least 2 players in the room.
If on the right side, for each player the room sets their name and colour, sends the message then immediately sets them back.
If on the left side, for each player the room finds a different player, sets their name and colour and immediately sets them back after sending the message. If there is no other player, it shows it on the right side instead.
// Tell a player off if they use a bad word.
.@EventListener("player.sentchat")
onPlayerChat(ev: PlayerChatEvent<Room>) {
const badWords = [ "sprout", "barney" ];
for (const word of badWords) {
if (ev.chatMessage.includes(word)) {
ev.message.cancel(); // Don't broadcast the message to other players
ev.room.sendChat("<color=red>You used a bad word there, mister.</color>", { target: ev.player });
}
}
}
The message to send.
Options for the method.
Set whether or not acting hosts are enabled, calling either disableActingHosts or enableActingHosts.
Whether or not to enable acting hosts
Set the actual host for the room, cannot be used in rooms using SaaH.
The player to set as the host.
Change the the privacy of the room.
room.setAlterGameTag(AlterGameTag.ChangePrivacy, 1); // 0 for private, 1 for public.
Set whether SaaH is enabled on this room, calling either enableSaaH or disableSaaH. and tell clients the new host (unless they are an acting host.).
Whether or not SaaH should be enabled.
Set whether SaaH is enabled on this room, calling either enableSaaH or disableSaaH. and tell clients the new host (unless they are an acting host.).
Whether or not SaaH should be enabled.
Whether or not to add the current host as an acting host
Set whether SaaH is enabled on this room, calling either enableSaaH or disableSaaH. and tell clients the new host (unless they are an acting host.).
Whether or not SaaH should be enabled.
Whether or not to add the current host as an acting host, if SaaH is being enabled.
Change the settings of the room. If the host, it will broadcast these changes.
room.syncSettings({
crewmateVision: 0.5,
votingTime: 120
});
The settings to set to (Can be partial).
Spawn a component (Not broadcasted to all clients, see spawnPrefabOfType).
const meetinghud = new MeetingHud(
this,
this.getNextNetId(),
ownerId,
{
dirtyBit: 0,
states: new Map(),
}
);
this.spawnComponent(meetinghud);
The component being spawned.
Spawn a prefab of an object.
The object that was spawned.
room.spawnPrefab(SpawnType.Player, client.myPlayer);
The type of object to spawn.
Optional
flags: numberOptional
componentData: any[]Optional
doBroadcast: booleanOptional
doAwake: booleanUpdate the host for the room or for a specific client.
The host to set.
Optional
recipient: ConnectionThe specific client recipient if required.
Whether or not this room has been destroyed, and is no longer active on the server.
The host of the room.
Whether or not the current client is the host of the room.
The current client in the room.
The name of the room, or just the code formatted as a string.
REDSUS
LOCAL
Generated using TypeDoc
Represents an object capable of hosting games.
See HostableEvents for events to listen to.