-class TileManager
-{
- private:
- TileManager();
- ~TileManager();
-
- std::vector<Tile*> tiles;
- static TileManager* instance_ ;
- static std::set<TileGroup>* tilegroups_;
- void load_tileset(std::string filename);
-
- std::string current_tileset;
-
- public:
- static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); }
- static void destroy_instance() { delete instance_; instance_ = 0; }
-
- static std::set<TileGroup>* tilegroups() { if(!instance_) { instance_ = new TileManager(); } return tilegroups_ ? tilegroups_ : tilegroups_ = new std::set<TileGroup>; }
- Tile* get(unsigned int id) {
- if(id < tiles.size())
- {
- return tiles[id];
- }
- else
- {
- // Never return 0, but return the 0th tile instead so that
- // user code doesn't have to check for NULL pointers all over
- // the place
- return tiles[0];
- }