2021-12-05 17:54:36 +00:00
|
|
|
#include "AgQbElevator.h"
|
|
|
|
#include "EntityManager.h"
|
|
|
|
#include "GameMessages.h"
|
2023-08-02 07:02:02 +00:00
|
|
|
#include "MovingPlatformComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void AgQbElevator::OnStartup(Entity* self) {
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//when the QB is finished being built by a player
|
2023-12-29 04:24:30 +00:00
|
|
|
void AgQbElevator::OnQuickBuildComplete(Entity* self, Entity* target) {
|
2021-12-05 17:54:36 +00:00
|
|
|
self->SetProximityRadius(proxRadius, "elevatorProx");
|
|
|
|
self->SetI64(u"qbPlayer", target->GetObjectID());
|
|
|
|
|
|
|
|
float delayTime = killTime - endTime;
|
|
|
|
if (delayTime < 1) delayTime = 1;
|
|
|
|
|
2023-08-02 07:02:02 +00:00
|
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS,
|
|
|
|
static_cast<eMovementPlatformState>(eMovementPlatformState::Waiting | eMovementPlatformState::ReachedDesiredWaypoint | eMovementPlatformState::ReachedFinalWaypoint)
|
|
|
|
, true, 0, 0, 0);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
//add a timer that will kill the QB if no players get on in the killTime
|
|
|
|
self->AddTimer("startKillTimer", killTime);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AgQbElevator::OnProximityUpdate(Entity* self, Entity* entering, std::string name, std::string status) {
|
|
|
|
//make sure we haven't already started pathing.
|
|
|
|
if (self->GetBoolean(u"qbPlayerRdy")) return;
|
|
|
|
|
|
|
|
if (status == "ENTER") {
|
2023-07-15 20:56:33 +00:00
|
|
|
Entity* builder = Game::entityManager->GetEntity(self->GetI64(u"qbPlayer"));
|
2021-12-05 17:54:36 +00:00
|
|
|
if (builder && builder == entering) {
|
|
|
|
//the builder has entered so cancel the start timer and just start moving
|
|
|
|
self->SetBoolean(u"qbPlayerRdy", true);
|
|
|
|
self->CancelTimer("StartElevator");
|
|
|
|
|
2023-08-02 07:02:02 +00:00
|
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, eMovementPlatformState::Travelling, true, 0,
|
|
|
|
1, 1);
|
2021-12-05 17:54:36 +00:00
|
|
|
} else if (!self->GetBoolean(u"StartTimer")) {
|
|
|
|
self->SetBoolean(u"StartTimer", true);
|
|
|
|
self->AddTimer("StartElevator", startTime);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AgQbElevator::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
|
|
|
|
if (timerName == "StartElevator") {
|
2023-08-02 07:02:02 +00:00
|
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, eMovementPlatformState::Travelling, true, 0,
|
|
|
|
1, 1);
|
2021-12-05 17:54:36 +00:00
|
|
|
} else if (timerName == "startKillTimer") {
|
|
|
|
killTimerStartup(self);
|
|
|
|
} else if (timerName == "KillTimer") {
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(self->GetObjectID(), eKillType::VIOLENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void AgQbElevator::killTimerStartup(Entity* self) const {
|
|
|
|
self->CancelAllTimers();
|
|
|
|
self->AddTimer("KillTimer", endTime);
|
|
|
|
self->SetNetworkVar<float>(u"startEffect", endTime); // Blinking effect
|
|
|
|
}
|