1 /***************************************************************************** 2 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $ 3 * @file 4 * @author Jim E. Brooks http://www.palomino3d.org 5 * @brief Special-effects container. 6 *//* 7 * LEGAL: COPYRIGHT (C) 2008 JIM E. BROOKS 8 * THIS SOURCE CODE IS RELEASED UNDER THE TERMS 9 * OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2). 10 *****************************************************************************/ 11 12 #ifndef FX_FX_HH 13 #define FX_FX_HH 1 14 15 #define GET_FX() (fx::FX::GetInstance()) 16 17 #include <list> 18 #include "base/singleton.hh" 19 #include "base/timer.hh" 20 21 namespace fx { 22 23 class ParticleSystem; 24 25 //////////////////////////////////////////////////////////////////////////////// 26 /// @brief Special-effects container (Singleton). 27 /// 28 class FX : public Singleton 29 { 30 PREVENT_COPYING(FX) 31 private: 32 // Containers of special-effects. 33 typedef std::list<shptr<Object> > Objects; 34 typedef std::list<shptr<ParticleSystem> > ParticleSystems; 35 36 FX( void ); 37 ~FX(); 38 39 private: 40 /// @brief Timer-tick. 41 CLASS_TICK_FUNCTOR( FX, mFX ) 42 43 // Interface for clients: 44 public: 45 DEFINE_GetInstance( FX ) // Singleton 46 void Reset( void ); 47 void MakeExplosion( const Milliseconds lifetime, 48 const WorldVertex& position, 49 const fp radius ); 50 void MakeSmokeTrail( const Milliseconds lifetime, 51 shptr<Object> trailMaker ); 52 53 // Restricted to fx module: 54 public: 55 void AddZombie( shptr<Object> zombie ); 56 void AddZombie( shptr<ParticleSystem> zombie ); 57 58 // Private methods: 59 private: 60 void Tick( const Milliseconds millisecElapsed ); 61 void Detach( Objects& objects ); // plural 62 void Detach( ParticleSystems& particleSystems ); // plural 63 64 private: 65 DECLARE_SINGLETON_CLASS_VARS( FX ) 66 shptr<TickFunctor> mTickFunctor; ///< tick for destroying zombies 67 Objects mObjects; ///< container of active special-effects 68 Objects mZombieObjects; ///< AddZombie() adds to this 69 ParticleSystems mParticleSystems; ///< container of active special-effects 70 ParticleSystems mZombieParticleSystems; ///< AddZombie() adds to this 71 }; 72 73 } // namespace fx 74 75 #endif // FX_FX_HH 76