ABSTRACT.H 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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/ABSTRACT.H 1 3/03/97 10:24a 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 : ABSTRACT.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : 01/26/95 *
  26. * *
  27. * Last Update : January 26, 1995 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef ABSTRACT_H
  33. #define ABSTRACT_H
  34. DirType Direction(CELL cell1, CELL cell2);
  35. DirType Direction(COORDINATE coord1, COORDINATE coord2);
  36. int Distance(COORDINATE coord1, COORDINATE coord2);
  37. COORDINATE As_Coord(TARGET target);
  38. class AbstractTypeClass;
  39. /*
  40. ** This class is the base class for all game objects that have an existence on the
  41. ** battlefield.
  42. */
  43. class AbstractClass
  44. {
  45. public:
  46. /*
  47. ** This specifies the type of object and the unique ID number
  48. ** associated with it. The ID number happens to match the index into
  49. ** the object heap appropriate for this object type.
  50. */
  51. RTTIType RTTI;
  52. int ID;
  53. /*
  54. ** The coordinate location of the unit. For vehicles, this is the center
  55. ** point. For buildings, it is the upper left corner.
  56. */
  57. COORDINATE Coord;
  58. /*
  59. ** This is the height of the object above ground (expressed in leptons).
  60. */
  61. int Height;
  62. /*
  63. ** The actual object ram-space is located in arrays in the data segment. This flag
  64. ** is used to indicate which objects are free to be reused and which are currently
  65. ** in use by the game.
  66. */
  67. unsigned IsActive:1;
  68. /*
  69. ** A flag to indicate that this object was recently created. Since an object's allocation is just a matter of whether
  70. ** the IsActive flag is set, during a logic frame an object with a given ID could be 'deleted' then reallocated
  71. ** as a different type of object in a different location. This flag lets us know that this happened. ST - 8/19/2019 5:33PM
  72. */
  73. unsigned IsRecentlyCreated:1;
  74. /*-----------------------------------------------------------------------------------
  75. ** Constructor & destructors.
  76. */
  77. AbstractClass(RTTIType rtti, int id) : RTTI(rtti), ID(id), Coord(0xFFFFFFFFL), Height(0) {};
  78. AbstractClass(NoInitClass const & x) {x();};
  79. virtual ~AbstractClass(void) {};
  80. /*
  81. ** Query functions.
  82. */
  83. virtual char const * Name(void) const {return("");}
  84. virtual HousesType Owner(void) const {return HOUSE_NONE;};
  85. TARGET As_Target(void) const {return(Build_Target(RTTI, ID));};
  86. RTTIType What_Am_I(void) const {return(RTTI);};
  87. /*
  88. ** Scenario and debug support.
  89. */
  90. #ifdef CHEAT_KEYS
  91. virtual void Debug_Dump(MonoClass * mono) const;
  92. #endif
  93. /*
  94. ** Coordinate query support functions.
  95. */
  96. virtual COORDINATE Center_Coord(void) const {return Coord;};
  97. virtual COORDINATE Target_Coord(void) const {return Coord;};
  98. /*
  99. ** Coordinate inquiry functions. These are used for both display and
  100. ** combat purposes.
  101. */
  102. DirType Direction(AbstractClass const * object) const {return ::Direction(Center_Coord(), object->Target_Coord());};
  103. DirType Direction(COORDINATE coord) const {return ::Direction(Center_Coord(), coord);};
  104. DirType Direction(TARGET target) const {return ::Direction(Center_Coord(), As_Coord(target));};
  105. DirType Direction(CELL cell) const {return ::Direction(Coord_Cell(Center_Coord()), cell);};
  106. int Distance(TARGET target) const;
  107. int Distance(COORDINATE coord) const {return ::Distance(Center_Coord(), coord);};
  108. int Distance(AbstractClass const * object) const {return ::Distance(Center_Coord(), object->Target_Coord());};
  109. /*
  110. ** Object entry and exit from the game system.
  111. */
  112. virtual MoveType Can_Enter_Cell(CELL , FacingType = FACING_NONE) const {return MOVE_OK;};
  113. /*
  114. ** AI.
  115. */
  116. virtual void AI(void) {};
  117. /*
  118. ** Set the new recently created flag every time the active flag is set. ST - 8/19/2019 5:41PM
  119. */
  120. void Set_Active(void) {IsActive = true; IsRecentlyCreated = true;}
  121. };
  122. #endif