EditorObjects.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. #ifndef EDITOROBJECTS_H
  2. #define EDITOROBJECTS_H
  3. /*************************************************************************************************\
  4. EditorObjects.h : Interface for the EditorObjects, buildings, mechs etc.
  5. //---------------------------------------------------------------------------//
  6. // Copyright (C) Microsoft Corporation. All rights reserved. //
  7. //===========================================================================//
  8. \*************************************************************************************************/
  9. class FitIniFile;
  10. #include "ObjectAppearance.h"
  11. #ifndef HEAP_H
  12. #include <heap.h>
  13. #endif
  14. #ifndef ELIST_H
  15. #include "EList.h"
  16. #endif
  17. #include "DAprType.h"
  18. #define MAX_PILOT 64
  19. //*************************************************************************************************
  20. class EditorObject
  21. {
  22. public:
  23. EditorObject();
  24. virtual ~EditorObject();
  25. EditorObject( const EditorObject& );
  26. EditorObject& operator=( const EditorObject& );
  27. virtual void CastAndCopy(const EditorObject &master) { (*this) = master; }
  28. virtual EditorObject *Clone() { return(new EditorObject(*this)); }
  29. void *operator new (size_t mySize);
  30. void operator delete (void *us);
  31. void select( bool bSelect );
  32. inline bool isSelected() const { return appearInfo->appearance->selected ? true : false; }
  33. void setAlignment( int align );
  34. inline int getAlignment( )const{ return appearInfo->appearance->teamId; }
  35. unsigned long getColor() const;
  36. long getID() const { return id; }
  37. void getCells( long& cellJ, long& cellI ) const;
  38. virtual bool save( FitIniFile* file, int warriorNumber ){ return false; }
  39. virtual bool load( FitIniFile* file, int warriorNumber ){ return false; }
  40. virtual int getType() const { return BLDG_TYPE; }
  41. int getSpecialType() const;
  42. int getGroup() const;
  43. int getIndexInGroup() const;
  44. void setDamage( bool bDamage );
  45. bool getDamage() const;
  46. const char* getDisplayName() const;
  47. const Stuff::Vector3D& getPosition() const { return appearance()->position; }
  48. void markTerrain (_ScenarioMapCellInfo* pInfo, int type, int counter)
  49. {
  50. appearInfo->appearance->markTerrain(pInfo,type, counter);
  51. }
  52. void setAppearance( int Group, int indexInGroup );
  53. ObjectAppearance* appearance() { return appearInfo->appearance; }
  54. const ObjectAppearance* appearance() const { return appearInfo->appearance; }
  55. long getForestID() const { return forestId; }
  56. void setForestID( int newID ) { forestId = newID; }
  57. void setScale( long newScale ) { scale = newScale; }
  58. long getScale( ) const { return scale; }
  59. protected:
  60. struct AppearanceInfo
  61. {
  62. ObjectAppearance* appearance;
  63. int refCount; // so we only delete once
  64. void *operator new (size_t mySize)
  65. {
  66. void *result = NULL;
  67. result = systemHeap->Malloc(mySize);
  68. return(result);
  69. }
  70. void operator delete (void *us)
  71. {
  72. systemHeap->Free(us);
  73. }
  74. AppearanceInfo& operator=( const AppearanceInfo& src );
  75. };
  76. long cellColumn;
  77. long cellRow;
  78. long id;
  79. AppearanceInfo* appearInfo;
  80. long forestId;
  81. long scale; // forest only
  82. friend class EditorObjectMgr; // the only thing that can move and change these things
  83. };
  84. // THIS CLASS CLEARLY NEEDS FLESHING OUT!
  85. //*************************************************************************************************
  86. class Pilot
  87. {
  88. public:
  89. Pilot(){info = 0;}
  90. static void initPilots();
  91. struct PilotInfo
  92. {
  93. char* name;
  94. char* fileName;
  95. };
  96. static PilotInfo s_GoodPilots[MAX_PILOT];
  97. static PilotInfo s_BadPilots[MAX_PILOT];
  98. static long goodCount;
  99. static long badCount;
  100. const char* getName() const { return info->name; }
  101. void setName( const char* );
  102. void save( FitIniFile* file, int bGoodGuy );
  103. void load( FitIniFile* file, int bGoodGuy );
  104. PilotInfo* info;
  105. /*note: The value of info should always be NULL or a pointer to static data. So the default
  106. assignment/copy operator (shallow copy) is valid. */
  107. };
  108. //*************************************************************************************************
  109. class Brain
  110. {
  111. long numCells;
  112. long *cellNum;
  113. long *cellType;
  114. float *cellData;
  115. long numStaticVars;
  116. char brainName[256];
  117. public:
  118. Brain (void)
  119. {
  120. numStaticVars = numCells = 0;
  121. cellNum = cellType = NULL;
  122. cellData = NULL;
  123. brainName[0] = 0;
  124. }
  125. ~Brain (void)
  126. {
  127. free(cellNum);
  128. free(cellType);
  129. free(cellData);
  130. numStaticVars = numCells = 0;
  131. cellNum = cellType = NULL;
  132. cellData = NULL;
  133. brainName[0] = 0;
  134. }
  135. Brain( const Brain& );
  136. Brain& operator=( const Brain& );
  137. bool save( FitIniFile* file, int warriorNumber, bool usePBrain = false );
  138. bool load( FitIniFile* file, int warriorNumber );
  139. };
  140. //*************************************************************************************************
  141. class CUnitList;
  142. class Unit : public EditorObject
  143. {
  144. public:
  145. Unit( int alignment );
  146. Unit( const Unit& src );
  147. Unit& operator=( const Unit& src );
  148. virtual ~Unit();
  149. virtual void CastAndCopy(const EditorObject &master);
  150. virtual EditorObject *Clone() { return(new Unit(*this)); }
  151. void setLanceInfo( int newLance, int index ){ lance = newLance; lanceIndex = index; }
  152. void getLanceInfo( int &newLance, int &index ){ newLance = lance; index = lanceIndex; }
  153. virtual int getType() const { return GV_TYPE; }
  154. unsigned long getSquad() const { return squad; }
  155. void setSquad(unsigned long newSquad);
  156. virtual bool save( FitIniFile* file, int warriorNumber );
  157. virtual bool load( FitIniFile* file, int warriorNumber );
  158. void getColors( unsigned long& base, unsigned long& color1, unsigned long& color2 ) const;
  159. void setColors( unsigned long base, unsigned long color1, unsigned long color2 );
  160. bool getSelfRepairBehaviorEnabled() const { return selfRepairBehaviorEnabled; }
  161. void setSelfRepairBehaviorEnabled(bool val) { selfRepairBehaviorEnabled = val; }
  162. inline Pilot* getPilot() { return &pilot; }
  163. void setVariant( unsigned long newVar ){ variant = newVar; }
  164. inline int getVariant() const { return variant; }
  165. CUnitList *pAlternativeInstances;
  166. unsigned long tmpNumAlternativeInstances;
  167. unsigned long tmpAlternativeStartIndex;
  168. protected:
  169. bool save( FitIniFile* file, int WarriorNumber, int controlDataType, char* objectProfile );
  170. Brain brain;
  171. bool selfRepairBehaviorEnabled;
  172. int lance; // which lance
  173. int lanceIndex; // number within lance 1 to 12
  174. unsigned long squad;
  175. Pilot pilot;
  176. unsigned long baseColor;
  177. unsigned long highlightColor;
  178. unsigned long highlightColor2;
  179. unsigned long variant;
  180. };
  181. class CUnitList : public EList<Unit, Unit&> {};
  182. //*************************************************************************************************
  183. class DropZone : public EditorObject
  184. {
  185. public:
  186. DropZone( const Stuff::Vector3D& position, int alignment, bool bVTol );
  187. DropZone& operator=( const DropZone& src ) { bVTol = src.bVTol; EditorObject::operator=( src ); return *this; }
  188. virtual void CastAndCopy(const EditorObject &master);
  189. virtual EditorObject *Clone() { return(new DropZone(*this)); }
  190. virtual bool save( FitIniFile* file, int number );
  191. bool isVTol() { return bVTol; }
  192. private:
  193. bool bVTol;
  194. };
  195. class NavMarker : public EditorObject
  196. {
  197. public:
  198. NavMarker();
  199. virtual EditorObject *Clone() { return(new NavMarker(*this)); }
  200. virtual bool save( FitIniFile* file, int number );
  201. };
  202. //*************************************************************************************************
  203. #endif // end of file ( EditorObjects.h )