Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/Simulation2.cpp
Show All 37 Lines | |||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/ConfigDB.h" | #include "ps/ConfigDB.h" | ||||
#include "ps/Filesystem.h" | #include "ps/Filesystem.h" | ||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/Profile.h" | #include "ps/Profile.h" | ||||
#include "ps/Pyrogenesis.h" | #include "ps/Pyrogenesis.h" | ||||
#include "ps/Util.h" | #include "ps/Util.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
#include "renderer/RenderingOptions.h" | |||||
#include <iomanip> | #include <iomanip> | ||||
class CSimulation2Impl | class CSimulation2Impl | ||||
{ | { | ||||
public: | public: | ||||
CSimulation2Impl(CUnitManager* unitManager, shared_ptr<ScriptRuntime> rt, CTerrain* terrain) : | CSimulation2Impl(CUnitManager* unitManager, shared_ptr<ScriptRuntime> rt, CTerrain* terrain) : | ||||
m_SimContext(), m_ComponentManager(m_SimContext, rt), | m_SimContext(), m_ComponentManager(m_SimContext, rt), | ||||
▲ Show 20 Lines • Show All 628 Lines • ▼ Show 20 Lines | |||||
entity_id_t CSimulation2::AddEntity(const std::wstring& templateName, entity_id_t preferredId) | entity_id_t CSimulation2::AddEntity(const std::wstring& templateName, entity_id_t preferredId) | ||||
{ | { | ||||
return m->m_ComponentManager.AddEntity(templateName, m->m_ComponentManager.AllocateNewEntity(preferredId)); | return m->m_ComponentManager.AddEntity(templateName, m->m_ComponentManager.AllocateNewEntity(preferredId)); | ||||
} | } | ||||
entity_id_t CSimulation2::AddLocalEntity(const std::wstring& templateName) | entity_id_t CSimulation2::AddLocalEntity(const std::wstring& templateName) | ||||
{ | { | ||||
return m->m_ComponentManager.AddEntity(templateName, m->m_ComponentManager.AllocateNewLocalEntity()); | entity_id_t newEnt = INVALID_ENTITY; | ||||
bool isCorpse = templateName.find(L"corpse|") != std::string::npos; | |||||
if (isCorpse) | |||||
{ | |||||
int maxCorpses = g_RenderingOptions.GetMaxRagDolls(); | |||||
if (maxCorpses != -1 && CComponentManager::m_Corpses.size() >= static_cast<size_t>(maxCorpses)) | |||||
return newEnt; | |||||
newEnt = m->m_ComponentManager.AllocateNewLocalEntity(); | |||||
CComponentManager::m_Corpses.push_back(newEnt); | |||||
} | |||||
else | |||||
newEnt = m->m_ComponentManager.AllocateNewLocalEntity(); | |||||
return m->m_ComponentManager.AddEntity(templateName, newEnt); | |||||
} | } | ||||
void CSimulation2::DestroyEntity(entity_id_t ent) | void CSimulation2::DestroyEntity(entity_id_t ent) | ||||
{ | { | ||||
m->m_ComponentManager.DestroyComponentsSoon(ent); | m->m_ComponentManager.DestroyComponentsSoon(ent); | ||||
} | } | ||||
void CSimulation2::FlushDestroyedEntities() | void CSimulation2::FlushDestroyedEntities() | ||||
▲ Show 20 Lines • Show All 306 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator