mooball
    Preparing search index...

    Interface SandboxRoom

    interface SandboxRoom {
        autoTeams(byId: number): void;
        currentPlayerId: number;
        destroy(): void;
        executeEvent(eventMsg: MooballEvent): void;
        extrapolate(milliseconds: number): RoomState;
        gameState: GameState | null;
        initialize(): void;
        isRecording(): boolean;
        kickPlayer(
            playerId: number,
            reason: string,
            ban: boolean,
            byId: number,
        ): void;
        playerChat(msg: string, byId: number): void;
        playerInput(input: number, byId: number): void;
        playerJoin(
            id: number,
            name: string,
            flag: string,
            avatar: string,
            conn: string,
            auth: string,
        ): void;
        playerLeave(playerId: number): void;
        reorderPlayers(
            playerIdList: number[],
            moveToTop: boolean,
            byId: number,
        ): void;
        runSteps(count: number): void;
        sendAnnouncement(
            msg: string,
            color: number,
            style: number,
            sound: number,
            targetId: number,
            byId: number,
        ): void;
        sendBinaryCustomEvent(type: number, data: Uint8Array, byId: number): void;
        sendCustomEvent(type: number, data: object, byId: number): void;
        sendPingData(valueFunc: number[], byId: number): void;
        setCurrentStadium(value: IStadium, byId: number): void;
        setDiscProperties(
            discId: number,
            type: number,
            data: any[],
            byId: number,
        ): void;
        setGamePaused(value: boolean, byId: number): void;
        setKeyState(state: number): void;
        setKickRateLimit(
            min: number,
            rate: number,
            burst: number,
            byId: number,
        ): void;
        setPlayerAdmin(playerId: number, value: boolean, byId: number): void;
        setPlayerAvatar(value: string, byId: number): void;
        setPlayerChatIndicator(value: number, byId: number): void;
        setPlayerIdentity(
            id: number,
            data: IdentityData,
            signature: ArrayBuffer,
            byId: number,
        ): void;
        setPlayerSync(value: boolean, byId: number): void;
        setPlayerTeam(playerId: number, teamId: number, byId: number): void;
        setScoreLimit(value: number, byId: number): void;
        setSimulationSpeed(coefficient: number): void;
        setTeamColors(
            teamId: number,
            angle: number,
            colors: number[],
            byId: number,
        ): void;
        setTeamsLock(value: number, byId: number): void;
        setTimeLimit(value: number, byId: number): void;
        speed: number;
        startGame(byId: number): void;
        startRecording(): boolean;
        state: RoomState;
        stopGame(byId: number): void;
        stopRecording(): Uint8Array<ArrayBufferLike> | null;
        takeSnapshot(): RoomState;
        useSnapshot(newRoomState: RoomState): void;
    }

    Hierarchy (View Summary)

    Index

    Properties

    currentPlayerId: number

    This is a read-only property that always returns 0. It is only added for compatibility with renderers. (And it is only used in the initialization code of renderers.)

    gameState: GameState | null

    The original object that holds the game state information. Returns null if game is not active.

    speed: number

    The current speed of the simulation.

    state: RoomState

    An object containing all information about the current room state.

    Methods

    • Removes the last 2 players from spectators and adds them to opposite teams in order using a fake identity.

      Parameters

      • byId: number

        Id of the player who changed the teams of these players.

      Returns void

      void.

    • Frees the resources that are used by this object.

      Returns void

      void.

    • Applies an event to the current room state. For example; the event object may come from a ReplayData structure, or from a onOperationReceived(type, msg, globalFrameNo, clientFrameNo, customData) callback.

      Parameters

      Returns void

      void.

    • Extrapolates the current room state and sets the ext variables inside original objects to their newly calculated extrapolated states. Normally designed to be used in renderers.

      Parameters

      • milliseconds: number

        The time to extrapolate the state for in milliseconds.

      Returns RoomState

      The extrapolated room state.

    • Initializes the sandbox. (Should only be called if delayedInit is true.)

      Returns void

      void.

    • Returns whether the replay recorder is active or not.

      Returns boolean

      true if replay recording is active; false otherwise.

    • Kicks/bans a player using a fake identity.

      Parameters

      • playerId: number

        Id of the desired player to be kicked/banned.

      • reason: string

        Reason of kicking/banning.

        • If null, this event is interpreted as the player leaving by himself/herself.
      • ban: boolean

        Whether this is a banning event or not.

      • byId: number

        Id of the player who kicked/banned the player.

      Returns void

      void.

    • Sends a chat message as a player.

      Parameters

      • msg: string

        The chat message to be sent.

      • byId: number

        Id of the player who sent this message.

      Returns void

      void.

    • Sets the current key state of a player.

      Parameters

      • input: number

        The desired key state of the player.

      • byId: number

        Id of the player whose key state is being set.

      Returns void

      void.

    • Adds a new player to the room.

      Parameters

      • id: number

        Id of the new player.

      • name: string

        Name of the new player.

      • flag: string

        Flag of the new player.

      • avatar: string

        Avatar of the new player.

      • conn: string

        Connection string of the new player.

      • auth: string

        Auth of the new player.

      Returns void

      void.

    • Removes a player from the room.

      Parameters

      • playerId: number

        Id of the player to be removed.

      Returns void

      void.

    • Creates and applies a fake event by player(byId) to remove all of the players whose ids exist in the array playerIdList, and add them back in the given order to the top or bottom of the player list depending on the moveToTop value.

      Parameters

      • playerIdList: number[]

        The ids of players that are desired to be removed from the room's players list, reordered to match the order in idList and added back to the room's players list.

      • moveToTop: boolean

        Whether to add the players to the top or bottom of the room's players list.

      • byId: number

        This value must always be 0.

      Returns void

      void.

    • Runs the simulation count steps. Simulation should be stopped for this function to work as expected.

      Parameters

      • count: number

        Number of steps to run the simulation.

      Returns void

      void.

    • Sends an announcement message to a player.

      Parameters

      • msg: string

        The contents of the announcement message.

      • color: number

        The color of the announcement message. Range: -1 <= color < 16777216.

        • The color value can be converted into a rgba string via API's Utils.numberToColor function.
        • The special value -1 means transparent color.
      • style: number

        The style of the announcement message. Must be one of the following:

        • 0: use document's default font style.
        • 1: fontWeight = "bold".
        • 2: fontStyle = "italic".
        • 3: fontSize = "12px".
        • 4: fontWeight = "bold", fontSize = "12px".
        • 5: fontWeight = "italic", fontSize = "12px".
      • sound: number

        The sound of the announcement message. Must be one of the following:

        • 0: no sound.
        • 1: chat sound.
        • 2: highlight sound.
      • targetId: number

        Id of the player who will receive this announcement. If this value is null, the announcement is sent to everyone.

      • byId: number

        This value must always be 0.

      Returns void

      void.

    • Triggers a fake binary custom event using a fake identity.

      Parameters

      • type: number

        The type of the custom event.

      • data: Uint8Array

        Any custom binary data for this specific event.

      • byId: number

        Id of the player who triggered this custom binary event.

      Returns void

      void.

    • Triggers a fake custom event using a fake identity.

      Parameters

      • type: number

        The type of the custom event.

      • data: object

        The data of the custom event. (Any JSON object)

      • byId: number

        Id of the player who triggered this custom event.

      Returns void

      void.

    • Sets the ping values of all players.

      Parameters

      • valueFunc: number[]

        The desired ping values for all players.

      • byId: number

        This value must always be 0.

      Returns void

      void.

    • Sets the current stadium using a fake identity.

      Parameters

      • value: IStadium

        The desired stadium value.

      • byId: number

        The fake id of the player who changed this stadium.

      Returns void

      void.

    • Sets the properties of a disc.

      Parameters

      • discId: number

        Id of the disc whose properties are desired to be set.

      • type: number

        The type of this operation.

        • 0: discId is actually the id of a disc.
        • 1: discId is actually the id of a player.
      • data: any[]

        The desired properties to set. This will not change the omitted keys of the disc. properties has the following structure:

        • x: number | null: The desired x coordinate of the disc.
        • y: number | null: The desired y coordinate of the disc.
        • xspeed: number | null: The desired x component of the speed of the disc.
        • yspeed: number | null: The desired y component of the speed of the disc.
        • xgravity: number | null: The desired x component of the gravity of the disc.
        • ygravity: number | null: The desired y component of the gravity of the disc.
        • radius: number | null: The desired radius of the disc.
        • bCoeff: number | null: The desired bouncing coefficient of the disc.
        • invMass: number | null: The desired inverse mass of the disc.
        • damping: number | null: The desired damping of the disc.
        • color: int | null: The desired color of the disc.
        • cMask: int | null: The desired collision mask of the disc.
        • cGroup: int | null: The desired collision group of the disc.
      • byId: number

        This value must always be 0.

      Returns void

      void.

    • Pauses/resumes the game using a fake identity.

      Parameters

      • value: boolean

        The desired pausedness value of the game.

        • true: Pauses the game, if it is not already paused.
        • false: Resumes the game, if it is not already resumed.
      • byId: number

        Id of the player who paused/resumed the game.

      Returns void

      void.

    • Sets the current player's key state. (added for compatibility with normal rooms.)

      Parameters

      • state: number

        The desired key state.

      Returns void

      void.

    • Sets the room's kick rate limit using a fake identity.

      Parameters

      • min: number

        The desired min value of kick rate limit.

      • rate: number

        The desired rate value of kick rate limit.

      • burst: number

        The desired burst value of kick rate limit.

      • byId: number

        Id of the player who set the kick rate limit of the room.

      Returns void

      void.

    • Gives/takes away the admin status of a player using a fake identity.

      Parameters

      • playerId: number

        Id of the player whose admin status is being set.

      • value: boolean

        The desired admin status of the player.

        • true: Give admin rights to the player.
        • false: Take away admin rights from the player.
      • byId: number

        Id of the player who set the admin status of the player.

      Returns void

      void.

    • Sets the avatar of a player.

      Parameters

      • value: string

        The desired avatar value.

      • byId: number

        Id of the player whose avatar is being set.

      Returns void

      void.

    • Sets the chat indicator status of a player.

      Parameters

      • value: number

        The desired chat indicator status.

      • byId: number

        Id of the player whose chat indicator status is being set.

      Returns void

      void.

    • Triggers a fake identity event using a fake identity.

      Parameters

      • id: number

        Id of the player whose identity data is being changed.

      • data: IdentityData

        The new identity data.

      • signature: ArrayBuffer

        Signature of the identity data.

      • byId: number

        Id of the player who triggered this identity event.

      Returns void

      void.

    • Set the synchronization status of a player.

      Parameters

      • value: boolean

        The desired synchronization status.

      • byId: number

        Id of the player whose synchronization status is being set.

      Returns void

      void.

    • Moves a player to a team using a fake identity.

      Parameters

      • playerId: number

        Id of the player whose team is desired to be changed.

      • teamId: number

        Id of the desired team.

      • byId: number

        Id of the player who changed the team of this player.

      Returns void

      void.

    • Sets the game's score limit using a fake identity.

      Parameters

      • value: number

        The desired score limit of the game.

      • byId: number

        Id of the player who set the game's score limit.

      Returns void

      void.

    • Changes the speed of the simulation.

      Parameters

      • coefficient: number

        The desired speed coefficient. Must be a real number >=0. Meaning of possible value ranges is as follows:

        • value = 0 : stop simulation.
        • 0 < value < 1 : slow-motion simulation.
        • value = 1 : normal speed simulation.
        • value > 1 : fast-motion simulation.

      Returns void

      void.

    • Sets the colors of a team using a fake identity.

      Parameters

      • teamId: number

        Id of the team whose colors are desired to be changed.

        • 1: red.
        • 2: blue.
      • angle: number

        The angle of stripes. (in degrees)

      • colors: number[]

        Minimum 2, maximum 4 numeric (0 <= integer <= 16777215) color strings.

      • byId: number

        Id of the player who set the colors of the team.

      Returns void

      void.

    • Locks/unlocks the teams using a fake identity.

      Parameters

      • value: number

        The desired teams lock value of the game.

      • byId: number

        Id of the player who set the game's teams lock value.

      Returns void

      void.

    • Sets the game's time limit using a fake identity.

      Parameters

      • value: number

        The desired time limit of the game.

      • byId: number

        Id of the player who set the game's time limit.

      Returns void

      void.

    • Starts the game using a fake identity.

      Parameters

      • byId: number

        Id of the player who started the game.

      Returns void

      void.

    • Start recording replay. Recording should be stopped before calling this.

      Returns boolean

      true if succeeded, false otherwise.

    • Stops the game using a fake identity.

      Parameters

      • byId: number

        Id of the player who stopped the game.

      Returns void

      void.

    • Stop recording replay. Recording should be started before calling this.

      Returns Uint8Array<ArrayBufferLike> | null

      The recorded replay data if succeeded, null otherwise.

    • Generates a copy of the given RoomState and sets the current room state reference to the generated RoomState.

      Parameters

      • newRoomState: RoomState

        The RoomState to use. Should be created by takeSnapshot() first.

      Returns void

      void.