Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PlayerData<RoomType>

Represents the player of a client connected to the room.

See PlayerDataEvents for events to listen to.

Type parameters

  • RoomType: Hostable

Hierarchy

Index

Properties

Readonly clientId

clientId: number

control

control: undefined | PlayerControl<RoomType>

This player's player control component.

Readonly friendCode

friendCode: string = ""

inScene

inScene: boolean

Whether or not this player is in the game scene.

isReady

isReady: boolean

Whether or not this player is readied up to start the game.

Readonly platform

platform: PlatformSpecificData = ...

Readonly playerLevel

playerLevel: number = 0

Readonly puid

puid: string = ""

Optional role

role: BaseRole<Hostable<any>>

The actual instance of this player's role manager, see PlayerInfo.roleType to know which role this is.

room

room: RoomType

The room that this player object belongs to.

stream

The message stream to be sent on fixed update.

Readonly username

username: string

Constructors

constructor

  • new PlayerData<RoomType>(room: RoomType, clientId: number, username: string, platform?: PlatformSpecificData, playerLevel?: number, friendCode?: string, puid?: string): PlayerData<RoomType>
  • Type parameters

    • RoomType: Hostable<any, RoomType>

    Parameters

    • room: RoomType
    • clientId: number
    • username: string
    • platform: PlatformSpecificData = ...
    • playerLevel: number = 0
    • friendCode: string = ""
    • puid: string = ""

    Returns PlayerData<RoomType>

Methods

destroy

  • destroy(): void

emit

  • emit<Event>(event: Event): Promise<Event>

emitSerial

  • emitSerial<Event>(event: Event): Promise<Event>

emitSync

  • emitSync<Event>(event: Event): Event

getListeners

  • getListeners<Event>(event: string): Listener<Event>[]

off

  • off<EventName>(event: EventName, listener: Listener<PlayerDataEvents<RoomType>[EventName]>): void
  • off<K>(event: string, listener: Listener<K>): void
  • Type parameters

    • EventName: "component.spawn" | "component.despawn" | "player.checkcolor" | "player.checkmurder" | "player.checkname" | "player.checkprotect" | "player.completetask" | "player.die" | "player.usemovingplatform" | "player.murder" | "player.protect" | "player.removeprotection" | "player.reportbody" | "player.revertshapeshift" | "player.chat" | "player.quickchat" | "player.setcolor" | "player.sethat" | "player.setname" | "player.setnameplate" | "player.setpet" | "player.setrole" | "player.setskin" | "player.setstartcounter" | "player.setvisor" | "player.shapeshift" | "player.startmeeting" | "player.syncsettings" | "player.entervent" | "player.exitvent" | "player.climbladder" | "player.move" | "player.snapto" | "player.ready" | "player.join" | "player.leave" | "player.sethost" | "player.scenechange" | "player.spawn"

    Parameters

    • event: EventName
    • listener: Listener<PlayerDataEvents<RoomType>[EventName]>

    Returns void

  • Type parameters

    Parameters

    • event: string
    • listener: Listener<K>

    Returns void

on

  • on<EventName>(event: EventName, listener: Listener<PlayerDataEvents<RoomType>[EventName]>): () => void
  • on<K>(event: string, listener: Listener<K>): () => void
  • Type parameters

    • EventName: "component.spawn" | "component.despawn" | "player.checkcolor" | "player.checkmurder" | "player.checkname" | "player.checkprotect" | "player.completetask" | "player.die" | "player.usemovingplatform" | "player.murder" | "player.protect" | "player.removeprotection" | "player.reportbody" | "player.revertshapeshift" | "player.chat" | "player.quickchat" | "player.setcolor" | "player.sethat" | "player.setname" | "player.setnameplate" | "player.setpet" | "player.setrole" | "player.setskin" | "player.setstartcounter" | "player.setvisor" | "player.shapeshift" | "player.startmeeting" | "player.syncsettings" | "player.entervent" | "player.exitvent" | "player.climbladder" | "player.move" | "player.snapto" | "player.ready" | "player.join" | "player.leave" | "player.sethost" | "player.scenechange" | "player.spawn"

    Parameters

    • event: EventName
    • listener: Listener<PlayerDataEvents<RoomType>[EventName]>

    Returns () => void

      • (): void
      • Returns void

  • Type parameters

    Parameters

    • event: string
    • listener: Listener<K>

    Returns () => void

      • (): void
      • Returns void

once

  • once<EventName>(event: EventName, listener: Listener<PlayerDataEvents<RoomType>[EventName]>): () => void
  • once<K>(event: string, listener: Listener<K>): () => void
  • Type parameters

    • EventName: "component.spawn" | "component.despawn" | "player.checkcolor" | "player.checkmurder" | "player.checkname" | "player.checkprotect" | "player.completetask" | "player.die" | "player.usemovingplatform" | "player.murder" | "player.protect" | "player.removeprotection" | "player.reportbody" | "player.revertshapeshift" | "player.chat" | "player.quickchat" | "player.setcolor" | "player.sethat" | "player.setname" | "player.setnameplate" | "player.setpet" | "player.setrole" | "player.setskin" | "player.setstartcounter" | "player.setvisor" | "player.shapeshift" | "player.startmeeting" | "player.syncsettings" | "player.entervent" | "player.exitvent" | "player.climbladder" | "player.move" | "player.snapto" | "player.ready" | "player.join" | "player.leave" | "player.sethost" | "player.scenechange" | "player.spawn"

    Parameters

    • event: EventName
    • listener: Listener<PlayerDataEvents<RoomType>[EventName]>

    Returns () => void

      • (): void
      • Returns void

  • Type parameters

    Parameters

    • event: string
    • listener: Listener<K>

    Returns () => void

      • (): void
      • Returns void

removeAllListeners

  • removeAllListeners(): void

removeListeners

  • removeListeners(event: string): void

setReady

  • setReady(): Promise<void>

wait

  • wait<EventName>(event: EventName): Promise<PlayerDataEvents<RoomType>[EventName]>
  • wait(event: string): Promise<BasicEvent>
  • Type parameters

    • EventName: "component.spawn" | "component.despawn" | "player.checkcolor" | "player.checkmurder" | "player.checkname" | "player.checkprotect" | "player.completetask" | "player.die" | "player.usemovingplatform" | "player.murder" | "player.protect" | "player.removeprotection" | "player.reportbody" | "player.revertshapeshift" | "player.chat" | "player.quickchat" | "player.setcolor" | "player.sethat" | "player.setname" | "player.setnameplate" | "player.setpet" | "player.setrole" | "player.setskin" | "player.setstartcounter" | "player.setvisor" | "player.shapeshift" | "player.startmeeting" | "player.syncsettings" | "player.entervent" | "player.exitvent" | "player.climbladder" | "player.move" | "player.snapto" | "player.ready" | "player.join" | "player.leave" | "player.sethost" | "player.scenechange" | "player.spawn"

    Parameters

    • event: EventName

    Returns Promise<PlayerDataEvents<RoomType>[EventName]>

  • Parameters

    • event: string

    Returns Promise<BasicEvent>

waitf

  • waitf<EventName>(event: EventName, filter: (ev: PlayerDataEvents<RoomType>[EventName]) => boolean | Promise<boolean>): Promise<PlayerDataEvents<RoomType>[EventName]>
  • waitf<K>(event: string, filter: (ev: K) => boolean | Promise<boolean>): Promise<BasicEvent>
  • Type parameters

    • EventName: "component.spawn" | "component.despawn" | "player.checkcolor" | "player.checkmurder" | "player.checkname" | "player.checkprotect" | "player.completetask" | "player.die" | "player.usemovingplatform" | "player.murder" | "player.protect" | "player.removeprotection" | "player.reportbody" | "player.revertshapeshift" | "player.chat" | "player.quickchat" | "player.setcolor" | "player.sethat" | "player.setname" | "player.setnameplate" | "player.setpet" | "player.setrole" | "player.setskin" | "player.setstartcounter" | "player.setvisor" | "player.shapeshift" | "player.startmeeting" | "player.syncsettings" | "player.entervent" | "player.exitvent" | "player.climbladder" | "player.move" | "player.snapto" | "player.ready" | "player.join" | "player.leave" | "player.sethost" | "player.scenechange" | "player.spawn"

    Parameters

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

          • ev: PlayerDataEvents<RoomType>[EventName]

          Returns boolean | Promise<boolean>

    Returns Promise<PlayerDataEvents<RoomType>[EventName]>

  • Type parameters

    Parameters

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

          • ev: K

          Returns boolean | Promise<boolean>

    Returns Promise<BasicEvent>

Accessors

hasSpawned

  • get hasSpawned(): boolean

isFakePlayer

  • get isFakePlayer(): undefined | boolean
  • Whether or not this player is a fake player, as in they are entirely client-side and have no real player behind them.

    Returns undefined | boolean

isHost

  • get isHost(): boolean

isMe

  • get isMe(): boolean

physics

  • get physics(): undefined | PlayerPhysics<RoomType>

playerId

  • get playerId(): undefined | number

playerInfo

  • get playerInfo(): undefined | PlayerInfo<Hostable<any>>
  • The player's game information, such as dead/impostor/disconnected states, hats, names, pets, etc.

    Returns undefined | PlayerInfo<Hostable<any>>

playerName

  • get playerName(): undefined | string
  • Shorthand for player.playerInfo.defaultOutfit.name.

    This will return the player's name as it appears in-game, not including the name of the player that they might have shapeshifted into.

    Returns undefined | string

transform

  • get transform(): undefined | CustomNetworkTransform<RoomType>

Generated using TypeDoc