Files
DarkflameServer/dScripts/02_server/Map/njhub/FireTransRocks.cpp
Aaron Kimbrell 3c0858578f fix(njhub): Fire Temple rocks restart their timers as the Lua's AddTimerWithCancel
L_FIRE_TRANS_ROCKS and L_FIRE_TRANS_ROCKS_MANAGER use AddTimerWithCancel: a timer started again replaces the running
one instead of running twice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-29 00:38:38 -06:00

26 lines
979 B
C++

#include "FireTransRocks.h"
#include "Entity.h"
#include "EntityManager.h"
#include "MovingPlatformComponent.h"
void FireTransRocks::OnStartup(Entity* self) {
if (!self->HasVar(u"RockManagerGroup")) self->SetVar<std::u16string>(u"RockManagerGroup", u"FireTransRocksManager");
}
void FireTransRocks::OnArrivedAtDesiredWaypoint(Entity* self, const uint32_t waypointIndex) {
if (waypointIndex == 1) {
self->CancelTimer("PlatHold");
self->AddTimer("PlatHold", 3.5f);
return;
}
// The first manager there is hears that the rock is down
const auto managers = Game::entityManager->GetEntitiesInGroup(self->GetVarAsString(u"RockManagerGroup"));
if (!managers.empty()) managers.front()->GetScript()->OnNotifyObject(managers.front(), self, "PlatformDown");
}
void FireTransRocks::OnTimerDone(Entity* self, std::string timerName) {
if (timerName != "PlatHold") return;
if (auto* const platform = self->GetComponent<MovingPlatformComponent>()) platform->GotoWaypoint(0);
}