melee / ranged effects
[gemrb.git] / gemrb / core / Particles.h
blobfb9cf8aeeaff6471f1fe305129154a240a8dbf3f
1 /* GemRB - Infinity Engine Emulator
2 * Copyright (C) 2006 The GemRB Project
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /**
22 * @file Particles.h
23 * Declares Particles class implementing weather and spark effects
24 * and related defines
27 #ifndef PARTICLES_H
28 #define PARTICLES_H
30 #include "exports.h"
31 #include "ie_types.h"
33 #include "Region.h"
35 class CharAnimations;
36 class Scriptable;
38 //global phase for the while spark structure
39 #define P_GROW 0
40 #define P_FADE 1
41 #define P_EMPTY 2
43 // this structure holds data for a single particle element
44 struct Element {
45 int state;
46 Point pos;
49 /**
50 * @class Particles
51 * Class holding information about particles and rendering them.
54 #define SP_TYPE_POINT 0
55 #define SP_TYPE_LINE 1
56 #define SP_TYPE_CIRCLE 2
57 #define SP_TYPE_BITMAP 3
59 #define SP_PATH_FALL 0 //free falling
60 #define SP_PATH_FOUNT 1 //going up and down
61 #define SP_PATH_FLIT 2 //flitting
62 #define SP_PATH_RAIN 3 //falling and vanishing quickly
63 #define SP_PATH_EXPL 4 //explosion (mostly used with fragments)
65 #define SP_SPAWN_NONE 0 //don't create new sparks
66 #define SP_SPAWN_FULL 1 //fill all at setup, then switch to none
67 #define SP_SPAWN_SOME 2 //add some new elements regularly
69 #define SPARK_COLOR_BLUE 0
70 #define SPARK_COLOR_GOLD 1
71 #define SPARK_COLOR_PURPLE 2
72 #define SPARK_COLOR_ICE 3
73 #define SPARK_COLOR_STONE 4
74 #define SPARK_COLOR_BLACK 5
75 #define SPARK_COLOR_CHROM 6
76 #define SPARK_COLOR_RED 7
77 #define SPARK_COLOR_GREEN 8
78 #define SPARK_COLOR_WHITE 9
79 #define SPARK_COLOR_MAGENTA 10
80 #define SPARK_COLOR_ORANGE 11
81 #define SPARK_COLOR_CUSTOM 12
83 #define MAX_SPARK_COLOR 13
84 #define MAX_SPARK_PHASE 5
86 class GEM_EXPORT Particles {
87 public:
88 Particles(int s);
89 ~Particles();
91 void SetBitmap(unsigned int FragAnimID);
92 void SetPhase(ieByte ph) { phase = ph; }
93 int GetPhase() const { return phase; }
94 bool MatchPos(const Point &p) const { return pos.x==p.x && pos.y==p.y; }
95 void SetType(ieByte t, ieByte p=SP_PATH_FALL, ieByte st=SP_SPAWN_NONE)
97 type=t;
98 path=p;
99 spawn_type=st;
101 void SetRegion(int x, int y, int w, int h)
103 pos.x = x;
104 pos.y = y;
105 pos.w = w;
106 pos.h = h;
108 void SetTimeToLive(int ttl) { timetolive = ttl; }
109 void SetColor(ieByte c) { color=c; }
110 void SetOwner(Scriptable *o) { owner=o; }
111 /* returns true if it cannot add new elements */
112 bool AddNew(const Point &point);
113 void Draw(const Region &screen);
114 void AddParticles(int count);
115 /* returns true if it could be destroyed (didn't draw anything) */
116 int Update();
117 int GetHeight() const { return pos.y+pos.h; }
118 private:
119 Element *points;
120 ieDword timetolive;
121 ieDword target; //could be 0, in that case target is pos
122 ieWord size; //spark number
123 ieWord last_insert;//last spark idx added
124 Scriptable *owner; //could be area or game or actor
125 Region pos;
126 ieByte phase; //global phase
127 ieByte type; //draw type (snow, rain)
128 ieByte path; //path type
129 ieByte color; //general spark color
130 ieByte spawn_type;
131 //use char animations for the fragment animations
132 //1. the cycles are loaded only when needed
133 //2. the fragments ARE avatar animations in the original IE (for some unknown reason)
134 CharAnimations *fragments;
137 #endif // ! PARTICLES_H