50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#include "precompile.h"
|
|
|
|
#include "mapmgr.h"
|
|
#include "room.h"
|
|
#include "mapinstance.h"
|
|
#include "metamgr.h"
|
|
|
|
void MapMgr::Init()
|
|
{
|
|
{
|
|
MapInstance* map_instance = new MapInstance();
|
|
map_instance->map_id = 2001;
|
|
map_instance->Init();
|
|
instance_hash_[map_instance->map_id] = map_instance;
|
|
}
|
|
if (MetaMgr::Instance()->GetMap(3001)) {
|
|
MapInstance* map_instance = new MapInstance();
|
|
map_instance->map_id = 3001;
|
|
map_instance->Init();
|
|
instance_hash_[map_instance->map_id] = map_instance;
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
MapInstance* map_instance = GetMapInstance(2001);
|
|
if (init_info.room_mode == kZombieMode) {
|
|
map_instance = GetMapInstance(3001);
|
|
}
|
|
if (!map_instance) {
|
|
abort();
|
|
}
|
|
map_instance->AttachRoom(room, init_info);
|
|
}
|
|
|
|
MapInstance* MapMgr::GetMapInstance(int map_id)
|
|
{
|
|
auto itr = instance_hash_.find(map_id);
|
|
return itr != instance_hash_.end() ? itr->second : nullptr;
|
|
}
|