2021-12-05 17:54:36 +00:00
|
|
|
#include "FvBrickPuzzleServer.h"
|
|
|
|
#include "GeneralUtils.h"
|
|
|
|
#include "dZoneManager.h"
|
|
|
|
#include "Spawner.h"
|
2023-12-29 04:24:30 +00:00
|
|
|
#include "QuickBuildComponent.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
void FvBrickPuzzleServer::OnStartup(Entity* self) {
|
|
|
|
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
int32_t pipeNum = 0;
|
|
|
|
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
|
|
|
|
return;
|
|
|
|
}
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (pipeNum != 1) {
|
|
|
|
self->AddTimer("reset", 30);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FvBrickPuzzleServer::OnDie(Entity* self, Entity* killer) {
|
|
|
|
const auto myGroup = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner_name"));
|
|
|
|
|
|
|
|
int32_t pipeNum = 0;
|
|
|
|
if (!GeneralUtils::TryParse<int32_t>(myGroup.substr(10, 1), pipeNum)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const auto pipeGroup = myGroup.substr(0, 10);
|
|
|
|
|
|
|
|
const auto nextPipeNum = pipeNum + 1;
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto samePipeSpawners = Game::zoneManager->GetSpawnersByName(myGroup);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (!samePipeSpawners.empty()) {
|
|
|
|
samePipeSpawners[0]->SoftReset();
|
|
|
|
|
|
|
|
samePipeSpawners[0]->Deactivate();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (killer != nullptr && killer->IsPlayer()) {
|
|
|
|
const auto nextPipe = pipeGroup + std::to_string(nextPipeNum);
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto nextPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
if (!nextPipeSpawners.empty()) {
|
|
|
|
nextPipeSpawners[0]->Activate();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
const auto nextPipe = pipeGroup + "1";
|
|
|
|
|
2023-07-17 22:55:33 +00:00
|
|
|
const auto firstPipeSpawners = Game::zoneManager->GetSpawnersByName(nextPipe);
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2021-12-05 17:54:36 +00:00
|
|
|
if (!firstPipeSpawners.empty()) {
|
|
|
|
firstPipeSpawners[0]->Activate();
|
2022-07-28 13:39:57 +00:00
|
|
|
}
|
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void FvBrickPuzzleServer::OnTimerDone(Entity* self, std::string timerName) {
|
|
|
|
if (timerName == "reset") {
|
2023-12-29 04:24:30 +00:00
|
|
|
auto* quickBuildComponent = self->GetComponent<QuickBuildComponent>();
|
2022-07-28 13:39:57 +00:00
|
|
|
|
2023-12-29 04:24:30 +00:00
|
|
|
if (quickBuildComponent != nullptr && quickBuildComponent->GetState() == eQuickBuildState::OPEN) {
|
2023-05-02 22:39:21 +00:00
|
|
|
self->Smash(self->GetObjectID(), eKillType::SILENT);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|