mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 17:54:01 +00:00
Move EntityManager to Game namespace (#1140)
* Move EntityManager to Game namespace * move initialization to later Need to wait for dZoneManager to be initialized. * Fix bugs - Cannot delete from a RandomAccessIterator while in a range based for loop. Touchup zone manager initialize replace magic numbers with better named constants replace magic zonecontrol id with a more readable hex alternative condense stack variables move initializers closer to their use initialize entity manager with zone control change initialize timings If zone is not zero we expect to initialize the entity manager during zone manager initialization Add constexpr for zone control LOT * Add proper error handling * revert vanity changes * Update WorldServer.cpp * Update dZoneManager.cpp
This commit is contained in:
@@ -78,7 +78,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 +95,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 +111,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);
|
||||
@@ -137,7 +137,7 @@ 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));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (!player) return;
|
||||
|
||||
if (identifier == u"Scoreboardinfo") {
|
||||
@@ -193,7 +193,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", "");
|
||||
|
||||
@@ -234,13 +234,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);
|
||||
|
||||
@@ -284,8 +284,8 @@ 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);
|
||||
EntityManager::Instance()->ConstructEntity(enemy);
|
||||
auto* enemy = Game::entityManager->CreateEntity(info, nullptr, self);
|
||||
Game::entityManager->ConstructEntity(enemy);
|
||||
|
||||
auto* movementAI = new MovementAIComponent(enemy, {});
|
||||
|
||||
@@ -334,12 +334,12 @@ void SGCannon::StartGame(Entity* self) {
|
||||
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));
|
||||
Game::logger->Log("SGCannon", "Sending ActivityStart");
|
||||
@@ -384,9 +384,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:
|
||||
@@ -422,7 +422,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;
|
||||
|
||||
@@ -508,7 +508,7 @@ 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")) {
|
||||
for (auto* cannon : Game::entityManager->GetEntitiesInGroup("cannongroup")) {
|
||||
RenderComponent::PlayAnimation(cannon, animationName, priority);
|
||||
}
|
||||
|
||||
@@ -517,7 +517,7 @@ void SGCannon::PlaySceneAnimation(Entity* self, const std::u16string& animationN
|
||||
}
|
||||
|
||||
if (onPlayer) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(PlayerIDVariable));
|
||||
if (player != nullptr) {
|
||||
RenderComponent::PlayAnimation(player, animationName, priority);
|
||||
}
|
||||
@@ -538,7 +538,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;
|
||||
|
||||
@@ -596,7 +596,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();
|
||||
}
|
||||
|
||||
@@ -663,7 +663,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>();
|
||||
@@ -713,7 +713,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");
|
||||
@@ -788,8 +788,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);
|
||||
|
@@ -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