mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-30 01:41:40 +00:00
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>
26 lines
979 B
C++
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);
|
|
}
|