#pragma once

#include <list>
#include <map>

#include "state/state.hpp"

namespace sound {
    struct SoundHandle;

#if 0
    class SoundEffect {
    public:
        virtual ~SoundEffects()
        {
        }

        // return false if it can be deleted
        virtual bool advance(float dt) = 0;
    };
#endif

    class SoundEffects {
        public:
            SoundEffects()
            {
            }

            void advance(float dt, const std::list<game::StateUpdateEvent*> &updates);

        private:
            void fadeIn(SoundHandle *handle, float fadeInTime=0.3f);
            void fadeOut(SoundHandle *handle, float fadeOutTime=0.3f);

            void addSoundHandleForObject(game::Object *obj, SoundHandle *handle);
            void fadeOutSoundHandlesForObject(game::Object *obj, float fadeOutTime=0.3f);

        private:
            std::list<SoundHandle*> m_soundHandles;
            std::multimap<size_t, SoundHandle*> m_mapObjectToSoundHandle;
            //std::list<SoundEffect*> m_effects;
    };
}
