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

@@ -57,7 +57,7 @@ void NtAssemblyTubeServer::RunAssemblyTube(Entity* self, Entity* player) {
const auto animTime = 3;
self->AddCallbackTimer(animTime, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -73,7 +73,7 @@ void NtAssemblyTubeServer::TeleportPlayer(Entity* self, Entity* player) {
auto* destination = self;
if (!destinationGroup.empty()) {
const auto& groupObjs = EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
const auto& groupObjs = Game::entityManager->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
if (!groupObjs.empty()) {
destination = groupObjs[0];
@@ -92,7 +92,7 @@ void NtAssemblyTubeServer::TeleportPlayer(Entity* self, Entity* player) {
const auto playerID = player->GetObjectID();
self->AddCallbackTimer(animTime, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;

View File

@@ -4,7 +4,7 @@
void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) {
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID);
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
if (challengeObject != nullptr) {
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
@@ -16,7 +16,7 @@ void NtCombatChallengeDummy::OnDie(Entity* self, Entity* killer) {
void NtCombatChallengeDummy::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID);
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
if (challengeObject != nullptr) {
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {

View File

@@ -5,7 +5,7 @@
void NtCombatChallengeExplodingDummy::OnDie(Entity* self, Entity* killer) {
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID);
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
if (challengeObject != nullptr) {
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {
@@ -17,7 +17,7 @@ void NtCombatChallengeExplodingDummy::OnDie(Entity* self, Entity* killer) {
void NtCombatChallengeExplodingDummy::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {
const auto challengeObjectID = self->GetVar<LWOOBJID>(u"challengeObjectID");
auto* challengeObject = EntityManager::Instance()->GetEntity(challengeObjectID);
auto* challengeObject = Game::entityManager->GetEntity(challengeObjectID);
if (challengeObject != nullptr) {
for (CppScripts::Script* script : CppScripts::GetEntityScripts(challengeObject)) {

View File

@@ -19,7 +19,7 @@ void NtCombatChallengeServer::OnDie(Entity* self, Entity* killer) {
void NtCombatChallengeServer::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t damage) {
const auto playerID = self->GetVar<LWOOBJID>(u"playerID");
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -69,7 +69,7 @@ void NtCombatChallengeServer::OnMessageBoxResponse(Entity* self, Entity* sender,
void NtCombatChallengeServer::SpawnTargetDummy(Entity* self) {
const auto playerID = self->GetVar<LWOOBJID>(u"playerID");
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -91,11 +91,11 @@ void NtCombatChallengeServer::SpawnTargetDummy(Entity* self) {
info.rot = self->GetRotation();
info.settings = { new LDFData<std::string>(u"custom_script_server", "scripts\\02_server\\Map\\NT\\L_NT_COMBAT_CHALLENGE_DUMMY.lua") };
auto* dummy = EntityManager::Instance()->CreateEntity(info);
auto* dummy = Game::entityManager->CreateEntity(info);
dummy->SetVar(u"challengeObjectID", self->GetObjectID());
EntityManager::Instance()->ConstructEntity(dummy);
Game::entityManager->ConstructEntity(dummy);
self->SetVar(u"currentDummy", dummy->GetObjectID());
}
@@ -111,7 +111,7 @@ void NtCombatChallengeServer::OnChildLoaded(Entity* self, Entity* child) {
const auto playerID = self->GetVar<LWOOBJID>(u"playerID");
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -121,7 +121,7 @@ void NtCombatChallengeServer::OnChildLoaded(Entity* self, Entity* child) {
self->SetVar(u"currentTargetID", child->GetObjectID());
EntityManager::Instance()->SerializeEntity(child);
Game::entityManager->SerializeEntity(child);
child->GetGroups().push_back("targets_" + std::to_string(self->GetObjectID()));
}
@@ -130,7 +130,7 @@ void NtCombatChallengeServer::ResetGame(Entity* self) {
const auto totalDmg = self->GetVar<int32_t>(u"totalDmg");
const auto playerID = self->GetVar<LWOOBJID>(u"playerID");
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr) {
auto* missionComponent = player->GetComponent<MissionComponent>();
@@ -150,7 +150,7 @@ void NtCombatChallengeServer::ResetGame(Entity* self) {
self->SetNetworkVar(u"totalDmg", false);
self->SetNetworkVar(u"update_time", 0);
const auto& targetObjs = EntityManager::Instance()->GetEntitiesInGroup("targets_" + std::to_string(self->GetObjectID()));
const auto& targetObjs = Game::entityManager->GetEntitiesInGroup("targets_" + std::to_string(self->GetObjectID()));
for (auto* target : targetObjs) {
target->Smash(self->GetObjectID());
@@ -158,7 +158,7 @@ void NtCombatChallengeServer::ResetGame(Entity* self) {
const auto currentID = self->GetVar<LWOOBJID>(u"currentDummy");
auto* current = EntityManager::Instance()->GetEntity(currentID);
auto* current = Game::entityManager->GetEntity(currentID);
if (current != nullptr) {
current->Smash(self->GetObjectID());

View File

@@ -40,7 +40,7 @@ void NtImagBeamBuffer::OnTimerDone(Entity* self, std::string timerName) {
}
for (const auto entityID : m_EntitiesInProximity) {
auto* entity = EntityManager::Instance()->GetEntity(entityID);
auto* entity = Game::entityManager->GetEntity(entityID);
if (entity == nullptr) {
continue;

View File

@@ -21,7 +21,7 @@ void NtOverbuildServer::SetVariables(Entity* self) {
// Find the second object Dr. Overbuild interacts with
LWOOBJID otherConvoObjectID = LWOOBJID_EMPTY;
for (auto* otherConvoObject : EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(m_OtherEntitiesGroupVariable)))) {
for (auto* otherConvoObject : Game::entityManager->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(m_OtherEntitiesGroupVariable)))) {
otherConvoObjectID = otherConvoObject->GetObjectID();
break;
}

View File

@@ -25,7 +25,7 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) {
}
self->AddCallbackTimer(2, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -55,7 +55,7 @@ void NtParadoxPanelServer::OnUse(Entity* self, Entity* user) {
GameMessages::SendPlayFXEffect(self, 6432, u"create", "console_sparks", LWOOBJID_EMPTY, 1.0, 1.0, true);
self->AddCallbackTimer(2, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;

View File

@@ -33,7 +33,7 @@ void NtParadoxTeleServer::OnProximityUpdate(Entity* self, Entity* entering, std:
if (animTime == 0.0f) animTime = 2.0f;
self->AddCallbackTimer(animTime, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -55,7 +55,7 @@ void NtParadoxTeleServer::TeleportPlayer(Entity* self, Entity* player) {
auto* destination = self;
if (!destinationGroup.empty()) {
const auto& groupObjs = EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
const auto& groupObjs = Game::entityManager->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
if (!groupObjs.empty()) {
destination = groupObjs[0];
@@ -81,7 +81,7 @@ void NtParadoxTeleServer::TeleportPlayer(Entity* self, Entity* player) {
const auto playerID = player->GetObjectID();
self->AddCallbackTimer(animTime, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;

View File

@@ -25,7 +25,7 @@ void NtSentinelWalkwayServer::OnStartup(Entity* self) {
phantomPhysicsComponent->SetDirection(forward);
phantomPhysicsComponent->SetPhysicsEffectActive(true);
EntityManager::Instance()->SerializeEntity(self);
Game::entityManager->SerializeEntity(self);
self->SetProximityRadius(3, "speedboost");
}

View File

@@ -44,7 +44,7 @@ void NtVentureCannonServer::OnUse(Entity* self, Entity* user) {
});
self->AddCallbackTimer(1.5f, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -57,7 +57,7 @@ void NtVentureCannonServer::OnUse(Entity* self, Entity* user) {
void NtVentureCannonServer::EnterCannonEnded(Entity* self, Entity* player) {
const auto playerID = player->GetObjectID();
const auto& cannonEffectGroup = EntityManager::Instance()->GetEntitiesInGroup("cannonEffect");
const auto& cannonEffectGroup = Game::entityManager->GetEntitiesInGroup("cannonEffect");
if (!cannonEffectGroup.empty()) {
auto* cannonEffect = cannonEffectGroup[0];
@@ -83,7 +83,7 @@ void NtVentureCannonServer::EnterCannonEnded(Entity* self, Entity* player) {
);
self->AddCallbackTimer(1.5f, [this, self, playerID]() {
auto* player = EntityManager::Instance()->GetEntity(playerID);
auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr) {
return;
@@ -112,7 +112,7 @@ void NtVentureCannonServer::FirePlayer(Entity* self, Entity* player) {
auto* destination = self;
if (!destinationGroup.empty()) {
const auto& groupObjs = EntityManager::Instance()->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
const auto& groupObjs = Game::entityManager->GetEntitiesInGroup(GeneralUtils::UTF16ToWTF8(destinationGroup));
if (!groupObjs.empty()) {
destination = groupObjs[0];