Skip to main content

TGameStateManager

Index

Constructors

publicconstructor

Methods

publiccurrent

  • Returns the current active state or undefined if no state active.


    Returns undefined | default

publicgetActiveCamera

  • getActiveCamera(): undefined | ICamera

publicgetRenderTasks

  • getRenderTasks(): TSerializedRenderTask[]
  • Returns TSerializedRenderTask[]

publicpop

  • pop(...args: unknown[]): Promise<void>
  • Triggers [[TGameState.onLeave]] on current state, removes from it from the stack. Makes the state below the current state and then calls [[`TGameState.onResume``]]

    It does not trigger [[TGameState.onEnter]].


    Parameters

    • rest...args: unknown[]

      args to pass to the resumed state

    Returns Promise<void>

publicpush

  • push(name: string, ...args: unknown[]): Promise<void>
  • Pushes a new state onto the stack. It triggers [[TGameState.onEnter]] on the new state.

    It does not trigger [[TGameState.onLeave]] on previously active state.


    Parameters

    • name: string

      state name

    • rest...args: unknown[]

      args to pass to the resumed state

    Returns Promise<void>

publicregister

  • register(name: string, state: TGameStateType): void
  • Register new state type with the manager. Usually done as game init.


    Parameters

    • name: string
    • state: TGameStateType

    Returns void

publicswitch

  • switch(name: string, ...args: unknown[]): Promise<void>
  • Switches the current active state with the provided one. Triggers [[TGameState.onLeave]] on the previously active state, then [[TGameState.onEnter]] on the new state.


    Parameters

    • name: string

      state name

    • rest...args: unknown[]

      args to pass to the new state

    Returns Promise<void>

publicupdate