#pragma once

#include <map>
#include <list>
#include <set>
#include <vector>

#include "LDTypes.h"


class Unit;
class RopePiece;
class Player;
struct IDirect3DDevice8;

class Level
{

  public:

    std::list<Unit*>                          Units;

    std::list<Unit*>                          DecoUnits;

    float                                     FixedTimeStepPos;

    int                                       Grid[32][24];

    Unit*                                     CloudUnits[33][25];

    std::list<LD::Point>                      GrowingTiles;

    int                                       Score;
    int                                       NumEmeralds;

    Player*                                   pPlayer;



    Level();
    ~Level();



    void Display( IDirect3DDevice8* pDevice );
    void Update( float ElapsedTime );
    void UpdateUnits( float ElapsedTime );
    void UpdateFixedTimeStep();


    void AddUnit( Unit* pUnit, int X, int Y );
    void RemoveUnit( Unit* pRemoveUnit );
    void ClearUnits();

    void AddDecoUnit( Unit* pUnit );
    void AddDecoUnit( Unit* pUnit, const LD::Point& Pos );

    void GrowTile();
    void CheckCloud( int X, int Y, int DX, int DY );
    bool TileSet( int X, int Y );

    void SetTile( int X, int Y, int Value );

    void CheckCollisions();

};
