KSP API
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
KerbalFSM Class Reference

A finite state machine. States are represented by KFSMState objects, and "events" (transitions between states) are represented by KFSMEvent objects. More...

Inheritance diagram for KerbalFSM:
TutorialScenario.TutorialFSM

Public Member Functions

 KerbalFSM ()
 
void AddEvent (KFSMEvent ev, params KFSMState[] toStates)
 Add a new event (possible transition) to the finite state machine. More...
 
void AddEventExcluding (KFSMEvent ev, params KFSMState[] excStates)
 Add a new event (possible transition) to the finite state machine. More...
 
void AddState (KFSMState st)
 Add a new possible state to the machine. More...
 
void FixedUpdateFSM ()
 
void LateUpdateFSM ()
 
void RunEvent (KFSMEvent evt)
 Cause the machine to execute the transition specified by evt. More...
 
void StartFSM (KFSMState initialState)
 Start the state machine in a given initial state. More...
 
void StartFSM (string initialStateName)
 Start the state machine in a given initial state. More...
 
void UpdateFSM ()
 

Public Attributes

string currentStateName
 The name of the state the machine is currently in. More...
 
bool DebugBreakOnStateChange
 
string lastEventName
 The name of the last event that occurred. More...
 

Protected Member Functions

void updateFSM (KFSMUpdateMode mode)
 

Protected Attributes

KFSMState currentState
 
bool fsmStarted
 
KFSMEvent lastEvent
 
KFSMState lastState
 
List< KFSMStateStates
 

Properties

KFSMState CurrentState [get]
 The state the machine is currently in. More...
 
int FramesInCurrentState [get]
 How many frames the machine has been in this state. More...
 
KFSMEvent LastEvent [get]
 The last event that occurred. More...
 
KFSMState LastState [get]
 The state the machine was in before this state. More...
 
bool Started [get]
 Whether the state machine has been started. More...
 
double TimeAtCurrentState [get]
 How long the machine has been in the current state, in seconds. More...
 

Detailed Description

A finite state machine. States are represented by KFSMState objects, and "events" (transitions between states) are represented by KFSMEvent objects.

Constructor & Destructor Documentation

KerbalFSM.KerbalFSM ( )

Member Function Documentation

void KerbalFSM.AddEvent ( KFSMEvent  ev,
params KFSMState[]  toStates 
)

Add a new event (possible transition) to the finite state machine.

Parameters
evThe event to add.
toStatesThe states to add the event to. The event can only be triggered when the machine is in one of these states.
void KerbalFSM.AddEventExcluding ( KFSMEvent  ev,
params KFSMState[]  excStates 
)

Add a new event (possible transition) to the finite state machine.

Parameters
evThe event to add.
excStatesA list of states not to add the event to. The event can only be triggered when the machine is not in one of these states.
void KerbalFSM.AddState ( KFSMState  st)

Add a new possible state to the machine.

Parameters
stThe state to add.
void KerbalFSM.FixedUpdateFSM ( )
void KerbalFSM.LateUpdateFSM ( )
void KerbalFSM.RunEvent ( KFSMEvent  evt)

Cause the machine to execute the transition specified by evt.

Parameters
evtThe event to execute.
void KerbalFSM.StartFSM ( KFSMState  initialState)

Start the state machine in a given initial state.

Parameters
initialStateThe state to start in.
void KerbalFSM.StartFSM ( string  initialStateName)

Start the state machine in a given initial state.

Parameters
initialStateNameThe name of the state to start in
void KerbalFSM.UpdateFSM ( )
void KerbalFSM.updateFSM ( KFSMUpdateMode  mode)
protected

Member Data Documentation

KFSMState KerbalFSM.currentState
protected
string KerbalFSM.currentStateName

The name of the state the machine is currently in.

bool KerbalFSM.DebugBreakOnStateChange
bool KerbalFSM.fsmStarted
protected
KFSMEvent KerbalFSM.lastEvent
protected
string KerbalFSM.lastEventName

The name of the last event that occurred.

KFSMState KerbalFSM.lastState
protected
List<KFSMState> KerbalFSM.States
protected

Property Documentation

KFSMState KerbalFSM.CurrentState
get

The state the machine is currently in.

int KerbalFSM.FramesInCurrentState
get

How many frames the machine has been in this state.

KFSMEvent KerbalFSM.LastEvent
get

The last event that occurred.

KFSMState KerbalFSM.LastState
get

The state the machine was in before this state.

bool KerbalFSM.Started
get

Whether the state machine has been started.

double KerbalFSM.TimeAtCurrentState
get

How long the machine has been in the current state, in seconds.


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