#ifndef __WORLD_H__
#define __WORLD_H__
#include <SDL/SDL.h>
#include "artfactory.h"
#include "sprite.h"
#include "entity.h"
#include "cache.h"
class Cell
{
private:
bool right_order(void);
public:
void add(Entity *entity);
void remove(Entity *entity) { entity->inCell = NULL; entities.remove(entity); }
void blit(int x, int y);
list<Entity*> entities;
LandTile *landTile;
};
class Block
{
public:
void produce(Uint32 bid, bool tdmap, Block &block);
void recycle(Block &block);
void renderTiles();
Cell cells[8][8];
bool rendered;
Uint32 id;
bool tdmap;
};
class World
{
public:
World();
~World();
bool paused(void) const;
void pause(void);
void unpause(void);
Cell *getCell(Uint16 globalX, Uint16 globalY, bool tdmap, bool renderBlock);
Mobile *focus;
map <Uint32, Mobile*> mobiles;
Cache<Uint32, Sprite, ArtFactory> artSprites;
MapCache<Uint32, Block, Block, false> mapBlocks; /**< map0.mul block cache */
MapCache<Uint32, Block, Block, true> mapBlocksTD; /**< map2.mul block cache */
//ifstream artidx; /**< artidx.mul filehandle */
//ifstream artfile; /**< art.mul filehandle */
ifstream mapfile; /**< map0.mul filehandle */
ifstream tdmapfile; /**< map2.mul filehandle */
ifstream staidxfile; /**< staidx0.mul filehandle */
ifstream tdstaidxfile; /**< staidx2.mul filehandle */
ifstream staticsfile; /**< statics0.mul filehandle */
ifstream tdstaticsfile; /**< statics2.mul filehandle */
private:
bool is_paused;
};
#endif