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
unit.h
Go to the documentation of this file.
1 /*
2  * Vega Strike
3  * Copyright (C) 2001-2002 Daniel Horn
4  *
5  * http://vegastrike.sourceforge.net/
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */
21 #ifndef _GAMEUNIT_H_
22 #define _GAMEUNIT_H_
23 
24 #ifdef VS_DEBUG
25 #define CONTAINER_DEBUG
26 #endif
27 
28 #include <string>
29 #include <vector>
30 #include <map>
31 #include <memory>
32 
33 class HaloSystem;
34 struct GFXColor; // labeled as class, declared as struct in gfxlib_struct.h
35 class QVector;
36 struct Transformation;
37 class Matrix;
38 class Vector;
39 class StarSystem;
40 
41 class Mesh;
42 class Flightgroup;
43 template < typename BOGUS >
44 struct UnitImages;
45 class Unit;
46 class VSSprite;
47 class Camera;
48 class UnitCollection;
49 
57 template < class UnitType >
58 class GameUnit : public UnitType
59 {
60  friend class UnitFactory;
61 protected:
62 //Default constructor. This is just to figure out where default
63 //constructors are used. The useless argument will be removed
64 //again later.
65 public: GameUnit( int dummy );
66 //Constructor that creates aa mesh with meshes as submeshes (number
67 //of them) as either as subunit with faction faction
68  GameUnit( std::vector< Mesh* > &meshes, bool Subunit, int faction );
69 //Constructor that creates a mesh from an XML file If it is a
70 //customizedUnit, it will check in that directory in the home dir for
71 //the unit.
72  GameUnit( const char *filename, bool SubUnit, int faction, std::string customizedUnit = std::string(
73  "" ), Flightgroup *flightgroup = NULL, int fg_subnumber = 0, std::string *netxml = NULL );
74  virtual ~GameUnit();
75  int nummesh() const;
79  bool RequestClearance( Unit *dockingunit );
81  void UpgradeInterface( Unit *base );
83  virtual void Cloak( bool cloak );
84 /*
85  **************************************************************************************
86  **** GFX/MESHES STUFF ***
87  **************************************************************************************
88  */
89  double sparkle_accum;
90  std::auto_ptr< HaloSystem >phalos;
93  void Split( int level );
94  void FixGauges();
96  void UpdateHudMatrix( int whichcam );
98  VSSprite * getHudImage() const;
100  virtual void Draw( const Transformation &quat, const Matrix &m );
101  virtual void Draw( const Transformation &quat );
102  virtual void Draw();
103  virtual void DrawNow( const Matrix &m, float lod = 1000000000 );
104  virtual void DrawNow();
106  void addHalo( const char *filename,
107  const QVector &loc,
108  const Vector &size,
109  const GFXColor &col,
110  std::string halo_type,
111  float halo_speed );
112 
113  virtual void applyTechniqueOverrides(const std::map<std::string, std::string> &overrides);
114 
115 /*
116  **************************************************************************************
117  **** STAR SYSTEM STUFF ***
118  **************************************************************************************
119  */
120  bool TransferUnitToSystem( unsigned int whichJumpQueue, StarSystem*&previouslyActiveStarSystem, bool DoSightAndSound );
122  bool Explode( bool draw, float timeit );
123 /*
124  **************************************************************************************
125  **** COLLISION STUFF ***
126  **************************************************************************************
127  */
130  bool queryFrustum( double frustum[6][4] ) const;
131 
134  bool querySphereClickList( int, int, float err, Camera *activeCam );
136 /*
137  **************************************************************************************
138  **** PHYSICS STUFF
139  **************************************************************************************
140  */
142  virtual void UpdatePhysics2( const Transformation &trans,
143  const Transformation &old_physical_state,
144  const Vector &accel,
145  float difficulty,
146  const Matrix &transmat,
147  const Vector &CumulativeVelocity,
148  bool ResolveLast,
149  UnitCollection *uc = NULL );
151  void Thrust( const Vector &amt, bool afterburn = false );
153  Vector ResolveForces( const Transformation&, const Matrix& );
154 //these functions play the damage sounds
155  virtual void ArmorDamageSound( const Vector &pnt );
156  virtual void HullDamageSound( const Vector &pnt );
158  float DealDamageToShield( const Vector &pnt, float &Damage );
159 /*
160  **************************************************************************************
161  **** CUSTOMIZE/UPGRADE STUFF
162  **************************************************************************************
163  */
164  bool UpgradeSubUnits( const Unit *up, int subunitoffset, bool touchme, bool downgrade, int &numave, double &percentage );
165  double Upgrade( const std::string &file, int mountoffset, int subunitoffset, bool force, bool loop_through_mounts );
166 /*
167  *******************************************
168  **** XML struct
169  *******************************************
170  */
172  Matrix WarpMatrix( const Matrix &ctm ) const;
173 };
174 
175 
176 
177 /*
178  ***************************************************************************
179  **** Since we now use templates, we have to include GameUnit related ***
180  **** .cpp files in unit.h to avoid problems with some compilers ***
181  ***************************************************************************
182  */
183 
185 //forward declarations of explicit instantiations, added by chuck_starchaser:
186 
187 class Asteroid;
188 template < class Asteroid >
189 class GameUnit;
190 
191 class Building;
192 template < class Building >
193 class GameUnit;
194 
195 class Planet;
196 template < class Planet >
197 class GameUnit;
198 
199 class Unit;
200 template < class Unit >
201 class GameUnit;
202 
203 class Missile;
204 template < class Missile >
205 class GameUnit;
206 
207 class Nebula;
208 template < class Nebula >
209 class GameUnit;
210 
211 class Enhancement;
212 template < class Enhancement >
213 class GameUnit;
214 
215 #endif