#include <StateMachine.h>
Inherits MemoryPoolObject, and Snapshot.
Inherited by AIAttackMoveStateMachine, AIAttackThenIdleStateMachine, AIDockMachine, AIGuardMachine, AIGuardRetaliateMachine, AIStateMachine, AITNGuardMachine, AttackStateMachine, DeliverPayloadStateMachine, DozerActionStateMachine, DozerPrimaryStateMachine, SupplyTruckStateMachine, TurretStateMachine, and WorkerStateMachine.
Public Member Functions | |
| StateMachine (Object *owner, AsciiString name) | |
| virtual StateReturnType | updateStateMachine () |
| run one step of the machine | |
| virtual void | clear () |
| clear the machine's internals to a known, initialized state | |
| virtual StateReturnType | resetToDefaultState () |
| clear the machine's internals and set to the default state | |
| virtual StateReturnType | initDefaultState () |
| virtual StateReturnType | setState (StateID newStateID) |
| change the current state of the machine (which may cause further state changes, due to onEnter) | |
| StateID | getCurrentStateID () const |
| return the id of the current state of the machine | |
| Bool | isInIdleState () const |
| Bool | isInAttackState () const |
| Bool | isInForceAttackState () const |
| Bool | isInGuardIdleState () const |
| Bool | isInBusyState () const |
| void | lock (const char *msg) |
| void | unlock () |
| Bool | isLocked () const |
| Object * | getOwner () |
| const Object * | getOwner () const |
| void | setGoalObject (const Object *obj) |
| Object * | getGoalObject () |
| const Object * | getGoalObject () const |
| void | setGoalPosition (const Coord3D *pos) |
| const Coord3D * | getGoalPosition () const |
| Bool | isGoalObjectDestroyed () const |
| Returns true if we had a goal object, but it has been destroyed. | |
| virtual void | halt (void) |
| Stops the state machine & disables it in preparation for deleting it. | |
| StateReturnType | internalSetState (StateID newStateID) |
| for internal use only - change the current state of the machine | |
| Bool | getWantsDebugOutput () const |
| AsciiString | getCurrentStateName () const |
Public Member Functions inherited from MemoryPoolObject | |
| void | deleteInstance () |
Public Member Functions inherited from Snapshot | |
| Snapshot (void) | |
| ~Snapshot (void) | |
Protected Member Functions | |
| virtual void | crc (Xfer *xfer) |
| virtual void | xfer (Xfer *xfer) |
| virtual void | loadPostProcess () |
| void | defineState (StateID id, State *state, StateID successID, StateID failureID, const StateConditionInfo *conditions=NULL) |
| State * | internalGetState (StateID id) |
Protected Member Functions inherited from MemoryPoolObject | |
| virtual | ~MemoryPoolObject () |
| void * | operator new (size_t s) |
| void | operator delete (void *p) |
| virtual MemoryPool * | getObjectMemoryPool ()=0 |
A finite state machine.
Definition at line 240 of file StateMachine.h.
| StateMachine::StateMachine | ( | Object * | owner, |
| AsciiString | name ) |
All of the states used by this machine should be instantiated and defined via defineState() in the machine's constructor.
Constructor
Definition at line 267 of file StateMachine.cpp.
|
virtual |
clear the machine's internals to a known, initialized state
Clear the machine
Reimplemented in AIStateMachine, and TurretStateMachine.
Definition at line 351 of file StateMachine.cpp.
|
protectedvirtual |
Implements Snapshot.
Reimplemented in AIAttackMoveStateMachine, AIAttackThenIdleStateMachine, AIDockMachine, AIGuardMachine, AIGuardRetaliateMachine, AIStateMachine, AITNGuardMachine, AttackStateMachine, DeliverPayloadStateMachine, DozerActionStateMachine, DozerPrimaryStateMachine, SupplyTruckStateMachine, TurretStateMachine, and WorkerStateMachine.
Definition at line 812 of file StateMachine.cpp.
|
protected |
Given a unique (to this machine) integer ID representing a state, and an instance of that state, the machine records this as a possible state, and internally maps the given integer ID to the state instance. These state id's are used to change the machine's state via setState().
Given a unique (for this machine) id number, and an instance of the State class, the machine records this as a possible state, and retains the id mapping. These state id's are used to change the machine's state via setState().
Definition at line 484 of file StateMachine.cpp.
|
inline |
return the id of the current state of the machine
Definition at line 266 of file StateMachine.h.
|
inline |
Definition at line 336 of file StateMachine.h.
| Object * StateMachine::getGoalObject | ( | ) |
Definition at line 780 of file StateMachine.cpp.
| const Object * StateMachine::getGoalObject | ( | ) | const |
Definition at line 786 of file StateMachine.cpp.
|
inline |
Definition at line 314 of file StateMachine.h.
|
inline |
Get the object that "owns" this machine. There need not be an object with a machine, but it is so common that it is useful to have this method in the generic state machine.
Definition at line 306 of file StateMachine.h.
|
inline |
Definition at line 307 of file StateMachine.h.
|
inline |
Definition at line 335 of file StateMachine.h.
|
virtual |
Stops the state machine & disables it in preparation for deleting it.
Reimplemented in AIDockMachine.
Definition at line 755 of file StateMachine.cpp.
|
virtual |
must be called to jump the StateMachine into the default state... this may fail (return a failure code), so it can't be done via the ctor. you MUST call this before using the state machine.
Define the default state of the machine, and set the machine's state to it.
Definition at line 665 of file StateMachine.cpp.
Given a state ID, return the state instance
Definition at line 513 of file StateMachine.cpp.
| StateReturnType StateMachine::internalSetState | ( | StateID | newStateID | ) |
for internal use only - change the current state of the machine
Change the current state of the machine. This causes the old state's onExit() method to be invoked, and the new state's onEnter() method to be invoked.
Definition at line 563 of file StateMachine.cpp.
| Bool StateMachine::isGoalObjectDestroyed | ( | ) | const |
Returns true if we had a goal object, but it has been destroyed.
Definition at line 745 of file StateMachine.cpp.
|
inline |
Definition at line 268 of file StateMachine.h.
|
inline |
Definition at line 273 of file StateMachine.h.
|
inline |
Definition at line 269 of file StateMachine.h.
|
inline |
Definition at line 270 of file StateMachine.h.
|
inline |
Definition at line 267 of file StateMachine.h.
|
inline |
Definition at line 299 of file StateMachine.h.
|
protectedvirtual |
Load post process
Implements Snapshot.
Reimplemented in AIAttackMoveStateMachine, AIAttackThenIdleStateMachine, AIDockMachine, AIGuardMachine, AIGuardRetaliateMachine, AIStateMachine, AITNGuardMachine, AttackStateMachine, DeliverPayloadStateMachine, DozerActionStateMachine, DozerPrimaryStateMachine, SupplyTruckStateMachine, TurretStateMachine, and WorkerStateMachine.
Definition at line 897 of file StateMachine.cpp.
|
inline |
Lock/unlock this state machine. If a machine is locked, it cannot be reset, or given external setStates(), etc.
Definition at line 283 of file StateMachine.h.
|
virtual |
clear the machine's internals and set to the default state
Reset the machine to its default state
Reimplemented in AIStateMachine, and TurretStateMachine.
Definition at line 376 of file StateMachine.cpp.
| void StateMachine::setGoalObject | ( | const Object * | obj | ) |
Definition at line 736 of file StateMachine.cpp.
| void StateMachine::setGoalPosition | ( | const Coord3D * | pos | ) |
Definition at line 792 of file StateMachine.cpp.
|
virtual |
change the current state of the machine (which may cause further state changes, due to onEnter)
Change the current state of the machine. This causes the old state's onExit() method to be invoked, and the new state's onEnter() method to be invoked.
Reimplemented in AIStateMachine, and TurretStateMachine.
Definition at line 542 of file StateMachine.cpp.
|
inline |
Definition at line 291 of file StateMachine.h.
|
virtual |
run one step of the machine
Run one step of the machine
Reimplemented in AIStateMachine.
Definition at line 419 of file StateMachine.cpp.
|
protectedvirtual |
Xfer Method Version Info 1: Initial version
Implements Snapshot.
Reimplemented in AIAttackMoveStateMachine, AIAttackThenIdleStateMachine, AIDockMachine, AIGuardMachine, AIGuardRetaliateMachine, AIStateMachine, AITNGuardMachine, AttackStateMachine, DeliverPayloadStateMachine, DozerActionStateMachine, DozerPrimaryStateMachine, SupplyTruckStateMachine, TurretStateMachine, and WorkerStateMachine.
Definition at line 823 of file StateMachine.cpp.