This commit is contained in:
aozhiwei 2024-01-23 15:12:01 +08:00
parent a5db73ab7c
commit a7733b8129
2 changed files with 26 additions and 1 deletions

View File

@ -36,6 +36,16 @@ static void LoadWorldObjects(const std::string& world_object_file,
obj->pos.z = pos->At("z")->AsXValue().GetDouble();
};
auto parse_monster_func =
[] (std::shared_ptr<a8::XObject> node, std::shared_ptr<mt::WorldObject> obj)
{
obj->object_id = node->At("id")->AsXValue();
auto pos = node->At("pos");
obj->pos.x = pos->At("x")->AsXValue().GetDouble();
obj->pos.y = pos->At("y")->AsXValue().GetDouble();
obj->pos.z = pos->At("z")->AsXValue().GetDouble();
};
a8::XObject root;
if (!world_object_file.empty() &&
root.ReadFromFile(mt::MetaMgr::Instance()->GetResDir() + world_object_file)) {
@ -71,7 +81,7 @@ static void LoadWorldObjects(const std::string& world_object_file,
for (int i = 0; i < thing->Size(); ++i) {
auto obj = std::make_shared<mt::WorldObject>();
obj->object_type = WorldObjectType_e::kMonsterType;
parse_func(thing->At(i), obj);
parse_monster_func(thing->At(i), obj);
world_objects.push_back(obj);
}
}

View File

@ -3210,6 +3210,21 @@ void Room::CreateWorldObjects()
}
}
break;
case WorldObjectType_e::kMonsterType:
{
const mt::Hero* hero_meta = mt::Hero::GetById(obj->object_id);
if (hero_meta) {
glm::vec3 pos = obj->pos - obj->size / 2.0f;
Hero* hero = CreateHero
(nullptr,
hero_meta,
pos,
GlmHelper::UP,
666,
0);
}
}
break;
case WorldObjectType_e::kBornPointType:
{
int uniid = AllocUniid();