BGC Tools
|
Implements a state machine that can be constructed programatically that is similar to the Unity animation state machine but not frame capped. More...
Public Member Functions | |
StateMachine (bool verbose=false) | |
Construct a StateMachine. Verbose dumps state transition information to UnityEngine.Log More... | |
void | AddState (State state) |
Add a state to the state machine More... | |
void | AddState (TriggeringState< TTriggerEnum > state) |
void | AddState (CoordinatingState< TBoolEnum, TTriggerEnum > state) |
Add a coordinating state to the state machine More... | |
void | AddEntryState (State state) |
Add a state to the StateMachine and sets it as the initial State More... | |
void | AddEntryState (CoordinatingState< TBoolEnum, TTriggerEnum > state) |
Add a coordinate state to the state machine that is the initial state More... | |
void | AddTransition (State fromState, State targetState, params TransitionCondition< TBoolEnum, TTriggerEnum >[] conditions) |
Add a Standard Transition between two States More... | |
void | AddAnyStateTransition (State targetState, params TransitionCondition< TBoolEnum, TTriggerEnum >[] conditions) |
Add a Transition that can occur from any state More... | |
void | AddBool (TBoolEnum key, bool initialValue) |
Add a boolean that can affect transitions More... | |
void | ActivateTriggerImmediate (TTriggerEnum key) |
Activate a trigger to move the state machine forward. Initiate a transition check if transitions aren't blocked. More... | |
void | ActivateTriggerDeferred (TTriggerEnum key) |
Activate a trigger to move the state machine forward. Relies upon the eventual calling of either an Update or an Immediate call. More... | |
void | SetBoolImmediate (TBoolEnum key, bool value) |
Set a boolean that can affect transitions. Initiate a transition check if transitions aren't blocked. More... | |
void | SetBoolDeferred (TBoolEnum key, bool value) |
Set a boolean that can affect transitions. Relies upon the eventual calling of either an Update or an Immediate call. More... | |
void | Update () |
Call update function on the currently active state. More... | |
void | Start () |
Run the first state of the state machine More... | |
void | Reset (bool restartStateMachine=false) |
Reset the state machine by exiting the current state and setting the state to the entry state. If restartStateMachine is set to true then entry state will be entered and the StateMachine will have effectively restarted More... | |
TriggerCondition< TBoolEnum, TTriggerEnum > | CreateTriggerCondition (TTriggerEnum key) |
BoolCondition< TBoolEnum, TTriggerEnum > | CreateBoolCondition (TBoolEnum key, bool value) |
OrConjunction< TBoolEnum, TTriggerEnum > | CreateOrConjunction (params TransitionCondition< TBoolEnum, TTriggerEnum >[] conditions) |
Properties | |
State | CurrentState [get, private set] |
Get the name of the current State that the StateMachine is in More... | |
Private Member Functions | |
Transition< TBoolEnum, TTriggerEnum > | CheckTransitions () |
Test to see if there is a valid transitions and return it, or null. Clears the dirtyTransitionState flag. More... | |
void | ExecuteTransitions () |
Run transitions as long as we have a valid one to perform next. Blocks immediate transitions from occuring. More... | |
void IStateTrigger< TTriggerEnum >. | ActivateTrigger (TTriggerEnum key) |
bool IStateTrigger< TTriggerEnum >. | GetTrigger (TTriggerEnum key) |
void IStateDataBool< TBoolEnum >. | SetBool (TBoolEnum key, bool value) |
bool IStateDataBool< TBoolEnum >. | GetBool (TBoolEnum key) |
bool ITransitionDataRetriever< TBoolEnum, TTriggerEnum >. | GetBool (TBoolEnum key) |
bool ITransitionDataRetriever< TBoolEnum, TTriggerEnum >. | GetTrigger (TTriggerEnum key) |
void ITransitionDataRetriever< TBoolEnum, TTriggerEnum >. | ConsumeTrigger (TTriggerEnum key) |
void | Log (string str) |
Log the string if verbose More... | |
Private Attributes | |
readonly Dictionary< State, List< Transition< TBoolEnum, TTriggerEnum > > > | stateTransitions |
readonly List< Transition< TBoolEnum, TTriggerEnum > > | anyStateTransitions |
readonly StateData< TBoolEnum, TTriggerEnum > | stateData |
readonly bool | verbose |
State | entryState = null |
bool | running = false |
bool | dirtyTransitionState = false |
bool | blockTransitions = false |
Implements a state machine that can be constructed programatically that is similar to the Unity animation state machine but not frame capped.
To use the update function, put the Update call in a MonoBehavior class Update call.
TBoolEnum | : | Enum | |
TTriggerEnum | : | Enum |
Definition at line 14 of file StateMachine.cs.
|
inline |
Construct a StateMachine. Verbose dumps state transition information to UnityEngine.Log
Definition at line 42 of file StateMachine.cs.
|
private |
Implements BGC.StateMachine.IStateTrigger< TTriggerEnum >.
|
inline |
Activate a trigger to move the state machine forward. Relies upon the eventual calling of either an Update or an Immediate call.
Definition at line 186 of file StateMachine.cs.
|
inline |
Activate a trigger to move the state machine forward. Initiate a transition check if transitions aren't blocked.
Definition at line 165 of file StateMachine.cs.
|
inline |
Add a Transition that can occur from any state
Definition at line 145 of file StateMachine.cs.
References BGC.StateMachine.Transition< TBoolEnum, TTriggerEnum >.SetStateDataRetrievers().
void BGC.StateMachine.StateMachine< TBoolEnum, TTriggerEnum >.AddBool | ( | TBoolEnum | key, |
bool | initialValue | ||
) |
Add a boolean that can affect transitions
|
inline |
Add a state to the StateMachine and sets it as the initial State
Definition at line 91 of file StateMachine.cs.
|
inline |
Add a coordinate state to the state machine that is the initial state
state |
Definition at line 109 of file StateMachine.cs.
|
inline |
Add a state to the state machine
Definition at line 53 of file StateMachine.cs.
References BGC.StateMachine.State.SetVerbose().
|
inline |
Definition at line 70 of file StateMachine.cs.
References BGC.StateMachine.TriggeringState< TTriggerEnum >.SetStateMachineFunctions(), and BGC.StateMachine.State.SetVerbose().
|
inline |
Add a coordinating state to the state machine
state |
Definition at line 81 of file StateMachine.cs.
References BGC.StateMachine.CoordinatingState< TBoolEnum, TTriggerEnum >.SetStateMachineFunctions(), and BGC.StateMachine.State.SetVerbose().
|
inline |
Add a Standard Transition between two States
Definition at line 126 of file StateMachine.cs.
References BGC.StateMachine.Transition< TBoolEnum, TTriggerEnum >.SetStateDataRetrievers().
|
inlineprivate |
Test to see if there is a valid transitions and return it, or null. Clears the dirtyTransitionState flag.
Definition at line 319 of file StateMachine.cs.
|
private |
|
inline |
Definition at line 389 of file StateMachine.cs.
|
inline |
Definition at line 394 of file StateMachine.cs.
|
inline |
Definition at line 384 of file StateMachine.cs.
|
inlineprivate |
Run transitions as long as we have a valid one to perform next. Blocks immediate transitions from occuring.
Definition at line 349 of file StateMachine.cs.
References BGC.StateMachine.IStateTrigger< TTriggerEnum >.ActivateTrigger(), BGC.StateMachine.ITransitionDataRetriever< TBoolEnum, TTriggerEnum >.ConsumeTrigger(), BGC.StateMachine.IStateDataBool< TBoolEnum >.GetBool(), BGC.StateMachine.ITransitionDataRetriever< TBoolEnum, TTriggerEnum >.GetBool(), BGC.StateMachine.IStateTrigger< TTriggerEnum >.GetTrigger(), BGC.StateMachine.ITransitionDataRetriever< TBoolEnum, TTriggerEnum >.GetTrigger(), BGC.StateMachine.State.OnEnter(), BGC.StateMachine.Transition< TBoolEnum, TTriggerEnum >.OnTransition(), BGC.StateMachine.IStateDataBool< TBoolEnum >.SetBool(), and BGC.StateMachine.Transition< TBoolEnum, TTriggerEnum >.TargetState.
|
private |
Implements BGC.StateMachine.IStateDataBool< TBoolEnum >.
|
private |
Implements BGC.StateMachine.IStateDataBool< TBoolEnum >.
|
private |
Implements BGC.StateMachine.IStateTrigger< TTriggerEnum >.
|
private |
Implements BGC.StateMachine.IStateTrigger< TTriggerEnum >.
|
inlineprivate |
|
inline |
Reset the state machine by exiting the current state and setting the state to the entry state. If restartStateMachine is set to true then entry state will be entered and the StateMachine will have effectively restarted
Definition at line 294 of file StateMachine.cs.
|
private |
Implements BGC.StateMachine.IStateDataBool< TBoolEnum >.
|
inline |
Set a boolean that can affect transitions. Relies upon the eventual calling of either an Update or an Immediate call.
Definition at line 220 of file StateMachine.cs.
|
inline |
Set a boolean that can affect transitions. Initiate a transition check if transitions aren't blocked.
Definition at line 199 of file StateMachine.cs.
|
inline |
Run the first state of the state machine
Definition at line 265 of file StateMachine.cs.
|
inline |
Call update function on the currently active state.
Definition at line 232 of file StateMachine.cs.
References BGC.StateMachine.State.OnEnter().
|
private |
Definition at line 22 of file StateMachine.cs.
|
private |
Definition at line 30 of file StateMachine.cs.
|
private |
Definition at line 29 of file StateMachine.cs.
|
private |
Definition at line 26 of file StateMachine.cs.
|
private |
Definition at line 28 of file StateMachine.cs.
|
private |
Definition at line 23 of file StateMachine.cs.
|
private |
Definition at line 21 of file StateMachine.cs.
|
private |
Definition at line 24 of file StateMachine.cs.
|
getprivate set |
Get the name of the current State that the StateMachine is in
Definition at line 35 of file StateMachine.cs.