OBJECT.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. //
  2. // Copyright 2020 Electronic Arts Inc.
  3. //
  4. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free
  5. // software: you can redistribute it and/or modify it under the terms of
  6. // the GNU General Public License as published by the Free Software Foundation,
  7. // either version 3 of the License, or (at your option) any later version.
  8. // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed
  9. // in the hope that it will be useful, but with permitted additional restrictions
  10. // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT
  11. // distributed with this program. You should have received a copy of the
  12. // GNU General Public License along with permitted additional restrictions
  13. // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
  14. /* $Header: /CounterStrike/OBJECT.H 1 3/03/97 10:25a Joe_bostic $ */
  15. /***********************************************************************************************
  16. *** 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 ***
  17. ***********************************************************************************************
  18. * *
  19. * Project Name : Command & Conquer *
  20. * *
  21. * File Name : OBJECT.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : April 29, 1994 *
  26. * *
  27. * Last Update : April 29, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef OBJECT_H
  33. #define OBJECT_H
  34. #include "abstract.h"
  35. class ObjectClass;
  36. class TechnoClass;
  37. class ObjectTypeClass;
  38. class HouseClass;
  39. class BuildingClass;
  40. class RadioClass;
  41. class TriggerClass;
  42. /**********************************************************************
  43. ** Every game object (that can exist on the map) is ultimately derived from this object
  44. ** class. It holds the common information between all objects. This is primarily the
  45. ** object unique ID number and its location in the world. All common operations between
  46. ** game objects are represented by virtual functions in this class.
  47. */
  48. class ObjectClass : public AbstractClass
  49. {
  50. public:
  51. /*
  52. ** The object can be in one of two states -- placed down on the map, or not. If the
  53. ** object is placed down on the map, then this flag will be true.
  54. */
  55. unsigned IsDown:1;
  56. /*
  57. ** This is a support flag that is only used while building a list of objects to
  58. ** be damaged by a proximity affect (explosion). When this flag is set, this object
  59. ** will not be added to the list of units to damage. When damage is applied to the
  60. ** object, this flag is cleared again. This process ensures that an object is never
  61. ** subject to "double jeopardy".
  62. */
  63. unsigned IsToDamage:1;
  64. /*
  65. ** Is this object flagged to be displayed during the next rendering process? This
  66. ** flag could be set by many different circumstances. It is automatically cleared
  67. ** when the object is rerendered.
  68. */
  69. unsigned IsToDisplay:1;
  70. /*
  71. ** An object in the game may be valid yet held in a state of "limbo". Units are in such
  72. ** a state if they are being transported or are otherwise "inside" another unit. They can
  73. ** also be in limbo if they have been created but are being held until the proper time
  74. ** for delivery.
  75. */
  76. unsigned IsInLimbo:1;
  77. /*
  78. ** When an object is "selected" it is given a floating bar graph or other graphic imagery
  79. ** to display this fact. When the player performs I/O, the actions may have a direct
  80. ** bearing on the actions of the currently selected object. For quick checking purposes,
  81. ** if this object is the one that is "selected", this flag will be true.
  82. */
  83. unsigned IsSelected:1;
  84. //Added a mask instead of bool for selecting players. This is because we must now support multiplayer.
  85. // - 6/26/2019
  86. // Needs more than 16 bits since RA has more than 16 factions. ST - 8/14/2019 12:15PM
  87. unsigned int IsSelectedMask;
  88. /*
  89. ** If an animation is attached to this object, then this flag will be true.
  90. */
  91. unsigned IsAnimAttached:1;
  92. /*
  93. ** If this object should process falling logic, then this flag will be true. Such
  94. ** objects might be ballistic projectiles, grenades, or parachuters.
  95. */
  96. unsigned IsFalling:1;
  97. int Riser;
  98. /*
  99. ** Several objects could exist in the same cell list. This is a pointer to the
  100. ** next object in the cell list. The objects in this list are not in any
  101. ** significant order.
  102. */
  103. SmartPtr<ObjectClass> Next;
  104. /*
  105. ** Every object can be assigned a trigger; the same trigger can be assigned
  106. ** to multiple objects.
  107. */
  108. CCPtr<TriggerClass> Trigger;
  109. /*
  110. ** This is the current strength of this object.
  111. */
  112. short Strength;
  113. /*
  114. ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
  115. */
  116. unsigned char SaveLoadPadding[16];
  117. /*-----------------------------------------------------------------------------------
  118. ** Constructor & destructors.
  119. */
  120. ObjectClass(RTTIType rtti, int id);
  121. ObjectClass(NoInitClass const & x) : AbstractClass(x), Next(x), Trigger(x) {};
  122. virtual ~ObjectClass(void) {Next = 0;};
  123. int operator < (ObjectClass const & object) const {return Sort_Y() < object.Sort_Y();};
  124. int operator > (ObjectClass const & object) const {return Sort_Y() > object.Sort_Y();};
  125. /*
  126. ** Object selection control.
  127. */
  128. static void Init(void);
  129. /*
  130. ** Query functions.
  131. */
  132. virtual bool Is_Players_Army(void) const {return(false);}
  133. virtual void const * Get_Image_Data(void) const;
  134. virtual ActionType What_Action(ObjectClass const *) const;
  135. virtual ActionType What_Action(CELL) const;
  136. virtual LayerType In_Which_Layer(void) const;
  137. bool Is_Infantry(void) const {return(RTTI == RTTI_INFANTRY);};
  138. bool Is_Foot(void) const {return(RTTI == RTTI_INFANTRY || RTTI == RTTI_UNIT || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
  139. bool Is_Techno(void) const {return(RTTI == RTTI_BUILDING || RTTI == RTTI_UNIT || RTTI == RTTI_INFANTRY || RTTI == RTTI_VESSEL || RTTI == RTTI_AIRCRAFT);};
  140. virtual int Get_Ownable(void) const;
  141. virtual ObjectTypeClass const & Class_Of(void) const = 0;
  142. virtual char const * Name(void) const;
  143. virtual int Full_Name(void) const;
  144. virtual bool Can_Repair(void) const;
  145. virtual bool Can_Demolish(void) const;
  146. virtual bool Can_Demolish_Unit(void) const;
  147. virtual bool Can_Capture(void) const;
  148. virtual bool Can_Player_Fire(void) const;
  149. virtual bool Can_Player_Move(void) const;
  150. /*
  151. ** Coordinate inquiry functions. These are used for both display and
  152. ** combat purposes.
  153. */
  154. virtual COORDINATE Docking_Coord(void) const;
  155. virtual COORDINATE Target_Coord(void) const;
  156. virtual COORDINATE Center_Coord(void) const;
  157. virtual COORDINATE Render_Coord(void) const;
  158. virtual COORDINATE Sort_Y(void) const;
  159. virtual FireDataType Fire_Data(int which) const;
  160. virtual COORDINATE Fire_Coord(int which) const;
  161. virtual COORDINATE Exit_Coord(void) const;
  162. /*
  163. ** Object entry and exit from the game system.
  164. */
  165. virtual bool Limbo(void);
  166. virtual bool Unlimbo(COORDINATE , DirType facing = DIR_N);
  167. virtual void Detach(TARGET target, bool all=true);
  168. virtual void Detach_All(bool all=true);
  169. virtual void Record_The_Kill(TechnoClass * );
  170. virtual bool Paradrop(COORDINATE coord);
  171. bool Attach_Trigger(TriggerClass * trigger);
  172. /*
  173. ** Display and rendering support functionality. Supports imagery and how
  174. ** object interacts with the map and thus indirectly controls rendering.
  175. */
  176. virtual void Do_Shimmer(void);
  177. virtual int Exit_Object(TechnoClass *);
  178. virtual bool Render(bool forced) const;
  179. virtual short const * Occupy_List(bool placement=false) const;
  180. virtual short const * Overlap_List(bool redraw=false) const;
  181. virtual fixed Health_Ratio(void) const;
  182. virtual void Draw_It(int x, int y, WindowNumberType ) const = 0;
  183. virtual void Hidden(void);
  184. virtual void Look(bool incremental=false);
  185. virtual bool Mark(MarkType=MARK_CHANGE);
  186. private:
  187. virtual void Mark_For_Redraw(void);
  188. public:
  189. /*
  190. ** User I/O.
  191. */
  192. virtual void Active_Click_With(ActionType , ObjectClass *);
  193. virtual void Active_Click_With(ActionType , CELL );
  194. virtual void Clicked_As_Target(HousesType house, int = 7); // 2019/09/20 JAS - Added record of who clicked on the object
  195. virtual bool Select(bool allow_mixed = false);
  196. virtual void Unselect(void);
  197. //These selection functions were added to handle the fact that we now need to support
  198. //client-server multiplayer. - JAS 6/26/2019
  199. virtual void Unselect_All_Players(void);
  200. virtual void Unselect_All_Players_Except_Owner(void);
  201. virtual bool Is_Selected_By_Player(HouseClass *player = NULL) const;
  202. virtual void Set_Selected_By_Player(HouseClass *player = NULL);
  203. virtual void Set_Unselected_By_Player(HouseClass *player = NULL);
  204. /*
  205. ** Combat related.
  206. */
  207. virtual bool In_Range(COORDINATE , int=0) const;
  208. virtual int Weapon_Range(int =0) const;
  209. virtual ResultType Take_Damage(int & damage, int distance, WarheadType warhead, TechnoClass * source=0, bool forced=false);
  210. virtual void Scatter(COORDINATE , bool forced=false, bool nokidding=false);
  211. virtual bool Catch_Fire(void);
  212. virtual void Fire_Out(void);
  213. virtual int Value(void) const;
  214. virtual MissionType Get_Mission(void) const;
  215. /*
  216. ** AI.
  217. */
  218. virtual void Per_Cell_Process(PCPType) {}
  219. virtual BuildingClass * Who_Can_Build_Me(bool intheory, bool legal) const;
  220. virtual RadioMessageType Receive_Message(RadioClass * from, RadioMessageType message, long & param);
  221. virtual bool Revealed(HouseClass * house);
  222. virtual void Repair(int );
  223. virtual void Sell_Back(int );
  224. virtual void AI(void);
  225. /*
  226. ** File I/O.
  227. */
  228. virtual void Code_Pointers(void);
  229. virtual void Decode_Pointers(void);
  230. /*
  231. ** Scenario and debug support.
  232. */
  233. #ifdef CHEAT_KEYS
  234. virtual void Debug_Dump(MonoClass *mono) const;
  235. #endif
  236. virtual void Move(FacingType);
  237. enum {FLIGHT_LEVEL=256};
  238. };
  239. #endif