Skip to main content

StateMachine$1

ZEPETO.Character.Controller.StateMachine$1

StateMachine manages the States, Transitions, and Events. By updating states according to specified conditions and elapsed time, it enables the definition and control of diverse states for objects.

Type parameters

NameDescription
TEnumType of states and transitions, constrained to be an enumeration.

Hierarchy

Constructors

constructor

new StateMachine$1<TEnum>()

Type parameters

NameDescription
TEnumDefines the type that influences the available options, functionality, and behavior of the StateMachine$1 object.

Inherited from

System.Object.constructor

Properties

OnChangedState

OnChangedState: Action$2<TEnum, TEnum>

Event triggered when the camera state changes. Registered listeners receive two parameters:

  • The new state.
  • The previous state.

Accessors

Current

get Current(): State$1<TEnum>

Retrieves the current state.

Returns

State$1<TEnum>


Events

get Events(): TransitionBase$1<TEnum>[]

Provides an array of all the events defined in the state machine.

Returns

TransitionBase$1<TEnum>[]


IsRunning

get IsRunning(): boolean

Indicates whether the state machine is actively processing states and transitions.

Returns

boolean


Prev

get Prev(): State$1<TEnum>

Retrieves the previous state.

Returns

State$1<TEnum>


stateCount

get stateCount(): number

Retrieves the count of states defined in the state machine.

Returns

number


transitionCount

get transitionCount(): number

Retrieves the count of transitions defined in the state machine.

Returns

number

Methods

EnterState

EnterState($state): void

Transitions the state machine into a specified state.

Parameters

NameTypeDescription
$stateTEnumThe state to which the state machine will transition.

Returns

void


FindState

FindState($state, $success, $failed): void

Finds a state within the state machine and executes a callback on success.

Parameters

NameTypeDescription
$stateTEnumState to find within the state machine.
$successAction$1<State$1<TEnum>>Callback function to handle the found State.
$failedActionCallback function to handle the case when the state is not found.

Returns

void


FindTransition

FindTransition($from, $to, $success, $failed): void

Finds a transition within the state machine and executes a callback on success.

Parameters

NameTypeDescription
$fromTEnumState from which the transition starts.
$toTEnumState to which the transition will occur.
$successAction$1<Transition$1<TEnum>>Callback function to handle the found Transition.
$failedActionCallback function to handle the case when the transition is not found.

Returns

void


FindTransitions

FindTransitions($from, $success, $failed): void

Finds transitions within the state machine and executes a callback on success.

Parameters

NameTypeDescription
$fromTEnumState from which the transition starts.
$successAction$1<Transition$1<TEnum>[]>Callback function to handle the found array of Transition.
$failedActionCallback function to handle the case when transitions are not found.

Returns

void


LeaveState

LeaveState($nextState): void

The state machine exits the current state.

Parameters

NameTypeDescription
$nextStateTEnumThe next state to be handled by the current state's OnLeave.

Returns

void


Start

Start($state): void

Initiates the processing of the state machine.

Parameters

NameTypeDescription
$stateTEnumState from which the state machine will start its processing.

Returns

void


Stop

Stop(): void

Stops the processing of the state machine.

Returns

void


Update

Update($deltaTime): void

Updates the current state and transition of the state machine.

Parameters

NameTypeDescription
$deltaTimenumberTime elapsed in seconds since the last Update call.

Returns

void