00001 /* 00002 * The Mana World 00003 * Copyright (C) 2006 The Mana World Development Team 00004 * 00005 * This file is part of The Mana World. 00006 * 00007 * This program is free software; you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published by 00009 * the Free Software Foundation; either version 2 of the License, or 00010 * any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 */ 00021 00022 #ifndef _PARTICLEEMITTER_H 00023 #define _PARTICLEEMITTER_H 00024 00025 #include <list> 00026 00027 #include "utils/xml.h" 00028 00029 #include "particleemitterprop.h" 00030 00031 #include "resources/animation.h" 00032 00033 class Image; 00034 class Map; 00035 class Particle; 00036 00041 class ParticleEmitter 00042 { 00043 public: 00047 ParticleEmitter(xmlNodePtr emitterNode, Particle *target, Map *map, int rotation = 0); 00048 00052 ParticleEmitter(const ParticleEmitter &o); 00053 00057 ParticleEmitter & operator=(const ParticleEmitter &o); 00058 00062 ~ParticleEmitter(); 00063 00068 std::list<Particle *> createParticles(int tick); 00069 00073 void setTarget(Particle *target) 00074 { mParticleTarget = target; }; 00075 00076 private: 00077 template <typename T> ParticleEmitterProp<T> readParticleEmitterProp(xmlNodePtr propertyNode, T def); 00078 00082 ParticleEmitterProp<float> mParticlePosX, mParticlePosY, mParticlePosZ; 00083 00087 ParticleEmitterProp<float> mParticleAngleHorizontal, mParticleAngleVertical; 00088 00092 ParticleEmitterProp<float> mParticlePower; 00093 00094 /* 00095 * Vector changing of particles: 00096 */ 00097 ParticleEmitterProp<float> mParticleGravity; 00098 ParticleEmitterProp<int> mParticleRandomness; 00099 ParticleEmitterProp<float> mParticleBounce; 00100 bool mParticleFollow; 00101 00102 /* 00103 * Properties of targeting particles: 00104 */ 00105 Particle *mParticleTarget; 00106 ParticleEmitterProp<float> mParticleAcceleration; 00107 ParticleEmitterProp<float> mParticleDieDistance; 00108 ParticleEmitterProp<float> mParticleMomentum; 00109 00110 /* 00111 * Behavior over time of the particles: 00112 */ 00113 ParticleEmitterProp<int> mParticleLifetime; 00114 ParticleEmitterProp<int> mParticleFadeOut; 00115 ParticleEmitterProp<int> mParticleFadeIn; 00116 00117 Map *mMap; 00119 ParticleEmitterProp<int> mOutput; 00120 ParticleEmitterProp<int> mOutputPause; 00121 int mOutputPauseLeft; 00122 00123 /* 00124 * Graphical representation of the particle 00125 */ 00126 Image *mParticleImage; 00127 Animation mParticleAnimation; 00128 ParticleEmitterProp<float> mParticleAlpha; 00131 std::list<ParticleEmitter> mParticleChildEmitters; 00132 }; 00133 #endif