/*Copyright (C) 2010 Deveaux Duncan

This file is part of Hikou no mizu.

Hikou no mizu is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

Hikou no mizu is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with Hikou no mizu.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DEF_ARENA
#define DEF_ARENA

#include <SFML/Graphics.hpp>
#include "Platform.hpp"

#include "Engines/Physics/PhysicsEngine.hpp"

//Static loadFromXML method
#include "Engines/Resources/ImageManager.hpp"
#include "extlibs/TinyXML/tinyxml.h"

//Class representing an arena.
//It can contain platforms, specify players spawn position...
class Arena
{
    public:
        Arena();
        Arena(const sf::Sprite &background, float ground, float gravity);
        
        void render(sf::RenderWindow &renderWindow);
        
        void addPlatform(const Platform &platform, int platformIx = -1);
        void removePlatform(int platformIx);
        
        void applyToPhysics(PhysicsEngine &physicsEngine);
        void subscribeObjects(PhysicsEngine &physicsEngine);
        
        //Get and set methods
            //Graphics
        void setBackground(const sf::Sprite &background);
        const sf::Sprite &getBackground() const;
        
            //Physics
        void setGround(float ground);
        float getGround() const;
        
        void setGravity(float gravity);
        float getGravity() const;
        
            //Other
        void setPlayerSpawn(unsigned int ix, const sf::Vector2f &playerSpawn);
        bool getPlayerSpawn(unsigned int ix, sf::Vector2f &target) const;
        
        //Static methods
        static Arena loadFromXML(const std::string &name, const std::string &xmlPath);
    
    private:
        sf::Sprite m_background;
        float m_ground;
        float m_gravity;
        
        std::vector<Platform> m_platformsList;
        std::map<unsigned int, sf::Vector2f> m_playerSpawns;
};

#endif