Space Engineers
Public Member Functions | Protected Member Functions | Protected Attributes | Properties | Events | List of all members
VRage.Generics.MyStateMachine Class Reference

Implementation of generic multistate state machine. Is able to run multiple independent cursors at once updated with every update call. Use cursors as access point to active states. More...

Inheritance diagram for VRage.Generics.MyStateMachine:
VRage.Game.VisualScripting.Missions.MyVSStateMachine VRage.Generics.MySingleStateMachine VRage.Game.VisualScripting.Campaign.MyCampaignStateMachine VRageRender.Animations.MyAnimationStateMachine

Public Member Functions

virtual MyStateMachineCursor CreateCursor (string nodeName)
 Creates new active cursor. More...
 
MyStateMachineCursor FindCursor (int cursorId)
 
virtual bool DeleteCursor (int id)
 
virtual bool AddNode (MyStateMachineNode newNode)
 
MyStateMachineNode FindNode (string nodeName)
 
virtual bool DeleteNode (string nodeName)
 
virtual MyStateMachineTransition AddTransition (string startNodeName, string endNodeName, MyStateMachineTransition existingInstance=null, string name=null)
 
MyStateMachineTransition FindTransition (int transitionId)
 
MyStateMachineTransitionWithStart FindTransitionWithStart (int transitionId)
 
virtual bool DeleteTransition (int transitionId)
 
virtual bool SetState (int cursorId, string nameOfNewState)
 Set the current state. Warning - this is not a thing that you would like to normally do, state machine should live its own life (based on transition condition). Returns true on success. More...
 
virtual void Update ()
 Update the state machine. Transition to new states. More...
 
void TriggerAction (MyStringId actionName)
 Trigger an action in this layer. If there is a transition having given (non-null) name, it is followed immediatelly. Conditions of transition are ignored. More...
 
void SortTransitions ()
 Sort the transitions between states according to their priorities. More...
 
delegate void StateChangedHandler (MyStateMachineTransitionWithStart transition)
 
 MyStateMachine ()
 
bool AddNode (MyStateMachineNode newNode)
 
MyStateMachineNode FindNode (string nodeName)
 
bool DeleteNode (string nodeName)
 
MyStateMachineTransition AddTransition (string startNodeName, string endNodeName, MyStateMachineTransition existingInstance=null)
 
MyStateMachineTransition FindTransition (int transitionId)
 
bool DeleteTransition (int transitionId)
 
virtual bool SetState (string nameOfNewState)
 Set the current state. Warning - this is not a thing that you would like to normally do, state machine should live its own life (based on transition condition). Returns true on success. More...
 
void Update ()
 
void TriggerAction (MyStringId actionName)
 Trigger an action in this layer. If there is a transition having given (non-null) name, it is followed immediatelly. Conditions of transition are ignored. More...
 
void SortTransitions ()
 Sort the transitions between states according to their priorities. More...
 

Protected Member Functions

void NotifyStateChanged (MyStateMachineTransitionWithStart transitionWithStart)
 

Protected Attributes

Dictionary< string, MyStateMachineNodem_nodes = new Dictionary<string, MyStateMachineNode>()
 
Dictionary< int, MyStateMachineTransitionWithStartm_transitions = new Dictionary<int, MyStateMachineTransitionWithStart>()
 
Dictionary< int, MyStateMachineCursorm_activeCursorsById = new Dictionary<int, MyStateMachineCursor>()
 
CachingList< MyStateMachineCursorm_activeCursors = new CachingList<MyStateMachineCursor>()
 
MyConcurrentHashSet< MyStringIdm_enqueuedActions = new MyConcurrentHashSet<MyStringId>()
 

Properties

DictionaryReader< string, MyStateMachineNodeAllNodes [get]
 
List< MyStateMachineCursorActiveCursors [get]
 
string Name [get, set]
 
MyStateMachineNode CurrentNode [get, protected set]
 

Events

StateChangedHandler OnStateChanged
 

Detailed Description

Implementation of generic multistate state machine. Is able to run multiple independent cursors at once updated with every update call. Use cursors as access point to active states.

Implementation of generic state machine. Inherit from this class to create your own state machine. Transitions are performed automatically on each update (if conditions of transition are fulfilled).

Definition at line 12 of file MyMultiStateMachine.cs.

Constructor & Destructor Documentation

VRage.Generics.MyStateMachine.MyStateMachine ( )
inline

Definition at line 47 of file MyStateMachine.cs.

Member Function Documentation

bool VRage.Generics.MyStateMachine.AddNode ( MyStateMachineNode  newNode)
inline

Definition at line 57 of file MyStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.AddNode ( MyStateMachineNode  newNode)
inlinevirtual

Definition at line 86 of file MyMultiStateMachine.cs.

MyStateMachineTransition VRage.Generics.MyStateMachine.AddTransition ( string  startNodeName,
string  endNodeName,
MyStateMachineTransition  existingInstance = null 
)
inline

Definition at line 104 of file MyStateMachine.cs.

virtual MyStateMachineTransition VRage.Generics.MyStateMachine.AddTransition ( string  startNodeName,
string  endNodeName,
MyStateMachineTransition  existingInstance = null,
string  name = null 
)
inlinevirtual

Definition at line 141 of file MyMultiStateMachine.cs.

virtual MyStateMachineCursor VRage.Generics.MyStateMachine.CreateCursor ( string  nodeName)
inlinevirtual

Creates new active cursor.

Reimplemented in VRage.Game.VisualScripting.Missions.MyVSStateMachine, and VRage.Generics.MySingleStateMachine.

Definition at line 46 of file MyMultiStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.DeleteCursor ( int  id)
inlinevirtual

Reimplemented in VRage.Generics.MySingleStateMachine.

Definition at line 69 of file MyMultiStateMachine.cs.

bool VRage.Generics.MyStateMachine.DeleteNode ( string  nodeName)
inline

Definition at line 79 of file MyStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.DeleteNode ( string  nodeName)
inlinevirtual

Definition at line 108 of file MyMultiStateMachine.cs.

bool VRage.Generics.MyStateMachine.DeleteTransition ( int  transitionId)
inline

Definition at line 143 of file MyStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.DeleteTransition ( int  transitionId)
inlinevirtual

Definition at line 192 of file MyMultiStateMachine.cs.

MyStateMachineCursor VRage.Generics.MyStateMachine.FindCursor ( int  cursorId)
inline

Definition at line 61 of file MyMultiStateMachine.cs.

MyStateMachineNode VRage.Generics.MyStateMachine.FindNode ( string  nodeName)
inline

Definition at line 71 of file MyStateMachine.cs.

MyStateMachineNode VRage.Generics.MyStateMachine.FindNode ( string  nodeName)
inline

Definition at line 100 of file MyMultiStateMachine.cs.

MyStateMachineTransition VRage.Generics.MyStateMachine.FindTransition ( int  transitionId)
inline

Definition at line 135 of file MyStateMachine.cs.

MyStateMachineTransition VRage.Generics.MyStateMachine.FindTransition ( int  transitionId)
inline

Definition at line 178 of file MyMultiStateMachine.cs.

MyStateMachineTransitionWithStart VRage.Generics.MyStateMachine.FindTransitionWithStart ( int  transitionId)
inline

Definition at line 184 of file MyMultiStateMachine.cs.

void VRage.Generics.MyStateMachine.NotifyStateChanged ( MyStateMachineTransitionWithStart  transitionWithStart)
inlineprotected

Definition at line 35 of file MyStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.SetState ( string  nameOfNewState)
inlinevirtual

Set the current state. Warning - this is not a thing that you would like to normally do, state machine should live its own life (based on transition condition). Returns true on success.

Reimplemented in VRage.Generics.MySingleStateMachine.

Definition at line 165 of file MyStateMachine.cs.

virtual bool VRage.Generics.MyStateMachine.SetState ( int  cursorId,
string  nameOfNewState 
)
inlinevirtual

Set the current state. Warning - this is not a thing that you would like to normally do, state machine should live its own life (based on transition condition). Returns true on success.

Definition at line 217 of file MyMultiStateMachine.cs.

void VRage.Generics.MyStateMachine.SortTransitions ( )
inline

Sort the transitions between states according to their priorities.

Definition at line 246 of file MyStateMachine.cs.

void VRage.Generics.MyStateMachine.SortTransitions ( )
inline

Sort the transitions between states according to their priorities.

Definition at line 263 of file MyMultiStateMachine.cs.

delegate void VRage.Generics.MyStateMachine.StateChangedHandler ( MyStateMachineTransitionWithStart  transition)
void VRage.Generics.MyStateMachine.TriggerAction ( MyStringId  actionName)
inline

Trigger an action in this layer. If there is a transition having given (non-null) name, it is followed immediatelly. Conditions of transition are ignored.

Definition at line 238 of file MyStateMachine.cs.

void VRage.Generics.MyStateMachine.TriggerAction ( MyStringId  actionName)
inline

Trigger an action in this layer. If there is a transition having given (non-null) name, it is followed immediatelly. Conditions of transition are ignored.

Definition at line 255 of file MyMultiStateMachine.cs.

void VRage.Generics.MyStateMachine.Update ( )
inline

Definition at line 180 of file MyStateMachine.cs.

virtual void VRage.Generics.MyStateMachine.Update ( )
inlinevirtual

Update the state machine. Transition to new states.

Reimplemented in VRage.Game.VisualScripting.Missions.MyVSStateMachine.

Definition at line 233 of file MyMultiStateMachine.cs.

Member Data Documentation

CachingList<MyStateMachineCursor> VRage.Generics.MyStateMachine.m_activeCursors = new CachingList<MyStateMachineCursor>()
protected

Definition at line 23 of file MyMultiStateMachine.cs.

Dictionary<int, MyStateMachineCursor> VRage.Generics.MyStateMachine.m_activeCursorsById = new Dictionary<int, MyStateMachineCursor>()
protected

Definition at line 21 of file MyMultiStateMachine.cs.

MyConcurrentHashSet< MyStringId > VRage.Generics.MyStateMachine.m_enqueuedActions = new MyConcurrentHashSet<MyStringId>()
protected

Definition at line 25 of file MyMultiStateMachine.cs.

Dictionary< string, MyStateMachineNode > VRage.Generics.MyStateMachine.m_nodes = new Dictionary<string, MyStateMachineNode>()
protected

Definition at line 17 of file MyMultiStateMachine.cs.

Dictionary< int, MyStateMachineTransitionWithStart > VRage.Generics.MyStateMachine.m_transitions = new Dictionary<int, MyStateMachineTransitionWithStart>()
protected

Definition at line 19 of file MyMultiStateMachine.cs.

Property Documentation

List<MyStateMachineCursor> VRage.Generics.MyStateMachine.ActiveCursors
get

Definition at line 36 of file MyMultiStateMachine.cs.

DictionaryReader< string, MyStateMachineNode > VRage.Generics.MyStateMachine.AllNodes
get

Definition at line 29 of file MyMultiStateMachine.cs.

MyStateMachineNode VRage.Generics.MyStateMachine.CurrentNode
getprotected set

Definition at line 44 of file MyStateMachine.cs.

string VRage.Generics.MyStateMachine.Name
getset

Definition at line 41 of file MyMultiStateMachine.cs.

Event Documentation

StateChangedHandler VRage.Generics.MyStateMachine.OnStateChanged

Definition at line 34 of file MyStateMachine.cs.


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