2021-12-05 17:54:36 +00:00
|
|
|
#include "NjIceRailActivator.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void NjIceRailActivator::OnPlayerRailArrived(Entity* self, Entity* sender, const std::u16string& pathName,
|
|
|
|
int32_t waypoint) {
|
|
|
|
const auto breakPoint = self->GetVar<int32_t>(BreakpointVariable);
|
|
|
|
if (breakPoint == waypoint) {
|
|
|
|
const auto& blockGroup = self->GetVar<std::u16string>(BlockGroupVariable);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
for (auto* block : EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(blockGroup))) {
|
|
|
|
GameMessages::SendPlayAnimation(block, u"explode");
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
const auto blockID = block->GetObjectID();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddCallbackTimer(1.0f, [self, blockID]() {
|
|
|
|
auto* block = EntityManager::Instance()->GetEntity(blockID);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (block != nullptr) {
|
|
|
|
block->Kill(self);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|