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:
@@ -61,13 +61,13 @@ void BossSpiderQueenEnemyServer::OnDie(Entity* self, Entity* killer) {
|
||||
}
|
||||
|
||||
// There is suppose to be a 0.1 second delay here but that may be admitted?
|
||||
auto* controller = EntityManager::Instance()->GetZoneControlEntity();
|
||||
auto* controller = Game::entityManager->GetZoneControlEntity();
|
||||
|
||||
GameMessages::SendNotifyClientObject(self->GetObjectID(), u"SetColGroup", 10, 0, 0, "", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
self->SetPosition({ 10000, 0, 10000 });
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
controller->OnFireEventServerSide(self, "ClearProperty");
|
||||
}
|
||||
@@ -97,7 +97,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
|
||||
|
||||
rot = controllable->GetRotation();
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
auto* baseCombatAi = self->GetComponent<BaseCombatAIComponent>();
|
||||
|
||||
@@ -113,7 +113,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
|
||||
//TODO: Set faction to -1 and set immunity
|
||||
destroyable->SetFaction(-1);
|
||||
destroyable->SetIsImmune(true);
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
self->AddTimer("WithdrawComplete", withdrawTime + 1.0f);
|
||||
waitForIdle = true;
|
||||
@@ -146,7 +146,7 @@ void BossSpiderQueenEnemyServer::WithdrawSpider(Entity* self, const bool withdra
|
||||
//Reset the current wave death counter
|
||||
m_DeathCounter = 0;
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
// Prepare a timer for post leap attack
|
||||
self->AddTimer("AdvanceAttack", attackPause);
|
||||
@@ -179,7 +179,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
|
||||
|
||||
std::vector<LWOOBJID> spiderEggs{};
|
||||
|
||||
auto spooders = EntityManager::Instance()->GetEntitiesInGroup("EGG");
|
||||
auto spooders = Game::entityManager->GetEntitiesInGroup("EGG");
|
||||
for (auto spodder : spooders) {
|
||||
spiderEggs.push_back(spodder->GetObjectID());
|
||||
}
|
||||
@@ -201,7 +201,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
|
||||
}
|
||||
|
||||
if (randomEgg) {
|
||||
auto* eggEntity = EntityManager::Instance()->GetEntity(randomEgg);
|
||||
auto* eggEntity = Game::entityManager->GetEntity(randomEgg);
|
||||
|
||||
if (eggEntity == nullptr) {
|
||||
continue;
|
||||
@@ -234,7 +234,7 @@ void BossSpiderQueenEnemyServer::SpiderWaveManager(Entity* self) {
|
||||
// We have successfully readied a full wave
|
||||
// initiate hatching!
|
||||
for (auto egg : hatchList) {
|
||||
auto* eggEntity = EntityManager::Instance()->GetEntity(egg);
|
||||
auto* eggEntity = Game::entityManager->GetEntity(egg);
|
||||
|
||||
if (eggEntity == nullptr) {
|
||||
continue;
|
||||
@@ -304,7 +304,7 @@ void BossSpiderQueenEnemyServer::RunRainOfFire(Entity* self) {
|
||||
|
||||
void BossSpiderQueenEnemyServer::RainOfFireManager(Entity* self) {
|
||||
if (!impactList.empty()) {
|
||||
auto* entity = EntityManager::Instance()->GetEntity(impactList[0]);
|
||||
auto* entity = Game::entityManager->GetEntity(impactList[0]);
|
||||
|
||||
impactList.erase(impactList.begin());
|
||||
|
||||
@@ -408,7 +408,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
|
||||
controllable->SetStatic(false);
|
||||
controllable->SetRotation(rot);
|
||||
controllable->SetStatic(true);
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
//Play the Spider Boss' mountain idle anim
|
||||
auto time = PlayAnimAndReturnTime(self, spiderWithdrawIdle);
|
||||
@@ -419,7 +419,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
|
||||
rot = controllable->GetRotation();
|
||||
|
||||
//If there are still baby spiders, don't do anyhting either
|
||||
const auto spiders = EntityManager::Instance()->GetEntitiesInGroup("BabySpider");
|
||||
const auto spiders = Game::entityManager->GetEntitiesInGroup("BabySpider");
|
||||
if (spiders.size() > 0)
|
||||
self->AddTimer("checkForSpiders", time);
|
||||
else
|
||||
@@ -491,7 +491,7 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
|
||||
}*/
|
||||
|
||||
auto landingTarget = self->GetI64(u"LandingTarget");
|
||||
auto landingEntity = EntityManager::Instance()->GetEntity(landingTarget);
|
||||
auto landingEntity = Game::entityManager->GetEntity(landingTarget);
|
||||
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
|
||||
@@ -547,10 +547,10 @@ void BossSpiderQueenEnemyServer::OnTimerDone(Entity* self, const std::string tim
|
||||
destroyable->SetIsImmune(false);
|
||||
destroyable->SetFaction(4);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
|
||||
} else if (timerName == "Clear") {
|
||||
EntityManager::Instance()->FireEventServerSide(self, "ClearProperty");
|
||||
Game::entityManager->FireEventServerSide(self, "ClearProperty");
|
||||
self->CancelAllTimers();
|
||||
} else if (timerName == "UnlockSpecials") {
|
||||
//We no longer need to lock specials
|
||||
@@ -605,7 +605,7 @@ void BossSpiderQueenEnemyServer::OnUpdate(Entity* self) {
|
||||
controllable->SetRotation(NiQuaternion::IDENTITY);
|
||||
controllable->SetStatic(true);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
}
|
||||
|
||||
//----------------------------------------------
|
||||
|
@@ -28,7 +28,7 @@ void AmDarklingDragon::OnDie(Entity* self, Entity* killer) {
|
||||
|
||||
auto golemId = self->GetVar<LWOOBJID>(u"Golem");
|
||||
|
||||
auto* golem = EntityManager::Instance()->GetEntity(golemId);
|
||||
auto* golem = Game::entityManager->GetEntity(golemId);
|
||||
|
||||
if (golem != nullptr) {
|
||||
golem->Smash(self->GetObjectID());
|
||||
@@ -109,9 +109,9 @@ void AmDarklingDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
|
||||
new LDFData<LWOOBJID>(u"Dragon", self->GetObjectID())
|
||||
};
|
||||
|
||||
auto* golemObject = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* golemObject = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(golemObject);
|
||||
Game::entityManager->ConstructEntity(golemObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
void FvMaelstromCavalry::OnStartup(Entity* self) {
|
||||
for (const auto& group : self->GetGroups()) {
|
||||
const auto& objects = EntityManager::Instance()->GetEntitiesInGroup(group);
|
||||
const auto& objects = Game::entityManager->GetEntitiesInGroup(group);
|
||||
|
||||
for (auto* obj : objects) {
|
||||
if (obj->GetLOT() != 8551) continue;
|
||||
@@ -22,7 +22,7 @@ void FvMaelstromCavalry::OnDie(Entity* self, Entity* killer) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto& triggers = EntityManager::Instance()->GetEntitiesInGroup("HorsemenTrigger");
|
||||
const auto& triggers = Game::entityManager->GetEntitiesInGroup("HorsemenTrigger");
|
||||
|
||||
for (auto* trigger : triggers) {
|
||||
trigger->OnFireEventServerSide(self, "HorsemenDeath");
|
||||
|
@@ -35,13 +35,13 @@ void FvMaelstromDragon::OnDie(Entity* self, Entity* killer) {
|
||||
info.rot = rotation;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* chest = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* chest = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(chest);
|
||||
Game::entityManager->ConstructEntity(chest);
|
||||
|
||||
auto golemId = self->GetVar<LWOOBJID>(u"Golem");
|
||||
|
||||
auto* golem = EntityManager::Instance()->GetEntity(golemId);
|
||||
auto* golem = Game::entityManager->GetEntity(golemId);
|
||||
|
||||
if (golem != nullptr) {
|
||||
golem->Smash(self->GetObjectID());
|
||||
@@ -125,9 +125,9 @@ void FvMaelstromDragon::OnHitOrHealResult(Entity* self, Entity* attacker, int32_
|
||||
new LDFData<LWOOBJID>(u"Dragon", self->GetObjectID())
|
||||
};
|
||||
|
||||
auto* golemObject = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* golemObject = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(golemObject);
|
||||
Game::entityManager->ConstructEntity(golemObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ void BaseEnemyApe::OnStartup(Entity* self) {
|
||||
}
|
||||
|
||||
void BaseEnemyApe::OnDie(Entity* self, Entity* killer) {
|
||||
auto* anchor = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"QB"));
|
||||
auto* anchor = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"QB"));
|
||||
if (anchor != nullptr && !anchor->GetIsDead()) {
|
||||
anchor->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (destroyableComponent != nullptr) {
|
||||
destroyableComponent->SetArmor(destroyableComponent->GetMaxArmor() / timesStunned);
|
||||
}
|
||||
EntityManager::Instance()->SerializeEntity(self);
|
||||
Game::entityManager->SerializeEntity(self);
|
||||
GameMessages::SendChangeIdleFlags(self->GetObjectID(), eAnimationFlags::IDLE_COMBAT, eAnimationFlags::IDLE_NONE, UNASSIGNED_SYSTEM_ADDRESS);
|
||||
self->SetVar<uint32_t>(u"timesStunned", timesStunned + 1);
|
||||
StunApe(self, false);
|
||||
@@ -92,14 +92,14 @@ void BaseEnemyApe::OnTimerDone(Entity* self, std::string timerName) {
|
||||
new LDFData<LWOOBJID>(u"ape", self->GetObjectID())
|
||||
};
|
||||
|
||||
auto* anchor = EntityManager::Instance()->CreateEntity(entityInfo);
|
||||
EntityManager::Instance()->ConstructEntity(anchor);
|
||||
auto* anchor = Game::entityManager->CreateEntity(entityInfo);
|
||||
Game::entityManager->ConstructEntity(anchor);
|
||||
self->SetVar<LWOOBJID>(u"QB", anchor->GetObjectID());
|
||||
|
||||
} else if (timerName == "anchorDamageTimer") {
|
||||
|
||||
// Attacks the ape with some god skill
|
||||
const auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"smasher"));
|
||||
const auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"smasher"));
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
@@ -38,8 +38,8 @@ void BaseEnemyMech::OnDie(Entity* self, Entity* killer) {
|
||||
info.spawnerID = self->GetObjectID();
|
||||
info.settings = cfg;
|
||||
|
||||
Entity* turret = EntityManager::Instance()->CreateEntity(info, nullptr);
|
||||
Entity* turret = Game::entityManager->CreateEntity(info, nullptr);
|
||||
if (turret) {
|
||||
EntityManager::Instance()->ConstructEntity(turret);
|
||||
Game::entityManager->ConstructEntity(turret);
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,7 @@ void GfApeSmashingQB::OnTimerDone(Entity* self, std::string timerName) {
|
||||
}
|
||||
|
||||
void GfApeSmashingQB::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
auto* ape = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"ape"));
|
||||
auto* ape = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"ape"));
|
||||
if (ape != nullptr) {
|
||||
ape->OnFireEventServerSide(target, "rebuildDone");
|
||||
RenderComponent::PlayAnimation(self, u"smash", 1.7f);
|
||||
|
@@ -29,7 +29,7 @@ void TreasureChestDragonServer::OnUse(Entity* self, Entity* user) {
|
||||
rating = team->members.size();
|
||||
|
||||
for (const auto member : team->members) {
|
||||
auto* memberObject = EntityManager::Instance()->GetEntity(member);
|
||||
auto* memberObject = Game::entityManager->GetEntity(member);
|
||||
|
||||
if (memberObject == nullptr) continue;
|
||||
|
||||
|
Reference in New Issue
Block a user