#include "FallingTile.h" #include "MovingPlatformComponent.h" #include "GameMessages.h" #include "EffectsMessages.h" namespace { // The sounds live played on the tile: shaking once stepped on, landing, and rising back constexpr const char* ShakeSound = "{b7b848ad-7db0-4d51-a664-e38b386607dc}"; constexpr const char* LandSound = "{7665b557-a611-4718-8bb1-9bb1fb0f8f0f}"; constexpr const char* RiseSound = "{6f07abbd-1710-4047-8d54-e772c22a970f}"; } void FallingTile::OnStartup(Entity* self) { auto* movingPlatfromComponent = self->GetComponent(); if (movingPlatfromComponent == nullptr) { return; } movingPlatfromComponent->SetSerialized(true); } void FallingTile::OnCollisionPhantom(Entity* self, Entity* target) { if (self->GetVar(u"AboutToFall")) { return; } GameMessages::PlayNDAudioEmitter(self->GetObjectID(), ShakeSound).Send(UNASSIGNED_SYSTEM_ADDRESS); self->AddTimer("flipTime", 0.75f); self->SetVar(u"AboutToFall", true); self->SetNetworkVar(u"startEffect", 2); } void FallingTile::OnWaypointReached(Entity* self, uint32_t waypointIndex) { if (waypointIndex == 1) { GameMessages::PlayNDAudioEmitter(self->GetObjectID(), LandSound).Send(UNASSIGNED_SYSTEM_ADDRESS); GameMessages::StopNDAudioEmitter(self->GetObjectID(), ShakeSound).Send(UNASSIGNED_SYSTEM_ADDRESS); } else if (waypointIndex == 0) { GameMessages::StopNDAudioEmitter(self->GetObjectID(), RiseSound).Send(UNASSIGNED_SYSTEM_ADDRESS); } } void FallingTile::OnTimerDone(Entity* self, std::string timerName) { auto* movingPlatfromComponent = self->GetComponent(); if (movingPlatfromComponent == nullptr) { return; } if (timerName == "flipTime") { self->AddTimer("flipBack", 2.0f); self->SetNetworkVar(u"stopEffect", 3); movingPlatfromComponent->GotoWaypoint(1); GameMessages::PlayFXEffect(self->GetObjectID(), -1, u"down", "down").Send(UNASSIGNED_SYSTEM_ADDRESS); } else if (timerName == "flipBack") { self->SetVar(u"AboutToFall", false); movingPlatfromComponent->GotoWaypoint(0); GameMessages::PlayFXEffect(self->GetObjectID(), -1, u"up", "up").Send(UNASSIGNED_SYSTEM_ADDRESS); GameMessages::PlayNDAudioEmitter(self->GetObjectID(), RiseSound).Send(UNASSIGNED_SYSTEM_ADDRESS); } }