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:
@@ -27,16 +27,16 @@ void AmBlueX::OnSkillEventFired(Entity* self, Entity* caster, const std::string&
|
||||
info.rot = self->GetRotation();
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* fxObject = EntityManager::Instance()->CreateEntity(info, nullptr, self);
|
||||
EntityManager::Instance()->ConstructEntity(fxObject);
|
||||
auto* fxObject = Game::entityManager->CreateEntity(info, nullptr, self);
|
||||
Game::entityManager->ConstructEntity(fxObject);
|
||||
|
||||
auto fxObjectID = fxObject->GetObjectID();
|
||||
auto playerID = caster->GetObjectID();
|
||||
|
||||
// Add a callback for the bomb to explode
|
||||
self->AddCallbackTimer(m_BombTime, [this, self, fxObjectID, playerID]() {
|
||||
auto* fxObject = EntityManager::Instance()->GetEntity(fxObjectID);
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* fxObject = Game::entityManager->GetEntity(fxObjectID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
auto* skillComponent = self->GetComponent<SkillComponent>();
|
||||
|
||||
if (skillComponent == nullptr)
|
||||
|
@@ -6,7 +6,7 @@ void AmBridge::OnStartup(Entity* self) {
|
||||
}
|
||||
|
||||
void AmBridge::OnRebuildComplete(Entity* self, Entity* target) {
|
||||
const auto consoles = EntityManager::Instance()->GetEntitiesInGroup("Console" + GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"bridge")));
|
||||
const auto consoles = Game::entityManager->GetEntitiesInGroup("Console" + GeneralUtils::UTF16ToWTF8(self->GetVar<std::u16string>(u"bridge")));
|
||||
|
||||
if (consoles.empty()) {
|
||||
return;
|
||||
|
@@ -68,7 +68,7 @@ void AmDrawBridge::OnTimerDone(Entity* self, std::string timerName) {
|
||||
|
||||
simplePhysicsComponent->SetAngularVelocity(NiPoint3::ZERO);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(bridge);
|
||||
Game::entityManager->SerializeEntity(bridge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void AmDrawBridge::MoveBridgeDown(Entity* self, Entity* bridge, bool down) {
|
||||
|
||||
simplePhysicsComponent->SetAngularVelocity(forwardVect);
|
||||
|
||||
EntityManager::Instance()->SerializeEntity(bridge);
|
||||
Game::entityManager->SerializeEntity(bridge);
|
||||
|
||||
self->AddTimer("rotateBridgeDown", travelTime);
|
||||
}
|
||||
@@ -118,5 +118,5 @@ void AmDrawBridge::NotifyDie(Entity* self, Entity* other) {
|
||||
Entity* AmDrawBridge::GetBridge(Entity* self) {
|
||||
const auto bridgeID = self->GetVar<LWOOBJID>(u"BridgeID");
|
||||
|
||||
return EntityManager::Instance()->GetEntity(bridgeID);
|
||||
return Game::entityManager->GetEntity(bridgeID);
|
||||
}
|
||||
|
@@ -49,7 +49,7 @@ void AmShieldGenerator::OnProximityUpdate(Entity* self, Entity* entering, std::s
|
||||
void AmShieldGenerator::OnDie(Entity* self, Entity* killer) {
|
||||
self->CancelAllTimers();
|
||||
|
||||
auto* child = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Child"));
|
||||
auto* child = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Child"));
|
||||
|
||||
if (child != nullptr) {
|
||||
child->Kill();
|
||||
@@ -69,7 +69,7 @@ void AmShieldGenerator::OnTimerDone(Entity* self, std::string timerName) {
|
||||
auto enemiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Enemies");
|
||||
|
||||
for (const auto enemyID : enemiesInProximity) {
|
||||
auto* enemy = EntityManager::Instance()->GetEntity(enemyID);
|
||||
auto* enemy = Game::entityManager->GetEntity(enemyID);
|
||||
|
||||
if (enemy != nullptr) {
|
||||
EnemyEnteredShield(self, enemy);
|
||||
@@ -94,7 +94,7 @@ void AmShieldGenerator::StartShield(Entity* self) {
|
||||
info.rot = myRot;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* child = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* child = Game::entityManager->CreateEntity(info);
|
||||
|
||||
self->SetVar(u"Child", child->GetObjectID());
|
||||
|
||||
@@ -111,7 +111,7 @@ void AmShieldGenerator::BuffPlayers(Entity* self) {
|
||||
auto entitiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Players");
|
||||
|
||||
for (const auto playerID : entitiesInProximity) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
|
@@ -69,7 +69,7 @@ void AmShieldGeneratorQuickbuild::OnProximityUpdate(Entity* self, Entity* enteri
|
||||
void AmShieldGeneratorQuickbuild::OnDie(Entity* self, Entity* killer) {
|
||||
self->CancelAllTimers();
|
||||
|
||||
auto* child = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Child"));
|
||||
auto* child = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Child"));
|
||||
|
||||
if (child != nullptr) {
|
||||
child->Kill();
|
||||
@@ -89,7 +89,7 @@ void AmShieldGeneratorQuickbuild::OnTimerDone(Entity* self, std::string timerNam
|
||||
auto enemiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Enemies");
|
||||
|
||||
for (const auto enemyID : enemiesInProximity) {
|
||||
auto* enemy = EntityManager::Instance()->GetEntity(enemyID);
|
||||
auto* enemy = Game::entityManager->GetEntity(enemyID);
|
||||
|
||||
if (enemy != nullptr) {
|
||||
EnemyEnteredShield(self, enemy);
|
||||
@@ -106,7 +106,7 @@ void AmShieldGeneratorQuickbuild::OnRebuildComplete(Entity* self, Entity* target
|
||||
auto enemiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Enemies");
|
||||
|
||||
for (const auto enemyID : enemiesInProximity) {
|
||||
auto* enemy = EntityManager::Instance()->GetEntity(enemyID);
|
||||
auto* enemy = Game::entityManager->GetEntity(enemyID);
|
||||
|
||||
if (enemy != nullptr) {
|
||||
enemy->Smash();
|
||||
@@ -116,7 +116,7 @@ void AmShieldGeneratorQuickbuild::OnRebuildComplete(Entity* self, Entity* target
|
||||
auto entitiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Players");
|
||||
|
||||
for (const auto playerID : entitiesInProximity) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
continue;
|
||||
@@ -146,7 +146,7 @@ void AmShieldGeneratorQuickbuild::StartShield(Entity* self) {
|
||||
info.rot = myRot;
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* child = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* child = Game::entityManager->CreateEntity(info);
|
||||
|
||||
self->SetVar(u"Child", child->GetObjectID());
|
||||
|
||||
@@ -163,7 +163,7 @@ void AmShieldGeneratorQuickbuild::BuffPlayers(Entity* self) {
|
||||
auto entitiesInProximity = self->GetVar<std::vector<LWOOBJID>>(u"Players");
|
||||
|
||||
for (const auto playerID : entitiesInProximity) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
|
@@ -44,7 +44,7 @@ Entity* AmSkullkinDrill::GetStandObj(Entity* self) {
|
||||
|
||||
groupName.push_back(myGroup[0][myGroup[0].size() - 1]);
|
||||
|
||||
const auto standObjs = EntityManager::Instance()->GetEntitiesInGroup(groupName);
|
||||
const auto standObjs = Game::entityManager->GetEntitiesInGroup(groupName);
|
||||
|
||||
if (standObjs.empty()) {
|
||||
return nullptr;
|
||||
@@ -105,16 +105,16 @@ void AmSkullkinDrill::OnWaypointReached(Entity* self, uint32_t waypointIndex) {
|
||||
info.scale = 3; // Needs the scale, otherwise attacks fail
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
auto* child = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* child = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(child);
|
||||
Game::entityManager->ConstructEntity(child);
|
||||
|
||||
self->SetVar(u"ChildSmash", child->GetObjectID());
|
||||
|
||||
child->AddDieCallback([this, self]() {
|
||||
const auto& userID = self->GetVar<LWOOBJID>(u"activaterID");
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(userID);
|
||||
auto* player = Game::entityManager->GetEntity(userID);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
@@ -180,7 +180,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) {
|
||||
|
||||
const auto playerID = self->GetVar<LWOOBJID>(u"userID");
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player != nullptr) {
|
||||
PlayAnim(self, player, "spinjitzu-staff-end");
|
||||
@@ -199,7 +199,7 @@ void AmSkullkinDrill::OnArrived(Entity* self, uint32_t waypointIndex) {
|
||||
}
|
||||
|
||||
void AmSkullkinDrill::PlayCinematic(Entity* self) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"userID"));
|
||||
auto* player = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"userID"));
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
@@ -235,7 +235,7 @@ void AmSkullkinDrill::OnHitOrHealResult(Entity* self, Entity* attacker, int32_t
|
||||
|
||||
const auto activaterID = self->GetVar<LWOOBJID>(u"activaterID");
|
||||
|
||||
auto* activator = EntityManager::Instance()->GetEntity(activaterID);
|
||||
auto* activator = Game::entityManager->GetEntity(activaterID);
|
||||
|
||||
// TODO: Missions
|
||||
if (activator != nullptr) {
|
||||
@@ -263,7 +263,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) {
|
||||
if (timerName == "killDrill") {
|
||||
const auto childID = self->GetVar<LWOOBJID>(u"ChildSmash");
|
||||
|
||||
auto* child = EntityManager::Instance()->GetEntity(childID);
|
||||
auto* child = Game::entityManager->GetEntity(childID);
|
||||
|
||||
if (child != nullptr) {
|
||||
child->Smash(self->GetObjectID(), eKillType::SILENT);
|
||||
@@ -301,7 +301,7 @@ void AmSkullkinDrill::OnTimerDone(Entity* self, std::string timerName) {
|
||||
|
||||
const auto playerID = self->GetVar<LWOOBJID>(u"userID");
|
||||
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
return;
|
||||
|
@@ -64,9 +64,9 @@ void AmSkullkinTower::SpawnLegs(Entity* self, const std::string& loc) {
|
||||
|
||||
info.rot = NiQuaternion::LookAt(info.pos, self->GetPosition());
|
||||
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* entity = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
|
||||
OnChildLoaded(self, entity);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ void AmSkullkinTower::OnChildLoaded(Entity* self, Entity* child) {
|
||||
const auto selfID = self->GetObjectID();
|
||||
|
||||
child->AddDieCallback([this, selfID, child]() {
|
||||
auto* self = EntityManager::Instance()->GetEntity(selfID);
|
||||
auto* self = Game::entityManager->GetEntity(selfID);
|
||||
auto* destroyableComponent = child->GetComponent<DestroyableComponent>();
|
||||
|
||||
if (destroyableComponent == nullptr || self == nullptr) {
|
||||
@@ -157,7 +157,7 @@ void AmSkullkinTower::OnChildRemoved(Entity* self, Entity* child) {
|
||||
const auto& players = self->GetVar<std::vector<LWOOBJID>>(u"Players");
|
||||
|
||||
for (const auto& playerID : players) {
|
||||
auto* player = EntityManager::Instance()->GetEntity(playerID);
|
||||
auto* player = Game::entityManager->GetEntity(playerID);
|
||||
|
||||
if (player == nullptr) {
|
||||
continue;
|
||||
@@ -233,9 +233,9 @@ void AmSkullkinTower::OnTimerDone(Entity* self, std::string timerName) {
|
||||
for (size_t i = 0; i < 2; i++) {
|
||||
info.pos.x += i * 2; // Just to set the apart a bit
|
||||
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* entity = Game::entityManager->CreateEntity(info);
|
||||
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
}
|
||||
|
||||
self->AddTimer("killTower", 0.7f);
|
||||
|
Reference in New Issue
Block a user