Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PlayerControl<RoomType>

Represents a player object for interacting with the game and other players.

See PlayerControlEvents for events to listen to.

Type parameters

  • RoomType: Hostable

Hierarchy

Implements

Index

Methods

Awake

  • Awake(): void

Deserialize

  • Deserialize(reader: HazelReader, spawn?: boolean): void

Destroy

  • Destroy(): void

FixedUpdate

  • FixedUpdate(delta: number): void

HandleRpc

PreSerialize

  • PreSerialize(): void

Serialize

  • Serialize(writer: HazelWriter, spawn?: boolean): boolean

canBeManaged

  • canBeManaged(): boolean

checkColor

  • checkColor(color: Color): Promise<void>

checkName

  • checkName(name: string): Promise<void>
  • Request for the host to check a name for this player and append numbers if it's taken.

    Parameters

    • name: string

      The name to request.

    Returns Promise<void>

completeTask

  • completeTask(taskIdx: number): void

despawn

  • despawn(): void
  • Despawns the component from the room it belongs in.

    Returns void

emit

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

emitSerial

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

emitSync

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

getComponent

  • getComponent<T>(component: NetworkableConstructor<T>): undefined | T
  • Type parameters

    • T: Networkable<any, NetworkableEvents<Hostable<any>>, Hostable<any>, T>

    Parameters

    • component: NetworkableConstructor<T>

    Returns undefined | T

getListeners

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

kill

  • kill(reason: string): Promise<void>

murderPlayer

  • murderPlayer(victim: PlayerData<Hostable<any>>): Promise<void>
  • Murder another a player. This operation can only be called if the player is the impostor on official servers.

    Due to technical limitations, this operation cannot be canceled or reverted without advanced "breaking game", therefore it is out of scope of a single .revert() function on the event emitted.

    Emits a player.murder event.

    Parameters

    • victim: PlayerData<Hostable<any>>

      The player to murder.

    Returns Promise<void>

off

  • off<EventName>(event: EventName, listener: Listener<PlayerControlEvents<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"

    Parameters

    Returns void

  • Type parameters

    Parameters

    • event: string
    • listener: Listener<K>

    Returns void

on

  • on<EventName>(event: EventName, listener: Listener<PlayerControlEvents<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"

    Parameters

    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<PlayerControlEvents<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"

    Parameters

    Returns () => void

      • (): void
      • Returns void

  • Type parameters

    Parameters

    • event: string
    • listener: Listener<K>

    Returns () => void

      • (): void
      • Returns void

protectPlayer

  • protectPlayer(target: PlayerData<Hostable<any>>, angelColor?: Color): Promise<void>

removeAllListeners

  • removeAllListeners(): void

removeListeners

  • removeListeners(event: string): void

removeProtection

  • removeProtection(timeout?: boolean): Promise<void>
  • Remove this player's protection from a guardian angel, if they have one.

    Emits a player.removeprotection event. This is not networked, so other players will not see this update.

    Parameters

    • timeout: boolean = false

      Whether or not this is because of a timeout.

    Returns Promise<void>

revertShapeshift

  • revertShapeshift(): Promise<void>

sendChat

  • sendChat(message: string): void

sendChatNote

  • sendChatNote(player: PlayerData<Hostable<any>>, type: DidVote): void

sendQuickChat

  • sendQuickChat(message: PlayerData<Hostable<any>> | StringNames, format?: (PlayerData<Hostable<any>> | StringNames)[]): void
  • Send a quick chat message as this player.

    Due to technical impossibilities, this event cannot be canceled or reverted.

    Emits a player.quickchat event.

    Parameters

    • message: PlayerData<Hostable<any>> | StringNames
    • Optional format: (PlayerData<Hostable<any>> | StringNames)[]

    Returns void

setColor

  • setColor(color: Color): Promise<void>

setHat

  • setHat(hatId: string): Promise<void>
  • Update this player's hat. This is not a host operation unless the client does not own this player.

    Emits a player.sethat event.

    Parameters

    • hatId: string

      The hat to set this player's hat to, see Hat.

    Returns Promise<void>

setName

  • setName(name: string): Promise<void>

setNameplate

  • setNameplate(nameplateId: string): Promise<void>

setPet

  • setPet(petId: string): Promise<void>
  • Update this player's pet. This is not a host operation unless the client does not own this player.

    Emits a player.setpet event.

    Parameters

    • petId: string

      The pet to set this player's pet to, see Pet.

    Returns Promise<void>

setRole

  • setRole(roleCtr: typeof BaseRole): Promise<void>

setSkin

  • setSkin(skinId: string): Promise<void>

setStartCounter

  • setStartCounter(counter: number): Promise<void>
  • Change the counter at the bottom of the screen while in the lobby, usually counting down from 5 to 1. This is a host-only operation on official servers.

    Emits a player.setstartcounter event.

    Parameters

    • counter: number

      The counter to set to.

    Returns Promise<void>

setVisor

  • setVisor(visorId: string): Promise<void>

shapeshift

  • shapeshift(target: PlayerData<RoomType>, doAnimation?: boolean): Promise<void>

spawn

  • spawn(): void
  • Spawn this component if does not exist in the room it belongs in.

    Returns void

startMeeting

  • startMeeting(body: PlayerData<Hostable<any>> | "emergency", caller?: PlayerData<Hostable<any>>): Promise<void>
  • If you're the host, this will immediately begin a meeting Start a meeting and begin the meeting

    Emits a player.startmeeting event.

    Parameters

    • body: PlayerData<Hostable<any>> | "emergency"

      The body that was reported, or "emergency" if it is an emergency meeting.

    • Optional caller: PlayerData<Hostable<any>>

      The player that called this meeting.

    Returns Promise<void>

syncSettings

  • syncSettings(settings: GameSettings): Promise<void>

usePlatform

  • usePlatform(): Promise<void>

wait

  • 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"

    Parameters

    • event: EventName

    Returns Promise<PlayerControlEvents<RoomType>[EventName]>

  • Parameters

    • event: string

    Returns Promise<BasicEvent>

waitf

  • waitf<EventName>(event: EventName, filter: (ev: PlayerControlEvents<RoomType>[EventName]) => boolean | Promise<boolean>): Promise<PlayerControlEvents<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"

    Parameters

    Returns Promise<PlayerControlEvents<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>

Properties

components

components: Networkable<any, NetworkableEvents<Hostable<any>>, RoomType>[]

dirtyBit

dirtyBit: number = 0

The dirty state of this component.

flags

flags: number

Flags for this object, see SpawnFlag.

Optional guardianProtector

guardianProtector: PlayerData<RoomType>

The player (i.e. a guardian angel) who has protected this player, if the player is being protected..

isNew

isNew: boolean

Whether the player was just spawned, or was spawned before joining.

netId

netId: number

The net ID of this component.

ownerId

ownerId: number

The ID of the owner of this component.

player

player: PlayerData<RoomType>

The player that this component belongs to.

playerId

playerId: number

The player ID of the player.

protectedByGuardian

protectedByGuardian: boolean

Whether or not this player has been protected bya guardian angel.

room

room: RoomType

The room that this component belongs to.

Optional shapeshiftTarget

shapeshiftTarget: PlayerData<RoomType>

The player that this player has shapeshifted as, if any.

spawnType

spawnType: SpawnType

The type of object that this component belongs to.

Constructors

constructor

Accessors

owner

  • get owner(): undefined | Hostable<any> | PlayerData<RoomType>

Generated using TypeDoc