Cannon Cove: Fix incorrect sign (#1211)

Update CMakeVariables.txt

Cannon Cove: Fix incorrect sign
This commit is contained in:
David Markowitz 2023-10-09 13:29:11 -07:00 committed by GitHub
parent 3dd2791066
commit 094797881b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 182 additions and 144 deletions

View File

@ -160,14 +160,15 @@ void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button
} }
} }
void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) { void SGCannon::SuperChargeTimerFunc(Entity* self) {
if (name == SuperChargeTimer && !self->GetVar<bool>(SuperChargePausedVariable)) {
if (self->GetVar<bool>(WaveStatusVariable) || self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable) < 1) { if (self->GetVar<bool>(WaveStatusVariable) || self->GetVar<uint32_t>(CurrentSuperChargedTimeVariable) < 1) {
self->SetNetworkVar<uint32_t>(ChargeCountingVariable, 99); self->SetNetworkVar<uint32_t>(ChargeCountingVariable, 99);
self->SetNetworkVar<uint32_t>(SuperChargeBarVariable, 0); self->SetNetworkVar<uint32_t>(SuperChargeBarVariable, 0);
ToggleSuperCharge(self, false); ToggleSuperCharge(self, false);
} }
} else if (name == SpawnWaveTimer) { }
void SGCannon::SpawnWaveTimerFunc(Entity* self) {
if (self->GetVar<bool>(GameStartedVariable)) { if (self->GetVar<bool>(GameStartedVariable)) {
self->SetVar<bool>(WaveStatusVariable, true); self->SetVar<bool>(WaveStatusVariable, true);
const auto wave = (int32_t)self->GetVar<uint32_t>(ThisWaveVariable); const auto wave = (int32_t)self->GetVar<uint32_t>(ThisWaveVariable);
@ -203,7 +204,9 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress()); GameMessages::SendActivityPause(self->GetObjectID(), false, player->GetSystemAddress());
} }
} }
} else if (name == EndWaveTimer) { }
void SGCannon::EndWaveTimerFunc(Entity* self) {
self->SetVar<bool>(WaveStatusVariable, false); self->SetVar<bool>(WaveStatusVariable, false);
TimerToggle(self); TimerToggle(self);
RecordPlayerScore(self); RecordPlayerScore(self);
@ -233,7 +236,9 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
if (self->GetVar<bool>(SuperChargeActiveVariable) && !self->GetVar<bool>(SuperChargePausedVariable)) { if (self->GetVar<bool>(SuperChargeActiveVariable) && !self->GetVar<bool>(SuperChargePausedVariable)) {
PauseChargeCannon(self); PauseChargeCannon(self);
} }
} else if (name == GameOverTimer) { }
void SGCannon::GameOverTimerFunc(Entity* self) {
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable)); auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
if (player != nullptr) { if (player != nullptr) {
Game::logger->Log("SGCannon", "Sending ActivityPause true"); Game::logger->Log("SGCannon", "Sending ActivityPause true");
@ -252,22 +257,32 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
TimerToggle(self); TimerToggle(self);
} }
} else if (name.rfind(DoSpawnTimer, 0) == 0) { }
void SGCannon::DoSpawnTimerFunc(Entity* self, const std::string& name) {
if (self->GetVar<bool>(GameStartedVariable)) { if (self->GetVar<bool>(GameStartedVariable)) {
Game::logger->LogDebug("SGCannon", "time name %s %s", name.c_str(), name.substr(7).c_str());
const auto spawnNumber = (uint32_t)std::stoi(name.substr(7)); const auto spawnNumber = (uint32_t)std::stoi(name.substr(7));
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable); const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
if (activeSpawns.size() < spawnNumber) { Game::logger->LogDebug("SGCannon", "size %i, %i", activeSpawns.size(), spawnNumber);
if (activeSpawns.size() <= spawnNumber) {
Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size()); Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
return; return;
} }
const auto& toSpawn = activeSpawns.at(spawnNumber); const auto& toSpawn = activeSpawns.at(spawnNumber);
Game::logger->LogDebug("SGCannon", "toSpawn %i", toSpawn.spawnPaths.size());
const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1); const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1);
Game::logger->LogDebug("SGCannon", "index %f", pathIndex);
Game::logger->LogDebug("SGCannon", "%s", toSpawn.spawnPaths.at(pathIndex).c_str());
const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex)); const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex));
if (!path) { if (!path) {
Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex); Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
return; return;
} }
Game::logger->LogDebug("SGCannon", "%s", path->pathName.c_str());
auto info = EntityInfo{}; auto info = EntityInfo{};
info.lot = toSpawn.lot; info.lot = toSpawn.lot;
info.spawnerID = self->GetObjectID(); info.spawnerID = self->GetObjectID();
@ -317,10 +332,27 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS); GameMessages::SendPlatformResync(enemy, UNASSIGNED_SYSTEM_ADDRESS);
} }
} }
} else if (name == EndGameBufferTimer) { }
void SGCannon::EndGameBufferTimerFunc(Entity* self) {
RecordPlayerScore(self); RecordPlayerScore(self);
StopGame(self, false); StopGame(self, false);
} }
void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
if (name == SuperChargeTimer && !self->GetVar<bool>(SuperChargePausedVariable)) {
SuperChargeTimerFunc(self);
} else if (name == SpawnWaveTimer) {
SpawnWaveTimerFunc(self);
} else if (name == EndWaveTimer) {
EndWaveTimerFunc(self);
} else if (name == GameOverTimer) {
GameOverTimerFunc(self);
} else if (name.rfind(DoSpawnTimer, 0) == 0) {
DoSpawnTimerFunc(self, name);
} else if (name == EndGameBufferTimer) {
EndGameBufferTimerFunc(self);
}
} }
void void

View File

@ -68,6 +68,12 @@ public:
void OnActivityTimerDone(Entity* self, const std::string& name) override; void OnActivityTimerDone(Entity* self, const std::string& name) override;
void OnActivityTimerUpdate(Entity* self, const std::string& name, float_t timeRemaining, float_t elapsedTime) override; void OnActivityTimerUpdate(Entity* self, const std::string& name, float_t timeRemaining, float_t elapsedTime) override;
void OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override; void OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override;
void SuperChargeTimerFunc(Entity* self);
void SpawnWaveTimerFunc(Entity* self);
void EndWaveTimerFunc(Entity* self);
void GameOverTimerFunc(Entity* self);
void DoSpawnTimerFunc(Entity* self, const std::string& name);
void EndGameBufferTimerFunc(Entity* self);
private: private:
static std::vector<std::vector<SGEnemy>> GetWaves(); static std::vector<std::vector<SGEnemy>> GetWaves();
static SGConstants GetConstants(); static SGConstants GetConstants();