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
Name | Description |
---|---|
TEnum | Type of states and transitions, constrained to be an enumeration. |
Hierarchy
↳
StateMachine$1
Constructors
constructor
• new StateMachine$1<TEnum
>()
Type parameters
Name | Description |
---|---|
TEnum | Defines 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
Name | Type | Description |
---|---|---|
$state | TEnum | The 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
Name | Type | Description |
---|---|---|
$state | TEnum | State to find within the state machine. |
$success | Action$1 <State$1 <TEnum >> | Callback function to handle the found State . |
$failed | Action | Callback 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
Name | Type | Description |
---|---|---|
$from | TEnum | State from which the transition starts. |
$to | TEnum | State to which the transition will occur. |
$success | Action$1 <Transition$1 <TEnum >> | Callback function to handle the found Transition . |
$failed | Action | Callback 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
Name | Type | Description |
---|---|---|
$from | TEnum | State from which the transition starts. |
$success | Action$1 <Transition$1 <TEnum >[]> | Callback function to handle the found array of Transition . |
$failed | Action | Callback function to handle the case when transitions are not found. |
Returns
void
LeaveState
▸ LeaveState($nextState
): void
The state machine exits the current state.
Parameters
Name | Type | Description |
---|---|---|
$nextState | TEnum | The 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
Name | Type | Description |
---|---|---|
$state | TEnum | State 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
Name | Type | Description |
---|---|---|
$deltaTime | number | Time elapsed in seconds since the last Update call. |
Returns
void