Class StateMachineBehavior
The UnityEngine.MonoBehaviour derivative of a StateMachine
Inheritance
Implements
Namespace: Atlas
Assembly: Atlas.Runtime.dll
Syntax
public class StateMachineBehavior : MonoBehaviour, IStateMachine
Properties
| Improve this Doc View SourceCurrentState
The state that's currently executing, or null if no state is running
Declaration
public State CurrentState { get; }
Property Value
Type | Description |
---|---|
State |
PreviousState
The state that was running before the current one, or null if no previous state exists
Declaration
public State PreviousState { get; }
Property Value
Type | Description |
---|---|
State |
Methods
| Improve this Doc View SourceAddState<StateType>(StateType)
Adds the given state to the state machine
Declaration
public void AddState<StateType>(StateType state)
where StateType : State
Parameters
Type | Name | Description |
---|---|---|
StateType | state | The state to add |
Type Parameters
Name | Description |
---|---|
StateType | Type of state to add |
GetState<StateType>()
Gets the state of the given type. If multiple states exist with the given type, the first state of the desired type is returned.
Declaration
public StateType GetState<StateType>()
where StateType : State
Returns
Type | Description |
---|---|
StateType | The state with the given type |
Type Parameters
Name | Description |
---|---|
StateType | Type of state to get |
RemoveState<StateType>()
Removes the state of the given type. If multiple states exist with the given type, the first state of the desired type is removed.
Declaration
public void RemoveState<StateType>()
where StateType : State
Type Parameters
Name | Description |
---|---|
StateType | Type of state to remove |
RevertToPrevState()
Reverts the state machine to the previously running state
Declaration
public void RevertToPrevState()
SetState<StateType>()
Sets the current state to the state of the desired type
Declaration
public void SetState<StateType>()
where StateType : State
Type Parameters
Name | Description |
---|---|
StateType | Type of state to change to |
Tick()
Updates the state machine, called in Update() automatically
Declaration
public void Tick()
Update()
Updates the state machine, called by Unity
Declaration
protected virtual void Update()