mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-14 03:19:56 +00:00
Merge branch 'main' into npc-pathing
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "InventoryComponent.h"
|
||||
#include "eMissionTaskType.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
#include "RenderComponent.h"
|
||||
#include "eGameActivity.h"
|
||||
#include "MovingPlatformComponent.h"
|
||||
|
||||
@@ -78,7 +79,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
|
||||
const std::u16string& stringValue) {
|
||||
Game::logger->Log("SGCannon", "Got activity state change request: %s", GeneralUtils::UTF16ToWTF8(stringValue).c_str());
|
||||
if (stringValue == u"clientready") {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
Game::logger->Log("SGCannon", "Player is ready");
|
||||
/*GameMessages::SendSetStunned(player->GetObjectID(), eStateChangeType::PUSH, player->GetSystemAddress(), LWOOBJID_EMPTY,
|
||||
@@ -95,7 +96,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
|
||||
|
||||
Game::logger->Log("SGCannon", "Setting player ID");
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
} else {
|
||||
Game::logger->Log("SGCannon", "Shooting gallery component is null");
|
||||
}
|
||||
@@ -111,7 +112,7 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
|
||||
possessor->SetPossessableType(ePossessionType::NO_POSSESSION);
|
||||
}
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(player);
|
||||
Game::entityManager->SerializeEntity(player);
|
||||
}
|
||||
|
||||
self->SetNetworkVar<bool>(HideScoreBoardVariable, true);
|
||||
@@ -136,38 +137,26 @@ void SGCannon::OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int
|
||||
}
|
||||
}
|
||||
|
||||
void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier,
|
||||
const std::u16string& userData) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
if (button == 1 && identifier == u"Shooting_Gallery_Stop") {
|
||||
void SGCannon::OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) {
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (!player) return;
|
||||
|
||||
if (identifier == u"Scoreboardinfo") {
|
||||
GameMessages::SendDisplayMessageBox(player->GetObjectID(), true,
|
||||
Game::zoneManager->GetZoneControlObject()->GetObjectID(),
|
||||
u"Shooting_Gallery_Retry", 2, u"Retry?",
|
||||
u"", player->GetSystemAddress());
|
||||
} else {
|
||||
if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay")) || identifier == u"SG1" || button == 0) {
|
||||
if (IsPlayerInActivity(self, player->GetObjectID())) return;
|
||||
self->SetNetworkVar<bool>(ClearVariable, true);
|
||||
StartGame(self);
|
||||
} else if (button == 0 && ((identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay"))) {
|
||||
RemovePlayer(player->GetObjectID());
|
||||
UpdatePlayer(self, player->GetObjectID(), true);
|
||||
} else if (button == 1 && identifier == u"Shooting_Gallery_Exit") {
|
||||
UpdatePlayer(self, player->GetObjectID(), true);
|
||||
RemovePlayer(player->GetObjectID());
|
||||
StopGame(self, true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (identifier == u"Scoreboardinfo") {
|
||||
GameMessages::SendDisplayMessageBox(player->GetObjectID(), true,
|
||||
dZoneManager::Instance()->GetZoneControlObject()->GetObjectID(),
|
||||
u"Shooting_Gallery_Retry?", 2, u"Retry?",
|
||||
u"", player->GetSystemAddress());
|
||||
} else {
|
||||
if ((button == 1 && (identifier == u"Shooting_Gallery_Retry" || identifier == u"RePlay"))
|
||||
|| identifier == u"SG1" || button == 0) {
|
||||
|
||||
if (identifier == u"RePlay") {
|
||||
static_cast<Player*>(player)->SendToZone(1300);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
self->SetNetworkVar<bool>(ClearVariable, true);
|
||||
StartGame(self);
|
||||
} else if (button == 1 && identifier == u"Shooting_Gallery_Exit") {
|
||||
UpdatePlayer(self, player->GetObjectID(), true);
|
||||
RemovePlayer(player->GetObjectID());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,7 +194,7 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
|
||||
ActivityTimerStart(self, EndWaveTimer, timeLimit, timeLimit);
|
||||
}
|
||||
|
||||
const auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
const auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
GameMessages::SendPlayFXEffect(player->GetObjectID(), -1, u"SG-start", "");
|
||||
|
||||
@@ -246,13 +235,13 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
|
||||
PauseChargeCannon(self);
|
||||
}
|
||||
} else if (name == GameOverTimer) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
Game::logger->Log("SGCannon", "Sending ActivityPause true");
|
||||
|
||||
GameMessages::SendActivityPause(self->GetObjectID(), true, player->GetSystemAddress());
|
||||
|
||||
/*const auto leftoverCannonballs = EntityManager::Instance()->GetEntitiesInGroup("cannonball");
|
||||
/*const auto leftoverCannonballs = Game::entityManager->GetEntitiesInGroup("cannonball");
|
||||
if (leftoverCannonballs.empty()) {
|
||||
RecordPlayerScore(self);
|
||||
|
||||
@@ -268,13 +257,17 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
|
||||
if (self->GetVar<bool>(GameStartedVariable)) {
|
||||
const auto spawnNumber = (uint32_t)std::stoi(name.substr(7));
|
||||
const auto& activeSpawns = self->GetVar<std::vector<SGEnemy>>(ActiveSpawnsVariable);
|
||||
if (activeSpawns.size() < spawnNumber) {
|
||||
Game::logger->Log("SGCannon", "Trying to spawn %i when spawns size is only %i", spawnNumber, activeSpawns.size());
|
||||
return;
|
||||
}
|
||||
const auto& toSpawn = activeSpawns.at(spawnNumber);
|
||||
|
||||
const auto pathIndex = GeneralUtils::GenerateRandomNumber<float_t>(0, toSpawn.spawnPaths.size() - 1);
|
||||
|
||||
const auto* path = dZoneManager::Instance()->GetZone()->GetPath(
|
||||
toSpawn.spawnPaths.at(pathIndex)
|
||||
);
|
||||
const auto* path = Game::zoneManager->GetZone()->GetPath(toSpawn.spawnPaths.at(pathIndex));
|
||||
if (!path) {
|
||||
Game::logger->Log("SGCannon", "Path %s at index %i is null", toSpawn.spawnPaths.at(pathIndex).c_str(), pathIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
auto info = EntityInfo{};
|
||||
info.lot = toSpawn.lot;
|
||||
@@ -292,9 +285,9 @@ void SGCannon::OnActivityTimerDone(Entity* self, const std::string& name) {
|
||||
|
||||
Game::logger->Log("SGCannon", "Spawning enemy %i on path %s", toSpawn.lot, path->pathName.c_str());
|
||||
|
||||
auto* enemy = EntityManager::Instance()->CreateEntity(info, nullptr, self);
|
||||
auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self);
|
||||
if (enemy) {
|
||||
EntityManager::Instance()->ConstructEntity(enemy);
|
||||
Game::entityManager->ConstructEntity(enemy);
|
||||
auto* movementAI = enemy->GetComponent<MovementAIComponent>();
|
||||
if (!movementAI) return;
|
||||
|
||||
@@ -327,18 +320,19 @@ SGCannon::OnActivityTimerUpdate(Entity* self, const std::string& name, float_t t
|
||||
}
|
||||
|
||||
void SGCannon::StartGame(Entity* self) {
|
||||
if (self->GetVar<bool>(GameStartedVariable)) return;
|
||||
self->SetNetworkVar<uint32_t>(TimeLimitVariable, self->GetVar<uint32_t>(TimeLimitVariable));
|
||||
self->SetNetworkVar<bool>(AudioStartIntroVariable, true);
|
||||
self->SetVar<LOT>(CurrentRewardVariable, LOT_NULL);
|
||||
|
||||
auto rewardObjects = EntityManager::Instance()->GetEntitiesInGroup(constants.rewardModelGroup);
|
||||
auto rewardObjects = Game::entityManager->GetEntitiesInGroup(constants.rewardModelGroup);
|
||||
for (auto* reward : rewardObjects) {
|
||||
reward->OnFireEventServerSide(self, ModelToBuildEvent);
|
||||
}
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
GetLeaderboardData(self, player->GetObjectID(), GetActivityID(self));
|
||||
GetLeaderboardData(self, player->GetObjectID(), GetActivityID(self), 1);
|
||||
Game::logger->Log("SGCannon", "Sending ActivityStart");
|
||||
GameMessages::SendActivityStart(self->GetObjectID(), player->GetSystemAddress());
|
||||
|
||||
@@ -381,9 +375,9 @@ void SGCannon::SpawnNewModel(Entity* self) {
|
||||
self->SetNetworkVar<int32_t>(RewardAddedVariable, currentReward);
|
||||
}
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
for (auto* rewardModel : EntityManager::Instance()->GetEntitiesInGroup(constants.rewardModelGroup)) {
|
||||
for (auto* rewardModel : Game::entityManager->GetEntitiesInGroup(constants.rewardModelGroup)) {
|
||||
uint32_t lootMatrix;
|
||||
switch (self->GetVar<uint32_t>(MatrixVariable)) {
|
||||
case 1:
|
||||
@@ -419,7 +413,7 @@ void SGCannon::SpawnNewModel(Entity* self) {
|
||||
}
|
||||
|
||||
void SGCannon::RemovePlayer(LWOOBJID playerID) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
if (player == nullptr)
|
||||
return;
|
||||
|
||||
@@ -433,6 +427,14 @@ void SGCannon::RemovePlayer(LWOOBJID playerID) {
|
||||
}
|
||||
}
|
||||
|
||||
void SGCannon::OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) {
|
||||
if (canceled) {
|
||||
StopGame(self, canceled);
|
||||
RemovePlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SGCannon::StartChargedCannon(Entity* self, uint32_t optionalTime) {
|
||||
optionalTime = optionalTime == 0 ? constants.chargedTime : optionalTime;
|
||||
self->SetVar<bool>(SuperChargePausedVariable, false);
|
||||
@@ -497,18 +499,18 @@ void SGCannon::RecordPlayerScore(Entity* self) {
|
||||
}
|
||||
|
||||
void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationName, bool onCannon, bool onPlayer, float_t priority) {
|
||||
for (auto* cannon : EntityManager::Instance()->GetEntitiesInGroup("cannongroup")) {
|
||||
GameMessages::SendPlayAnimation(cannon, animationName, priority);
|
||||
for (auto* cannon : Game::entityManager->GetEntitiesInGroup("cannongroup")) {
|
||||
RenderComponent::PlayAnimation(cannon, animationName, priority);
|
||||
}
|
||||
|
||||
if (onCannon) {
|
||||
GameMessages::SendPlayAnimation(self, animationName, priority);
|
||||
RenderComponent::PlayAnimation(self, animationName, priority);
|
||||
}
|
||||
|
||||
if (onPlayer) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
GameMessages::SendPlayAnimation(player, animationName, priority);
|
||||
RenderComponent::PlayAnimation(player, animationName, priority);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -527,7 +529,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
|
||||
self->SetNetworkVar<bool>(ReSetSuperChargeVariable, true);
|
||||
self->SetNetworkVar<bool>(HideSuperChargeVariable, true);
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player == nullptr)
|
||||
return;
|
||||
|
||||
@@ -535,7 +537,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
|
||||
|
||||
// The player won, store all the score and send rewards
|
||||
if (!cancel) {
|
||||
auto percentage = 0;
|
||||
int32_t percentage = 0.0f;
|
||||
auto misses = self->GetVar<uint32_t>(MissesVariable);
|
||||
auto fired = self->GetVar<uint32_t>(ShotsFiredVariable);
|
||||
|
||||
@@ -553,6 +555,9 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
|
||||
|
||||
LootGenerator::Instance().GiveActivityLoot(player, self, GetGameID(self), self->GetVar<uint32_t>(TotalScoreVariable));
|
||||
|
||||
SaveScore(self, player->GetObjectID(),
|
||||
static_cast<float>(self->GetVar<uint32_t>(TotalScoreVariable)), static_cast<float>(self->GetVar<uint32_t>(MaxStreakVariable)), percentage);
|
||||
|
||||
StopActivity(self, player->GetObjectID(), self->GetVar<uint32_t>(TotalScoreVariable), self->GetVar<uint32_t>(MaxStreakVariable), percentage);
|
||||
self->SetNetworkVar<bool>(AudioFinalWaveDoneVariable, true);
|
||||
|
||||
@@ -566,17 +571,6 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
|
||||
|
||||
self->SetNetworkVar<std::u16string>(u"UI_Rewards",
|
||||
GeneralUtils::to_u16string(self->GetVar<uint32_t>(TotalScoreVariable)) + u"_0_0_0_0_0_0"
|
||||
);
|
||||
|
||||
GameMessages::SendRequestActivitySummaryLeaderboardData(
|
||||
player->GetObjectID(),
|
||||
self->GetObjectID(),
|
||||
player->GetSystemAddress(),
|
||||
GetGameID(self),
|
||||
1,
|
||||
10,
|
||||
0,
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@@ -585,7 +579,7 @@ void SGCannon::StopGame(Entity* self, bool cancel) {
|
||||
ActivityTimerStopAllTimers(self);
|
||||
|
||||
// Destroy all spawners
|
||||
for (auto* entity : EntityManager::Instance()->GetEntitiesInGroup("SGEnemy")) {
|
||||
for (auto* entity : Game::entityManager->GetEntitiesInGroup("SGEnemy")) {
|
||||
entity->Kill();
|
||||
}
|
||||
|
||||
@@ -652,7 +646,7 @@ void SGCannon::RegisterHit(Entity* self, Entity* target, const std::string& time
|
||||
|
||||
self->SetNetworkVar<std::u16string>(u"beatHighScore", GeneralUtils::to_u16string(newScore));
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player == nullptr) return;
|
||||
|
||||
auto missionComponent = player->GetComponent<MissionComponent>();
|
||||
@@ -702,7 +696,7 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
if (enable && self->GetVar<bool>(SuperChargeActiveVariable))
|
||||
return;
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
|
||||
if (player == nullptr) {
|
||||
Game::logger->Log("SGCannon", "Player not found in toggle super charge");
|
||||
@@ -777,8 +771,8 @@ void SGCannon::ToggleSuperCharge(Entity* self, bool enable) {
|
||||
|
||||
shootingGalleryComponent->SetDynamicParams(properties);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
EntityManager::Instance()->SerializeEntity(player);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(player);
|
||||
|
||||
self->SetNetworkVar<uint64_t>(CannonBallSkillIDVariable, skillID);
|
||||
self->SetVar<bool>(SuperChargeActiveVariable, enable);
|
||||
|
@@ -63,12 +63,11 @@ public:
|
||||
void OnStartup(Entity* self) override;
|
||||
void OnPlayerLoaded(Entity* self, Entity* player) override;
|
||||
void OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2, int32_t param3) override;
|
||||
void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1,
|
||||
int32_t value2, const std::u16string& stringValue) override;
|
||||
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier,
|
||||
const std::u16string& userData) override;
|
||||
void OnActivityStateChangeRequest(Entity* self, LWOOBJID senderID, int32_t value1, int32_t value2, const std::u16string& stringValue) override;
|
||||
void OnMessageBoxResponse(Entity* self, Entity* sender, int32_t button, const std::u16string& identifier, const std::u16string& userData) 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 OnRequestActivityExit(Entity* self, LWOOBJID player, bool canceled) override;
|
||||
private:
|
||||
static std::vector<std::vector<SGEnemy>> GetWaves();
|
||||
static SGConstants GetConstants();
|
||||
|
@@ -2,7 +2,7 @@
|
||||
#include "EntityManager.h"
|
||||
|
||||
void ZoneSGServer::OnStartup(Entity* self) {
|
||||
const auto cannons = EntityManager::Instance()->GetEntitiesByLOT(1864);
|
||||
const auto cannons = Game::entityManager->GetEntitiesByLOT(1864);
|
||||
for (const auto& cannon : cannons)
|
||||
self->SetVar<LWOOBJID>(CannonIDVariable, cannon->GetObjectID());
|
||||
}
|
||||
@@ -10,7 +10,7 @@ void ZoneSGServer::OnStartup(Entity* self) {
|
||||
void ZoneSGServer::OnActivityStateChangeRequest(Entity* self, const LWOOBJID senderID, const int32_t value1,
|
||||
const int32_t value2, const std::u16string& stringValue) {
|
||||
|
||||
auto* cannon = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(CannonIDVariable));
|
||||
auto* cannon = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(CannonIDVariable));
|
||||
if (cannon != nullptr) {
|
||||
cannon->OnActivityStateChangeRequest(senderID, value1, value2, stringValue);
|
||||
}
|
||||
@@ -19,7 +19,7 @@ void ZoneSGServer::OnActivityStateChangeRequest(Entity* self, const LWOOBJID sen
|
||||
void ZoneSGServer::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1, int32_t param2,
|
||||
int32_t param3) {
|
||||
|
||||
auto* cannon = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(CannonIDVariable));
|
||||
auto* cannon = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(CannonIDVariable));
|
||||
if (cannon != nullptr) {
|
||||
cannon->OnFireEventServerSide(sender, args, param1, param2, param3);
|
||||
}
|
||||
|
Reference in New Issue
Block a user