ANIM.H 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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/ANIM.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 : ANIM.H *
  22. * *
  23. * Programmer : Joe L. Bostic *
  24. * *
  25. * Start Date : May 30, 1994 *
  26. * *
  27. * Last Update : May 30, 1994 [JLB] *
  28. * *
  29. *---------------------------------------------------------------------------------------------*
  30. * Functions: *
  31. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  32. #ifndef ANIM_H
  33. #define ANIM_H
  34. #include "type.h"
  35. /**********************************************************************************************
  36. ** This is the class that controls the shape animation objects. Shape animation objects are
  37. ** displayed over the top of the game map. Typically, they are used for explosion and fire
  38. ** effects.
  39. */
  40. class AnimClass : public ObjectClass, public StageClass {
  41. /*
  42. ** This points to the type of animation object this is.
  43. */
  44. CCPtr<AnimTypeClass> Class;
  45. public:
  46. AnimClass(AnimType animnum, COORDINATE coord, unsigned char timedelay=0, char loop=1);
  47. AnimClass(NoInitClass const & x) : ObjectClass(x), Class(x), StageClass(x) {};
  48. virtual ~AnimClass(void);
  49. operator AnimType(void) const {return Class->Type;};
  50. static void * operator new(size_t size);
  51. static void * operator new(size_t , void * ptr) {return(ptr);};
  52. static void operator delete(void *ptr);
  53. /*---------------------------------------------------------------------
  54. ** Member function prototypes.
  55. */
  56. static void Init(void);
  57. void Attach_To(ObjectClass *obj);
  58. void Sort_Above(TARGET target);
  59. void Make_Invisible(void) {IsInvisible = true;};
  60. void Make_Visible(void) {IsInvisible = false;};
  61. void Kill_At(unsigned long long kill_time) {KillTime = kill_time;}
  62. static void Do_Atom_Damage(HousesType ownerhouse, CELL cell);
  63. /*
  64. ** 2019/09/19 JAS
  65. ** Added functions for accessing which players can see this anim
  66. */
  67. void Set_Visible_Flags(unsigned flags);
  68. unsigned Get_Visible_Flags() const { return (Delay == 0) ? VisibleFlags : 0; }
  69. virtual void Set_Owner(HousesType owner);
  70. virtual HousesType Owner(void) const {return OwnerHouse;};
  71. virtual bool Can_Place_Here(COORDINATE ) const {return true;}
  72. virtual bool Mark(MarkType mark=MARK_CHANGE);
  73. virtual bool Render(bool forced) const;
  74. virtual COORDINATE Center_Coord(void) const;
  75. virtual COORDINATE Sort_Y(void) const;
  76. virtual LayerType In_Which_Layer(void) const;
  77. virtual ObjectTypeClass const & Class_Of(void) const {return *Class;};
  78. virtual short const * Occupy_List(bool = false) const;
  79. virtual short const * Overlap_List(void) const;
  80. virtual void Draw_It(int x, int y, WindowNumberType window) const;
  81. virtual void AI(void);
  82. virtual void Detach(TARGET target, bool all);
  83. /*
  84. ** File I/O.
  85. */
  86. bool Load(Straw & file);
  87. bool Save(FileClass & file);
  88. /*
  89. ** If this animation is attached to an object, then this points to that object. An
  90. ** animation that is attached will follow that object as it moves. This is important
  91. ** for animations such as flames and smoke.
  92. */
  93. TARGET xObject;
  94. /*
  95. ** If specified, this animation uses the sort target for Y sorting
  96. */
  97. TARGET SortTarget;
  98. /*
  99. ** If this animation has an owner, then it will be recorded here. An owner
  100. ** is used when damage is caused by this animation during the middle of its
  101. ** animation.
  102. */
  103. HousesType OwnerHouse;
  104. /*
  105. ** This counter tells how many more times the animation should loop before it
  106. ** terminates.
  107. */
  108. char Loops;
  109. protected:
  110. void Middle(void);
  111. void Start(void);
  112. void Chain(void);
  113. private:
  114. /*
  115. ** Delete this animation at the next opportunity. This is flagged when the
  116. ** animation is to be prematurely ended as a result of some outside event.
  117. */
  118. unsigned IsToDelete:1;
  119. /*
  120. ** If the animation has just been created, then don't do any animation
  121. ** processing until it has been through the render loop at least once.
  122. */
  123. unsigned IsBrandNew:1;
  124. /*
  125. ** If this animation is invisible, then this flag will be true. An invisible
  126. ** animation is one that is created for the sole purpose of keeping all
  127. ** machines synchronized. It will not be displayed.
  128. */
  129. unsigned IsInvisible:1;
  130. /*
  131. ** 2019/09/19 JAS
  132. ** Flags storing which players can see this anim.
  133. */
  134. unsigned VisibleFlags;
  135. /*
  136. ** Is this animation in a temporary suspended state? If so, then it won't
  137. ** be rendered until this value is zero. The flag will be set to false
  138. ** after the first countdown timer reaches 0.
  139. */
  140. int Delay;
  141. /*
  142. ** If this is an animation that damages whatever it is attached to, then this
  143. ** value holds the accumulation of fractional damage points. When the accumulated
  144. ** fractions reach 256, then one damage point is applied to the attached object.
  145. */
  146. fixed Accum;
  147. /*
  148. ** The map layer this animation is in when attached to an object.
  149. */
  150. LayerType AttachLayer;
  151. /*
  152. ** This references the virtual animation.
  153. */
  154. TARGET VirtualAnimTarget;
  155. /*
  156. ** Real-time point to kill this animation.
  157. */
  158. unsigned long long KillTime;
  159. /*
  160. ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load
  161. */
  162. unsigned char SaveLoadPadding[24];
  163. };
  164. #endif