Class Hostable<T>

Represents an object capable of hosting games.

See HostableEvents for events to listen to.

Type Parameters

Hierarchy

Properties

FixedUpdateInterval: number

How often a FixedUpdate should be called.

code: number

The code of the room.

counter: number

The current start counter for the room.

endGameIntents: EndGameIntent<any>[]

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.

gameData: undefined | GameData<Hostable<T>>

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.

gameState: GameState

The state that the game is currently in.

hostId: number

The ID of the host of the room.

lobbyBehaviour: undefined | LobbyBehaviour<Hostable<T>>

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.

meetingHud: undefined | MeetingHud<Hostable<T>>

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.

messageStream: BaseGameDataMessage[]

The current message stream to be sent to the server on fixed update.

netobjects: Map<number, Networkable<any, NetworkableEvents<Hostable<any>>, Hostable<T>>>

The networkable components in the room.

objectList: Networkable<any, NetworkableEvents<Hostable<any>>, Hostable<any>>[]

A list of all objects in the room.

players: Map<number, PlayerData<Hostable<T>>>

The players in the room.

privacy: PrivacyType

The privacy state of the room.

registeredPrefabs: Map<number, NetworkableConstructor<any>[]>

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.

registeredRoles: Map<number, typeof BaseRole>

All roles that can be assigned to players. See registerRole.

settings: GameSettings

The settings of the room.

shipStatus: undefined | InnerShipStatus<Hostable<T>>

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.

voteBanSystem: undefined | VoteBanSystem<Hostable<T>>

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.

Methods

  • Returns Promise<void>

  • Whether or not this client/room is able to manage an object, i.e. perform host actions on it.

    Returns

    Whether or not the object can be managed by this client/room.

    Parameters

    Returns boolean

  • Returns void

  • Create a fake player in the room that doesn't need a client to be connected to own it.

    To dispose of the player, use player.despawn().

    Returns

    The fake player created.

    Parameters

    • Optional isNew: boolean

      Whether or not the player should be seen jumping off of the seat in the lobby.

    Returns PlayerData<Hostable<T>>

  • Returns void

  • Type Parameters

    • Event extends BasicEvent<Event>

    Parameters

    • event: Event

    Returns Promise<Event>

  • Type Parameters

    • Event extends BasicEvent<Event>

    Parameters

    • event: Event

    Returns Promise<Event>

  • Type Parameters

    • Event extends BasicEvent<Event>

    Parameters

    • event: Event

    Returns Event

  • Parameters

    Returns Promise<void>

  • Parameters

    • displayName: string

    Returns PlayerData<Hostable<T>>[]

  • Get an available player ID.

    Returns

    The player ID that was found.

    Example

    // Get an available player ID and add it to the gamedata.
    const playerId = room.getAvailablePlayerID();
    room.gamedata.add(playerId);

    Returns number

  • Returns SpawnMessage[]

  • Type Parameters

    • Event extends BasicEvent<Event> = BasicEvent

    Parameters

    • event: string

    Returns Listener<Event>[]

  • Returns number

  • Get a player by one of their components' netIds.

    Returns

    The player that was found, or null if they do not exist.

    Example

    const player = room.getPlayerByNetId(34);
    

    Parameters

    • netId: number

      The net ID of the component of the player to search.

    Returns undefined | PlayerData<Hostable<T>>

  • Get a player by their player ID.

    Returns

    The player that was found, or null if they do not exist.

    Example

    const player = room.getPlayerByPlayerId(1);
    

    Parameters

    • playerId: number

      The player ID of the player.

    Returns undefined | PlayerData<Hostable<T>>

  • Parameters

    • playerId: number

    Returns undefined | PlayerControl<Hostable<T>>

  • Handle when the game is ended.

    Parameters

    Returns Promise<void>

  • Handle a client readying up.

    Parameters

    Returns Promise<void>

  • Handle when the game is started.

    Returns Promise<void>

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • event: EventName
    • listener: Listener<T[EventName]>

    Returns void

  • Type Parameters

    • K extends BasicEvent<K>

    Parameters

    • event: string
    • listener: Listener<K>

    Returns void

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • event: EventName
    • listener: Listener<T[EventName]>

    Returns (() => void)

      • (): void
      • Returns void

  • Type Parameters

    • K extends BasicEvent<K>

    Parameters

    • event: string
    • listener: Listener<K>

    Returns (() => void)

      • (): void
      • Returns void

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • event: EventName
    • listener: Listener<T[EventName]>

    Returns (() => void)

      • (): void
      • Returns void

  • Type Parameters

    • K extends BasicEvent<K>

    Parameters

    • event: string
    • listener: Listener<K>

    Returns (() => void)

      • (): void
      • Returns void

  • Register an intent to end the game.

    Parameters

    • endGameIntent: EndGameIntent<any>

      The intention to end the game.

    Returns void

  • Register a role that can be assigned to a player.

    Parameters

    • roleCtr: typeof BaseRole

      The role to register to the room.

    Returns void

  • Returns void

  • Parameters

    • event: string

    Returns void

  • Resolve a player by some identifier.

    Returns

    The resolved player.

    Example

    // Resolve a player by their client id.
    const player = room.resolvePlayer(11013);

    Parameters

    Returns undefined | PlayerData<Hostable<T>>

  • Resolve a client id by some identifier.

    Returns

    The resolved client ID.

    Parameters

    Returns undefined | number

  • Resolve a player ID by some identifier.

    Returns

    The resolved player ID.

    Parameters

    Returns undefined | number

  • Set the code of the room.

    Example

    room.setCode("ABCDEF");
    

    Parameters

    Returns void

  • Set the host of the room. If the current client is the host, it will conduct required host changes. e.g. Spawning objects if they are not already spawned.

    Parameters

    Returns Promise<void>

  • Change the the privacy of the room.

    Example

    room.setAlterGameTag(AlterGameTag.ChangePrivacy, 1); // 0 for private, 1 for public.
    

    Parameters

    Returns Promise<void>

  • Change the settings of the room. If the host, it will broadcast these changes.

    Example

    room.syncSettings({
    crewmateVision: 0.5,
    votingTime: 120
    });

    Parameters

    • settings: Partial<AllGameSettings>

      The settings to set to (Can be partial).

    Returns void

  • Returns void

  • Spawn a prefab of an object.

    Returns

    The object that was spawned.

    Example

    room.spawnPrefab(SpawnType.Player, client.myPlayer);
    

    Parameters

    • spawnType: number

      The type of object to spawn.

    • ownerId: undefined | number | PlayerData<Hostable<any>>
    • Optional flags: number
    • Optional componentData: any[]
    • Optional doBroadcast: boolean
    • Optional doAwake: boolean

    Returns undefined | Networkable<any, any, Hostable<T>>

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • event: EventName

    Returns Promise<T[EventName]>

  • Parameters

    • event: string

    Returns Promise<BasicEvent>

  • Type Parameters

    • EventName extends string | number | symbol

    Parameters

    • event: EventName
    • filter: ((ev: T[EventName]) => boolean | Promise<boolean>)
        • (ev: T[EventName]): boolean | Promise<boolean>
        • Parameters

          • ev: T[EventName]

          Returns boolean | Promise<boolean>

    Returns Promise<T[EventName]>

  • Type Parameters

    • K extends BasicEvent<K>

    Parameters

    • event: string
    • filter: ((ev: K) => boolean | Promise<boolean>)
        • (ev: K): boolean | Promise<boolean>
        • Parameters

          • ev: K

          Returns boolean | Promise<boolean>

    Returns Promise<BasicEvent>

Constructors

Accessors

  • get destroyed(): boolean
  • Returns boolean

  • get host(): undefined | PlayerData<this>
  • The host of the room.

    Returns undefined | PlayerData<this>

  • get hostIsMe(): boolean
  • Whether or not the current client is the host of the room.

    Returns boolean

  • get myPlayer(): undefined | PlayerData<this>
  • The current client in the room.

    Returns undefined | PlayerData<this>

Generated using TypeDoc