![]() |
BomberUnits
...a Unity learning project
|
Common Base class for all state machines. More...
Inheritance diagram for StateMachine:
Collaboration diagram for StateMachine:Public Member Functions | |
| State | GetActiveState () |
| Returns a reference to the currently active state. | |
| void | TriggerTransition (string transName) |
| Overload to enable external transition triggering from current state. More... | |
| void | TriggerTransition (string fromState, string transName) |
| Overload to enable external transition triggering using state and transition names. More... | |
| void | TriggerTransition (State fromState, string transName) |
| Attempts to execute the given transition. More... | |
| void | UpdateCurrentState (State stateRef) |
| Used bu all States to announce themselves as currently active state when entered. | |
| void | RegisterState (State state) |
| Used by all States to register themselves at the SM during startup. More... | |
Public Attributes | |
| bool | logEnabled |
Protected Member Functions | |
| virtual void | MyStart () |
| Override to provide an extended Start function for subclasses. Do not override 'Start()' itself! | |
Protected Attributes | |
| State | activeState = null |
| Holds a reference to the current active state. | |
| Animator | controller = null |
| Reference to the Unity (Animation) mechanism for SM design. | |
Private Member Functions | |
| void | Start () |
| Callback is used to provide the state registering mechanism. More... | |
Private Attributes | |
| List< State > | states = new List<State>() |
| The list of available states within this SM. | |
Common Base class for all state machines.
Implementing subclasses may use the public interface, as well as the provided start method: MyStart() The reference to the animator's controller is initialized by this class.
Definition at line 8 of file StateMachine.cs.
|
inline |
Used by all States to register themselves at the SM during startup.
Not to be used for other purposes than the SM plumbing layer.
Definition at line 82 of file StateMachine.cs.
|
inlineprivate |
Callback is used to provide the state registering mechanism.
Do not override! A replacing 'MyStart()' function is provided!
Definition at line 102 of file StateMachine.cs.
|
inline |
Overload to enable external transition triggering from current state.
Use with care, as having to explicitly give the state to transition from is safer!
Definition at line 34 of file StateMachine.cs.
|
inline |
Overload to enable external transition triggering using state and transition names.
Checks whether the given state name exists.
Definition at line 41 of file StateMachine.cs.
|
inline |
Attempts to execute the given transition.
Will throw a warning and abort if the transition is not applicable for the given state, or the state is not the currently active state.
Definition at line 56 of file StateMachine.cs.