VORTEX.H (7178B)
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 /*********************************************************************************************** 17 *** 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 *** 18 *********************************************************************************************** 19 * * 20 * Project Name : Command & Conquer - Red Alert * 21 * * 22 * File Name : VORTEX.H * 23 * * 24 * Programmer : Steve Tall * 25 * * 26 * Start Date : 8/12/96 * 27 * * 28 * Last Update : August 29th, 1996 [ST] * 29 * * 30 *---------------------------------------------------------------------------------------------* 31 * Overview: * 32 * Definition of ChronalVortexClass. The Chronal vortex sometimes appears when the * 33 * chronosphere is used. * 34 * * 35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 36 37 #ifndef VORTEX_H 38 #define VORTEX_H 39 40 41 #define MAX_REMAP_SHADES 16 //Number of lookup tables required for vortex shading. 42 #define VORTEX_FRAMES 16 //Number of frames in one complete rotation of the vortex. 43 44 45 46 class ChronalVortexClass { 47 48 public: 49 50 /* 51 ** Constructor and destructor. 52 */ 53 ChronalVortexClass(void); 54 ~ChronalVortexClass(void); 55 56 void Detach(TARGET target); 57 58 /* 59 ** Makes the vortex appear at the specified coordinate. 60 */ 61 void Appear (COORDINATE coordinate); 62 63 /* 64 ** Makes the vortex go away. 65 */ 66 void Disappear (void); 67 68 /* 69 ** Call this every frame. 70 */ 71 void AI (void); 72 73 /* 74 ** Render the vortex 75 */ 76 void Render (void); 77 78 /* 79 ** Flags cells under the vortex to be redrawn 80 */ 81 void Set_Redraw (void); 82 83 /* 84 ** Call whenever the theater changes to recalculate the shading lookup tables 85 */ 86 void Setup_Remap_Tables (TheaterType theater); 87 88 /* 89 ** Functions to load and save the vortex. 90 */ 91 void Load(Straw &file); 92 void Save(Pipe &file); 93 94 /* 95 ** Returns true of vortex is currently active. 96 */ 97 bool Is_Active(void) {return (Active);}; 98 99 /* 100 ** Makes the vortex attack the specified target. Target must be in range of the vortex. 101 */ 102 void Set_Target (ObjectClass *target); 103 104 /* 105 ** Disables the vortex. 106 */ 107 void Stop(void); 108 109 /* 110 ** Members to allow read access to private data 111 */ 112 COORDINATE Get_Position (void) {return (Position);}; 113 int Get_Range (void) {return (Range);}; 114 int Get_Speed (void) {return (Speed);}; 115 int Get_Damage (void) {return (Damage);}; 116 117 /* 118 ** Members to allow write access to private data. 119 */ 120 void Set_Range (int range) {Range = range;}; 121 void Set_Speed (int speed) {Speed = speed;}; 122 void Set_Damage (int damage) {Damage = damage;}; 123 124 /* 125 ** Possible states the vortex can be in. 126 */ 127 typedef enum AnimStateType : unsigned char { 128 STATE_GROW, //Vortex has just appeared and is growing larger 129 STATE_ROTATE, //Vortex is rotating 130 STATE_SHRINK //Vortex is shrinking and about to disappear 131 }AnimStateType; 132 133 private: 134 135 /* 136 ** Members for setting up the lookup tables. 137 */ 138 void Build_Fading_Table (PaletteClass const & palette, void * dest, int color, int frac); 139 void Coordinate_Remap ( GraphicViewPortClass *inbuffer, int x, int y, int width, int height, unsigned char *remap_table); 140 141 /* 142 ** Misc internal functions 143 */ 144 void Attack(void); 145 void Zap_Target(void); 146 void Movement(void); 147 void Hide(void); 148 void Show(void); 149 150 /* 151 ** Position of the top left of the vortex 152 */ 153 COORDINATE Position; 154 155 /* 156 ** Direction of rotation 157 */ 158 int AnimateDir; 159 160 /* 161 ** Current frame of animation 162 */ 163 int AnimateFrame; 164 165 /* 166 ** Animation flag. When 0 vortex will animate 1 frame. 167 */ 168 int Animate; 169 170 /* 171 ** State of vortex. See ENUM for info. 172 */ 173 AnimStateType State; 174 175 /* 176 ** Color lookup tables for shading on vortex. 177 */ 178 unsigned char VortexRemapTables [MAX_REMAP_SHADES][256]; 179 180 /* 181 ** Color lookup table to make the blue lightning orange. 182 */ 183 unsigned char LightningRemap[256]; 184 185 /* 186 ** Is vortex currently active? 187 */ 188 int Active : 1; 189 190 /* 191 ** Is the vortex winding down? 192 */ 193 int StartShutdown : 1; 194 195 /* 196 ** Is the vortex about to hide from view? 197 */ 198 int StartHiding : 1; 199 200 /* 201 ** Is the vortex active but hidden? 202 */ 203 int Hidden : 1; 204 205 /* 206 ** Theater that lookup table is good for. 207 */ 208 TheaterType Theater; 209 210 /* 211 ** Last frame that vortex attacked on 212 */ 213 int LastAttackFrame; 214 215 /* 216 ** How many times lightning has zapped on this attack 217 */ 218 int ZapFrame; 219 220 /* 221 ** Ptr to object that the vortex is zapping 222 */ 223 TARGET TargetObject; 224 // ObjectClass *TargetObject; 225 226 /* 227 ** Distance to the target object 228 */ 229 int TargetDistance; 230 231 /* 232 ** Game frame that vortex hid on. 233 */ 234 int HiddenFrame; 235 236 /* 237 ** Direction vortex is going in. 238 */ 239 int XDir; 240 int YDir; 241 242 /* 243 ** Direction vortex should be going in 244 */ 245 int DesiredXDir; 246 int DesiredYDir; 247 248 /* 249 ** Range in cells of the vortex lightning 250 */ 251 int Range; 252 253 /* 254 ** Max speed in leptons per frame of the vortex. 255 */ 256 int Speed; 257 258 /* 259 ** Damge of vortex lightning zap. 260 */ 261 int Damage; 262 263 /* 264 ** Offscreen buffer to render vortex into. This is needed so we can handle clipping. 265 */ 266 GraphicBufferClass *RenderBuffer; 267 }; 268 269 270 #endif