2021-12-05 17:54:36 +00:00
|
|
|
#include "HydrantBroken.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
|
2022-04-19 02:02:04 +00:00
|
|
|
void HydrantBroken::OnStartup(Entity* self) {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("playEffect", 1);
|
|
|
|
|
|
|
|
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
|
|
|
|
|
2023-07-15 20:56:33 +00:00
|
|
|
const auto bouncers = Game::entityManager->GetEntitiesInGroup(hydrant);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
for (auto* bouncer : bouncers) {
|
|
|
|
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
|
|
|
|
|
|
|
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), true, UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
|
|
|
|
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"enableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
}
|
2022-04-19 02:02:04 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->AddTimer("KillBroken", 25);
|
|
|
|
}
|
|
|
|
|
2022-04-19 02:02:04 +00:00
|
|
|
void HydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
|
2021-12-05 17:54:36 +00:00
|
|
|
if (timerName == "KillBroken") {
|
2023-07-15 20:56:33 +00:00
|
|
|
auto* bouncer = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (bouncer != nullptr) {
|
|
|
|
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
GameMessages::SendNotifyObject(bouncer->GetObjectID(), self->GetObjectID(), u"disableCollision", UNASSIGNED_SYSTEM_ADDRESS);
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
self->Kill();
|
|
|
|
} else if (timerName == "playEffect") {
|
|
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), 384, u"water", "water", LWOOBJID_EMPTY, 1, 1, true);
|
|
|
|
}
|
|
|
|
}
|