Summary
A simple keyless Finite State Machine system.
- Assembly
- Animancer
.dll - Namespace
- Animancer
.FSM - Base Types
-
- Object
- Derived Types
graph BT
Type-->Base0["Object"]
Type["StateMachine<TState>"]
class Type type-node
Derived0["StateMachine<TState>.WithDefault"]-->Type
click Derived0 "/animancer/api/Animancer.FSM/WithDefault"
Derived1["StateMachine<TKey, TState>"]-->Type
click Derived1 "/animancer/api/Animancer.FSM/StateMachine_2"
Syntax
[HelpURL(StateExtensions.APIDocumentationURL + nameof(StateMachine<TState>) + "_1")]
public class StateMachine<TState> where TState : class, IState
Remarks
This class doesn't keep track of any states other than the currently active one.
See
Animancer.FSM.StateMachine`2
for a system that allows states to be pre-registered and accessed
using a separate key.
Documentation: Finite State Machines
Attributes
Type | Description |
---|---|
HelpURLAttribute |
Type Parameters
Name | Description |
---|---|
TState |
Constructors
Name | Summary |
---|---|
StateMachine |
Creates a new Animancer.FSM.StateMachine`1 , leaving the Animancer.FSM.StateMachine`1.CurrentState null. |
StateMachine |
Creates a new Animancer.FSM.StateMachine`1 and immediately enters the `state`. |
Properties
Name | Value | Summary |
---|---|---|
AllowNullStates | bool |
[Assert-Only] Should the
Animancer.FSM.StateMachine`1.CurrentState be allowed to be set to null? Default is false. |
CurrentState | TState |
The currently active state.
|
NextState | TState |
The
Animancer.FSM.StateChange`1.NextState . |
PreviousState | TState |
The
Animancer.FSM.StateChange`1.PreviousState . |
Methods
Name | Value | Summary |
---|---|---|
CanSetState |
TState |
Returns the first of the `states` which can currently be entered.
|
CanSetState |
bool |
Is it currently possible to enter the specified `state`?
|
ForceSetState |
void |
Calls
Animancer.FSM.IState.OnExitState on the Animancer.FSM.StateMachine`1.CurrentState then changes to the
specified `state` and calls Animancer.FSM.IState.OnEnterState on it.
This method does not check Animancer.FSM.IState.CanExitState or
Animancer.FSM.IState.CanEnterState . To do that, you should use Animancer.FSM.StateMachine`1.TrySetState(`0) instead.
|
OnInspectorGUI |
void |
[Editor-Only] Draws an Inspector field for the
Animancer.FSM.StateMachine`1.CurrentState . |
SetAllowNullStates |
void |
[Assert-Conditional] Sets
Animancer.FSM.StateMachine`1.AllowNullStates . |
ToString |
string |
Returns a string describing the type of this state machine and its
Animancer.FSM.StateMachine`1.CurrentState . |
TryResetState |
bool |
Attempts to enter any of the specified `states` and returns true if successful.
This method does not check if the `state` is already the
Animancer.FSM.StateMachine`1.CurrentState . To do so, use
Animancer.FSM.StateMachine`1.TrySetState(System.Collections.Generic.IList{`0}) instead.
|
TryResetState |
bool |
Attempts to enter the specified `state` and returns true if successful.
This method does not check if the `state` is already the
Animancer.FSM.StateMachine`1.CurrentState . To do so, use
Animancer.FSM.StateMachine`1.TrySetState(`0) instead.
|
TrySetState |
bool |
Attempts to enter any of the specified `states` and returns true if successful.
This method returns true and does nothing else if the
Animancer.FSM.StateMachine`1.CurrentState is in the list.
To allow directly re-entering the same state, use Animancer.FSM.StateMachine`1.TryResetState(System.Collections.Generic.IList{`0}) instead.
|
TrySetState |
bool |
Attempts to enter the specified `state` and returns true if successful.
This method returns true immediately if the specified `state` is already the
Animancer.FSM.StateMachine`1.CurrentState .
To allow directly re-entering the same state, use Animancer.FSM.StateMachine`1.TryResetState(`0) instead.
|