mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-04 09:44:10 +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:
@@ -4,7 +4,7 @@
|
||||
#include "EntityManager.h"
|
||||
|
||||
void PropertyDeathPlane::OnCollisionPhantom(Entity* self, Entity* target) {
|
||||
const auto teleportGroup = EntityManager::Instance()->GetEntitiesInGroup("Teleport");
|
||||
const auto teleportGroup = Game::entityManager->GetEntitiesInGroup("Teleport");
|
||||
|
||||
if (teleportGroup.size() == 0) {
|
||||
return;
|
||||
|
@@ -49,7 +49,7 @@ void NsConcertInstrument::OnFireEventServerSide(Entity* self, Entity* sender, st
|
||||
if (activePlayerID == LWOOBJID_EMPTY)
|
||||
return;
|
||||
|
||||
const auto activePlayer = EntityManager::Instance()->GetEntity(activePlayerID);
|
||||
const auto activePlayer = Game::entityManager->GetEntity(activePlayerID);
|
||||
if (activePlayer == nullptr)
|
||||
return;
|
||||
|
||||
@@ -63,7 +63,7 @@ void NsConcertInstrument::OnTimerDone(Entity* self, std::string name) {
|
||||
return;
|
||||
|
||||
// If for some reason the player becomes null (for example an unexpected leave), we need to clean up
|
||||
const auto activePlayer = EntityManager::Instance()->GetEntity(activePlayerID);
|
||||
const auto activePlayer = Game::entityManager->GetEntity(activePlayerID);
|
||||
if (activePlayer == nullptr && name != "cleanupAfterStop") {
|
||||
StopPlayingInstrument(self, nullptr);
|
||||
return;
|
||||
@@ -126,7 +126,7 @@ void NsConcertInstrument::StartPlayingInstrument(Entity* self, Entity* player) {
|
||||
RenderComponent::PlayAnimation(player, animations.at(instrumentLot), 2.0f);
|
||||
});
|
||||
|
||||
for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) {
|
||||
for (auto* soundBox : Game::entityManager->GetEntitiesInGroup("Audio-Concert")) {
|
||||
auto* soundTrigger = soundBox->GetComponent<SoundTriggerComponent>();
|
||||
if (soundTrigger != nullptr) {
|
||||
soundTrigger->ActivateMusicCue(music.at(instrumentLot));
|
||||
@@ -161,7 +161,7 @@ void NsConcertInstrument::StopPlayingInstrument(Entity* self, Entity* player) {
|
||||
|
||||
self->SetVar<bool>(u"beingPlayed", false);
|
||||
|
||||
for (auto* soundBox : EntityManager::Instance()->GetEntitiesInGroup("Audio-Concert")) {
|
||||
for (auto* soundBox : Game::entityManager->GetEntitiesInGroup("Audio-Concert")) {
|
||||
auto* soundTrigger = soundBox->GetComponent<SoundTriggerComponent>();
|
||||
if (soundTrigger != nullptr) {
|
||||
soundTrigger->DeactivateMusicCue(music.at(instrumentLot));
|
||||
|
@@ -42,7 +42,7 @@ void NsConcertQuickBuild::OnStartup(Entity* self) {
|
||||
|
||||
// Get the manager of the crate of this quick build
|
||||
const auto groupNumber = std::stoi(splitGroup.at(3));
|
||||
const auto managerObjects = EntityManager::Instance()->GetEntitiesInGroup("CB_" + std::to_string(groupNumber));
|
||||
const auto managerObjects = Game::entityManager->GetEntitiesInGroup("CB_" + std::to_string(groupNumber));
|
||||
if (managerObjects.empty())
|
||||
return;
|
||||
|
||||
@@ -67,7 +67,7 @@ float NsConcertQuickBuild::GetBlinkTime(float time) {
|
||||
}
|
||||
|
||||
void NsConcertQuickBuild::OnDie(Entity* self, Entity* killer) {
|
||||
auto* managerObject = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"managerObject"));
|
||||
auto* managerObject = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"managerObject"));
|
||||
if (managerObject) {
|
||||
managerObject->CancelAllTimers();
|
||||
managerObject->AddCallbackTimer(1.0f, [managerObject]() {
|
||||
@@ -90,7 +90,7 @@ void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
// Find all the quick build objects of the same lot
|
||||
auto finishedQuickBuildObjects = std::vector<Entity*>();
|
||||
for (auto quickBuildID : finishedQuickBuilds) {
|
||||
const auto quickBuildObject = EntityManager::Instance()->GetEntity(quickBuildID);
|
||||
const auto quickBuildObject = Game::entityManager->GetEntity(quickBuildID);
|
||||
if (quickBuildObject && quickBuildObject->GetLOT() == self->GetLOT()) {
|
||||
quickBuildObject->SetVar<LWOOBJID>(u"Player_" + (GeneralUtils::to_u16string(groupNumber)), target->GetObjectID());
|
||||
finishedQuickBuildObjects.push_back(quickBuildObject);
|
||||
@@ -101,7 +101,7 @@ void NsConcertQuickBuild::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
if (finishedQuickBuildObjects.size() >= 4) {
|
||||
|
||||
// Move all the platforms so the user can collect the imagination brick
|
||||
const auto movingPlatforms = EntityManager::Instance()->GetEntitiesInGroup("ConcertPlatforms");
|
||||
const auto movingPlatforms = Game::entityManager->GetEntitiesInGroup("ConcertPlatforms");
|
||||
for (auto* movingPlatform : movingPlatforms) {
|
||||
auto* component = movingPlatform->GetComponent<MovingPlatformComponent>();
|
||||
if (component) {
|
||||
@@ -184,7 +184,7 @@ void NsConcertQuickBuild::ProgressLicensedTechnician(Entity* self) {
|
||||
for (auto i = 1; i < 5; i++) {
|
||||
const auto playerID = self->GetVar<LWOOBJID>(u"Player_" + (GeneralUtils::to_u16string(i)));
|
||||
if (playerID != LWOOBJID_EMPTY) {
|
||||
const auto player = EntityManager::Instance()->GetEntity(playerID);
|
||||
const auto player = Game::entityManager->GetEntity(playerID);
|
||||
if (player) {
|
||||
auto playerMissionComponent = player->GetComponent<MissionComponent>();
|
||||
if (playerMissionComponent)
|
||||
@@ -202,7 +202,7 @@ void NsConcertQuickBuild::UpdateEffects(Entity* self) {
|
||||
return;
|
||||
|
||||
for (const auto& effectName : setIterator->second.effects) {
|
||||
const auto effectObjects = EntityManager::Instance()->GetEntitiesInGroup(quickBuildFX.at(effectName));
|
||||
const auto effectObjects = Game::entityManager->GetEntitiesInGroup(quickBuildFX.at(effectName));
|
||||
for (auto* effectObject : effectObjects) {
|
||||
GameMessages::SendPlayFXEffect(effectObject, 0, GeneralUtils::ASCIIToUTF16(effectName),
|
||||
effectName + "Effect", LWOOBJID_EMPTY, 1, 1, true);
|
||||
@@ -216,7 +216,7 @@ void NsConcertQuickBuild::CancelEffects(Entity* self) {
|
||||
return;
|
||||
|
||||
for (const auto& effectName : setIterator->second.effects) {
|
||||
const auto effectObjects = EntityManager::Instance()->GetEntitiesInGroup(quickBuildFX.at(effectName));
|
||||
const auto effectObjects = Game::entityManager->GetEntitiesInGroup(quickBuildFX.at(effectName));
|
||||
for (auto* effectObject : effectObjects) {
|
||||
GameMessages::SendStopFXEffect(effectObject, true, effectName + "Effect");
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ void NsQbImaginationStatue::OnTimerDone(Entity* self, std::string timerName) {
|
||||
void NsQbImaginationStatue::SpawnLoot(Entity* self) {
|
||||
const auto playerId = self->GetVar<LWOOBJID>(u"Player");
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerId);
|
||||
auto* player = Game::entityManager->GetEntity(playerId);
|
||||
|
||||
if (player == nullptr) return;
|
||||
|
||||
|
@@ -7,7 +7,7 @@ void RockHydrantBroken::OnStartup(Entity* self) {
|
||||
|
||||
const auto hydrant = "hydrant" + self->GetVar<std::string>(u"hydrant");
|
||||
|
||||
const auto bouncers = EntityManager::Instance()->GetEntitiesInGroup(hydrant);
|
||||
const auto bouncers = Game::entityManager->GetEntitiesInGroup(hydrant);
|
||||
|
||||
for (auto* bouncer : bouncers) {
|
||||
self->SetVar<LWOOBJID>(u"bouncer", bouncer->GetObjectID());
|
||||
@@ -23,7 +23,7 @@ void RockHydrantBroken::OnStartup(Entity* self) {
|
||||
|
||||
void RockHydrantBroken::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "KillBroken") {
|
||||
auto* bouncer = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
||||
auto* bouncer = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"bouncer"));
|
||||
|
||||
if (bouncer != nullptr) {
|
||||
GameMessages::SendBouncerActiveStatus(bouncer->GetObjectID(), false, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
@@ -15,7 +15,7 @@ void RockHydrantSmashable::OnDie(Entity* self, Entity* killer) {
|
||||
info.settings = { data };
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
|
||||
auto* hydrant = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* hydrant = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(hydrant);
|
||||
Game::entityManager->ConstructEntity(hydrant);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
|
||||
fanGroup = "";
|
||||
}
|
||||
|
||||
std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup);
|
||||
std::vector<Entity*> fanVolumes = Game::entityManager->GetEntitiesInGroup(fanGroup);
|
||||
|
||||
auto* renderComponent = self->GetComponent<RenderComponent>();
|
||||
|
||||
@@ -41,7 +41,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
|
||||
auto volumePhys = volume->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(false);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
Game::entityManager->SerializeEntity(volume);
|
||||
}
|
||||
} else if (!self->GetVar<bool>(u"on") && self->GetVar<bool>(u"alive")) {
|
||||
RenderComponent::PlayAnimation(self, u"fan-on");
|
||||
@@ -52,7 +52,7 @@ void WhFans::ToggleFX(Entity* self, bool hit) {
|
||||
auto volumePhys = volume->GetComponent<PhantomPhysicsComponent>();
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(true);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
Game::entityManager->SerializeEntity(volume);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user