DarkflameServer/dScripts/ai/NS/WH/RockHydrantSmashable.cpp

21 lines
630 B
C++
Raw Permalink Normal View History

#include "RockHydrantSmashable.h"
#include "EntityManager.h"
2022-04-18 00:43:17 +00:00
#include "GeneralUtils.h"
2022-07-28 13:39:57 +00:00
void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) {
2022-04-18 00:43:17 +00:00
const auto hydrantName = self->GetVar<std::u16string>(u"hydrant");
2022-04-18 00:43:17 +00:00
LDFBaseData* data = new LDFData<std::string>(u"hydrant", GeneralUtils::UTF16ToWTF8(hydrantName));
2022-07-28 13:39:57 +00:00
EntityInfo info{};
info.lot = ROCK_HYDRANT_BROKEN;
2022-04-18 00:43:17 +00:00
info.pos = self->GetPosition();
info.rot = self->GetRotation();
2022-07-28 13:39:57 +00:00
info.settings = { data };
info.spawnerID = self->GetSpawnerID();
auto* hydrant = EntityManager::Instance()->CreateEntity(info);
2022-04-18 00:43:17 +00:00
EntityManager::Instance()->ConstructEntity(hydrant);
2022-04-18 00:43:17 +00:00
}