mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 14:07:20 +00:00
6aa90ad5b2
* Breakout rest of the enums from dcommonvars so we don't have to deal with merge conflicts ePlayerFlags is not a scoped enum, yet, due to it's complexity * address feedback * make player flag types consistent * fix typo
61 lines
2.0 KiB
C++
61 lines
2.0 KiB
C++
#include "AgQbElevator.h"
|
|
#include "EntityManager.h"
|
|
#include "GameMessages.h"
|
|
|
|
void AgQbElevator::OnStartup(Entity* self) {
|
|
|
|
}
|
|
|
|
//when the QB is finished being built by a player
|
|
void AgQbElevator::OnRebuildComplete(Entity* self, Entity* target) {
|
|
self->SetProximityRadius(proxRadius, "elevatorProx");
|
|
self->SetI64(u"qbPlayer", target->GetObjectID());
|
|
|
|
float delayTime = killTime - endTime;
|
|
if (delayTime < 1) delayTime = 1;
|
|
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
|
|
0, 0, eMovementPlatformState::Stationary);
|
|
|
|
//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") {
|
|
Entity* builder = EntityManager::Instance()->GetEntity(self->GetI64(u"qbPlayer"));
|
|
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");
|
|
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
|
|
1, 1, eMovementPlatformState::Moving);
|
|
} 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") {
|
|
GameMessages::SendPlatformResync(self, UNASSIGNED_SYSTEM_ADDRESS, true, 0,
|
|
1, 1, eMovementPlatformState::Moving);
|
|
} else if (timerName == "startKillTimer") {
|
|
killTimerStartup(self);
|
|
} else if (timerName == "KillTimer") {
|
|
self->Smash(self->GetObjectID(), eKillType::VIOLENT);
|
|
}
|
|
}
|
|
|
|
void AgQbElevator::killTimerStartup(Entity* self) const {
|
|
self->CancelAllTimers();
|
|
self->AddTimer("KillTimer", endTime);
|
|
self->SetNetworkVar<float>(u"startEffect", endTime); // Blinking effect
|
|
}
|