mooball
    Preparing search index...

    Interface EventFactory

    interface EventFactory {
        addStadiumObject(type: number, value: object): StadiumAddObjectEvent;
        autoTeams(): AutoTeamsEvent;
        binaryCustomEvent(type: number, data: Uint8Array): BinaryCustomEvent;
        checkConsistency(data: ArrayBuffer): ConsistencyCheckEvent;
        controls(type: number, params: any[]): ControlsEvent;
        create(type: OperationType): MooballEvent | undefined;
        createFromStream(reader: Reader): MooballEvent;
        customEvent(type: number, data: object): CustomEvent;
        joinRoom(
            id: number,
            name: string,
            flag: string,
            avatar: string,
            conn: string,
            auth: string,
        ): JoinRoomEvent;
        kickBanPlayer(id: number, reason: string, ban: boolean): KickBanPlayerEvent;
        pauseResumeGame(paused: boolean): PauseResumeGameEvent;
        ping(pings: number[]): PingEvent;
        playCustomSound(soundName: string): PlayCustomSoundEvent;
        removeStadiumObject(type: number, id: number): StadiumRemoveObjectEvent;
        reorderPlayers(
            playerIdList: number[],
            moveToTop: boolean,
        ): ReorderPlayersEvent;
        sendAnnouncement(
            msg: string,
            color: number,
            style: number,
            sound: number,
        ): SendAnnouncementEvent;
        sendAnnouncement2(
            msg: string,
            cssVar?: string,
            sound?: string,
        ): SendAnnouncement2Event;
        sendChat(msg: string): SendChatEvent;
        sendChatIndicator(active: number): SendChatIndicatorEvent;
        sendDirection(value: number): SendDirectionEvent;
        sendInput(input: number): SendInputEvent;
        setAvatar(value: string): SetAvatarEvent;
        setClockPaused(value: number): SetGamePlayValueEvent;
        setDirectionActive(value: number): SetGamePlayValueEvent;
        setDiscProperties(id: number, data: object): SetDiscPropertiesEvent;
        setElapsedTime(value: number): SetGamePlayValueEvent;
        setHeadlessAvatar(id: number, avatar: string): SetHeadlessAvatarEvent;
        setKickRateLimit(
            min: number,
            rate: number,
            burst: number,
        ): SetKickRateLimitEvent;
        setMaxEndTicks(value: number): SetGamePlayValueEvent;
        setMaxGoalTicks(value: number): SetGamePlayValueEvent;
        setMaxPauseTicks(value: number): SetGamePlayValueEvent;
        setOvertimeLimit(value: number): SetLimitEvent;
        setPlayerAdmin(playerId: number, value: boolean): SetPlayerAdminEvent;
        setPlayerCssVar(id: number, cssVar: string | null): SetPlayerCssVarEvent;
        setPlayerDirection(id: number, value: number): SetPlayerDirectionEvent;
        setPlayerDiscProperties(id: number, data: object): SetDiscPropertiesEvent;
        setPlayerEnergy(id: number, data: number[]): SetPlayerEnergyEvent;
        setPlayerIdentity(
            id: number,
            data: IdentityData,
            signature: ArrayBuffer,
        ): IdentityEvent;
        setPlayerSkin(id: number, skin: Texture | null): SetPlayerSkinEvent;
        setPlayerSync(value: boolean): SetPlayerSyncEvent;
        setPlayerTeam(playerId: number, teamId: number): SetPlayerTeamEvent;
        setRoomName(name: string): SetRoomNameEvent;
        setRunDefaultGameLogic(value: boolean): SetRunDefaultGameLogicEvent;
        setScoreLimit(value: number): SetLimitEvent;
        setStadium(stadium: IStadium): SetStadiumEvent;
        setTeamColors(teamId: number, colors: TeamColors): SetTeamColorsEvent;
        setTeamScore(teamId: number, value: number): SetGamePlayValueEvent;
        setTeamsLock(value: boolean): SetTeamsLockEvent;
        setTimeLimit(value: number): SetLimitEvent;
        startGame(): StartGameEvent;
        stopGame(): StopGameEvent;
        updateCssVar(name: string, value: string): UpdateCssVarEvent;
        updateStadiumObject(
            type: number,
            id: number,
            value: object,
        ): StadiumUpdateObjectEvent;
    }
    Index

    Methods

    • Creates a StadiumAddObjectEvent object that can be used to add a new stadium object.

      Parameters

      • type: number

        Type of the object to be added.

      • value: object

        An object that is supposed to contain all parameters required to add that type of object.

      Returns StadiumAddObjectEvent

      An instance of StadiumAddObjectEvent.

    • Creates a AutoTeamsEvent object that can be used to trigger an autoTeams event. Returning event's byId is also required to be set before it can be used.

      Returns AutoTeamsEvent

      An instance of AutoTeamsEvent.

    • Creates a BinaryCustomEvent object that can be used to trigger a binary custom event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • type: number

        The type of the binary custom event.

      • data: Uint8Array

        Any custom binary data for this specific event.

      Returns BinaryCustomEvent

      An instance of BinaryCustomEvent.

    • Creates a ConsistencyCheckEvent object that can be used to trigger a consistency check. Returning event's byId is also required to be set before it can be used.

      Parameters

      • data: ArrayBuffer

        The consistency data to check.

      Returns ConsistencyCheckEvent

      An instance of ConsistencyCheckEvent.

    • Creates a ControlsEvent object that can be used to (introduce new/remove existing) game input controls where each new input control is assigned the next bit of player.input value.

      Parameters

      • type: number

        Type of the operation. (0: add, 1: remove).

      • params: any[]

        Parameters for the specific operation.

      Returns ControlsEvent

      An instance of ControlsEvent.

    • Creates a MooballEvent object that can be used to trigger events. Returning event's various values might also be required to be set before it can be used, depending on the value of type parameter.

      Parameters

      Returns MooballEvent | undefined

      An instance of MooballEvent, or undefined if the given type is not a recognized value.

    • Reads bytes from a stream to create a MooballEvent object.

      Parameters

      • reader: Reader

        The stream reader to be used.

      Returns MooballEvent

      An instance of MooballEvent.

    • Creates a CustomEvent object that can be used to trigger a custom event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • type: number

        The type of the custom event.

      • data: object

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

      Returns CustomEvent

      An instance of CustomEvent.

    • Creates a JoinRoomEvent object that can be used to trigger a joinRoom event. Returning event's byId must be set to 0 before it can be used.

      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 JoinRoomEvent

      An instance of JoinRoomEvent.

    • Creates a KickBanPlayerEvent object that can be used to trigger a kickBanPlayer event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • id: 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.

      Returns KickBanPlayerEvent

      An instance of KickBanPlayerEvent.

    • Creates a PauseResumeGameEvent object that can be used to trigger a pauseResumeGame event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • paused: boolean

        Whether the game is desired to be paused or resumed.

      Returns PauseResumeGameEvent

      An instance of PauseResumeGameEvent.

    • Creates a PingEvent object that can be used to update the ping values of all player. Returning event's byId must be set to 0 before it can be used.

      Parameters

      • pings: number[]

        The desired ping values for all players.

      Returns PingEvent

      An instance of PingEvent.

    • Creates a PlayCustomSoundEvent object that can be used to play a custom sound.

      Parameters

      • soundName: string

        Name of the sound to be played.

      Returns PlayCustomSoundEvent

      An instance of PlayCustomSoundEvent.

    • Creates a StadiumRemoveObjectEvent. object that can be used to remove an existing stadium object.

      Parameters

      • type: number

        Type of the object to be removed.

      • id: number

        Id of the object to be removed.

      Returns StadiumRemoveObjectEvent

      An instance of StadiumRemoveObjectEvent.

    • Creates a ReorderPlayersEvent object that can be used to trigger a reorderPlayers event. Returning event's byId must be set to 0 before it can be used.

      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.

      Returns ReorderPlayersEvent

      An instance of ReorderPlayersEvent.

    • Creates a SendAnnouncementEvent object that can be used to trigger a sendAnnouncement event. Returning event's byId must be set to 0 before it can be used.

      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.

      Returns SendAnnouncementEvent

      An instance of SendAnnouncementEvent.

    • Creates a SendAnnouncement2Event object that can be used to send announcement using the improved announcement api.

      Parameters

      • msg: string

        The announcement message. ( max length = 1000 )

      • OptionalcssVar: string

        The cssVar of the announcement message.

      • Optionalsound: string

        The sound of the announcement message.

      Returns SendAnnouncement2Event

      An instance of SendAnnouncement2Event

    • Creates a SendChatEvent object that can be used to trigger a sendChat event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • msg: string

        The chat message.

      Returns SendChatEvent

      An instance of SendChatEvent.

    • Creates a SendChatIndicatorEvent object that can be used to trigger a sendChatIndicator event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • active: number

        The desired chat indicator status. (0: passive, 1: active.)

      Returns SendChatIndicatorEvent

      An instance of SendChatIndicatorEvent.

    • Creates a SendDirectionEvent object that can be used to set the player's current direction. room.state.directionActive must be true for this to work.

      Parameters

      • value: number

        New direction value of the current player.

      Returns SendDirectionEvent

      An instance of SendDirectionEvent

    • Creates a SendInputEvent object that can be used to trigger a sendInput event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • input: number

        The desired input value. ( 0 <= input < 32 )

      Returns SendInputEvent

      An instance of SendInputEvent.

    • Creates a SetAvatarEvent object that can be used to trigger a setAvatar event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • value: string

        The desired avatar value. value.length must be <= 2. * *

      Returns SetAvatarEvent

      An instance of SetAvatarEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually pause/resume the game clock.

      Parameters

      • value: number

        Whether the game will be paused(1) or resumed(0).

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set whether direction is active or not.

      Parameters

      • value: number

        New directionActive value.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetDiscPropertiesEvent object that can be used to trigger a setDiscProperties event. Returning event's byId must be set to 0 before it can be used.

      Parameters

      • id: number

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

      • data: object

        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.

      Returns SetDiscPropertiesEvent

      An instance of SetDiscPropertiesEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set the current elapsed time.

      Parameters

      • value: number

        New elapsed time value.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetHeadlessAvatarEvent object that can be used to trigger a setHeadlessAvatar event. Returning event's byId must be set to 0 before it can be used.

      Parameters

      • id: number

        Id of the player whose headless avatar is intended to be changed.

      • avatar: string

        The new headless avatar value.

      Returns SetHeadlessAvatarEvent

      An instance of SetHeadlessAvatarEvent.

    • Creates a SetKickRateLimitEvent object that can be used to trigger a setKickRateLimit event. Returning event's byId is also required to be set before it can be used.

      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.

      Returns SetKickRateLimitEvent

      An instance of SetKickRateLimitEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set the current max end ticks.

      Parameters

      • value: number

        New max end ticks value.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set the current max goal ticks.

      Parameters

      • value: number

        New max goal ticks value.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set the current max pause ticks.

      Parameters

      • value: number

        New max pause ticks value.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetLimitEvent object that can be used to trigger a setOvertimeLimit event.

      Parameters

      • value: number

        The desired overtime limit of the game.

      Returns SetLimitEvent

      An instance of SetLimitEvent.

    • Creates a SetPlayerAdminEvent object that can be used to trigger a setPlayerAdmin event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • playerId: number

        Id of the player whose admin status is being set.

      • value: boolean

        The desired admin status of the player.

      Returns SetPlayerAdminEvent

      An instance of SetPlayerAdminEvent.

    • Creates a SetPlayerCssVarEvent object that can be used to set the cssVar attribute of a player to change its appearance in the room gui.

      Parameters

      • id: number

        Id of the player whose cssVar will be modified.

      • cssVar: string | null

        New cssVar value of the player.

      Returns SetPlayerCssVarEvent

      An instance of SetPlayerCssVarEvent.

    • Creates a SetPlayerDirectionEvent object that can be used to manually change the direction of an individual player. room.state.directionActive must be true for this to work.

      Parameters

      • id: number

        Id of the player whose energy values will be modified.

      • value: number

        New direction value of the player.

      Returns SetPlayerDirectionEvent

      An instance of SetPlayerDirectionEvent.

    • Creates a SetDiscPropertiesEvent object that can be used to trigger a setPlayerDiscProperties event. Returning event's byId must be set to 0 before it can be used.

      Parameters

      • id: number

        Id of the player whose disc properties are desired to be changed.

      • data: object

        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.

      Returns SetDiscPropertiesEvent

      An instance of SetDiscPropertiesEvent.

    • Creates a SetPlayerEnergyEvent object that can be used to manually change the energy of an individual player.

      Parameters

      • id: number

        Id of the player whose energy values will be modified.

      • data: number[]

        New values. Order of values is supposed to be: [energy, kEnergyGain, kEnergyDrain]. null means no change for each value.

      Returns SetPlayerEnergyEvent

      An instance of SetPlayerEnergyEvent.

    • Creates an IdentityEvent object that can be used to trigger a identity event. Returning event's byId must be set to 0 before it can be used.

      Parameters

      • id: number

        Id of the player whose identity data is desired to be changed.

      • data: IdentityData

        The identity data that should be received from moo-hoo.com.

      • signature: ArrayBuffer

        Signature of the identity data.

      Returns IdentityEvent

      An instance of IdentityEvent.

    • Creates a SetPlayerSkinEvent object that can be used to update the current skin(textureId) of a player.

      Parameters

      • id: number

        Id of the player whose skin will be modified.

      • skin: Texture | null

        New skin value of the player.

      Returns SetPlayerSkinEvent

      An instance of SetPlayerSkinEvent.

    • Creates a SetPlayerSyncEvent object that can be used to trigger a setPlayerSync event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • value: boolean

        The desired synchronization status.

      Returns SetPlayerSyncEvent

      An instance of SetPlayerSyncEvent.

    • Creates a SetPlayerTeamEvent object that can be used to trigger a setPlayerTeam event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • playerId: number

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

      • teamId: number

        Id of the desired team.

      Returns SetPlayerTeamEvent

      An instance of SetPlayerTeamEvent.

    • Creates a SetRoomNameEvent object that can be used to change the name of the room.

      Parameters

      • name: string

        The new room name.

      Returns SetRoomNameEvent

      An instance of SetRoomNameEvent.

    • Creates a SetRunDefaultGameLogicEvent object that can be used to set whether to use default game logic or not.

      Parameters

      • value: boolean

        Whether the default game logic is active(1) or passive(0).

      Returns SetRunDefaultGameLogicEvent

      An instance of SetRunDefaultGameLogicEvent.

    • Creates a SetLimitEvent object that can be used to trigger a setScoreLimit event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • value: number

        The desired score limit of the game.

      Returns SetLimitEvent

      An instance of SetLimitEvent.

    • Creates a SetStadiumEvent object that can be used to trigger a setStadium event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • stadium: IStadium

        The desired stadium value.

      Returns SetStadiumEvent

      An instance of SetStadiumEvent.

    • Creates a SetTeamColorsEvent object that can be used to trigger a setTeamColors event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • teamId: number

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

        • 1: red.
        • 2: blue.
      • colors: TeamColors

        An instance of TeamColors that defines the colors of a team.

      Returns SetTeamColorsEvent

      An instance of SetTeamColorsEvent.

    • Creates a SetGamePlayValueEvent object that can be used to manually set the current team scores.

      Parameters

      • teamId: number

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

      • value: number

        New score for the team.

      Returns SetGamePlayValueEvent

      An instance of SetGamePlayValueEvent.

    • Creates a SetTeamsLockEvent object that can be used to trigger a setTeamsLock event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • value: boolean

        The desired teams lock value of the game.

      Returns SetTeamsLockEvent

      An instance of SetTeamsLockEvent.

    • Creates a SetLimitEvent object that can be used to trigger a setTimeLimit event. Returning event's byId is also required to be set before it can be used.

      Parameters

      • value: number

        The desired time limit of the game.

      Returns SetLimitEvent

      An instance of SetLimitEvent.

    • Creates a StartGameEvent object that can be used to trigger a startGame event. Returning event's byId is also required to be set before it can be used.

      Returns StartGameEvent

      An instance of StartGameEvent.

    • Creates a StopGameEvent object that can be used to trigger a stopGame event. Returning event's byId is also required to be set before it can be used.

      Returns StopGameEvent

      An instance of StopGameEvent.

    • Creates a UpdateCssVarEvent object that can be used to update the current contents of a css variable.

      Parameters

      • name: string

        Name of the css variable..

      • value: string

        New value of the css variable.

      Returns UpdateCssVarEvent

      An instance of UpdateCssVarEvent.

    • Creates a StadiumUpdateObjectEvent object that can be used to update an existing stadium object.

      Parameters

      • type: number

        Type of the object to be updated.

      • id: number

        Id of the object to be updated.

      • value: object

        An object that is supposed to contain all parameters required to update that type of object.

      Returns StadiumUpdateObjectEvent

      An instance of StadiumUpdateObjectEvent.