添加房间读表
This commit is contained in:
parent
8b5d30762b
commit
3fc0c50c98
@ -156,7 +156,7 @@ namespace MetaData
|
||||
for (auto& str : strings) {
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(str, strings2, ':');
|
||||
assert(strings.size() == 2);
|
||||
assert(strings2.size() == 2);
|
||||
rand_space += a8::XValue(strings2[1]).GetInt();
|
||||
things.push_back(std::make_tuple(
|
||||
a8::XValue(strings2[0]),
|
||||
|
@ -79,7 +79,7 @@ private:
|
||||
item.i = &meta;
|
||||
item.Init();
|
||||
gamemap_hash[item.i->map_id()] = &item;
|
||||
#if 0
|
||||
#if 1
|
||||
{
|
||||
for (auto& tuple : item.template_list) {
|
||||
auto itr = maptpl_meta_hash.find(std::get<0>(tuple));
|
||||
|
@ -395,6 +395,50 @@ void Room::ProcDrop(Vector2D center, int drop_id)
|
||||
}
|
||||
}
|
||||
|
||||
void Room::CreateThings()
|
||||
{
|
||||
std::string tpl_name = map_meta->RandTemplate();
|
||||
std::vector<MetaData::MapTplThing>* things = MetaMgr::Instance()->GetMapTplThing(tpl_name);
|
||||
if (things) {
|
||||
for (auto& thing_tpl : *things) {
|
||||
if (thing_tpl.i->weight() >= rand() % 10000) {
|
||||
int thing_id = thing_tpl.RandThing();
|
||||
MetaData::MapThing* thing_meta = MetaMgr::Instance()->GetMapThing(thing_id);
|
||||
if (thing_meta) {
|
||||
if (thing_meta->i->is_house()) {
|
||||
MetaData::Building* building_meta = MetaMgr::Instance()->GetBuilding(1);
|
||||
if (building_meta) {
|
||||
Building* entity = new Building();
|
||||
entity->room = this;
|
||||
entity->meta = building_meta;
|
||||
entity->entity_uniid = AllocUniid();
|
||||
entity->pos = Vector2D(thing_tpl.i->x(), thing_tpl.i->y());
|
||||
entity->Initialize();
|
||||
uniid_hash_[entity->entity_uniid] = entity;
|
||||
for (auto& pair : human_hash_) {
|
||||
pair.second->new_objects.insert(entity);
|
||||
pair.second->part_objects.insert(entity);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Obstacle* entity = new Obstacle();
|
||||
entity->room = this;
|
||||
entity->meta = thing_meta;
|
||||
entity->entity_uniid = AllocUniid();
|
||||
entity->pos = Vector2D(thing_tpl.i->x(), thing_tpl.i->y());
|
||||
entity->Initialize();
|
||||
uniid_hash_[entity->entity_uniid] = entity;
|
||||
for (auto& pair : human_hash_) {
|
||||
pair.second->new_objects.insert(entity);
|
||||
pair.second->part_objects.insert(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Room::ClearDeletedObjects()
|
||||
{
|
||||
for (auto& obj_uniid : frame_data.deleted_objects) {
|
||||
|
@ -61,6 +61,7 @@ public:
|
||||
std::function<void (Player*, a8::XParams&)> func);
|
||||
void BeAddedObject(Entity* entity);
|
||||
void ProcDrop(Vector2D center, int drop_id);
|
||||
void CreateThings();
|
||||
|
||||
private:
|
||||
void ClearDeletedObjects();
|
||||
|
@ -23,6 +23,10 @@ message MapThing
|
||||
optional float damage_dia = 7; //伤害半径
|
||||
optional int32 drop = 8; //掉落
|
||||
optional int32 attackable = 9; //是否可攻击
|
||||
optional int32 is_door = 10; //是否门
|
||||
optional int32 is_house = 11; //是否房间
|
||||
optional int32 is_tree = 12; //是否树
|
||||
optional int32 house_id = 13; //房间id
|
||||
}
|
||||
|
||||
message SafeArea
|
||||
@ -140,6 +144,6 @@ message MapTplThingJson
|
||||
optional string name = 2;
|
||||
optional string things = 3;
|
||||
optional int32 weight = 4;
|
||||
// optional float x = 5;
|
||||
// optional float y = 6;
|
||||
optional float x = 5;
|
||||
optional float y = 6;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user