#pragma once
#include "gamestate.h"
#include "Universe.h"

#include "LDTypes.h"
#include "Unit.h"

#include <map>
#include <vector>
#include <string>
#include <set>



class CGSPlanet : public CGameState
{

  public:

    std::list<std::string>  m_Messages;

    float                   m_MessageDisplayTime;

    std::list<LD::Resource> m_Resources;

    Universe::Star*         m_pVisitedStarSystem;
    Universe::Planet*       m_pPlanet;

    int                     m_PlanetIndex;

    Unit*                   m_pPlayerUnit;

    bool                    m_DisplayActionMenu;

    int                     m_MouseX;
    int                     m_MouseY;

    int                     m_DisplayOffsetX;
    int                     m_DisplayOffsetY;

    float                   m_OxygenSupply;
    float                   m_FullOxygenSupply;

    float                   m_Shield;
    float                   m_ShieldMax;

    int                     m_Health;

    std::list<Unit>         m_Units;

    float                   m_VehicleSpeed;
    float                   m_VehicleTurnSpeed;
    bool                    m_VehicleCanGoBack;

    float                   m_ParticleDelay;

    LD::VehicleType         m_Vehicle;

    Unit*                   m_pBase;

    bool                    m_RoverActive;

    float                   m_ShotDelay;

    bool                    m_Won;



    CGSPlanet( Universe::Star* pStar = NULL, Universe::Planet* pPlanet = NULL, int PlanetIndex = 0 );
    virtual ~CGSPlanet();

    virtual void            Display( IDirect3DDevice8* pDevice );

    void                    RenderBar( int X, int Y, int W, int H, DWORD BackColor, DWORD BarColor, int Pos );

    virtual void            UpdateFrame( const float fElapsedTime );

    virtual void            OnChar( int iChar );
    virtual void            OnKeyDown( int iChar );
    virtual void            OnMouse( int X, int Y, int Buttons );

    unsigned long           ResourceColor( LD::ResourceType Resource );
    int                     DetermineRadarPos( LD::ResourceType Resource, LD::Resource*& pResource, float& AngleToResource );

    void                    RemoveResource( LD::Resource* pResource );

    void                    CreateMovementParticles( float ElapsedTime, bool AtFront = false );

    void                    SpawnParticle( int X, int Y, LD::TextureTypes Texture, bool SpawnBack = false );
    void                    SpawnShot( Unit* pShooter, float DX, float DY, float Angle, LD::TextureTypes Texture, int Power, float Speed );

    float                   SafeDistance( int X, int Y, int X2, int Y2, float& AngleToResource );
    void                    CheckCollisions();

};
