/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks  http://www.palomino3d.org
 * @brief   Special-effects container.
 *//*
 * LEGAL:   COPYRIGHT (C) 2008 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef FX_FX_HH
#define FX_FX_HH 1

#define GET_FX() (fx::FX::GetInstance())

#include <list>
#include "base/singleton.hh"
#include "base/timer.hh"

namespace fx {

class ParticleSystem;

////////////////////////////////////////////////////////////////////////////////
/// @brief Special-effects container (Singleton).
///
class FX : public Singleton
{
PREVENT_COPYING(FX)
private:
    // Containers of special-effects.
    typedef std::list<shptr<Object> > Objects;
    typedef std::list<shptr<ParticleSystem> > ParticleSystems;

    FX( void );
    ~FX();

private:
    /// @brief Timer-tick.
    CLASS_TICK_FUNCTOR( FX, mFX )

// Interface for clients:
public:
                DEFINE_GetInstance( FX )   // Singleton
    void        Reset( void );
    void        MakeExplosion( const Milliseconds lifetime,
                               const WorldVertex& position,
                               const fp radius );
    void        MakeSmokeTrail( const Milliseconds lifetime,
                                shptr<Object> trailMaker );

// Restricted to fx module:
public:
    void        AddZombie( shptr<Object> zombie );
    void        AddZombie( shptr<ParticleSystem> zombie );

// Private methods:
private:
    void        Tick( const Milliseconds millisecElapsed );
    void        Detach( Objects& objects );  // plural
    void        Detach( ParticleSystems& particleSystems );  // plural

private:
    DECLARE_SINGLETON_CLASS_VARS( FX )
    shptr<TickFunctor>  mTickFunctor;             ///< tick for destroying zombies
    Objects             mObjects;                 ///< container of active special-effects
    Objects             mZombieObjects;           ///< AddZombie() adds to this
    ParticleSystems     mParticleSystems;         ///< container of active special-effects
    ParticleSystems     mZombieParticleSystems;   ///< AddZombie() adds to this
};

} // namespace fx

#endif // FX_FX_HH
