1
This commit is contained in:
parent
20ff6afd30
commit
7b082b7748
@ -35,10 +35,11 @@ void MapInstance::Init()
|
|||||||
MAP_GRID_WIDTH);
|
MAP_GRID_WIDTH);
|
||||||
CreateThings();
|
CreateThings();
|
||||||
a8::UdpLog::Instance()->Info
|
a8::UdpLog::Instance()->Info
|
||||||
("current_uniid:%d loots:%d mini_room_spawn_points:%d normal_room_spawn_points:%d "
|
("map_id:%d current_uniid:%d loots:%d mini_room_spawn_points:%d normal_room_spawn_points:%d "
|
||||||
"building_num:%d obstalce_num:%d obstacle0_num:%d "
|
"building_num:%d obstalce_num:%d obstacle0_num:%d "
|
||||||
"obstacle1_num:%d obstacle2_num:%d",
|
"obstacle1_num:%d obstacle2_num:%d",
|
||||||
{
|
{
|
||||||
|
map_id,
|
||||||
current_uniid_,
|
current_uniid_,
|
||||||
loots_.size(),
|
loots_.size(),
|
||||||
mini_room_spawn_points_.size(),
|
mini_room_spawn_points_.size(),
|
||||||
@ -62,6 +63,21 @@ void MapInstance::UnInit()
|
|||||||
A8_SAFE_DELETE(grid_service_);
|
A8_SAFE_DELETE(grid_service_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MapInstance::AttachRoom(Room* room, RoomInitInfo& init_info)
|
||||||
|
{
|
||||||
|
init_info.map_tpl_name = map_tpl_name_;
|
||||||
|
init_info.map_meta = map_meta_;
|
||||||
|
init_info.grid_service = grid_service_;
|
||||||
|
init_info.map_service = map_service_;
|
||||||
|
init_info.mini_room_spawn_points = &mini_room_spawn_points_;
|
||||||
|
init_info.normal_room_spawn_points = &normal_room_spawn_points_;
|
||||||
|
init_info.level0room_born_point_meta = level0room_born_point_;
|
||||||
|
init_info.level1room_born_point_meta = level1room_born_point_;
|
||||||
|
init_info.loots = &loots_;
|
||||||
|
init_info.buildings = &buildings_;
|
||||||
|
init_info.level0room_spec_things = &level0room_spec_things_;
|
||||||
|
}
|
||||||
|
|
||||||
void MapInstance::CreateThings()
|
void MapInstance::CreateThings()
|
||||||
{
|
{
|
||||||
map_tpl_name_ = map_meta_->RandTemplate();
|
map_tpl_name_ = map_meta_->RandTemplate();
|
||||||
|
@ -21,6 +21,8 @@ class MapInstance
|
|||||||
void Init();
|
void Init();
|
||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
|
void AttachRoom(Room* room, RoomInitInfo& init_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CreateThings();
|
void CreateThings();
|
||||||
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
void CreateMapObject(MetaData::MapTplThing& thing_tpl);
|
||||||
|
@ -1,36 +1,39 @@
|
|||||||
#include "precompile.h"
|
#include "precompile.h"
|
||||||
|
|
||||||
#include "mapservice.h"
|
|
||||||
#include "gridservice.h"
|
|
||||||
#include "building.h"
|
|
||||||
#include "obstacle.h"
|
|
||||||
#include "loot.h"
|
|
||||||
#include "mapmgr.h"
|
#include "mapmgr.h"
|
||||||
#include "metamgr.h"
|
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "entityfactory.h"
|
#include "mapinstance.h"
|
||||||
|
|
||||||
void MapMgr::Init()
|
void MapMgr::Init()
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
MapInstance* map_instance = new MapInstance();
|
||||||
|
map_instance->map_id = 2001;
|
||||||
|
map_instance->Init();
|
||||||
|
instance_hash_[map_instance->map_id] = map_instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::UnInit()
|
void MapMgr::UnInit()
|
||||||
{
|
{
|
||||||
|
for (auto& pair : instance_hash_) {
|
||||||
|
pair.second->UnInit();
|
||||||
|
delete pair.second;
|
||||||
|
}
|
||||||
|
instance_hash_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info)
|
void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info)
|
||||||
{
|
{
|
||||||
#if 0
|
MapInstance* map_instance = GetMapInstance(2001);
|
||||||
init_info.map_tpl_name = map_tpl_name_;
|
if (!map_instance) {
|
||||||
init_info.map_meta = map_meta_;
|
abort();
|
||||||
init_info.grid_service = grid_service_;
|
}
|
||||||
init_info.map_service = map_service_;
|
map_instance->AttachRoom(room, init_info);
|
||||||
init_info.mini_room_spawn_points = &mini_room_spawn_points_;
|
}
|
||||||
init_info.normal_room_spawn_points = &normal_room_spawn_points_;
|
|
||||||
init_info.level0room_born_point_meta = level0room_born_point_;
|
MapInstance* MapMgr::GetMapInstance(int map_id)
|
||||||
init_info.level1room_born_point_meta = level1room_born_point_;
|
{
|
||||||
init_info.loots = &loots_;
|
auto itr = instance_hash_.find(map_id);
|
||||||
init_info.buildings = &buildings_;
|
return itr != instance_hash_.end() ? itr->second : nullptr;
|
||||||
init_info.level0room_spec_things = &level0room_spec_things_;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,19 @@ class MapInstance;
|
|||||||
class Room;
|
class Room;
|
||||||
class MapMgr : public a8::Singleton<MapMgr>
|
class MapMgr : public a8::Singleton<MapMgr>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
MapMgr() {};
|
MapMgr() {};
|
||||||
friend class a8::Singleton<MapMgr>;
|
friend class a8::Singleton<MapMgr>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void Init();
|
void Init();
|
||||||
void UnInit();
|
void UnInit();
|
||||||
|
|
||||||
void AttachRoom(Room* room, RoomInitInfo& init_info);
|
void AttachRoom(Room* room, RoomInitInfo& init_info);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
MapInstance* GetMapInstance(int map_id);
|
||||||
|
|
||||||
|
private:
|
||||||
std::map<int, MapInstance*> instance_hash_;
|
std::map<int, MapInstance*> instance_hash_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user