add child loading (#1706)

Tested that the NT combat challenge, am skullkin towers and qa wall in avant gardens all function as before.
This commit is contained in:
David Markowitz
2024-12-31 22:46:00 -08:00
committed by GitHub
parent 0b261e934f
commit 021db0ecd1
10 changed files with 54 additions and 33 deletions

View File

@@ -64,21 +64,22 @@ void AmSkullkinTower::SpawnLegs(Entity* self, const std::string& loc) {
info.rot = NiQuaternion::LookAt(info.pos, self->GetPosition());
auto* entity = Game::entityManager->CreateEntity(info);
auto* entity = Game::entityManager->CreateEntity(info, nullptr, self);
Game::entityManager->ConstructEntity(entity);
OnChildLoaded(self, entity);
}
void AmSkullkinTower::OnChildLoaded(Entity* self, Entity* child) {
auto legTable = self->GetVar<std::vector<LWOOBJID>>(u"legTable");
void AmSkullkinTower::OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) {
auto legTable = self.GetVar<std::vector<LWOOBJID>>(u"legTable");
legTable.push_back(child->GetObjectID());
legTable.push_back(childLoaded.childID);
self->SetVar(u"legTable", legTable);
self.SetVar(u"legTable", legTable);
const auto selfID = self->GetObjectID();
const auto selfID = self.GetObjectID();
auto* const child = Game::entityManager->GetEntity(childLoaded.childID);
if (!child) return;
child->AddDieCallback([this, selfID, child]() {
auto* self = Game::entityManager->GetEntity(selfID);

View File

@@ -8,7 +8,7 @@ public:
void SpawnLegs(Entity* self, const std::string& loc);
void OnChildLoaded(Entity* self, Entity* child);
void OnChildLoaded(Entity& self, GameMessages::ChildLoaded& childLoaded) override;
void NotifyDie(Entity* self, Entity* other, Entity* killer);