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:
@@ -24,12 +24,12 @@ void AgBusDoor::OnProximityUpdate(Entity* self, Entity* entering, std::string na
|
||||
m_OuterCounter = 0;
|
||||
|
||||
for (const auto& pair : proximityMonitorComponent->GetProximityObjects("busDoor")) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair.first);
|
||||
auto* entity = Game::entityManager->GetEntity(pair.first);
|
||||
if (entity != nullptr && entity->IsPlayer()) m_Counter++;
|
||||
}
|
||||
|
||||
for (const auto& pair : proximityMonitorComponent->GetProximityObjects("busDoorOuter")) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(pair.first);
|
||||
auto* entity = Game::entityManager->GetEntity(pair.first);
|
||||
if (entity != nullptr && entity->IsPlayer()) m_OuterCounter++;
|
||||
}
|
||||
|
||||
|
@@ -25,7 +25,7 @@ void AgFans::OnStartup(Entity* self) {
|
||||
|
||||
void AgFans::ToggleFX(Entity* self, bool hit) {
|
||||
std::string fanGroup = self->GetGroups()[0];
|
||||
std::vector<Entity*> fanVolumes = EntityManager::Instance()->GetEntitiesInGroup(fanGroup);
|
||||
std::vector<Entity*> fanVolumes = Game::entityManager->GetEntitiesInGroup(fanGroup);
|
||||
|
||||
auto* renderComponent = static_cast<RenderComponent*>(self->GetComponent(eReplicaComponentType::RENDER));
|
||||
|
||||
@@ -45,9 +45,9 @@ void AgFans::ToggleFX(Entity* self, bool hit) {
|
||||
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS));
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(false);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
Game::entityManager->SerializeEntity(volume);
|
||||
if (!hit) {
|
||||
Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0];
|
||||
Entity* fxObj = Game::entityManager->GetEntitiesInGroup(fanGroup + "fx")[0];
|
||||
RenderComponent::PlayAnimation(fxObj, u"trigger");
|
||||
}
|
||||
}
|
||||
@@ -61,9 +61,9 @@ void AgFans::ToggleFX(Entity* self, bool hit) {
|
||||
PhantomPhysicsComponent* volumePhys = static_cast<PhantomPhysicsComponent*>(volume->GetComponent(eReplicaComponentType::PHANTOM_PHYSICS));
|
||||
if (!volumePhys) continue;
|
||||
volumePhys->SetPhysicsEffectActive(true);
|
||||
EntityManager::Instance()->SerializeEntity(volume);
|
||||
Game::entityManager->SerializeEntity(volume);
|
||||
if (!hit) {
|
||||
Entity* fxObj = EntityManager::Instance()->GetEntitiesInGroup(fanGroup + "fx")[0];
|
||||
Entity* fxObj = Game::entityManager->GetEntitiesInGroup(fanGroup + "fx")[0];
|
||||
RenderComponent::PlayAnimation(fxObj, u"idle");
|
||||
}
|
||||
}
|
||||
|
@@ -36,9 +36,9 @@ void AgImagSmashable::CrateAnimal(Entity* self) {
|
||||
info.spawnerID = self->GetSpawnerID();
|
||||
info.spawnerNodeID = 0;
|
||||
|
||||
Entity* newEntity = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
Entity* newEntity = Game::entityManager->CreateEntity(info, nullptr);
|
||||
if (newEntity) {
|
||||
EntityManager::Instance()->ConstructEntity(newEntity);
|
||||
Game::entityManager->ConstructEntity(newEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -12,7 +12,7 @@ void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
|
||||
);
|
||||
inUse = true;
|
||||
|
||||
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
|
||||
auto entities = Game::entityManager->GetEntitiesInGroup("Jet_FX");
|
||||
if (entities.empty()) return;
|
||||
GameMessages::SendPlayFXEffect(entities.at(0), 641, u"create", "radarDish", LWOOBJID_EMPTY, 1, 1, true);
|
||||
self->AddTimer("radarDish", 2.0f);
|
||||
@@ -22,7 +22,7 @@ void AgJetEffectServer::OnUse(Entity* self, Entity* user) {
|
||||
|
||||
void AgJetEffectServer::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
if (self->GetLOT() != 6209) return;
|
||||
auto entities = EntityManager::Instance()->GetEntitiesInGroup("Jet_FX");
|
||||
auto entities = Game::entityManager->GetEntitiesInGroup("Jet_FX");
|
||||
if (entities.empty()) return;
|
||||
RenderComponent::PlayAnimation(entities.at(0), u"jetFX");
|
||||
|
||||
@@ -40,7 +40,7 @@ void AgJetEffectServer::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "radarDish") {
|
||||
GameMessages::SendStopFXEffect(self, true, "radarDish");
|
||||
} else if (timerName == "PlayEffect") {
|
||||
auto entities = EntityManager::Instance()->GetEntitiesInGroup("mortarMain");
|
||||
auto entities = Game::entityManager->GetEntitiesInGroup("mortarMain");
|
||||
if (entities.empty()) return;
|
||||
|
||||
const auto selected = GeneralUtils::GenerateRandomNumber<int>(0, entities.size() - 1);
|
||||
|
@@ -26,7 +26,7 @@ void AgQbElevator::OnProximityUpdate(Entity* self, Entity* entering, std::string
|
||||
if (self->GetBoolean(u"qbPlayerRdy")) return;
|
||||
|
||||
if (status == "ENTER") {
|
||||
Entity* builder = EntityManager::Instance()->GetEntity(self->GetI64(u"qbPlayer"));
|
||||
Entity* builder = Game::entityManager->GetEntity(self->GetI64(u"qbPlayer"));
|
||||
if (builder && builder == entering) {
|
||||
//the builder has entered so cancel the start timer and just start moving
|
||||
self->SetBoolean(u"qbPlayerRdy", true);
|
||||
|
@@ -4,7 +4,7 @@ void AgQbWall::OnRebuildComplete(Entity* self, Entity* player) {
|
||||
self->SetVar(u"player", player->GetObjectID());
|
||||
auto targetWallSpawners = GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"spawner"));
|
||||
if (targetWallSpawners != "") {
|
||||
auto groupObjs = EntityManager::Instance()->GetEntitiesInGroup(targetWallSpawners);
|
||||
auto groupObjs = Game::entityManager->GetEntitiesInGroup(targetWallSpawners);
|
||||
for (auto* obj : groupObjs) {
|
||||
if (obj) {
|
||||
obj->SetVar(u"player", player->GetObjectID());
|
||||
|
@@ -15,9 +15,9 @@ void AgSpaceStuff::OnStartup(Entity* self) {
|
||||
info.lot = 33;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* ref = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* ref = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(ref);
|
||||
Game::entityManager->ConstructEntity(ref);
|
||||
|
||||
self->SetVar(u"ShakeObject", ref->GetObjectID());
|
||||
|
||||
@@ -47,7 +47,7 @@ void AgSpaceStuff::OnTimerDone(Entity* self, std::string timerName) {
|
||||
void AgSpaceStuff::DoShake(Entity* self, bool explodeIdle) {
|
||||
|
||||
if (!explodeIdle) {
|
||||
auto* ref = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"ShakeObject"));
|
||||
auto* ref = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"ShakeObject"));
|
||||
|
||||
const auto randomTime = self->GetVar<int>(u"RandomTime");
|
||||
auto time = GeneralUtils::GenerateRandomNumber<int>(0, randomTime + 1);
|
||||
@@ -92,7 +92,7 @@ void AgSpaceStuff::DoShake(Entity* self, bool explodeIdle) {
|
||||
}
|
||||
|
||||
Entity* AgSpaceStuff::GetEntityInGroup(const std::string& group) {
|
||||
auto entities = EntityManager::Instance()->GetEntitiesInGroup(group);
|
||||
auto entities = Game::entityManager->GetEntitiesInGroup(group);
|
||||
Entity* en = nullptr;
|
||||
|
||||
for (auto entity : entities) {
|
||||
|
Reference in New Issue
Block a user