|
Drag[en]gine Script Module DragonScript 1.35
|
State machine context. More...
Public Member Functions | |
| void | addActionsFromContext (SMContext context) |
| Add actions from another context. | |
| void | addConditionsFromContext (SMContext context) |
| Add conditions from another context. | |
| void | forEachAction (Block ablock) |
| Visit actions using block with parameters String (name) and SMAction (action). | |
| void | forEachCondition (Block ablock) |
| Visit conditions using block with parameters String (name) and SMCondition (condition). | |
| SMAction | getAction (String name) |
| Action for name or null if absent. | |
| SMCondition | getCondition (String name) |
| Condition for name or null if absent. | |
| int | getConditionCount () |
| Count of conditions. | |
| Console | getConsole () |
| Console or null if not wishing to log anything. | |
| SMState | getCurrentState () |
| Current state or null if in transition. | |
| Object | getEventParameter () |
| Event parameter or null. | |
| bool | getLogActions () |
| Log actions. | |
| String | getLoggingName () |
| Logging name to tell apart logs. | |
| bool | getLogStateChanges () |
| Log state machine state changes. | |
| bool | getLogTransitions () |
| Log state machine steps. | |
| StateMachine | getStateMachine () |
| State machine. | |
| bool | hasAction (String name) |
| Action is present. | |
| bool | hasCondition (String name) |
| Condition is present. | |
| SMContext | new (SMContext context) |
| Create copy of state machine context. | |
| SMContext | new (SMContext context, StateMachine stateMachine) |
| Create copy of state machine context but using a different state machine. | |
| SMContext | new (StateMachine stateMachine) |
| Create state machine context. | |
| void | readFromFile (PersistencyEnvironment env, FileReader reader) |
| Read state from file. | |
| void | removeAction (String name) |
| Remove action. | |
| void | removeAllActions () |
| Remove all actions. | |
| void | removeAllConditions () |
| Remove all conditions. | |
| void | removeCondition (String name) |
| Remove condition. | |
| void | runEvent (String event) |
| Run event on state machine. | |
| void | runEvent (String event, Object parameter) |
| Run event on state machine with parameter. | |
| void | setAction (String name, Block action) |
| Set action for name using block. | |
| void | setAction (String name, SMAction action) |
| Set action for name. | |
| void | setCondition (String name, Block condition) |
| Set condition for name using block. | |
| void | setCondition (String name, SMCondition condition) |
| Set condition for name. | |
| void | setConsole (Console console) |
| Set console or null if not wishing to log anything. | |
| void | setCurrentState (SMState state) |
| Set current state or null if in transition. | |
| void | setLogActions (bool logActions) |
| Set actions. | |
| void | setLoggingName (String name) |
| Set logging name to tell apart logs. | |
| void | setLogStateChanges (bool logStateChanges) |
| Set log state machine state changes. | |
| void | setLogTransitions (bool logSteps) |
| Set log state machine steps. | |
| void | setStateMachine (StateMachine stateMachine) |
| Set state machine and reset state. | |
| void | writeToFile (PersistencyEnvironment env, FileWriter writer) |
| Write state to file. | |
Public Attributes | |
| Dictionary | pConditions |
| Console | pConsole |
| SMState | pCurrentState |
| Array | pDelayedEvents |
| Object | pEventParameter |
| String | pLoggingName |
| bool | pLogTransitions |
| StateMachine | pStateMachine |
State machine context.
Used to run a state machine instance. The state machine itself is shared across contexts while the individual state is stored in the context. Context has to provide the SMAction instances for the state machine states to call. Subclass the context to provide the required data for your SMAction subclasses to work properly.
After creating the context the initial state is the current state. No enter actions are run on the initial state since during that time no actions and conditions are present yet.
The context can be written to and restored from file readers. This class saves only the current state identifier. Subclass has to save its own states by overwriting readFromFile() and writeToFile().
| void Dragengine.StateMachineSystem.SMContext.addActionsFromContext | ( | SMContext | context | ) |
Add actions from another context.
References forEachCondition().
Referenced by writeToFile().
| void Dragengine.StateMachineSystem.SMContext.addConditionsFromContext | ( | SMContext | context | ) |
Add conditions from another context.
Referenced by getLogStateChanges(), and writeToFile().
| void Dragengine.StateMachineSystem.SMContext.forEachAction | ( | Block | ablock | ) |
Visit actions using block with parameters String (name) and SMAction (action).
References pStateMachine.
Referenced by runEvent().
| void Dragengine.StateMachineSystem.SMContext.forEachCondition | ( | Block | ablock | ) |
Visit conditions using block with parameters String (name) and SMCondition (condition).
Referenced by addActionsFromContext().
| SMAction Dragengine.StateMachineSystem.SMContext.getAction | ( | String | name | ) |
| SMCondition Dragengine.StateMachineSystem.SMContext.getCondition | ( | String | name | ) |
| int Dragengine.StateMachineSystem.SMContext.getConditionCount | ( | ) |
| Console Dragengine.StateMachineSystem.SMContext.getConsole | ( | ) |
Console or null if not wishing to log anything.
References pConditions.
Referenced by writeToFile().
| SMState Dragengine.StateMachineSystem.SMContext.getCurrentState | ( | ) |
Current state or null if in transition.
References pConditions, and setCondition().
Referenced by writeToFile().
| Object Dragengine.StateMachineSystem.SMContext.getEventParameter | ( | ) |
| bool Dragengine.StateMachineSystem.SMContext.getLogActions | ( | ) |
| String Dragengine.StateMachineSystem.SMContext.getLoggingName | ( | ) |
Logging name to tell apart logs.
References pConditions, and removeCondition().
Referenced by writeToFile().
| bool Dragengine.StateMachineSystem.SMContext.getLogStateChanges | ( | ) |
Log state machine state changes.
References addConditionsFromContext().
Referenced by writeToFile().
| bool Dragengine.StateMachineSystem.SMContext.getLogTransitions | ( | ) |
| StateMachine Dragengine.StateMachineSystem.SMContext.getStateMachine | ( | ) |
State machine.
Referenced by removeCondition().
| bool Dragengine.StateMachineSystem.SMContext.hasAction | ( | String | name | ) |
Action is present.
Referenced by getEventParameter().
| bool Dragengine.StateMachineSystem.SMContext.hasCondition | ( | String | name | ) |
Condition is present.
References pConsole, pLoggingName, and pLogTransitions.
Referenced by removeAllActions().
Create copy of state machine context.
Actions are copied as shallow copy. If you need a deep set all actions anew. The state of the context is the same as without creating a copy.
References pConditions, pCurrentState, pLoggingName, and pStateMachine.
| SMContext Dragengine.StateMachineSystem.SMContext.new | ( | SMContext | context, |
| StateMachine | stateMachine ) |
Create copy of state machine context but using a different state machine.
Actions are copied as shallow copy. If you need a deep set all actions anew. The state of the context is the same as without creating a copy.
This method is useful to use an initialized base context with a fallback state machine. Whenever a new context is required the base context is copied. This avoids the need to assign actions and conditions since they are copied from the base context.
| SMContext Dragengine.StateMachineSystem.SMContext.new | ( | StateMachine | stateMachine | ) |
Create state machine context.
| void Dragengine.StateMachineSystem.SMContext.readFromFile | ( | PersistencyEnvironment | env, |
| FileReader | reader ) |
Read state from file.
Referenced by writeToFile().
| void Dragengine.StateMachineSystem.SMContext.removeAction | ( | String | name | ) |
| void Dragengine.StateMachineSystem.SMContext.removeAllActions | ( | ) |
| void Dragengine.StateMachineSystem.SMContext.removeAllConditions | ( | ) |
Remove all conditions.
Referenced by setLoggingName().
| void Dragengine.StateMachineSystem.SMContext.removeCondition | ( | String | name | ) |
| void Dragengine.StateMachineSystem.SMContext.runEvent | ( | String | event | ) |
| void Dragengine.StateMachineSystem.SMContext.runEvent | ( | String | event, |
| Object | parameter ) |
Run event on state machine with parameter.
References setAction().
| void Dragengine.StateMachineSystem.SMContext.setAction | ( | String | name, |
| Block | action ) |
Set action for name using block.
References getConditionCount(), and pConditions.
| void Dragengine.StateMachineSystem.SMContext.setAction | ( | String | name, |
| SMAction | action ) |
Set action for name.
Referenced by runEvent(), and writeToFile().
| void Dragengine.StateMachineSystem.SMContext.setCondition | ( | String | name, |
| Block | condition ) |
Set condition for name using block.
| void Dragengine.StateMachineSystem.SMContext.setCondition | ( | String | name, |
| SMCondition | condition ) |
Set condition for name.
References pCurrentState.
Referenced by getCurrentState(), and setCurrentState().
| void Dragengine.StateMachineSystem.SMContext.setConsole | ( | Console | console | ) |
Set console or null if not wishing to log anything.
Referenced by writeToFile().
| void Dragengine.StateMachineSystem.SMContext.setCurrentState | ( | SMState | state | ) |
Set current state or null if in transition.
If a state is already present the exit actions are run before switching. If state is not null entering actions are run after switching.
Calls onCurrentStateChanged() after all changes are done.
References setCondition().
Referenced by writeToFile().
| void Dragengine.StateMachineSystem.SMContext.setLogActions | ( | bool | logActions | ) |
| void Dragengine.StateMachineSystem.SMContext.setLoggingName | ( | String | name | ) |
| void Dragengine.StateMachineSystem.SMContext.setLogStateChanges | ( | bool | logStateChanges | ) |
| void Dragengine.StateMachineSystem.SMContext.setLogTransitions | ( | bool | logSteps | ) |
Set log state machine steps.
Referenced by writeToFile().
| void Dragengine.StateMachineSystem.SMContext.setStateMachine | ( | StateMachine | stateMachine | ) |
Set state machine and reset state.
Sets the state machine then calls reset(). If you change the state machine during runtime you have to make sure it is also set before readFromFile() is called otherwise an exception can be thrown.
Referenced by getAction().
| void Dragengine.StateMachineSystem.SMContext.writeToFile | ( | PersistencyEnvironment | env, |
| FileWriter | writer ) |
Write state to file.
References addActionsFromContext(), addConditionsFromContext(), getConsole(), getCurrentState(), getEventParameter(), getLogActions(), getLoggingName(), getLogStateChanges(), getLogTransitions(), pConsole, pCurrentState, pDelayedEvents, pEventParameter, pLoggingName, pLogTransitions, pStateMachine, readFromFile(), removeAction(), removeAllActions(), runEvent(), setAction(), setConsole(), setCurrentState(), setLogActions(), setLoggingName(), setLogStateChanges(), setLogTransitions(), and writeToFile().
Referenced by writeToFile().
| Dictionary Dragengine.StateMachineSystem.SMContext.pConditions |
Referenced by getConditionCount(), getConsole(), getCurrentState(), getLoggingName(), getLogTransitions(), new(), removeAllActions(), setAction(), and setLogStateChanges().
| Console Dragengine.StateMachineSystem.SMContext.pConsole |
Referenced by hasCondition(), and writeToFile().
| SMState Dragengine.StateMachineSystem.SMContext.pCurrentState |
Referenced by getCondition(), new(), setCondition(), and writeToFile().
| Array Dragengine.StateMachineSystem.SMContext.pDelayedEvents |
Referenced by writeToFile().
| Object Dragengine.StateMachineSystem.SMContext.pEventParameter |
Referenced by writeToFile().
| String Dragengine.StateMachineSystem.SMContext.pLoggingName |
Referenced by hasCondition(), new(), and writeToFile().
| bool Dragengine.StateMachineSystem.SMContext.pLogTransitions |
Referenced by hasCondition(), and writeToFile().
| StateMachine Dragengine.StateMachineSystem.SMContext.pStateMachine |
Referenced by forEachAction(), getConditionCount(), new(), removeCondition(), and writeToFile().