Hexagon
Loading...
Searching...
No Matches
Hexagon.StateMachine.StateMachine< TParent > Class Template Reference

Universal state machine implementaion. see State machine notes for more information. More...

Inheritance diagram for Hexagon.StateMachine.StateMachine< TParent >:

Public Member Functions

delegate float GetCurrentTimeDelegate ()
 
virtual void Init< TStateEnum > (Dictionary< TStateEnum, State > enum2state)
 
virtual void AddTransition (Transition transition)
 
void AddTransitions (IEnumerable< Transition > transitions)
 
void AddTransitions (params TransitionGroup[] inputs)
 
virtual async void Update ()
 
virtual void FixedUpdate ()
 
virtual ? Transition GetNextState (Func< Transition, bool >? extraCondition=null)
 
virtual State FinishTransition ()
 
virtual void Die ()
 
void PushEvent (ExternalMachineEvent @event)
 
ExternalMachineEventPeekEvent ()
 
 StateMachine (TParent parent)
 

Static Public Member Functions

static StateID EnumToID< TEnumState > (TEnumState value)
 
static TEnumState IDToEnum< TEnumState > (StateID id)
 

Public Attributes

readonly Dictionary< StateID, State_enum2state = new()
 
readonly List< Transition_transitions = new()
 
readonly Dictionary< StateID, List< Transition > > _stateTree = new()
 Mapping of states to all their outgoing transitions.
 
GetCurrentTimeDelegate GetCurrentTimeFunction = () => UnityEngine.Time.time
 
virtual StateID
 

Protected Member Functions

virtual ? Transition GetTransitionFromCurrent (Func< Transition, bool >? extraCondition=null)
 
virtual void BeginTransition (StateID newState, Transition transition)
 
virtual void OnTransitionEnded (State from, State to)
 
virtual void OnTransitionStarted (State from, State to)
 

Protected Attributes

Transition_currentTransition = null
 
Queue< ExternalMachineEvent_eventQueue = new()
 

Properties

State _currentState = null! [get, protected set]
 
State_targetState = null [get, protected set]
 Target state of the ongoing transition if it exists, null otherwise.
 
State _previousState = null! [get, protected set]
 Previous state of the last transition, it is NOT nullified after exiting transition.
 
StateID _currentStateID = 0 [get, protected set]
 
bool _isTransitioning = false [get, protected set]
 
bool _isLocked = false [get, protected set]
 
bool _hasTransitionJustStarted = false [get, protected set]
 Whether the transition was started in the last call of Update (in the last frame).
 
TParent Parent [get]
 

Events

Action< State, State >? OnTransitionStartedEvent
 
Action< State, State >? OnTransitionEndedEvent
 

Detailed Description

Universal state machine implementaion. see State machine notes for more information.

Type Constraints
TParent :class 

Constructor & Destructor Documentation

◆ StateMachine()

Hexagon.StateMachine.StateMachine< TParent >.StateMachine ( TParent parent)
inline

Member Function Documentation

◆ AddTransition()

virtual void Hexagon.StateMachine.StateMachine< TParent >.AddTransition ( Transition transition)
inlinevirtual

◆ AddTransitions() [1/2]

void Hexagon.StateMachine.StateMachine< TParent >.AddTransitions ( IEnumerable< Transition > transitions)
inline

◆ AddTransitions() [2/2]

void Hexagon.StateMachine.StateMachine< TParent >.AddTransitions ( params TransitionGroup[] inputs)
inline

◆ BeginTransition()

virtual void Hexagon.StateMachine.StateMachine< TParent >.BeginTransition ( StateID newState,
Transition transition )
inlineprotectedvirtual

◆ Die()

virtual void Hexagon.StateMachine.StateMachine< TParent >.Die ( )
inlinevirtual

◆ EnumToID< TEnumState >()

static StateID Hexagon.StateMachine.StateMachine< TParent >.EnumToID< TEnumState > ( TEnumState value)
inlinestatic
Type Constraints
TEnumState :Enum 

◆ FinishTransition()

virtual State Hexagon.StateMachine.StateMachine< TParent >.FinishTransition ( )
inlinevirtual

◆ FixedUpdate()

virtual void Hexagon.StateMachine.StateMachine< TParent >.FixedUpdate ( )
inlinevirtual

◆ GetCurrentTimeDelegate()

delegate float Hexagon.StateMachine.StateMachine< TParent >.GetCurrentTimeDelegate ( )

◆ GetNextState()

virtual ? Transition Hexagon.StateMachine.StateMachine< TParent >.GetNextState ( Func< Transition, bool >? extraCondition = null)
inline

◆ GetTransitionFromCurrent()

virtual ? Transition Hexagon.StateMachine.StateMachine< TParent >.GetTransitionFromCurrent ( Func< Transition, bool >? extraCondition = null)
inlineprotectedvirtual

◆ IDToEnum< TEnumState >()

static TEnumState Hexagon.StateMachine.StateMachine< TParent >.IDToEnum< TEnumState > ( StateID id)
inlinestatic
Type Constraints
TEnumState :Enum 

◆ Init< TStateEnum >()

virtual void Hexagon.StateMachine.StateMachine< TParent >.Init< TStateEnum > ( Dictionary< TStateEnum, State > enum2state)
inlinevirtual
Type Constraints
TStateEnum :Enum 

◆ OnTransitionEnded()

virtual void Hexagon.StateMachine.StateMachine< TParent >.OnTransitionEnded ( State from,
State to )
inlineprotectedvirtual

◆ OnTransitionStarted()

virtual void Hexagon.StateMachine.StateMachine< TParent >.OnTransitionStarted ( State from,
State to )
inlineprotectedvirtual

◆ PeekEvent()

ExternalMachineEvent? Hexagon.StateMachine.StateMachine< TParent >.PeekEvent ( )
inline

◆ PushEvent()

void Hexagon.StateMachine.StateMachine< TParent >.PushEvent ( ExternalMachineEvent @ event)
inline

◆ Update()

virtual async void Hexagon.StateMachine.StateMachine< TParent >.Update ( )
inlinevirtual

Member Data Documentation

◆ _currentTransition

Transition? Hexagon.StateMachine.StateMachine< TParent >._currentTransition = null
protected

◆ _enum2state

readonly Dictionary<StateID, State> Hexagon.StateMachine.StateMachine< TParent >._enum2state = new()

◆ _eventQueue

Queue<ExternalMachineEvent> Hexagon.StateMachine.StateMachine< TParent >._eventQueue = new()
protected

◆ _stateTree

readonly Dictionary<StateID, List<Transition> > Hexagon.StateMachine.StateMachine< TParent >._stateTree = new()

Mapping of states to all their outgoing transitions.

◆ _transitions

readonly List<Transition> Hexagon.StateMachine.StateMachine< TParent >._transitions = new()

◆ GetCurrentTimeFunction

GetCurrentTimeDelegate Hexagon.StateMachine.StateMachine< TParent >.GetCurrentTimeFunction = () => UnityEngine.Time.time

◆ StateID

Property Documentation

◆ _currentState

State Hexagon.StateMachine.StateMachine< TParent >._currentState = null!
getprotected set

◆ _currentStateID

StateID Hexagon.StateMachine.StateMachine< TParent >._currentStateID = 0
getprotected set

◆ _hasTransitionJustStarted

bool Hexagon.StateMachine.StateMachine< TParent >._hasTransitionJustStarted = false
getprotected set

Whether the transition was started in the last call of Update (in the last frame).

◆ _isLocked

bool Hexagon.StateMachine.StateMachine< TParent >._isLocked = false
getprotected set

◆ _isTransitioning

bool Hexagon.StateMachine.StateMachine< TParent >._isTransitioning = false
getprotected set

◆ _previousState

State Hexagon.StateMachine.StateMachine< TParent >._previousState = null!
getprotected set

Previous state of the last transition, it is NOT nullified after exiting transition.

◆ _targetState

State? Hexagon.StateMachine.StateMachine< TParent >._targetState = null
getprotected set

Target state of the ongoing transition if it exists, null otherwise.

◆ Parent

TParent Hexagon.StateMachine.StateMachine< TParent >.Parent
get

Event Documentation

◆ OnTransitionEndedEvent

Action<State, State>? Hexagon.StateMachine.StateMachine< TParent >.OnTransitionEndedEvent

◆ OnTransitionStartedEvent

Action<State, State>? Hexagon.StateMachine.StateMachine< TParent >.OnTransitionStartedEvent

The documentation for this class was generated from the following file: