mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
remove singleton for dpWorld (#1427)
Removes the singleton inheritance from dpWorld. Tested that crux prime, nimbus station, avant gardens and nexus tower still use navmeshes and physics and that physics volumes are still collided with.
This commit is contained in:
@@ -9,6 +9,21 @@
|
||||
#include "Logger.h"
|
||||
#include "dConfig.h"
|
||||
|
||||
#include "dNavMesh.h"
|
||||
|
||||
namespace {
|
||||
dpGrid* m_Grid = nullptr;
|
||||
dNavMesh* m_NavMesh = nullptr;
|
||||
int32_t phys_sp_tilesize = 205;
|
||||
int32_t phys_sp_tilecount = 12;
|
||||
|
||||
uint32_t m_ZoneID = 0;
|
||||
|
||||
std::vector<dpEntity*> m_StaticEntities;
|
||||
std::vector<dpEntity*> m_DynamicEntites;
|
||||
bool phys_spatial_partitioning = true;
|
||||
};
|
||||
|
||||
void dpWorld::Initialize(unsigned int zoneID, bool generateNewNavMesh) {
|
||||
const auto physSpTilecount = Game::config->GetValue("phys_sp_tilecount");
|
||||
if (!physSpTilecount.empty()) GeneralUtils::TryParse(physSpTilecount, phys_sp_tilecount);
|
||||
@@ -51,7 +66,7 @@ void dpWorld::Reload() {
|
||||
}
|
||||
}
|
||||
|
||||
dpWorld::~dpWorld() {
|
||||
void dpWorld::Shutdown() {
|
||||
if (m_Grid) {
|
||||
// Triple check this is true
|
||||
m_Grid->SetDeleteGrid(true);
|
||||
@@ -65,6 +80,10 @@ dpWorld::~dpWorld() {
|
||||
}
|
||||
}
|
||||
|
||||
bool dpWorld::IsLoaded() {
|
||||
return m_NavMesh->GetdtNavMesh() != nullptr;
|
||||
}
|
||||
|
||||
void dpWorld::StepWorld(float deltaTime) {
|
||||
if (m_Grid) {
|
||||
m_Grid->Update(deltaTime);
|
||||
@@ -91,6 +110,10 @@ void dpWorld::StepWorld(float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
dNavMesh* dpWorld::GetNavMesh() {
|
||||
return m_NavMesh;
|
||||
}
|
||||
|
||||
void dpWorld::AddEntity(dpEntity* entity) {
|
||||
if (m_Grid) entity->SetGrid(m_Grid); //This sorts this entity into the right cell
|
||||
else { //old method, slow
|
||||
@@ -125,7 +148,7 @@ void dpWorld::RemoveEntity(dpEntity* entity) {
|
||||
}
|
||||
}
|
||||
|
||||
bool dpWorld::ShouldUseSP(unsigned int zoneID) {
|
||||
bool dpWorld::ShouldUseSP(uint32_t zoneID) {
|
||||
if (!phys_spatial_partitioning) return false;
|
||||
|
||||
// TODO: Add to this list as needed.
|
||||
|
Reference in New Issue
Block a user