2021-12-05 17:54:36 +00:00
|
|
|
#include "FallingTile.h"
|
|
|
|
#include "MovingPlatformComponent.h"
|
|
|
|
#include "GameMessages.h"
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FallingTile::OnStartup(Entity* self) {
|
|
|
|
auto* movingPlatfromComponent = self->GetComponent<MovingPlatformComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (movingPlatfromComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
movingPlatfromComponent->SetSerialized(true);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FallingTile::OnCollisionPhantom(Entity* self, Entity* target) {
|
|
|
|
if (self->GetVar<bool>(u"AboutToFall")) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->AddTimer("flipTime", 0.75f);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetVar<bool>(u"AboutToFall", true);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetNetworkVar<float>(u"startEffect", 2);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FallingTile::OnWaypointReached(Entity* self, uint32_t waypointIndex) {
|
|
|
|
if (waypointIndex == 1) {
|
|
|
|
} else if (waypointIndex == 0) {
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
void FallingTile::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
auto* movingPlatfromComponent = self->GetComponent<MovingPlatformComponent>();
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (movingPlatfromComponent == nullptr) {
|
|
|
|
return;
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
if (timerName == "flipTime") {
|
|
|
|
self->AddTimer("flipBack", 2.0f);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
self->SetNetworkVar<float>(u"stopEffect", 3);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
movingPlatfromComponent->GotoWaypoint(1);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"down", "down");
|
|
|
|
} else if (timerName == "flipBack") {
|
|
|
|
self->SetVar<bool>(u"AboutToFall", false);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-07-28 13:39:57 +00:00
|
|
|
movingPlatfromComponent->GotoWaypoint(0);
|
|
|
|
|
|
|
|
GameMessages::SendPlayFXEffect(self->GetObjectID(), -1, u"up", "up");
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|