VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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, DtVrfObject* owner,
94  DtSimManager * 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 

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)