rock hydrants work

This commit is contained in:
Aaron Kimbre 2022-04-17 19:43:17 -05:00
parent cc68b0768b
commit a343ed9493
2 changed files with 17 additions and 18 deletions

View File

@ -6,7 +6,7 @@ void RockHydrantBroken::OnStartup(Entity* self)
{ {
self->AddTimer("playEffect", 1); self->AddTimer("playEffect", 1);
const auto hydrant = "hydrant0" + self->GetVar<std::string>(u"hydrant"); const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant); const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);

View File

@ -1,24 +1,23 @@
#include "RockHydrantSmashable.h" #include "RockHydrantSmashable.h"
#include "EntityManager.h" #include "EntityManager.h"
#include "SimplePhysicsComponent.h" #include "GeneralUtils.h"
#include "Entity.h"
#include "GameMessages.h"
#include "Game.h"
#include "dLogger.h"
void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) { void RockHydrantSmashable::OnDie(Entity* self, Entity* killer)
SimplePhysicsComponent* physics = self->GetComponent<SimplePhysicsComponent>(); {
NiPoint3 pos = physics->GetPosition(); const auto hydrantName = self->GetVar<std::u16string>(u"hydrant");
EntityInfo info; LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
EntityInfo info {};
info.lot = 12293; info.lot = 12293;
info.pos = pos; info.pos = self->GetPosition();
info.spawner = nullptr; info.rot = self->GetRotation();
info.settings = {data};
info.spawnerID = self->GetSpawnerID(); info.spawnerID = self->GetSpawnerID();
info.spawnerNodeID = 0;
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr); Game::logger->Log("RockHydrantBroken", "Rock Hydrant spawned (%s)\n", data->GetString().c_str());
if (newEntity) {
EntityManager::Instance()->ConstructEntity(newEntity); auto* hydrant = EntityManager::Instance()->CreateEntity(info);
}
EntityManager::Instance()->ConstructEntity(hydrant);
} }