Game Development Reference
In-Depth Information
Process
Command
State
Waypoint Reached = true
Command = Patrol
Patrol/
Attack
State
Waypoint Reached = false
Figure 8-5.
The tank's finite state machine
The
FSM_StatesTank
enumeration identifies the different state ids used internally within the tank
state machine so that the state machine can identify and transition to the corresponding state
when needed.
The
FSM_StatesTank
enumeration (see Listing 8-9) consists of
FSM_STATE_NONE
: This indicates no state.
FSM_STATE_STEER_WAYPOINT
: This state id corresponds to the
patrol/attack state.
FSM_STATE_PROCESS_COMMAND
: This state id corresponds to the
process command state.
Listing 8-9. The Tank States
enum FSM_StatesTank
{
FSM_STATE_NONE,
FSM_STATE_STEER_WAYPOINT,
FSM_STATE_PROCESS_COMMAND,
};
The StateTank class holds the base class from which all other states for the tank are derived.
The
m_Parent
variable holds a reference to the driver of the tank and provides access to the
commands and data given to the AI-controlled vehicle and the tank object itself.
private Driver m_Parent;