OBJECT.H 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. /*
  2. ** Command & Conquer(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: F:\projects\c&c\vcs\code\object.h_v 2.15 16 Oct 1995 16:46:16 JOE_BOSTIC $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : OBJECT.H *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : April 29, 1994 *
  30. * *
  31. * Last Update : April 29, 1994 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  36. #ifndef OBJECT_H
  37. #define OBJECT_H
  38. #include "abstract.h"
  39. class ObjectClass;
  40. class TechnoClass;
  41. class ObjectTypeClass;
  42. class HouseClass;
  43. class TriggerClass;
  44. class BuildingClass;
  45. class RadioClass;
  46. //extern "C" {
  47. //unsigned Cardinal_To_Fixed(unsigned base, unsigned cardinal);
  48. //}
  49. /**********************************************************************
  50. ** Every game object (that can exist on the map) is ultimately derived from this object
  51. ** class. It holds the common information between all objects. This is primarily the
  52. ** object unique ID number and its location in the world. All common operations between
  53. ** game objects are represented by virtual functions in this class.
  54. */
  55. class ObjectClass : public AbstractClass
  56. {
  57. public:
  58. /*
  59. ** The object can be in one of two states -- placed down on the map, or not. If the
  60. ** object is placed down on the map, then this flag will be true.
  61. */
  62. unsigned IsDown:1;
  63. /*
  64. ** This is a support flag that is only used while building a list of objects to
  65. ** be damaged by a proximity affect (explosion). When this flag is set, this object
  66. ** will not be added to the list of units to damage. When damage is applied to the
  67. ** object, this flag is cleared again. This process ensures that an object is never
  68. ** subject to "double jeapordy".
  69. */
  70. unsigned IsToDamage:1;
  71. // private:
  72. /*
  73. ** Is this object flagged to be displayed during the next rendering process? This
  74. ** flag could be set by many different circumstances. It is automatically cleared
  75. ** when the object is rerendered.
  76. */
  77. unsigned IsToDisplay:1;
  78. public:
  79. /*
  80. ** An object in the game may be valid yet held in a state of "limbo". Units are in such
  81. ** a state if they are being transported or are otherwise "inside" another unit. They can
  82. ** also be in limbo if they have been created but are being held until the proper time
  83. ** for delivery.
  84. */
  85. unsigned IsInLimbo:1;
  86. /*
  87. ** When an object is "selected" it is given a floating bar graph or other graphic imagery
  88. ** to display this fact. When the player performs I/O, the actions may have a direct
  89. ** bearing on the actions of the currently selected object. For quick checking purposes,
  90. ** if this object is the one that is "selected", this flag will be true.
  91. */
  92. unsigned IsSelected:1;
  93. /*
  94. ** If an animation is attached to this object, then this flag will be true.
  95. */
  96. unsigned IsAnimAttached:1;
  97. /*
  98. ** Several objects could exist in the same cell list. This is a pointer to the
  99. ** next object in the cell list. The objects in this list are not in any
  100. ** significant order.
  101. */
  102. ObjectClass * Next;
  103. /*
  104. ** Every object can be assigned a trigger; the same trigger can be assigned
  105. ** to multiple objects.
  106. */
  107. TriggerClass * Trigger;
  108. /*
  109. ** This is the current strength of this object.
  110. */
  111. short Strength;
  112. /*-----------------------------------------------------------------------------------
  113. ** Constructor & destructors.
  114. */
  115. ObjectClass(void);
  116. virtual ~ObjectClass(void) {};
  117. virtual RTTIType What_Am_I(void) const;
  118. int operator < (ObjectClass const & object) const {return Sort_Y() < object.Sort_Y();};
  119. int operator > (ObjectClass const & object) const {return Sort_Y() > object.Sort_Y();};
  120. /*
  121. ** Object selection control.
  122. */
  123. static void Init(void);
  124. /*
  125. ** Query functions.
  126. */
  127. virtual ActionType What_Action(ObjectClass *) const;
  128. virtual ActionType What_Action(CELL) const;
  129. virtual LayerType In_Which_Layer(void) const;
  130. virtual bool Is_Infantry(void) const;
  131. virtual bool Is_Techno(void) const;
  132. virtual unsigned char Get_Ownable(void) const;
  133. virtual ObjectTypeClass const & Class_Of(void) const = 0;
  134. virtual int Full_Name(void) const;
  135. virtual bool Can_Repair(void) const;
  136. virtual bool Can_Demolish(void) const;
  137. virtual bool Can_Player_Fire(void) const;
  138. virtual bool Can_Player_Move(void) const;
  139. /*
  140. ** Coordinate inquiry functions. These are used for both display and
  141. ** combat purposes.
  142. */
  143. virtual COORDINATE Docking_Coord(void) const;
  144. virtual COORDINATE Target_Coord(void) const;
  145. virtual COORDINATE Center_Coord(void) const;
  146. virtual COORDINATE Render_Coord(void) const;
  147. virtual COORDINATE Sort_Y(void) const;
  148. virtual COORDINATE Fire_Coord(int ) const;
  149. /*
  150. ** Object entry and exit from the game system.
  151. */
  152. virtual bool Limbo(void);
  153. virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
  154. virtual void Detach(TARGET, bool) {};
  155. virtual void Detach_All(bool all=true);
  156. static void Detach_This_From_All(TARGET target, bool all=true);
  157. virtual void Record_The_Kill(TechnoClass * );
  158. /*
  159. ** Display and rendering support functionality. Supports imagery and how
  160. ** object interacts with the map and thus indirectly controls rendering.
  161. */
  162. virtual void Do_Shimmer(void);
  163. virtual int Exit_Object(TechnoClass *);
  164. virtual bool Render(bool forced);
  165. virtual short const * Occupy_List(bool placement=false) const;
  166. virtual short const * Overlap_List(void) const;
  167. virtual unsigned Health_Ratio(void) const;
  168. virtual void Draw_It(int x, int y, WindowNumberType ) = 0;
  169. virtual void Hidden(void);
  170. virtual void Look(bool =false);
  171. virtual bool Mark(MarkType);
  172. private:
  173. virtual void Mark_For_Redraw(void);
  174. public:
  175. /*
  176. ** User I/O.
  177. */
  178. virtual void Active_Click_With(ActionType , ObjectClass *);
  179. virtual void Active_Click_With(ActionType , CELL );
  180. virtual void Clicked_As_Target(int = 7);
  181. virtual bool Select(void);
  182. virtual void Unselect(void);
  183. /*
  184. ** Combat related.
  185. */
  186. virtual bool In_Range(COORDINATE , int=0) const;
  187. virtual int Weapon_Range(int =0) const;
  188. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0);
  189. virtual TARGET As_Target(void) const;
  190. virtual void Scatter(COORDINATE , bool=false);
  191. virtual bool Catch_Fire(void);
  192. virtual void Fire_Out(void);
  193. virtual int Value(void) const;
  194. virtual MissionType Get_Mission(void) const;
  195. /*
  196. ** AI.
  197. */
  198. virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal) const;
  199. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  200. virtual bool Revealed(HouseClass * house);
  201. virtual void Repair(int );
  202. virtual void Sell_Back(int );
  203. /*
  204. ** File I/O.
  205. */
  206. virtual void Code_Pointers(void);
  207. virtual void Decode_Pointers(void);
  208. /*
  209. ** Scenario and debug support.
  210. */
  211. #ifdef CHEAT_KEYS
  212. virtual void Debug_Dump(MonoClass *mono) const;
  213. #endif
  214. virtual void Move(FacingType);
  215. };
  216. #endif