ANIM.H (7825B)
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 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: F:\projects\c&c\vcs\code\anim.h_v 2.20 16 Oct 1995 16:45:40 JOE_BOSTIC $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : ANIM.H * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : May 30, 1994 * 28 * * 29 * Last Update : May 30, 1994 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 34 35 #ifndef ANIM_H 36 #define ANIM_H 37 38 #include "type.h" 39 40 /********************************************************************************************** 41 ** This is the class that controls the shape animation objects. Shape animation objects are 42 ** displayed over the top of the game map. Typically, they are used for explosion and fire 43 ** effects. 44 */ 45 class AnimClass : public ObjectClass, private StageClass { 46 public: 47 48 static void * AnimClass::operator new(size_t size); 49 static void AnimClass::operator delete(void *ptr); 50 AnimClass(void) : Class(0) {OwnerHouse=HOUSE_NONE;Object=0;}; // Default constructor does nothing. 51 AnimClass(AnimType animnum, COORDINATE coord, unsigned char timedelay=0, char loop=1, bool alt=false); 52 virtual ~AnimClass(void); 53 operator AnimType(void) const {return Class->Type;}; 54 virtual RTTIType What_Am_I(void) const {return RTTI_ANIM;}; 55 virtual HousesType Owner(void) const {return OwnerHouse;}; 56 57 /*--------------------------------------------------------------------- 58 ** Member function prototypes. 59 */ 60 static void Init(void); 61 62 void Attach_To(ObjectClass *obj); 63 void Sort_Above(TARGET target); 64 void Make_Invisible(void) {IsInvisible = true;}; 65 void Make_Visible(void) {IsInvisible = false;}; 66 void Kill_At(unsigned long long kill_time) {KillTime = kill_time;} 67 68 /* 69 ** 2019/09/19 JAS 70 ** Added functions for accessing which players can see this anim 71 */ 72 void Set_Visible_Flags(unsigned flags); 73 unsigned Get_Visible_Flags() const { return (Delay == 0) ? VisibleFlags : 0; } 74 75 virtual void Set_Owner(HousesType owner); 76 virtual bool Can_Place_Here(COORDINATE ) const {return true;} 77 virtual bool Mark(MarkType mark=MARK_CHANGE); 78 virtual bool Render(bool forced); 79 virtual COORDINATE Center_Coord(void) const; 80 virtual COORDINATE Sort_Y(void) const; 81 virtual LayerType In_Which_Layer(void) const; 82 virtual ObjectTypeClass const & Class_Of(void) const {return *Class;}; 83 virtual short const * Occupy_List(void) const; 84 virtual short const * Overlap_List(void) const; 85 virtual void Draw_It(int x, int y, WindowNumberType window); 86 virtual void AI(void); 87 virtual TARGET As_Target(void) const; 88 virtual void Detach(TARGET target, bool all); 89 90 /* 91 ** File I/O. 92 */ 93 bool Load(FileClass & file); 94 bool Save(FileClass & file); 95 virtual void Code_Pointers(void); 96 virtual void Decode_Pointers(void); 97 98 /* 99 ** Dee-buggin' support. 100 */ 101 int Validate(void) const; 102 103 /* 104 ** If this animation is attached to an object, then this points to that object. An 105 ** animation that is attached will follow that object as it moves. This is important 106 ** for animations such as flames and smoke. 107 */ 108 ObjectClass * Object; 109 110 /* 111 ** If specified, this animation uses the sort target for Y sorting 112 */ 113 TARGET SortTarget; 114 115 /* 116 ** If this animation has an owner, then it will be recorded here. An owner 117 ** is used when damage is caused by this animation during the middle of its 118 ** animation. 119 */ 120 HousesType OwnerHouse; 121 122 /* 123 ** This counter tells how many more times the animation should loop before it 124 ** terminates. 125 */ 126 char Loops; 127 128 protected: 129 void Middle(void); 130 void Start(void); 131 void Chain(void); 132 133 private: 134 /* 135 ** Define a function to make adjustments for where special animations 136 ** are going to render. 137 */ 138 COORDINATE Adjust_Coord(COORDINATE coord); 139 140 /* 141 ** Delete this animation at the next opportunity. This is flagged when the 142 ** animation is to be prematurely ended as a result of some outside event. 143 */ 144 unsigned IsToDelete:1; 145 146 /* 147 ** If the animation has just been created, then don't do any animation 148 ** processing until it has been through the render loop at least once. 149 */ 150 unsigned IsBrandNew:1; 151 152 /* 153 ** Use alternate color when drawing 154 */ 155 unsigned IsAlternate:1; 156 157 /* 158 ** If this animation is invisible, then this flag will be true. An invisible 159 ** animation is one that is created for the sole purpose of keeping all 160 ** machines syncronised. It will not be displayed. 161 */ 162 unsigned IsInvisible:1; 163 164 /* 165 ** 2019/09/19 JAS 166 ** Flags storing which players can see this anim. 167 */ 168 unsigned VisibleFlags; 169 170 /* 171 ** This points to the type of animation object this is. 172 */ 173 AnimTypeClass const * const Class; 174 175 /* 176 ** Is this animation in a temporary suspended state? If so, then it won't 177 ** be rendered until this flag is false. The flag will be set to false 178 ** after the first countdown timer reaches 0. 179 */ 180 unsigned char Delay; 181 182 /* 183 ** If this is an animation that damages whatever it is attached to, then this 184 ** value holds the accumulation of fractional damage points. When the accumulated 185 ** fractions reach 256, then one damage point is applied to the attached object. 186 */ 187 unsigned char Accum; 188 189 /* 190 ** This contains the value of the Virtual Function Table Pointer 191 */ 192 static void * VTable; 193 194 /* 195 ** This points to the virtual animation. 196 */ 197 AnimClass * VirtualAnim; 198 199 /* 200 ** Real-time point to kill this animation. 201 */ 202 unsigned long long KillTime; 203 204 /* 205 ** Some additional padding in case we need to add data to the class and maintain backwards compatibility for save/load 206 */ 207 unsigned char SaveLoadPadding[24]; 208 }; 209 210 211 212 #endif