Reference Source
import {StateManager} from 'state-manager'
public class | source

StateManager

Constructor Summary

Public Constructor
public

constructor(pStates: Object<State>)

Creates a new state machine manager.

Member Summary

Public Members
public

version: *

The version of the module.

Private Members
private

The current state of the state machine.

private

The logger module this module uses to log errors / logs.

private

An object containing all the registered states.

Method Summary

Public Methods
public

Gets the current state.

public

registerState(pName: string, pState: State)

Registers a new state with the state machine.

public

setState(pName: string, pRest: *)

Sets the current state of the state machine.

public

update(pDelta: number)

Updates the current state of the state machine.

Public Constructors

public constructor(pStates: Object<State>) source

Creates a new state machine manager.

Params:

NameTypeAttributeDescription
pStates Object<State>

Array of state objects to register.

Public Members

public version: * source

The version of the module.

Private Members

private currentState: State | null source

The current state of the state machine.

private logger: Object source

The logger module this module uses to log errors / logs.

private states: Object<string, State> source

An object containing all the registered states.

Public Methods

public getCurrentState(): * source

Gets the current state.

Return:

*

public registerState(pName: string, pState: State) source

Registers a new state with the state machine.

Params:

NameTypeAttributeDescription
pName string

The name of the state.

pState State

The state object.

public setState(pName: string, pRest: *) source

Sets the current state of the state machine.

Params:

NameTypeAttributeDescription
pName string

The name of the state to set.

pRest *

The arguments that were passed when setting this state.

public update(pDelta: number) source

Updates the current state of the state machine.

Params:

NameTypeAttributeDescription
pDelta number

The delta time since the last update in seconds.