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:
David Markowitz
2023-07-15 13:56:33 -07:00
committed by GitHub
parent 9375c36c7b
commit 455f9470a5
200 changed files with 861 additions and 862 deletions

View File

@@ -4,7 +4,7 @@
#include "GameMessages.h"
void ActNinjaSensei::OnStartup(Entity* self) {
auto students = EntityManager::Instance()->GetEntitiesInGroup(this->m_StudentGroup);
auto students = Game::entityManager->GetEntitiesInGroup(this->m_StudentGroup);
std::vector<Entity*> validStudents = {};
for (auto* student : students) {
if (student && student->GetLOT() == this->m_StudentLOT) validStudents.push_back(student);

View File

@@ -8,7 +8,7 @@
void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
const auto myGroup = "AllPipes";
const auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(myGroup);
const auto groupObjs = Game::entityManager->GetEntitiesInGroup(myGroup);
auto indexCount = 0;
@@ -27,14 +27,14 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
}
if (indexCount >= 2) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {
GameMessages::SendPlayFXEffect(refinery[0]->GetObjectID(), 3999, u"create", "pipeFX");
}
for (auto* object : groupObjs) {
auto* player = EntityManager::Instance()->GetEntity(object->GetVar<LWOOBJID>(u"PlayerID"));
auto* player = Game::entityManager->GetEntity(object->GetVar<LWOOBJID>(u"PlayerID"));
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
@@ -53,7 +53,7 @@ void ActParadoxPipeFix::OnRebuildComplete(Entity* self, Entity* target) {
void ActParadoxPipeFix::OnRebuildNotifyState(Entity* self, eRebuildState state) {
if (state == eRebuildState::RESETTING) {
const auto refinery = EntityManager::Instance()->GetEntitiesInGroup("Paradox");
const auto refinery = Game::entityManager->GetEntitiesInGroup("Paradox");
if (!refinery.empty()) {
GameMessages::SendStopFXEffect(refinery[0], true, "pipeFX");

View File

@@ -13,7 +13,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftUp");
@@ -22,7 +22,7 @@ void FvConsoleLeftQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState s
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftDown");
@@ -38,7 +38,7 @@ void FvConsoleLeftQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleLeftActive");

View File

@@ -13,7 +13,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
if (state == eRebuildState::COMPLETED) {
self->SetVar(u"IAmBuilt", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightUp");
@@ -22,7 +22,7 @@ void FvConsoleRightQuickbuild::OnRebuildNotifyState(Entity* self, eRebuildState
self->SetVar(u"IAmBuilt", false);
self->SetVar(u"AmActive", false);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightDown");
@@ -38,7 +38,7 @@ void FvConsoleRightQuickbuild::OnUse(Entity* self, Entity* user) {
if (self->GetVar<bool>(u"IAmBuilt")) {
self->SetVar(u"AmActive", true);
const auto objects = EntityManager::Instance()->GetEntitiesInGroup("Facility");
const auto objects = Game::entityManager->GetEntitiesInGroup("Facility");
if (!objects.empty()) {
objects[0]->NotifyObject(self, "ConsoleRightActive");

View File

@@ -21,7 +21,7 @@ void FvDragonSmashingGolemQb::OnRebuildNotifyState(Entity* self, eRebuildState s
const auto dragonId = self->GetVar<LWOOBJID>(u"Dragon");
auto* dragon = EntityManager::Instance()->GetEntity(dragonId);
auto* dragon = Game::entityManager->GetEntity(dragonId);
if (dragon != nullptr) {
dragon->OnFireEventServerSide(self, "rebuildDone");

View File

@@ -46,14 +46,14 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st
}
if (self->GetVar<bool>(u"ConsoleLEFTActive") && self->GetVar<bool>(u"ConsoleRIGHTActive")) {
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
auto* object = Game::entityManager->GetEntitiesInGroup("Brick")[0];
if (object != nullptr) {
GameMessages::SendPlayFXEffect(object->GetObjectID(), 122, u"create", "bluebrick");
GameMessages::SendPlayFXEffect(object->GetObjectID(), 1034, u"cast", "imaginationexplosion");
}
object = EntityManager::Instance()->GetEntitiesInGroup("Canister")[0];
object = Game::entityManager->GetEntitiesInGroup("Canister")[0];
if (object != nullptr) {
object->Smash(self->GetObjectID(), eKillType::SILENT);
@@ -64,7 +64,7 @@ void FvFacilityBrick::OnNotifyObject(Entity* self, Entity* sender, const std::st
} else if (self->GetVar<bool>(u"ConsoleLEFTActive") || self->GetVar<bool>(u"ConsoleRIGHTActive")) {
brickSpawner->Activate();
auto* object = EntityManager::Instance()->GetEntitiesInGroup("Brick")[0];
auto* object = Game::entityManager->GetEntitiesInGroup("Brick")[0];
if (object != nullptr) {
GameMessages::SendStopFXEffect(object, true, "bluebrick");

View File

@@ -34,7 +34,7 @@ void FvFlyingCreviceDragon::OnTimerDone(Entity* self, std::string timerName) {
groupName = "dragonFireballs3";
}
const auto& group = EntityManager::Instance()->GetEntitiesInGroup(groupName);
const auto& group = Game::entityManager->GetEntitiesInGroup(groupName);
if (group.empty()) {
return;
@@ -73,7 +73,7 @@ void FvFlyingCreviceDragon::OnArrived(Entity* self) {
} else if (point == 12) {
RenderComponent::PlayAnimation(self, u"attack2", 2.0f);
const auto& group2 = EntityManager::Instance()->GetEntitiesInGroup("dragonFireballs2");
const auto& group2 = Game::entityManager->GetEntitiesInGroup("dragonFireballs2");
if (group2.empty()) {
return;

View File

@@ -22,13 +22,13 @@ void FvNinjaGuard::OnEmoteReceived(Entity* self, const int32_t emote, Entity* ta
RenderComponent::PlayAnimation(self, u"scared");
if (self->GetLOT() == 7412) {
auto* rightGuard = EntityManager::Instance()->GetEntity(m_RightGuard);
auto* rightGuard = Game::entityManager->GetEntity(m_RightGuard);
if (rightGuard != nullptr) {
RenderComponent::PlayAnimation(rightGuard, u"laugh_rt");
}
} else if (self->GetLOT() == 11128) {
auto* leftGuard = EntityManager::Instance()->GetEntity(m_LeftGuard);
auto* leftGuard = Game::entityManager->GetEntity(m_LeftGuard);
if (leftGuard != nullptr) {
RenderComponent::PlayAnimation(leftGuard, u"laugh_lt");

View File

@@ -9,7 +9,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
auto* character = target->GetCharacter();
if (character != nullptr && character->GetPlayerFlag(81)) {
auto raceObjects = EntityManager::Instance()->GetEntitiesInGroup("PandaRaceObject");
auto raceObjects = Game::entityManager->GetEntitiesInGroup("PandaRaceObject");
if (raceObjects.empty())
return;
@@ -19,7 +19,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
return;
// If the player already spawned a panda
auto playerPandas = EntityManager::Instance()->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
auto playerPandas = Game::entityManager->GetEntitiesInGroup("panda" + std::to_string(target->GetObjectID()));
if (!playerPandas.empty()) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"playerPanda",
target->GetObjectID(), 0, 0, target->GetObjectID());
@@ -27,7 +27,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
}
// If there's already too many spawned pandas
auto pandas = EntityManager::Instance()->GetEntitiesInGroup("pandas");
auto pandas = Game::entityManager->GetEntitiesInGroup("pandas");
if (pandas.size() > 4) {
GameMessages::SendFireEventClientSide(self->GetObjectID(), target->GetSystemAddress(), u"tooManyPandas",
target->GetObjectID(), 0, 0, target->GetObjectID());
@@ -43,7 +43,7 @@ void FvPandaSpawnerServer::OnCollisionPhantom(Entity* self, Entity* target) {
new LDFData<std::u16string>(u"groupID", u"panda" + (GeneralUtils::to_u16string(target->GetObjectID())) + u";pandas")
};
auto* panda = EntityManager::Instance()->CreateEntity(info);
EntityManager::Instance()->ConstructEntity(panda);
auto* panda = Game::entityManager->CreateEntity(info);
Game::entityManager->ConstructEntity(panda);
}
}