LogisticsVariant.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. #ifndef LOGISTICSVARIANT_H
  2. #define LOGISTICSVARIANT_H
  3. /*************************************************************************************************\
  4. LogisticsVariant.h : Interface for the LogisticsVariant component. This thing
  5. is a simplified mech/vehicle object without AI.
  6. //---------------------------------------------------------------------------//
  7. // Copyright (C) Microsoft Corporation. All rights reserved. //
  8. //===========================================================================//
  9. \*************************************************************************************************/
  10. // forward declarations
  11. class MechAppearance;
  12. class LogisticsComponent;
  13. class CSVFile;
  14. class FitIniFile;
  15. #include "EString.h"
  16. #pragma warning (disable:4514)
  17. enum LOGISTICS_COMPONENT_LOCATION
  18. {
  19. HEAD = 0,
  20. CHEST = 1,
  21. LEGS = 2
  22. };
  23. class LogisticsChassis
  24. {
  25. public:
  26. LogisticsChassis( );
  27. int init( CSVFile* fileName, int chassisID );
  28. void setFitID( int id ){ fitID = id; }
  29. int getNameID() const { return chassisNameID; }
  30. int getEncyclopediaID() const { return encyclopediaID; }
  31. const EString& getFileName() const { return fileName; }
  32. int getHouseID() const{ return houseID; }
  33. float getMaxWeight() const{ return maxWeight; }
  34. const EString& getMechClass() const { return mechClass; }
  35. long getArmor() const { return baseArmor; }
  36. int getArmorClass() const;
  37. float getSpeed() const { return speed; }
  38. int getDisplaySpeed() const;
  39. void setScale( float newScale ) { scale = newScale; }
  40. float getScale() const { return scale; }
  41. long getMaxArmor() const { return maxArmor; }
  42. int getSensorID() const;
  43. int getECM() const;
  44. bool jumpJetsAllowed() const { return canHaveJumpJets; }
  45. protected:
  46. int refCount;
  47. float maxWeight;
  48. long chassisNameID; // resource ID
  49. long baseCost;
  50. long maxHeat;
  51. long baseArmor;
  52. long maxArmor;
  53. float speed;
  54. float scale;
  55. long iconPictureIndex;
  56. long ID;
  57. EString fileName;
  58. EString mechClass;
  59. EString iconFileNames[3];
  60. long componentAreaWidth;
  61. long componentAreaHeight;
  62. bool canHaveAdvSensor;//can Mech Have Advanced Sensor installed.
  63. bool canHaveOptics;//can Mech Have Optics Installed.
  64. bool canHaveGlobalSensor;//can Mech have Global Sensor installed.
  65. bool canHaveECM;//can Mech have ECM Installed.
  66. bool canHaveActiveProbe;//can Mech have Active Probe Installed.
  67. bool canHaveJumpJets;
  68. bool canHaveExtendedSensor;
  69. long encyclopediaID;
  70. long helpID;
  71. long houseID;
  72. long fitID;
  73. MechAppearance* appearance;
  74. friend class LogisticsVariant;
  75. friend class LogisticsMech;
  76. static int weightClasses[]; // mech weights
  77. friend class LogisticsData;
  78. struct ComponentInfo
  79. {
  80. long xCoord;
  81. long yCoord;
  82. LOGISTICS_COMPONENT_LOCATION location;
  83. LogisticsComponent* component;
  84. };
  85. };
  86. class LogisticsVariant
  87. {
  88. protected:
  89. public:
  90. LogisticsVariant();
  91. LogisticsVariant( const LogisticsChassis* pChassis, bool isDesignerMech );
  92. LogisticsVariant( const LogisticsVariant& ); // going to need copy c'tor
  93. virtual ~LogisticsVariant();
  94. int init( CSVFile* fileName, LogisticsChassis*, int blockID );
  95. int compareWeight( LogisticsVariant* );
  96. inline bool isAvailable() const { return (availableToUser && !bHidden); }
  97. unsigned long getID() const { return ID; }
  98. float getMaxWeight() const { return chassis->maxWeight; }
  99. long getChassisName() const { return chassis->chassisNameID; }
  100. const EString& getName() const { return variantName; }
  101. long getEncyclopediaID() const { return chassis->encyclopediaID; }
  102. long getHelpID() const { return chassis->helpID; }
  103. long getBaseCost() const { return chassis->baseCost; }
  104. long getComponentCount() const { return componentCount; }
  105. int canAddComponent( LogisticsComponent* pComponent, long& x, long& y ) const;
  106. int getCost() const;
  107. int getWeight() const;
  108. const EString& getMechClass() const;
  109. int getChassisID() const { return chassis->ID; }
  110. int getArmor() const;
  111. int getArmorClass() { return chassis->getArmorClass(); }
  112. int getJumpRange() const;
  113. int getMaxJumpRange() const;
  114. int getSpeed() const;
  115. int getDisplaySpeed() const;
  116. int getVariantID() const { return ID & 0x00ffffff; }
  117. const EString& getSmallIconFileName() const { return chassis->iconFileNames[0]; }
  118. const EString& getMediumIconFileName() const { return chassis->iconFileNames[1]; }
  119. const EString& getLargeIconFileName() const { return chassis->iconFileNames[2]; }
  120. int getComponentsWithLocation( long& count, long* IDArray, long* xLocationArray, long* yLocationArray );
  121. int removeComponent( long xCoord, long yCoord );
  122. int addComponent( LogisticsComponent*, long& xCoord, long& yCoord );
  123. inline bool canDelete( ) const { return !isDesignerMech(); }
  124. inline bool isDesignerMech() const { return bDesignerMech; }
  125. int getComponents( long& count, long* array );
  126. int getComponents( long& count, LogisticsComponent** array );
  127. int getHeat() const;
  128. int getMaxHeat() const;
  129. LogisticsVariant& operator=( const LogisticsVariant& );
  130. bool operator==( const LogisticsVariant& src );
  131. const EString& getFileName(){ return chassis->fileName; }
  132. long save( FitIniFile& file, long counter );
  133. const LogisticsChassis* getChassis() const { return chassis; }
  134. bool addComponent( int idFromFitFile, long& x, long& y );
  135. void setName( const char* name ); // will allocate for you
  136. void setAvailable( bool available );
  137. int getIconIndex() const { return chassis->iconPictureIndex; }
  138. int getComponentAreaWidth() const{ return chassis->componentAreaWidth; }
  139. int getComponentAreaHeight() const { return chassis->componentAreaHeight; }
  140. LogisticsComponent* getCompAtLocation( int i, int j, long& realI, long& realJ );
  141. int getComponentLocation( LogisticsComponent* pComp, long& i, long& j );
  142. int getOptimalRangeString( long& color ) const;
  143. long getHouseID(){ return chassis->houseID; }
  144. long getMaxArmor() const { return chassis->maxArmor; }
  145. int getSensorID() const { return chassis->getSensorID(); }
  146. int getECM() const { return chassis->getECM(); }
  147. bool allComponentsAvailable() const;
  148. int getFileID() const { return fileID; }
  149. protected:
  150. const LogisticsChassis::ComponentInfo* getComponentAtLocation(long x, long y) const;
  151. unsigned long ID; // bottom 8 bits = mech chassis, next 8 = number within
  152. int fileID; // in csv file
  153. LogisticsChassis* chassis;
  154. EString variantName; // in file
  155. long componentCount;
  156. LogisticsChassis::ComponentInfo components[54]; // I count a max of 54 components, might want to check though
  157. bool availableToUser;
  158. bool bDesignerMech;
  159. bool bHidden;
  160. // HELPERS
  161. bool hasJumpJets() const;
  162. bool hasECM() const;
  163. bool hasSensor() const;
  164. // SUPPRESSED
  165. friend class LogisticsMech;
  166. };
  167. class LogisticsVehicle : public LogisticsChassis
  168. {
  169. public:
  170. void init( FitIniFile& file );
  171. int getComponents( long& count, LogisticsComponent** array );
  172. protected:
  173. long componentCount;
  174. ComponentInfo components[54]; // I count a max of 54 components, might want to check though
  175. };
  176. //*************************************************************************************************
  177. #endif // end of file ( LogisticsVariant.h )