mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-11 09:58:05 +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:
@@ -36,13 +36,13 @@ void CavePrisonCage::Setup(Entity* self, Spawner* spawner) {
|
||||
info.spawnerID = self->GetObjectID();
|
||||
|
||||
// Spawn the villager inside the jail
|
||||
auto* entity = EntityManager::Instance()->CreateEntity(info);
|
||||
auto* entity = Game::entityManager->CreateEntity(info);
|
||||
|
||||
// Save the villeger ID
|
||||
self->SetVar<LWOOBJID>(u"villager", entity->GetObjectID());
|
||||
|
||||
// Construct the entity
|
||||
EntityManager::Instance()->ConstructEntity(entity);
|
||||
Game::entityManager->ConstructEntity(entity);
|
||||
}
|
||||
|
||||
void CavePrisonCage::OnRebuildNotifyState(Entity* self, eRebuildState state) {
|
||||
@@ -77,7 +77,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
|
||||
|
||||
rebuildComponent->AddRebuildCompleteCallback([this, self](Entity* user) {
|
||||
// The counterweight is a simple mover, which is not implemented, so we'll just set it's position
|
||||
auto* counterweight = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Counterweight"));
|
||||
auto* counterweight = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Counterweight"));
|
||||
|
||||
if (counterweight == nullptr) {
|
||||
return;
|
||||
@@ -87,7 +87,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
|
||||
counterweight->SetPosition(counterweight->GetPosition() + NiPoint3(0, -2, 0));
|
||||
|
||||
// Serialize the counterweight
|
||||
EntityManager::Instance()->SerializeEntity(counterweight);
|
||||
Game::entityManager->SerializeEntity(counterweight);
|
||||
|
||||
// notifyPlatformAtLastWaypoint
|
||||
|
||||
@@ -95,7 +95,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
|
||||
self->SetVar<LWOOBJID>(u"Builder", user->GetObjectID());
|
||||
|
||||
// Get the button and make sure it still exists
|
||||
auto* button = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Button"));
|
||||
auto* button = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Button"));
|
||||
|
||||
if (button == nullptr) {
|
||||
return;
|
||||
@@ -117,7 +117,7 @@ void CavePrisonCage::SpawnCounterweight(Entity* self, Spawner* spawner) {
|
||||
}
|
||||
|
||||
void CavePrisonCage::GetButton(Entity* self) {
|
||||
const auto buttons = EntityManager::Instance()->GetEntitiesInGroup("PrisonButton_0" + std::to_string(self->GetVarAs<int32_t>(u"myNumber")));
|
||||
const auto buttons = Game::entityManager->GetEntitiesInGroup("PrisonButton_0" + std::to_string(self->GetVarAs<int32_t>(u"myNumber")));
|
||||
|
||||
if (buttons.size() == 0) {
|
||||
// Try again in 0.5 seconds
|
||||
@@ -146,7 +146,7 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
RenderComponent::PlayAnimation(self, u"idle-up");
|
||||
|
||||
// Get the villeger
|
||||
auto* villager = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"villager"));
|
||||
auto* villager = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"villager"));
|
||||
|
||||
if (villager == nullptr) {
|
||||
return;
|
||||
@@ -155,7 +155,7 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
GameMessages::SendNotifyClientObject(villager->GetObjectID(), u"TimeToChat", 0, 0, LWOOBJID_EMPTY, "", UNASSIGNED_SYSTEM_ADDRESS);
|
||||
|
||||
// Get the builder and make sure it still exists
|
||||
auto* builder = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Builder"));
|
||||
auto* builder = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Builder"));
|
||||
|
||||
if (builder == nullptr) {
|
||||
return;
|
||||
@@ -170,7 +170,7 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
self->AddTimer("VillagerEscape", 5.0f);
|
||||
} else if (timerName == "VillagerEscape") {
|
||||
// Get the villeger and make sure it still exists
|
||||
auto* villager = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"villager"));
|
||||
auto* villager = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"villager"));
|
||||
|
||||
if (villager == nullptr) {
|
||||
return;
|
||||
@@ -183,7 +183,7 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
self->AddTimer("SmashCounterweight", 2.0f);
|
||||
} else if (timerName == "SmashCounterweight") {
|
||||
// Get the counterweight and make sure it still exists
|
||||
auto* counterweight = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Counterweight"));
|
||||
auto* counterweight = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Counterweight"));
|
||||
|
||||
if (counterweight == nullptr) {
|
||||
return;
|
||||
@@ -193,7 +193,7 @@ void CavePrisonCage::OnTimerDone(Entity* self, std::string timerName) {
|
||||
counterweight->Smash();
|
||||
|
||||
// Get the button and make sure it still exists
|
||||
auto* button = EntityManager::Instance()->GetEntity(self->GetVar<LWOOBJID>(u"Button"));
|
||||
auto* button = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"Button"));
|
||||
|
||||
if (button == nullptr) {
|
||||
return;
|
||||
|
Reference in New Issue
Block a user