Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Game

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

Private _connectCalledAt

_connectCalledAt: number = 0

Private _connectedAtMs

_connectedAtMs: number = 0

Private _encIdMapping

_encIdMapping: {} = {}

Type declaration

  • [encId: number]: string

Private _initializedAtMs

_initializedAtMs: number = 0

Private _onMapCounts

_onMapCounts: {} = {}

Type declaration

  • [mapId: string]: number

Private _timeToConnect

_timeToConnect: number = -1

completeMaps

completeMaps: {} = ...

Type declaration

connected

connected: boolean = false

Optional debugOverrideServer

debugOverrideServer: string

Private disconnectHandlers

disconnectHandlers: {} = {}

Type declaration

  • [uuid: string]: (code?: number, reason?: string) => void
      • (code?: number, reason?: string): void
      • Parameters

        • Optional code: number
        • Optional reason: string

        Returns void

Optional dispatchGameUpdate

dispatchGameUpdate: (delta: PartialGameState<Player>) => void

Type declaration

Optional dispatchMapUpdate

dispatchMapUpdate: (mapId: string, map: Readonly<GameMapV2>) => void

Type declaration

    • (mapId: string, map: Readonly<GameMapV2>): void
    • Parameters

      Returns void

engine

engine: Engine

Private eventSubscriptions

eventSubscriptions: {} = {}

Type declaration

getAuth

getAuth: () => Promise<EngineAuth>

Type declaration

Private hasSentMapSinceConnect

hasSentMapSinceConnect: boolean = false

inputId

inputId: number = 1

lastMapUpdateIds

lastMapUpdateIds: {} = ...

Type declaration

  • [id: string]: number

legacySubscriptions

legacySubscriptions: {} = {}
deprecated

Type declaration

  • [uuid: string]: GameSpaceSubscription

legacySubscriptionsConnection

legacySubscriptionsConnection: {} = {}
deprecated

Type declaration

  • [uuid: string]: (connected: boolean) => void
      • (connected: boolean): void
      • Parameters

        • connected: boolean

        Returns void

Private mapDataCheckInterval

mapDataCheckInterval: undefined | Timeout

Private mapDataChecks

mapDataChecks: number = 0

Private mapsAccumulator

mapsAccumulator: MapsAccumulator = ...

onInput

onInput: undefined | ((dir: MoveDirectionEnum_ENUM, stopped: boolean, inputId: number) => void)

partialMaps

partialMaps: {} = ...

Type declaration

players

players: {} = {}

Type declaration

putMetric

putMetric: (metricName: string, metricValue: any) => void = ...

Type declaration

    • (metricName: string, metricValue: any): void
    • Parameters

      • metricName: string
      • metricValue: any

      Returns void

Optional spaceId

spaceId: string

Private subscriptions

subscriptions: GameEventSubscriptionMap = {}

Private timeToFirstOnMapsMs

timeToFirstOnMapsMs: {} = {}

Type declaration

  • [mapId: string]: number

Private updateSubscriptionsPromise

updateSubscriptionsPromise: undefined | Promise<void>

Methods

_setupEngineCallbacks

  • _setupEngineCallbacks(): void

_startMapDataCheckInterval

  • _startMapDataCheckInterval(): void

banPlayer

  • banPlayer(user: string): void

block

  • block(blockedUserId: string, blocked: boolean): void

chat

  • chat(chatRecipient: string, localPlayers: string[], mapId: string, data: { contents: string; id?: string }): void
  • Parameters

    • chatRecipient: string
    • localPlayers: string[]
    • mapId: string
    • data: { contents: string; id?: string }
      • contents: string
      • Optional id?: string

    Returns void

clearItem

  • clearItem(targetId?: string): void

connect

  • connect(): undefined | Promise<void>

debug

  • debug(debugState?: boolean): void

deleteObject

  • deleteObject(mapId: string, objId: string, createTxnId?: boolean): Promise<unknown>

deleteObjectByKey

  • deleteObjectByKey(mapId: string, key: number, createTxnId?: boolean): Promise<unknown>

disconnect

  • disconnect(): void

editChatMessage

enter

  • enter(info: SpaceUserInfo, spawnToken?: string, targetId?: string): void

enterPortal

  • enterPortal(targetUrl: string, targetId?: string, bypassPrompt?: boolean): void

enterWhisper

exit

  • exit(): void

filterObjectsInMap

  • filterObjectsInMap(mapId: string, filter: (obj: Partial<MapObject>) => boolean): MapObject[]
  • Returns a list of all objects in the map matching a condition.

    example

    game.filterObjectsInMap("park-legacy", (obj) => obj.id.startsWith("password-door")); // finds all password doors in a map

    Parameters

    • mapId: string

      The map you want to filter objects on.

    • filter: (obj: Partial<MapObject>) => boolean

      A predicate that returns a truthy value if you want the object to be returned.

    Returns MapObject[]

filterPlayersInSpace

  • filterPlayersInSpace(filter: (player: Partial<Player>) => boolean): Player[]
  • Returns a list of all players in the space matching a condition.

    example

    filterPlayersInSpace((player) => player.name === "Evelyn"); // returns the Player object for all players named Evelyn

    Parameters

    • filter: (player: Partial<Player>) => boolean

      A predicate that retunrs a truthy value if you want the player to be returned

        • (player: Partial<Player>): boolean
        • Parameters

          Returns boolean

    Returns Player[]

getDebugHistory

  • getDebugHistory(): string

getKnownCompletedMaps

  • getKnownCompletedMaps(): string[]

getKnownPartialMaps

  • getKnownPartialMaps(): string[]
  • Returns all known maps- i.e the keys of game.partialMaps We add this abstraction for convience and clarity, and because game.partialMaps could be renamed. You should prefer to use this function.

    Returns string[]

getObject

  • getObject(objId: string, mapId?: string): null | { mapId: string; obj: undefined | MapObject }

getPlayer

  • getPlayer(uid: string): undefined | Player

getPlayersInMap

  • getPlayersInMap(mapId: string): Player[]
  • Returns all players that are in the same map as you.

    example

    game.getPlayersInMap("new office")

    Parameters

    • mapId: string

      The string mapId you want to filter on

    Returns Player[]

getStats

  • getStats(): { currentMap: undefined | string; engine: { bufferedAmount: SlidingWindowMetrics; bytesReceivedSinceConnect: number; bytesSentSinceConnect: number; closeCodeCount: {}; connected: boolean; eventCountsSinceOpen: {}; latency: SlidingWindowMetrics; reconnects: { recentAttempts: number; timeSpentDisconnectedMs: SlidingWindowMetrics } }; gameClientAgeMs: number; gameClientVersion: string; numPlayers: number; onMapCountsAllTime: {}; preferredRegion: undefined | string; preferredRegionPing: number; serverURL: string; timeToConnect: number; timeToFirstOnMapMs: {}; wsReadyState: undefined | number }
  • Returns { currentMap: undefined | string; engine: { bufferedAmount: SlidingWindowMetrics; bytesReceivedSinceConnect: number; bytesSentSinceConnect: number; closeCodeCount: {}; connected: boolean; eventCountsSinceOpen: {}; latency: SlidingWindowMetrics; reconnects: { recentAttempts: number; timeSpentDisconnectedMs: SlidingWindowMetrics } }; gameClientAgeMs: number; gameClientVersion: string; numPlayers: number; onMapCountsAllTime: {}; preferredRegion: undefined | string; preferredRegionPing: number; serverURL: string; timeToConnect: number; timeToFirstOnMapMs: {}; wsReadyState: undefined | number }

    • currentMap: undefined | string
    • engine: { bufferedAmount: SlidingWindowMetrics; bytesReceivedSinceConnect: number; bytesSentSinceConnect: number; closeCodeCount: {}; connected: boolean; eventCountsSinceOpen: {}; latency: SlidingWindowMetrics; reconnects: { recentAttempts: number; timeSpentDisconnectedMs: SlidingWindowMetrics } }
    • gameClientAgeMs: number
    • gameClientVersion: string
    • numPlayers: number
    • onMapCountsAllTime: {}
      • [mapId: string]: number
    • preferredRegion: undefined | string
    • preferredRegionPing: number
    • serverURL: string
    • timeToConnect: number
    • timeToFirstOnMapMs: {}
      • [mapId: string]: number
    • wsReadyState: undefined | number

ghost

  • ghost(ghost: number, targetId?: string): void
  • Puts the currently connected client in ghost mode

    Parameters

    • ghost: number

      ghost value, either 1 or 0; whether you are ghosting or not.

    • Optional targetId: string

      id of player whose ghost value you want to set (must be space owner to set)

    Returns void

init

  • init(spaceId: string, _overrideServer?: string): void

interact

  • interact(objId: string, data?: any): void

isPlayerInPrivateSpace

  • isPlayerInPrivateSpace(player: Partial<Player>, mapId: string, privateSpaceId: string): boolean
  • Utility function that returns true if a player is standing inside a given private space. Requires the map to be defined first - use game.waitForInit() to be sure it has been defined. You can pass this directly into filterPlayersInSpace using a thunk.

    example

    isPlayerInPrivateSpace(player, "new office", "library") // returns if a given player is in the library

    example

    filterPlayersInSpace((player) => isPlayerInPrivateSpace(player, "new office", "library")); // finds everyone on that tile

    Parameters

    • player: Partial<Player>

      A Partial referencing the player

    • mapId: string

      the map the private tile is in

    • privateSpaceId: string

      the name of the private space you put in the mapmaker

    Returns boolean

kickPlayer

  • kickPlayer(user: string): void

leaveWhisper

  • leaveWhisper(): void

move

moveMapObject

  • moveMapObject(mapId: string, objectId: string, targetWorldPos: { x: number; xOffset?: number; y: number; yOffset?: number }, durationMs: number, easing?: "Linear" | "Cubic" | "Elastic" | "Bounce" | "Back"): void
  • Animates an object moving from its current position to targetWorldPos. Also handles setting the object's new position in the map itself.

    Parameters

    • mapId: string
    • objectId: string
    • targetWorldPos: { x: number; xOffset?: number; y: number; yOffset?: number }
      • x: number
      • Optional xOffset?: number
      • y: number
      • Optional yOffset?: number
    • durationMs: number
    • easing: "Linear" | "Cubic" | "Elastic" | "Bounce" | "Back" = "Linear"

    Returns void

notify

  • notify(notification: string): void

patchGatherEventsSpaceSession

playSound

  • playSound(src: string, volume: number, targetId?: string): void
  • Utility function for map developers that plays a sound file on the client, once. Use targetId if you are a space owner to play a sound on another client. If no sound is specified, it plays for the entire space. You must be a space owner to play a sound on the whole space.

    Parameters

    • src: string

      HTMl5 compliant audio resource, e.g a URL to a mp3

    • volume: number

      scalar volume from 0 to 1.0

    • Optional targetId: string

      id of another player you want to play the sound on

    Returns void

pointer

  • pointer(objectId: string, x: number, y: number): void

publishEvent

  • Type parameters

    • T: "info" | "warn" | "error" | "ready" | "serverHeartbeat" | "transactionStatus" | "playerMoves" | "playerSetsStatus" | "playerSpotlights" | "playerRings" | "playerChats" | "playerInteracts" | "playerGhosts" | "playerEntersWhisper" | "playerLeavesWhisper" | "playerActivelySpeaks" | "playerSetsWorkCondition" | "playerSetsName" | "playerSetsTextStatus" | "playerSetsEmojiStatus" | "playerSetsAffiliation" | "playerExits" | "respawnComplete" | "playerSetsOutfitString" | "playerSetsIsSignedIn" | "spaceOverwrites" | "spaceIsClosed" | "playerEntersPortal" | "spaceSetsIdMapping" | "playerSetsLastActive" | "playerShootsConfetti" | "playerSetsEventStatus" | "playerSetsInConversation" | "playerSetsCurrentDesk" | "playerSetsCurrentArea" | "playerSetsImagePointer" | "cookieFound" | "playerEntersWhisperV2" | "playerSetsGoKartId" | "mapSetDimensions" | "mapSetCollisions" | "mapSetBackgroundImagePath" | "mapSetForegroundImagePath" | "mapSetSprites" | "mapSetSpaces" | "mapSetSpawns" | "mapSetPortals" | "mapSetAnnouncer" | "mapSetAssets" | "mapSetObjects" | "mapSetName" | "mapSetMuteOnEntry" | "mapSetUseDrawnBG" | "mapSetWalls" | "mapSetFloors" | "mapSetAreas" | "mapDeleteObject" | "mapSetSpawn" | "playerSetsIsAlone" | "playerJoins" | "mapSetEnabledChats" | "mapSetDescription" | "mapSetDecoration" | "mapSetTutorialTasks" | "mapSetMiniMapImagePath" | "spacePlaysSound" | "mapSetScript" | "mapSetDesks" | "playerSetsIsMobile" | "setScreenPointerServer" | "playerSetsEmoteV2" | "playerSetsFocusModeEndTime" | "spaceSetsSpaceMembers" | "customEvent" | "playerSetsOpenToConversation" | "playerBlocks" | "playerUpdatesFocusModeStatus" | "playerNotifies" | "playerSetsItemString" | "playerTriggersItem" | "playerSetsFollowTarget" | "playerRequestsToLead" | "playerSetsManualVideoSrc" | "playerSetsIsNpc" | "playerSetsSubtitle" | "mapCommitsChanges" | "playerUpdatesSession" | "mapMoveObject" | "playerEditsChatMessage"

    Parameters

    Returns void

requestToLead

  • requestToLead(target: string, snapshot?: string): Promise<void>

respawn

  • respawn(): void

ring

  • ring(user: string): void

screenPointer

  • screenPointer(screenId: string, x: number, y: number): void

setActivelySpeaking

  • setActivelySpeaking(activelySpeaking: boolean): void

setAffiliation

  • setAffiliation(affiliation: string, targetId?: string): void

setCurrentArea

  • setCurrentArea(currentArea: string, targetId?: string): void

setCurrentDesk

  • setCurrentDesk(currentDesk: string, targetId?: string): void

setEmojiStatus

  • setEmojiStatus(emojiStatus: string, targetId?: string): void

setEmote

  • setEmote(emote: undefined | string, targetId?: string): void

setEventStatus

  • setEventStatus(eventStatus: string, targetId?: string): void

setFocusModeEndTime

  • setFocusModeEndTime(focusModeEndTime: string, targetId?: string): void

setFollowTarget

  • setFollowTarget(followTarget: string): void

setGoKartId

  • setGoKartId(goKartId: string, targetId?: string): void

setImpassable

  • setImpassable(mapId: string, x: number, y: number, impassable?: boolean): void

setInConversation

  • setInConversation(inConversation: boolean, targetId?: string): void

setIsAlone

  • setIsAlone(isAlone: boolean, targetId?: string): void

setIsMobile

  • setIsMobile(isMobile: boolean): void

setItem

  • setItem(itemId: string, itemImage: string, targetId?: string): void

setManualVideoSrc

  • setManualVideoSrc(manualVideoSrc: string, targetId?: string): void

setMapAnnouncer

  • setMapAnnouncer(mapId: string, announcer: Announcer[]): void

setMapAreas

  • setMapAreas(mapId: string, areas: {}): void

setMapBackgroundImagePath

  • setMapBackgroundImagePath(mapId: string, backgroundImagePath: string): void

setMapCollisions

  • setMapCollisions(mapId: string, x: number, y: number, w: number, h: number, mask: string): void

setMapDecoration

  • setMapDecoration(mapId: string, decoration: string): void

setMapDescription

  • setMapDescription(mapId: string, description: string): void

setMapDimensions

  • setMapDimensions(mapId: string, width: number, height: number): void

setMapEnabledChats

  • setMapEnabledChats(mapId: string, enabledChats: EnabledChat[]): void

setMapFloors

setMapForegroundImagePath

  • setMapForegroundImagePath(mapId: string, foregroundImagePath: string): void

setMapMiniMapImagePath

  • setMapMiniMapImagePath(mapId: string, miniMapImagePath: string): void

setMapMuteOnEntry

  • setMapMuteOnEntry(mapId: string, muteOnEntry: boolean): void

setMapName

  • setMapName(mapId: string, name: string): void

setMapObjects

  • setMapObjects(mapId: string, objects: {}, updatesAreOverwrites?: boolean): void

setMapPortals

  • setMapPortals(mapId: string, portals: Portal[]): void

setMapSpaces

  • setMapSpaces(mapId: string, spaces: Space[]): void

setMapSpawns

  • setMapSpawns(mapId: string, spawns: SpawnPoint[]): void

setMapSprites

  • setMapSprites(mapId: string, sprites: number[]): void

setMapTutorialTasks

  • setMapTutorialTasks(mapId: string, tutorialTasks: TutorialTasks): void

setMapUseDrawnBG

  • setMapUseDrawnBG(mapId: string, useDrawnBG: boolean): void

setMapWalls

setName

  • setName(name: string, targetId?: string): void

setObject

  • setObject(mapId: string, objId: string, obj: Partial<MapObject>, useTxnId?: boolean): void | Promise<unknown>

setOpenToConversation

  • setOpenToConversation(openToConversation: boolean, targetId?: string): void

setOutfitString

  • setOutfitString(outfitString: string, targetId?: string): void

setSpotlight

  • setSpotlight(user: string, spotlighted: boolean): void

setStatus

  • setStatus(status: boolean, targetId?: string): void

setSubtitle

  • setSubtitle(subtitle: string, targetId?: string): Promise<void>

setTextStatus

  • setTextStatus(textStatus: string, targetId?: string): void

setWorkCondition

  • setWorkCondition(workCondition: boolean, targetId?: string): void

shootConfetti

  • shootConfetti(targetId?: string): void

spawn

  • spawn(spawnToken: string): void

subscribeToAll

  • subscribeToAll(): void

subscribeToConnection

  • subscribeToConnection(callback: (connected: boolean) => void): () => void
  • Parameters

    • callback: (connected: boolean) => void
        • (connected: boolean): void
        • Parameters

          • connected: boolean

          Returns void

    Returns () => void

      • (): void
      • Returns void

subscribeToDisconnection

  • subscribeToDisconnection(callback: (code?: number, reason?: string) => void): () => void
  • Parameters

    • callback: (code?: number, reason?: string) => void
        • (code?: number, reason?: string): void
        • Parameters

          • Optional code: number
          • Optional reason: string

          Returns void

    Returns () => void

      • (): void
      • Returns void

subscribeToEvent

  • Type parameters

    • T: "info" | "warn" | "error" | "ready" | "serverHeartbeat" | "transactionStatus" | "playerMoves" | "playerSetsStatus" | "playerSpotlights" | "playerRings" | "playerChats" | "playerInteracts" | "playerGhosts" | "playerEntersWhisper" | "playerLeavesWhisper" | "playerActivelySpeaks" | "playerSetsWorkCondition" | "playerSetsName" | "playerSetsTextStatus" | "playerSetsEmojiStatus" | "playerSetsAffiliation" | "playerExits" | "respawnComplete" | "playerSetsOutfitString" | "playerSetsIsSignedIn" | "spaceOverwrites" | "spaceIsClosed" | "playerEntersPortal" | "spaceSetsIdMapping" | "playerSetsLastActive" | "playerShootsConfetti" | "playerSetsEventStatus" | "playerSetsInConversation" | "playerSetsCurrentDesk" | "playerSetsCurrentArea" | "playerSetsImagePointer" | "cookieFound" | "playerEntersWhisperV2" | "playerSetsGoKartId" | "mapSetDimensions" | "mapSetCollisions" | "mapSetBackgroundImagePath" | "mapSetForegroundImagePath" | "mapSetSprites" | "mapSetSpaces" | "mapSetSpawns" | "mapSetPortals" | "mapSetAnnouncer" | "mapSetAssets" | "mapSetObjects" | "mapSetName" | "mapSetMuteOnEntry" | "mapSetUseDrawnBG" | "mapSetWalls" | "mapSetFloors" | "mapSetAreas" | "mapDeleteObject" | "mapSetSpawn" | "playerSetsIsAlone" | "playerJoins" | "mapSetEnabledChats" | "mapSetDescription" | "mapSetDecoration" | "mapSetTutorialTasks" | "mapSetMiniMapImagePath" | "spacePlaysSound" | "mapSetScript" | "mapSetDesks" | "playerSetsIsMobile" | "setScreenPointerServer" | "playerSetsEmoteV2" | "playerSetsFocusModeEndTime" | "spaceSetsSpaceMembers" | "customEvent" | "playerSetsOpenToConversation" | "playerBlocks" | "playerUpdatesFocusModeStatus" | "playerNotifies" | "playerSetsItemString" | "playerTriggersItem" | "playerSetsFollowTarget" | "playerRequestsToLead" | "playerSetsManualVideoSrc" | "playerSetsIsNpc" | "playerSetsSubtitle" | "mapCommitsChanges" | "playerUpdatesSession" | "mapMoveObject" | "playerEditsChatMessage"

    Parameters

    Returns () => void

      • (): void
      • Returns void

subscribeToSpace

  • subscribeToSpace(space: string, listeners: Readonly<{ onMap: any }>): () => void

Private subscriptionFailedCallback

  • subscriptionFailedCallback(reason: string): void

Private subscriptionFinishedCallback

  • subscriptionFinishedCallback(): void

teleport

triggerItem

  • triggerItem(closestObject?: string, closestObjectTemplate?: string, targetId?: string): void

waitForInit

  • waitForInit(): Promise<void>
  • Returns Promise<void>

    a Promise that resolves when initialization is finished. Rejects if you attempt to wait before init-ing.

Generated using TypeDoc