Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
navigation.h
Go to the documentation of this file.
1 #ifndef _CMD_NAVIGATION_ORDERS_H_
2 #define _CMD_NAVIGATION_ORDERS_H_
3 
4 #include "order.h"
5 #include "vegastrike.h"
6 #include "vs_globals.h"
7 
8 namespace Orders
9 {
10 const float bleed_threshold = 0.0001;
11 const float THRESHOLD = 0.01;
12 
23 {
24  bool afterburn;
25  unsigned char switchbacks;
26  unsigned char terminatingX;
27  unsigned char terminatingY;
28  unsigned char terminatingZ;
29  Vector last_velocity;
30  bool OptimizeSpeed( Unit *parent, float v, float &a, float max_speed );
31  bool Done( const Vector& );
32  bool selfterminating;
33 public:
34  void SetAfterburn( bool tf )
35  {
36  afterburn = tf;
37  }
38  MoveToParent( bool aft, unsigned char switchbacks, bool terminating = true )
39  : afterburn(aft)
40  , switchbacks(switchbacks)
41  , terminatingX( 0 )
42  , terminatingY( 0 )
43  , terminatingZ( 0 )
44  , last_velocity( 0, 0, 0 )
45  , selfterminating( terminating ) {}
46  bool Execute( Unit *parent, const QVector &targetlocation );
47 };
48 class MoveTo : public Order
49 {
50  MoveToParent m;
52 public:
53  void SetAfterburn( bool tf )
54  {
55  m.SetAfterburn( tf );
56  }
58  MoveTo( const QVector &target, bool aft, unsigned char switchbacks, bool terminating = true ) : Order( MOVEMENT,
59  SLOCATION )
60  , m( aft, switchbacks, terminating )
61  {
62  targetlocation = target;
63  done = false;
64  }
65  void SetDest( const QVector& );
66  virtual void Execute();
67  virtual ~MoveTo();
68  virtual string getOrderDescription()
69  {
70  return "moveto";
71  }
72 };
80 class ChangeHeading : public Order
81 {
82  float turningspeed;
83  unsigned char switchbacks;
84  unsigned char terminatingX;
85  unsigned char terminatingY;
86  Vector last_velocity;
87  QVector final_heading;
88  bool terminating;
89  bool OptimizeAngSpeed( float limitpos, float limitneg, float v, float &a );
90  bool Done( const Vector& );
91  void TurnToward( float angle, float ang_vel, float &torque );
92 protected:
93  void ResetDone()
94  {
95  done = false;
96  terminatingX = terminatingY = 0;
97  }
98 
99 public:
101  ChangeHeading( const QVector &final_heading, int switchback, float turning_speed = 1, bool term = false ) : Order( FACING,
102  SLOCATION )
103  , turningspeed( turning_speed )
104  , switchbacks( switchback )
105  , terminatingX( 0 )
106  , terminatingY( 0 )
107  , last_velocity( 0, 0, 0 )
108  , final_heading( final_heading )
109  , terminating( term ) {}
110  void SetDest( const QVector& );
111  virtual void Execute();
112  virtual string getOrderDescription()
113  {
114  return "chhead";
115  }
116  virtual ~ChangeHeading();
117 };
122 class FaceTarget : public ChangeHeading
123 {
124  bool finish;
125 public: FaceTarget( bool fini = false, int accuracy = 3 );
126  virtual void Execute();
127  virtual string getOrderDescription()
128  {
129  return "facet";
130  }
131  virtual ~FaceTarget();
132 };
138 {
139  bool finish;
140  bool deactivatewarp;
141  bool StraightToTarget;
142  bool inside_landing_zone;
143 
144  void MakeLinearVelocityOrder();
145  bool InsideLandingPort( const Unit *obstacle ) const;
146  QVector NewDestination( const QVector &curnewdestination, double magnitude );
147 public: AutoLongHaul( bool fini = false, int accuracy = 1 );
148  virtual void Execute();
149  virtual void SetParent( Unit *parent1 );
150  virtual string getOrderDescription()
151  {
152  return "ASAP";
153  }
154  virtual ~AutoLongHaul();
155 };
161 {
162  bool finish;
164  float speed;
165  bool useitts;
166 public: FaceTargetITTS( bool fini = false, int accuracy = 3 );
167  virtual void Execute();
168  virtual string getOrderDescription()
169  {
170  return "faceitts";
171  }
172  virtual ~FaceTargetITTS();
173 };
174 class FormUp : public MoveTo
175 {
176  QVector Pos;
177 public: FormUp( const QVector &Position );
178  void SetPos( const QVector& );
179  virtual void SetParent( Unit *parent1 );
180  virtual void Execute();
181  virtual string getOrderDescription()
182  {
183  return "formup";
184  }
185  virtual ~FormUp();
186 };
187 class FormUpToOwner : public MoveTo
188 {
189  QVector Pos;
190 public: FormUpToOwner( const QVector &Position );
191  void SetPos( const QVector& );
192  virtual void SetParent( Unit *parent1 );
193  virtual void Execute();
194  virtual string getOrderDescription()
195  {
196  return "formuptoowner";
197  }
198  virtual ~FormUpToOwner();
199 };
201 {
202  bool finish;
203  float dist;
204 public: FaceDirection( float distToMatchFacing, bool fini = false, int accuracy = 3 );
205  virtual void SetParent( Unit *parent1 );
206  virtual void Execute();
207  virtual string getOrderDescription()
208  {
209  return "facedir";
210  }
211  virtual ~FaceDirection();
212 };
213 }
214 #endif
215