terrobj.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. //---------------------------------------------------------------------------
  2. //
  3. // terrobj.h -- File contains the Terrain Object Definition
  4. //
  5. // MechCommander 2
  6. //
  7. //---------------------------------------------------------------------------//
  8. // Copyright (C) Microsoft Corporation. All rights reserved. //
  9. //===========================================================================//
  10. #ifndef TERROBJ_H
  11. #define TERROBJ_H
  12. #ifndef DTERROBJ_H
  13. #include "dterrobj.h"
  14. #endif
  15. #ifndef OBJTYPE_H
  16. #include "objtype.h"
  17. #endif
  18. #ifndef GAMEOBJ_H
  19. #include "gameobj.h"
  20. #endif
  21. #ifndef DCARNAGE_H
  22. #include "dcarnage.h"
  23. #endif
  24. #include <gosFX\gosfxheaders.hpp>
  25. //---------------------------------------------------------------------------
  26. // Macro Definitions
  27. //#define NO_RAM_FOR_BUILDING 0xDCDC0006
  28. //#define NO_APPEARANCE_TYPE_FOR_BLD 0xDCDC0007
  29. //#define NO_APPEARANCE_FOR_BLD 0xDCDC0008
  30. //#define APPEARANCE_NOT_VFX_APPEAR 0xDCDC0009
  31. //---------------------------------------------------------------------------
  32. typedef enum {
  33. TERROBJ_NONE,
  34. TERROBJ_TREE,
  35. TERROBJ_BRIDGE,
  36. TERROBJ_FOREST,
  37. TERROBJ_WALL_HEAVY,
  38. TERROBJ_WALL_MEDIUM,
  39. TERROBJ_WALL_LIGHT,
  40. NUM_TERROBJ_SUBTYPES
  41. } TerrainObjectSubType;
  42. class TerrainObjectType : public ObjectType {
  43. public:
  44. char subType;
  45. float damageLevel;
  46. long collisionOffsetX;
  47. long collisionOffsetY;
  48. bool setImpassable;
  49. long xImpasse;
  50. long yImpasse;
  51. float explDmg;
  52. float explRad;
  53. unsigned long fireTypeHandle;
  54. public:
  55. void init (void);
  56. TerrainObjectType (void) {
  57. ObjectType::init();
  58. init();
  59. }
  60. virtual void initMiscTerrObj (long objTypeNum);
  61. virtual long init (FilePtr objFile, unsigned long fileSize);
  62. long init (FitIniFilePtr objFile);
  63. ~TerrainObjectType (void) {
  64. destroy();
  65. }
  66. float getDamageLevel (void) {
  67. return(damageLevel);
  68. }
  69. virtual void destroy (void);
  70. virtual GameObjectPtr createInstance (void);
  71. virtual float getBurnDmg (void) {
  72. return(0.0);
  73. }
  74. virtual float getBurnTime (void) {
  75. return(0.0);
  76. }
  77. virtual bool handleCollision (GameObjectPtr collidee, GameObjectPtr collider);
  78. virtual bool handleDestruction (GameObjectPtr collidee, GameObjectPtr collider);
  79. };
  80. //---------------------------------------------------------------------------
  81. typedef struct _TerrainObjectData : public GameObjectData
  82. {
  83. float damage;
  84. long vertexNumber;
  85. long blockNumber;
  86. float pitchAngle;
  87. float fallRate;
  88. GameObjectWatchID powerSupply;
  89. short cellFootprint[4];
  90. Stuff::Vector3D vectorFootprint[4];
  91. short numSubAreas0;
  92. short numSubAreas1;
  93. short subAreas0[MAX_SPECIAL_SUB_AREAS];
  94. short subAreas1[MAX_SPECIAL_SUB_AREAS];
  95. unsigned char listID;
  96. unsigned char numCellsCovered;
  97. short cellsCovered[81];
  98. } TerrainObjectData;
  99. #define MAXLEN_TERRAINOBJECT_NAME 35
  100. class TerrainObject : public GameObject {
  101. public:
  102. float damage;
  103. long vertexNumber;
  104. long blockNumber;
  105. float pitchAngle;
  106. float fallRate;
  107. GameObjectWatchID powerSupply;
  108. short cellFootprint[4];
  109. Stuff::Vector3D vectorFootprint[4];
  110. short numSubAreas0;
  111. short numSubAreas1;
  112. short *subAreas0;
  113. short *subAreas1;
  114. unsigned char listID;
  115. unsigned char numCellsCovered;
  116. short* cellsCovered;
  117. gosFX::Effect *bldgDustPoofEffect;
  118. static long cellArray[9];
  119. public:
  120. virtual void init (bool create) {
  121. objectClass = TERRAINOBJECT;
  122. setFlag(OBJECT_FLAG_JUSTCREATED, true);
  123. appearance = NULL;
  124. vertexNumber = 0;
  125. blockNumber = 0;
  126. damage = 0.0;
  127. pitchAngle = 0.0f;
  128. fallRate = 0.0f;
  129. powerSupply = NULL;
  130. cellFootprint[0] = -1;
  131. cellFootprint[1] = -1;
  132. cellFootprint[2] = -1;
  133. cellFootprint[3] = -1;
  134. numSubAreas0 = 0;
  135. numSubAreas1 = 0;
  136. subAreas0 = NULL;
  137. subAreas1 = NULL;
  138. listID = 255;
  139. numCellsCovered = 0;
  140. cellsCovered = NULL;
  141. bldgDustPoofEffect = NULL;
  142. }
  143. TerrainObject (void) : GameObject() {
  144. init(true);
  145. }
  146. ~TerrainObject (void) {
  147. destroy();
  148. }
  149. virtual void updateDebugWindow (GameDebugWindow* debugWindow);
  150. virtual char* getName (void);
  151. virtual void killFire (void);
  152. void lightOnFire (float timeToBurn);
  153. virtual void destroy (void);
  154. virtual long update (void);
  155. virtual void render (void);
  156. virtual void renderShadows (void);
  157. virtual void init (bool create, ObjectTypePtr objType);
  158. virtual long handleWeaponHit (WeaponShotInfoPtr shotInfo, bool addMultiplayChunk = false);
  159. virtual void setTerrainPosition (const Stuff::Vector3D& position, const Stuff::Vector2DOf<long>& numbers);
  160. virtual void setDamage (long newDamage); //Damage encodes which groundtile to use, too.
  161. virtual void setRotation( float rot );
  162. virtual float getDamage (void)
  163. {
  164. return(damage);
  165. }
  166. virtual float getDamageLevel (void)
  167. {
  168. return ((TerrainObjectTypePtr)getObjectType())->getDamageLevel();
  169. }
  170. virtual float getDestructLevel (void)
  171. {
  172. return (getDamageLevel() - damage);
  173. }
  174. virtual float getStatusRating (void);
  175. long getSubType (void) {
  176. return(((TerrainObjectTypePtr)getObjectType())->subType);
  177. }
  178. virtual long kill (void) {
  179. //Do nothing for now. Later, Buildings may do something.
  180. return NO_ERR;
  181. }
  182. bool isVisible (void);
  183. virtual long getLineOfSightNodes (long eyeCellRow, long eyeCellCol, long* cells);
  184. virtual bool isTerrainObject (void) {
  185. return(true);
  186. }
  187. virtual void getBlockAndVertexNumber (long& blockNum, long& vertexNum) {
  188. blockNum = blockNumber;
  189. vertexNum = vertexNumber;
  190. }
  191. virtual void rotate (float yaw, float pitch);
  192. virtual float getAppearRadius (void)
  193. {
  194. return appearance->getRadius();
  195. }
  196. virtual void setPowerSupply (GameObjectPtr power)
  197. {
  198. powerSupply = power->getWatchID();
  199. }
  200. virtual void calcCellFootprint (Stuff::Vector3D& pos);
  201. virtual bool calcAdjacentAreaCell (long moveLevel, long areaID, long& adjRow, long& adjCol);
  202. void calcSubAreas (long numCells, short cells[MAX_GAME_OBJECT_CELLS][2]);
  203. void markMoveMap (bool passable);
  204. void openSubAreas (void);
  205. void closeSubAreas (void);
  206. void setSubAreasTeamId (long id);
  207. virtual void Save (PacketFilePtr file, long packetNum);
  208. void Load (TerrainObjectData *data);
  209. void CopyTo (TerrainObjectData *data);
  210. virtual Stuff::Vector3D getPositionFromHS (long weaponType)
  211. {
  212. //-----------------------------------------
  213. // Hotspot for buildings is position plus
  214. // some Z based on OBB to make Effect visible.
  215. // If this doesn't work, replace with art defined site.
  216. Stuff::Vector3D hsPos = position;
  217. if (appearance)
  218. hsPos.z += appearance->getTopZ() * 0.5f;
  219. return(hsPos);
  220. }
  221. virtual Stuff::Vector3D getLOSPosition (void)
  222. {
  223. //-----------------------------------------
  224. // Hotspot for buildings is position plus
  225. // some Z based on OBB to make Effect visible.
  226. //
  227. // Use THIS position for LOS Calc!!!
  228. Stuff::Vector3D hsPos = position;
  229. if (appearance)
  230. hsPos.z += appearance->getTopZ() * 0.5f;
  231. return(hsPos);
  232. }
  233. };
  234. //---------------------------------------------------------------------------
  235. #endif