2020-05-29 15:37:20 +08:00

49 lines
1.2 KiB
C++

#pragma once
namespace MetaData
{
struct Map;
struct MapTplThing;
}
class Entity;
class Obstacle;
class Building;
class MapService;
class GridService;
class Room;
class MapMgr : public a8::Singleton<MapMgr>
{
private:
MapMgr() {};
friend class a8::Singleton<MapMgr>;
public:
void Init();
void UnInit();
void AttachRoom(Room* room, RoomInitInfo& init_info);
private:
void CreateThings();
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
void CreateBuilding(int thing_id, float building_x, float building_y);
Obstacle* InternalCreateObstacle(int id, float x, float y,
std::function<void (Obstacle*)> on_precreate);
Entity* GetEntityByUniId(int uniid);
int AllocUniid();
private:
int current_uniid_ = 0;
std::map<int, Entity*> uniid_hash_;
std::string map_tpl_name_;
MetaData::Map* map_meta_ = nullptr;
MapService* map_service_ = nullptr;
GridService* grid_service_ = nullptr;
std::vector<MetaData::MapTplThing*> spawn_points_;
MetaData::MapTplThing* newbie_born_point_ = nullptr;
std::vector<MetaData::MapTplThing*> loots_;
std::vector<Building*> buildings_;
};