Class StateMachine
State machine logic pattern
Inheritance
System.Object
StateMachine
Namespace: FlaxEngine.Utilities
Assembly: FlaxEngine.CSharp.dll
Syntax
public abstract class StateMachine : Object
Constructors
StateMachine()
Declaration
protected StateMachine()
Fields
currentState
states
The states.
Declaration
protected readonly List<State> states
Field Value
System.Collections.Generic.List<State>
|
Properties
CurrentState
States
Gets the states (read-only).
Declaration
public IReadOnlyList<State> States { get; }
Property Value
System.Collections.Generic.IReadOnlyList<State>
|
Methods
AddState(State)
Adds the state.
Declaration
public virtual void AddState(State state)
Parameters
State
state
The state. |
GetState<TStateType>()
Gets state of given type.
Declaration
public State GetState<TStateType>()
Returns
State
|
Type Parameters
TStateType
The type of the state. |
GoToState(State)
Goes to the state.
Declaration
public virtual void GoToState(State state)
Parameters
State
state
The target state. |
Exceptions
System.ArgumentNullException
state |
GoToState<TStateType>()
Goes to the state.
Declaration
public void GoToState<TStateType>()
Type Parameters
TStateType
The type of the state. |
Exceptions
System.InvalidOperationException
Cannot find state of given type. |
RemoveState(State)
Removes the state.
Declaration
public virtual void RemoveState(State state)
Parameters
State
state
The state. |
SwitchState(State)
Switches the state.
Declaration
protected virtual void SwitchState(State nextState)
Parameters
State
nextState
Then next state. |
Events
StateChanged
Occurs when state gets changed.
Declaration
public event Action StateChanged
Event Type
System.Action
|
StateChanging
Occurs when state is being changed.
Declaration
public event Action StateChanging
Event Type
System.Action
|