VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
retreatCtrl.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2000 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 //
7 //class DtRetreatController
8 //
9 //The retreating behavior of this controller was not intended to be
10 //intelligent; it is meant to be an example of a controller invoked by a
11 //DtUserTask. Because the currentTarget is used to determine which way to
12 //flee, the behavior is best demonstrated tank vs. tank. Vehicles which do not
13 //target other vehicles, such as utility vehicles, will simply flee towards
14 //their current heading. Tanks will not flee from entities which they do
15 //not target, such as helicopters.
16 //
17 //The retreat DtUserTask takes one argument from the "Argument 1" box
18 //of the DtUserTask dialog. If it is set to "hold ground", entities set to
19 //retreat will not start moving untill their underFire flag is set.
20 //
21 //To enable an entity to retreat, there must be an entry for
22 //"retreat-controller" in its controller list in the object parameters
23 //database. The following sample can be used:
24 //
25 // (controllers
26 // ...
27 // (retreat
28 // (component-descriptor-type "component-descriptor")
29 // (component-type "retreat-controller")
30 // )
31 // ...
32 // )
33 //
34 // (connections
35 // ....
36 // (connect retreat:automotive-control powertrain:automotive-control)
37 // ...
38 // )
39 //
40 
43 
44 //String which uniquely identifies this controller
45 const char TestRetreatControllerType[] = "retreat-controller";
46 
48 {
49 public:
50  //constructor
53  DtReaderWriterRegistry * parentRegistry = 0);
54 
55  //destructor
56  virtual ~DtRetreatController();
57 
58  //copy constructor
60 
61  //assignment operator
63 
64  //This returns the string TestRetreatControllerType (defined above),
65  //used to uniquely identify the type of component.
66  virtual const char* type() const;
67 
68  //Register a callback for notification of DtUserTask tasks.
69  virtual void registerTaskMsgCallbacks();
70 
71  //Callback function (registered in registerTaskMsgCallbacks()) for
72  //DtRetreat task messages. Calls processRetreatTask() to actually handle
73  //the task.
74  static void retreatTaskCallback(DtSimMessage * msg, void * usr);
75 
76  //Callback function (registered in registerTaskMsgCallbacks()) for
77  //DtUserTask messages. Calls processUserTask() to actually handle
78  //the task.
79  static void userTaskCallback(DtSimMessage * msg, void * usr);
80 
81  //Called by retreatTaskCallback() when a new DtRetreatTask message is
82  //received.
83  virtual void processRetreatTask(DtSimMessage * msg);
84 
85  //Called by userTaskCallback() when a new DtRetreatTask message is
86  //received.
87  virtual void processUserTask(DtSimMessage * msg);
88 
89  //Update control values
90  virtual void tick();
91 
92  //This is called by the factory
93  static DtSimComponent* creator(const DtString & name, DtLocalObject* owner,
94  DtSimulationServices * simManager, DtComponentDescriptor* desc,
95  DtReaderWriterRegistry * parentRegistry);
96 
97  //Determine which way to flee based on the current target
98  virtual double getHeading();
99 
100  //Returns the amount of fuel left. If no fuel left, can no longer retreat
101  virtual double fuelLeft() const;
102 
103 protected:
105  //determined by DtUserTask arg1, see above
107 };
108 
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
static void userTaskCallback(DtSimMessage *msg, void *usr)
virtual void processUserTask(DtSimMessage *msg)
virtual double fuelLeft() const
DtRetreatController & operator=(const DtRetreatController &orig)
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
virtual ~DtRetreatController()
Definition: readerWriterRegistry.h:39
Definition: retreatCtrl.h:47
const char TestRetreatControllerType[]
Definition: retreatCtrl.h:45
static void retreatTaskCallback(DtSimMessage *msg, void *usr)
bool myHoldGround
Definition: retreatCtrl.h:106
virtual void registerTaskMsgCallbacks()
DtReal myCurrentHeading
Definition: retreatCtrl.h:104
File: simMsg.h.
Definition: simMessage.h:35
DtRetreatController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=NULL, DtReaderWriterRegistry *parentRegistry=0)
virtual void processRetreatTask(DtSimMessage *msg)
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:90
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:70
VRF4API_METHOD const DtSimulationServices * simManager() const
This is the deprecated API that can be used as a reference to migrate 4.X code to 5...
Definition: simComponent.h:566
virtual const char * type() const
Returns a string identifies the class type of component. Type values are defined in compTypes...
virtual DtSymbolString name() const
Accessor for name of this readable/writable object.
virtual double getHeading()
DtGroundAutoControllerComponent is a base controller that holds capabilitites common to all automotiv...
Definition: groundAutoControllerComponent.h:34
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)