From e7ff927ff7f0b9dd074c83b29e1e434a6a3f45dd Mon Sep 17 00:00:00 2001 From: espkk Date: Wed, 25 May 2022 02:13:37 +0300 Subject: [PATCH] [core] rework entity_manager pt.1 --- src/libs/animals/src/animals.cpp | 4 +- src/libs/animals/src/t_butterflies.cpp | 2 +- src/libs/animals/src/t_butterfly.cpp | 2 +- src/libs/animals/src/t_butterfly.h | 3 +- src/libs/animals/src/t_fish_schools.cpp | 10 +- src/libs/animals/src/t_seagulls.cpp | 6 +- src/libs/ball_splash/src/ball_splash.cpp | 4 +- .../src/item_entity/item_entity.cpp | 18 +- .../src/sea/battle_navigator.cpp | 6 +- .../battle_interface/src/sea/ship_pointer.cpp | 6 +- .../battle_interface/src/sea/ships_list.cpp | 12 +- .../src/spyglass/spyglass.cpp | 2 +- src/libs/blade/src/blade.cpp | 42 ++-- src/libs/blade/src/blade.h | 1 - src/libs/blot/src/blots.cpp | 10 +- src/libs/collide/src/coll.cpp | 32 ++- src/libs/collide/src/local_collide.cpp | 4 +- src/libs/collide/src/vcollide.h | 14 +- src/libs/common/include/collide.h | 10 +- src/libs/common/include/defines.h | 2 +- src/libs/core/include/core.h | 20 +- src/libs/core/include/entity.h | 11 ++ src/libs/core/include/entity_manager.h | 136 ------------- src/libs/core/src/core_impl.cpp | 129 ++++++++++--- src/libs/core/src/core_impl.h | 23 ++- src/libs/core/src/entity_manager.cpp | 182 ++++++++++-------- src/libs/core/src/entity_manager.h | 120 ++++++++++++ src/libs/core/src/internal_functions.cpp | 57 +++--- src/libs/island/src/foam.cpp | 2 +- src/libs/island/src/island.cpp | 50 ++--- src/libs/lighter/src/l_geometry.cpp | 4 +- src/libs/lighter/src/lighter.cpp | 8 +- src/libs/lighter/src/window.cpp | 2 +- src/libs/location/src/blood.cpp | 12 +- src/libs/location/src/character.cpp | 102 +++++----- .../src/character_animation_kipper.cpp | 4 +- src/libs/location/src/characters_groups.cpp | 40 ++-- src/libs/location/src/fader.cpp | 14 +- src/libs/location/src/grass.cpp | 10 +- src/libs/location/src/lights.cpp | 12 +- src/libs/location/src/lizards.cpp | 8 +- src/libs/location/src/loc_crabs.cpp | 12 +- src/libs/location/src/loc_eagle.cpp | 18 +- src/libs/location/src/loc_life.cpp | 16 +- src/libs/location/src/loc_rats.cpp | 12 +- src/libs/location/src/location.cpp | 90 ++++----- src/libs/location/src/location_camera.cpp | 20 +- src/libs/location/src/location_effects.cpp | 8 +- src/libs/location/src/location_script_lib.cpp | 4 +- src/libs/location/src/model_array.cpp | 36 ++-- src/libs/location/src/model_realizer.cpp | 2 +- src/libs/location/src/np_character.cpp | 16 +- src/libs/location/src/np_character.h | 2 +- src/libs/location/src/player.cpp | 24 +-- src/libs/location/src/supervisor.cpp | 4 +- src/libs/location/src/wide_screen.cpp | 6 +- src/libs/locator/src/blast.cpp | 10 +- src/libs/locator/src/locator.cpp | 8 +- src/libs/mast/src/mast.cpp | 66 +++---- src/libs/model/src/model.cpp | 2 +- src/libs/model/src/node.cpp | 8 +- .../particles/src/k2_wrapper/particles.cpp | 4 +- src/libs/renderer/src/s_device.cpp | 37 ++-- src/libs/rigging/src/flag.cpp | 10 +- src/libs/rigging/src/rope.cpp | 12 +- src/libs/rigging/src/sail.cpp | 56 +++--- src/libs/rigging/src/sailone.cpp | 16 +- src/libs/rigging/src/script_func.cpp | 12 +- src/libs/rigging/src/vant.cpp | 10 +- src/libs/sailors/src/sailors.cpp | 16 +- src/libs/sailors/src/sailors_editor.cpp | 22 +-- src/libs/sea/src/env_map.cpp | 52 ++--- src/libs/sea_ai/src/ai_balls.cpp | 24 +-- src/libs/sea_ai/src/ai_cannon.cpp | 2 +- src/libs/sea_ai/src/ai_fort.cpp | 18 +- src/libs/sea_ai/src/ai_fort.h | 2 +- src/libs/sea_ai/src/ai_group.cpp | 2 +- src/libs/sea_ai/src/ai_helper.cpp | 2 +- src/libs/sea_ai/src/ai_sea_goods.cpp | 6 +- src/libs/sea_ai/src/ai_ship.cpp | 4 +- src/libs/sea_ai/src/ai_ship.h | 2 +- .../sea_ai/src/ai_ship_move_controller.cpp | 8 +- src/libs/sea_ai/src/sea_ai.cpp | 4 +- src/libs/sea_cameras/src/common_camera.h | 6 +- src/libs/sea_cameras/src/free_camera.cpp | 12 +- src/libs/sea_cameras/src/sea_cameras.cpp | 4 +- src/libs/sea_cameras/src/ship_camera.cpp | 12 +- src/libs/sea_creatures/src/sharks.cpp | 60 +++--- src/libs/sea_foam/src/seafoam.cpp | 16 +- src/libs/sea_foam/src/seafoam_ps.cpp | 8 +- src/libs/sea_operator/src/sea_operator.cpp | 14 +- src/libs/shadow/src/shadow.cpp | 8 +- src/libs/ship/src/fire_place.cpp | 4 +- src/libs/ship/src/ship.cpp | 132 ++++++------- src/libs/ship/src/ship.h | 2 +- src/libs/ship/src/ship_lights.cpp | 6 +- src/libs/ship/src/ship_utils.cpp | 10 +- src/libs/ship/src/track.cpp | 4 +- src/libs/sink_effect/src/seps.cpp | 8 +- src/libs/sink_effect/src/sink_effect.cpp | 8 +- src/libs/sink_effect/src/t_flotsam.cpp | 8 +- src/libs/sound/src/sound.cpp | 2 +- src/libs/sound_service/src/debug_entity.cpp | 4 +- src/libs/sound_service/src/sound_service.cpp | 6 +- src/libs/tornado/src/debris.cpp | 12 +- src/libs/tornado/src/tornado.cpp | 10 +- src/libs/tornado/src/tornado_particles.cpp | 4 +- src/libs/touch/src/touch.cpp | 4 +- src/libs/water_rings/src/water_rings.cpp | 6 +- src/libs/weather/src/lightning.cpp | 2 +- src/libs/weather/src/planets.cpp | 4 +- src/libs/weather/src/rain.cpp | 19 +- src/libs/weather/src/sky.cpp | 12 +- src/libs/weather/src/stars.cpp | 4 +- src/libs/weather/src/sun_glow.cpp | 18 +- src/libs/weather/src/sun_glow.h | 2 +- src/libs/weather/src/water_flare.cpp | 8 +- src/libs/worldmap/src/world_map.cpp | 8 +- .../xinterface/src/aviplayer/aviplayer.cpp | 8 +- .../xinterface/src/back_scene/back_scene.cpp | 46 ++--- .../xinterface/src/back_scene/back_scene.h | 3 +- .../xinterface/src/nodes/xi_formt_text.cpp | 4 +- src/libs/xinterface/src/nodes/xi_scroller.cpp | 4 +- .../xinterface/src/nodes/xi_video_rect.cpp | 12 +- src/libs/xinterface/src/xdefines.h | 1 - src/libs/xinterface/src/xinterface.cpp | 6 +- 126 files changed, 1231 insertions(+), 1121 deletions(-) delete mode 100644 src/libs/core/include/entity_manager.h create mode 100644 src/libs/core/src/entity_manager.h diff --git a/src/libs/animals/src/animals.cpp b/src/libs/animals/src/animals.cpp index 3901156d5..efaa98dd1 100644 --- a/src/libs/animals/src/animals.cpp +++ b/src/libs/animals/src/animals.cpp @@ -20,8 +20,8 @@ ANIMALS::~ANIMALS() bool ANIMALS::Init() { - EntityManager::AddToLayer(REALIZE, GetId(), 77); - EntityManager::AddToLayer(EXECUTE, GetId(), 77); + core.AddToLayer(REALIZE, GetId(), 77); + core.AddToLayer(EXECUTE, GetId(), 77); seagulls->Init(); fishSchools->Init(); diff --git a/src/libs/animals/src/t_butterflies.cpp b/src/libs/animals/src/t_butterflies.cpp index cdb9d306f..56642089c 100644 --- a/src/libs/animals/src/t_butterflies.cpp +++ b/src/libs/animals/src/t_butterflies.cpp @@ -97,7 +97,7 @@ void TButterflies::Execute(uint32_t _dTime) butterflies[0].SetCenter(pos); int i; - const auto its = EntityManager::GetEntityIdIterators(SHADOW); + const auto its = core.GetEntityIds(SHADOW); // redefine minY yDefineTime += _dTime; diff --git a/src/libs/animals/src/t_butterfly.cpp b/src/libs/animals/src/t_butterfly.cpp index 6a4bb41f4..0c152e9ee 100644 --- a/src/libs/animals/src/t_butterfly.cpp +++ b/src/libs/animals/src/t_butterfly.cpp @@ -50,7 +50,7 @@ void TButterfly::Initialize(const CVECTOR &_center, float _radius, int32_t _buff } //-------------------------------------------------------------------- -void TButterfly::Calculate(int32_t _dTime, COLLIDE *_collide, EntityManager::LayerIterators its) +void TButterfly::Calculate(int32_t _dTime, COLLIDE *_collide, entity_container_cref its) { if (!active) { diff --git a/src/libs/animals/src/t_butterfly.h b/src/libs/animals/src/t_butterfly.h index 84930dead..ccee53a21 100644 --- a/src/libs/animals/src/t_butterfly.h +++ b/src/libs/animals/src/t_butterfly.h @@ -1,7 +1,6 @@ #pragma once #include "c_vector.h" -#include "entity_manager.h" #include "iv_buffer_manager.h" #include "collide.h" #include "model.h" @@ -43,7 +42,7 @@ class TButterfly virtual ~TButterfly(); void Initialize(const CVECTOR &_center, float _radius, int32_t _bufferIndex, int _tI, int _tJ); - void Calculate(int32_t _dTime, COLLIDE *_collide, EntityManager::LayerIterators its); + void Calculate(int32_t _dTime, COLLIDE *_collide, entity_container_cref its); void Effect(const CVECTOR &_position); static void SetCenter(const CVECTOR &_center) diff --git a/src/libs/animals/src/t_fish_schools.cpp b/src/libs/animals/src/t_fish_schools.cpp index b3cb408b4..ac9a361ac 100644 --- a/src/libs/animals/src/t_fish_schools.cpp +++ b/src/libs/animals/src/t_fish_schools.cpp @@ -21,7 +21,7 @@ TFishSchools::~TFishSchools() delete fishSchools[i]; } - EntityManager::EraseEntity(fishSchoolModel); + core.EraseEntity(fishSchoolModel); } //-------------------------------------------------------------------- @@ -44,7 +44,7 @@ void TFishSchools::Init() if (!renderService) throw std::runtime_error("!FishSchools: No service 'dx9render'"); - sea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + sea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); if (!sea) { enabled = false; @@ -64,7 +64,7 @@ void TFishSchools::Init() AddAttractor(&cameraObject); - fishSchoolModel = EntityManager::CreateEntity("MODELR"); + fishSchoolModel = core.CreateEntity("MODELR"); core.Send_Message(fishSchoolModel, "ls", MSG_MODEL_LOAD_GEO, ANIMALS_FISHSCHOOL_FILENAME); } @@ -122,14 +122,14 @@ void TFishSchools::Realize(uint32_t _dTime) float cameraPersp; renderService->GetCamera(cameraPos, cameraAng, cameraPersp); */ - sea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + sea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); if (!sea) { enabled = false; return; } - auto *fishSchool = static_cast(EntityManager::GetEntityPointer(fishSchoolModel)); + auto *fishSchool = static_cast(core.GetEntityPointer(fishSchoolModel)); if (!fishSchool) return; diff --git a/src/libs/animals/src/t_seagulls.cpp b/src/libs/animals/src/t_seagulls.cpp index 67ca06813..da95f02a5 100644 --- a/src/libs/animals/src/t_seagulls.cpp +++ b/src/libs/animals/src/t_seagulls.cpp @@ -16,7 +16,7 @@ TSeagulls::TSeagulls() : enabled(true), count(0), frightened(false) //-------------------------------------------------------------------- TSeagulls::~TSeagulls() { - EntityManager::EraseEntity(seagullModel); + core.EraseEntity(seagullModel); } //-------------------------------------------------------------------- @@ -65,7 +65,7 @@ void TSeagulls::Init() // if(!soundService) // throw std::runtime_error("!Seagulls: No service: sound"); - seagullModel = EntityManager::CreateEntity("MODELR"); + seagullModel = core.CreateEntity("MODELR"); core.Send_Message(seagullModel, "ls", MSG_MODEL_LOAD_GEO, ANIMALS_SEAGULL_FILENAME); } @@ -203,7 +203,7 @@ void TSeagulls::Realize(uint32_t _dTime) if (!count) Add(cameraPos.x, cameraPos.y, cameraPos.z); - auto *seagull = static_cast(EntityManager::GetEntityPointer(seagullModel)); + auto *seagull = static_cast(core.GetEntityPointer(seagullModel)); if (!seagull) return; diff --git a/src/libs/ball_splash/src/ball_splash.cpp b/src/libs/ball_splash/src/ball_splash.cpp index 6113dbe5d..4a0ce0864 100644 --- a/src/libs/ball_splash/src/ball_splash.cpp +++ b/src/libs/ball_splash/src/ball_splash.cpp @@ -26,11 +26,11 @@ bool BALLSPLASH::Init() { // GUARD(BALLSPLASH::Init) - sea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + sea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); renderer = static_cast(core.GetService("dx9render")); - // EntityManager::CreateEntity(&arrowModel,"MODELR"); + // core.CreateEntity(&arrowModel,"MODELR"); // core.Send_Message(arrowModel,"ls",MSG_MODEL_LOAD_GEO, "fish01"); InitializeSplashes(); diff --git a/src/libs/battle_interface/src/item_entity/item_entity.cpp b/src/libs/battle_interface/src/item_entity/item_entity.cpp index 8cc30ce40..0aeddd92b 100644 --- a/src/libs/battle_interface/src/item_entity/item_entity.cpp +++ b/src/libs/battle_interface/src/item_entity/item_entity.cpp @@ -107,10 +107,10 @@ bool ItemEntity::ReadAndCreate() auto *const pcTechnique = BIUtils::GetStringFromAttr(AttributesPointer, "technique", ""); if (pcModelName) { - if (m_eidModel = EntityManager::CreateEntity("modelr")) + if (m_eidModel = core.CreateEntity("modelr")) { core.Send_Message(m_eidModel, "ls", MSG_MODEL_LOAD_GEO, pcModelName); - m_pModel = static_cast(EntityManager::GetEntityPointer(m_eidModel)); + m_pModel = static_cast(core.GetEntityPointer(m_eidModel)); SetModelToPosition(m_mtxpos); SetTechnique(pcTechnique); } @@ -133,7 +133,7 @@ void ItemEntity::Release() { if (m_pModel) { - EntityManager::EraseEntity(m_eidModel); + core.EraseEntity(m_eidModel); m_pModel = nullptr; } DeleteParticle(); @@ -165,7 +165,7 @@ bool ItemEntity::TieToLocator(entid_t mdlEID, const char *pcLocName) { m_eidTieModel = mdlEID; m_sTieLocName = pcLocName; - auto *pMdl = static_cast(EntityManager::GetEntityPointer(mdlEID)); + auto *pMdl = static_cast(core.GetEntityPointer(mdlEID)); if (pMdl) { m_pMdlNode = pMdl->GetNode(0); @@ -198,7 +198,7 @@ void ItemEntity::EndEventProcess() void ItemEntity::DrawIntoLocator() { - auto *pMdl = static_cast(EntityManager::GetEntityPointer(m_eidTieModel)); + auto *pMdl = static_cast(core.GetEntityPointer(m_eidTieModel)); if (!pMdl) { UnTieFromLocator(); @@ -259,7 +259,7 @@ entid_t ItemEntity::GetModelEIDFromCharacterEID(entid_t chrEID) void ItemEntity::SetEventListener(entid_t mdlEID, entid_t mdlToTieEID, const char *pcLocName, const char *pcStartEvent, const char *pcEndEvent) { - auto *pMdl = static_cast(EntityManager::GetEntityPointer(mdlEID)); + auto *pMdl = static_cast(core.GetEntityPointer(mdlEID)); if (!pMdl) return; auto *a = pMdl->GetAnimation(); @@ -287,7 +287,7 @@ void ItemEntity::EventListener::Event(Animation *animation, int32_t playerIndex, } if (!m_bStartWaiting && m_sEndEvent == eventName) { - auto *pMdl = static_cast(EntityManager::GetEntityPointer(m_eidListenedModel)); + auto *pMdl = static_cast(core.GetEntityPointer(m_eidListenedModel)); if (pMdl) { auto *a = pMdl->GetAnimation(); @@ -307,7 +307,7 @@ bool ItemEntity::CreateParticle() auto *const pcParticleName = BIUtils::GetStringFromAttr(AttributesPointer, "particle", ""); if (pcParticleName && pcParticleName[0]) { - const auto eidParticle = EntityManager::GetEntityId("particles"); + const auto eidParticle = core.GetEntityId("particles"); if (eidParticle) { const auto vPos = m_mtxpos.Pos(); @@ -325,7 +325,7 @@ void ItemEntity::DeleteParticle() { if (m_pParticle) { - const auto eidParticle = EntityManager::GetEntityId("particles"); + const auto eidParticle = core.GetEntityId("particles"); if (eidParticle) { if (core.Send_Message(eidParticle, "lp", PS_VALIDATE_PARTICLE, m_pParticle)) diff --git a/src/libs/battle_interface/src/sea/battle_navigator.cpp b/src/libs/battle_interface/src/sea/battle_navigator.cpp index 80215e2cd..6d428599c 100644 --- a/src/libs/battle_interface/src/sea/battle_navigator.cpp +++ b/src/libs/battle_interface/src/sea/battle_navigator.cpp @@ -1346,10 +1346,10 @@ void BATTLE_NAVIGATOR::SetIsland() float islSize = 0; MODEL *pM = nullptr; - auto *pIsl = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("ISLAND"))); + auto *pIsl = static_cast(core.GetEntityPointer(core.GetEntityId("ISLAND"))); if (pIsl != nullptr) { - pM = static_cast(EntityManager::GetEntityPointer(pIsl->GetModelEID())); + pM = static_cast(core.GetEntityPointer(pIsl->GetModelEID())); } if (pM != nullptr) { @@ -1541,7 +1541,7 @@ void BATTLE_NAVIGATOR::UpdateWindParam() { if (!m_wb && !m_pAWeather) { - m_wb = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("weather"))); + m_wb = static_cast(core.GetEntityPointer(core.GetEntityId("weather"))); /*if( core.IsNetActive() && !m_wb && m_pOwnerEI ) { VDATA * pSVWeather = (VDATA*)core.GetScriptVariable((m_pOwnerEI->IsServer()) ? "NSWeather" : "NCWeather"); Assert(pSVWeather); m_pAWeather = pSVWeather->GetAClass(); Assert(m_pAWeather); diff --git a/src/libs/battle_interface/src/sea/ship_pointer.cpp b/src/libs/battle_interface/src/sea/ship_pointer.cpp index b313267d1..bcb36b0db 100644 --- a/src/libs/battle_interface/src/sea/ship_pointer.cpp +++ b/src/libs/battle_interface/src/sea/ship_pointer.cpp @@ -167,10 +167,10 @@ VAI_OBJBASE *SHIPPOINTER::FindShipByChrIndex(int32_t chrIdx) const if (chrIdx == -1) return nullptr; - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ship : entities) { - auto ps = static_cast(EntityManager::GetEntityPointer(ship)); + auto ps = static_cast(core.GetEntityPointer(ship)); if (ps != nullptr && ps->GetACharacter() != nullptr) { if (static_cast(ps->GetACharacter()->GetAttributeAsDword("index", -2)) == chrIdx) @@ -180,7 +180,7 @@ VAI_OBJBASE *SHIPPOINTER::FindShipByChrIndex(int32_t chrIdx) const /*if( NetFindClass(false,&ei,"netship") ) do { - VAI_OBJBASE * ps = (VAI_OBJBASE*)EntityManager::GetEntityPointer(ei); + VAI_OBJBASE * ps = (VAI_OBJBASE*)core.GetEntityPointer(ei); if(ps!= nullptr && ps->GetACharacter()!= nullptr) { if( (int32_t)ps->GetACharacter()->GetAttributeAsDword("id",-2) == chrIdx ) diff --git a/src/libs/battle_interface/src/sea/ships_list.cpp b/src/libs/battle_interface/src/sea/ships_list.cpp index 1bbcd357f..8ffea435e 100644 --- a/src/libs/battle_interface/src/sea/ships_list.cpp +++ b/src/libs/battle_interface/src/sea/ships_list.cpp @@ -215,10 +215,10 @@ void SHIP_DESCRIBE_LIST::Add(int32_t mainChrIndex, int32_t chIdx, ATTRIBUTES *pC pr->next = nullptr; // find this ship - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ship : entities) { - auto *vob = static_cast(EntityManager::GetEntityPointer(ship)); + auto *vob = static_cast(core.GetEntityPointer(ship)); if (vob == nullptr) continue; auto *pA = vob->GetACharacter(); @@ -230,7 +230,7 @@ void SHIP_DESCRIBE_LIST::Add(int32_t mainChrIndex, int32_t chIdx, ATTRIBUTES *pC } /*if( NetFindClass(false,&ei,"netship") ) do { - VAI_OBJBASE * vob = (VAI_OBJBASE*)EntityManager::GetEntityPointer(ei); + VAI_OBJBASE * vob = (VAI_OBJBASE*)core.GetEntityPointer(ei); if(vob== nullptr) continue; ATTRIBUTES *pA = vob->GetACharacter(); if((int32_t)pA->GetAttributeAsDword("id")==chIdx) @@ -285,10 +285,10 @@ void SHIP_DESCRIBE_LIST::Refresh() TMP_LONG_STACK tls; - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ship : entities) { - auto *vob = static_cast(EntityManager::GetEntityPointer(ship)); + auto *vob = static_cast(core.GetEntityPointer(ship)); if (vob == nullptr) continue; auto *pA = vob->GetACharacter(); @@ -299,7 +299,7 @@ void SHIP_DESCRIBE_LIST::Refresh() /*if( NetFindClass(false,&ei,"NetShip") ) do { - VAI_OBJBASE * vob = (VAI_OBJBASE*)EntityManager::GetEntityPointer(ei); + VAI_OBJBASE * vob = (VAI_OBJBASE*)core.GetEntityPointer(ei); if(vob== nullptr) continue; ATTRIBUTES * pA= vob->GetACharacter(); if(pA== nullptr) continue; diff --git a/src/libs/battle_interface/src/spyglass/spyglass.cpp b/src/libs/battle_interface/src/spyglass/spyglass.cpp index 2058863e8..8c9607f59 100644 --- a/src/libs/battle_interface/src/spyglass/spyglass.cpp +++ b/src/libs/battle_interface/src/spyglass/spyglass.cpp @@ -793,7 +793,7 @@ VAI_OBJBASE *ISPYGLASS::GetFort() { if (!m_pFortObj) { - m_pFortObj = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("AIFORT"))); + m_pFortObj = static_cast(core.GetEntityPointer(core.GetEntityId("AIFORT"))); } return m_pFortObj; } diff --git a/src/libs/blade/src/blade.cpp b/src/libs/blade/src/blade.cpp index da58ed0e5..0c8284eeb 100644 --- a/src/libs/blade/src/blade.cpp +++ b/src/libs/blade/src/blade.cpp @@ -42,12 +42,12 @@ BLADE::BLADE_INFO::BLADE_INFO() BLADE::BLADE_INFO::~BLADE_INFO() { - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); } void BLADE::BLADE_INFO::DrawBlade(VDX9RENDER *rs, unsigned int blendValue, MODEL *mdl, NODE *manNode) { - auto *obj = static_cast(EntityManager::GetEntityPointer(eid)); + auto *obj = static_cast(core.GetEntityPointer(eid)); if (obj != nullptr) { CMatrix perMtx; @@ -167,7 +167,7 @@ void BLADE::BLADE_INFO::DrawBlade(VDX9RENDER *rs, unsigned int blendValue, MODEL bool BLADE::BLADE_INFO::LoadBladeModel(MESSAGE &message) { - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); // model name const std::string &mdlName = message.String(); @@ -182,10 +182,10 @@ bool BLADE::BLADE_INFO::LoadBladeModel(MESSAGE &message) if (gs) gs->SetTexturePath("Ammo\\"); // Create a model - eid = EntityManager::CreateEntity("modelr"); + eid = core.CreateEntity("modelr"); if (!core.Send_Message(eid, "ls", MSG_MODEL_LOAD_GEO, path)) { - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); if (gs) gs->SetTexturePath(""); return false; @@ -210,7 +210,7 @@ BLADE::BLADE() BLADE::~BLADE() { - EntityManager::EraseEntity(gun); + core.EraseEntity(gun); for (int32_t i = 0; i < ITEMS_INFO_QUANTITY; i++) items[i].Release(); @@ -224,7 +224,7 @@ bool BLADE::Init() if (col == nullptr) throw std::runtime_error("No service: COLLIDE"); - EntityManager::AddToLayer(REALIZE, GetId(), 65550); + core.AddToLayer(REALIZE, GetId(), 65550); rs = static_cast(core.GetService("dx9render")); if (!rs) @@ -241,7 +241,7 @@ void BLADE::Realize(uint32_t Delta_Time) { blade[0].time += 0.001f * (Delta_Time); - auto *mdl = static_cast(EntityManager::GetEntityPointer(man)); + auto *mdl = static_cast(core.GetEntityPointer(man)); if (!mdl) return; @@ -262,7 +262,7 @@ void BLADE::Realize(uint32_t Delta_Time) // draw gun CMatrix perMtx; int32_t sti; - auto *obj = static_cast(EntityManager::GetEntityPointer(gun)); + auto *obj = static_cast(core.GetEntityPointer(gun)); if (obj != nullptr) { auto *gunNode = obj->GetNode(0); @@ -337,7 +337,7 @@ bool BLADE::LoadBladeModel(MESSAGE &message) bool BLADE::LoadGunModel(MESSAGE &message) { - EntityManager::EraseEntity(gun); + core.EraseEntity(gun); man = message.EntityID(); // model name const std::string &mdlName = message.String(); @@ -352,10 +352,10 @@ bool BLADE::LoadGunModel(MESSAGE &message) if (gs) gs->SetTexturePath("Ammo\\"); // Create a model - gun = EntityManager::CreateEntity("modelr"); + gun = core.CreateEntity("modelr"); if (!core.Send_Message(gun, "ls", MSG_MODEL_LOAD_GEO, path)) { - EntityManager::EraseEntity(gun); + core.EraseEntity(gun); if (gs) gs->SetTexturePath(""); return false; @@ -370,7 +370,7 @@ bool BLADE::LoadGunModel(MESSAGE &message) void BLADE::GunFire() { - auto *mdl = static_cast(EntityManager::GetEntityPointer(man)); + auto *mdl = static_cast(core.GetEntityPointer(man)); auto *manNode = mdl->GetNode(0); //------------------------------------------------------ @@ -378,9 +378,9 @@ void BLADE::GunFire() CMatrix perMtx; int32_t sti; - auto *obj = static_cast(EntityManager::GetEntityPointer(gun)); + auto *obj = static_cast(core.GetEntityPointer(gun)); if (obj == nullptr) // no pistol - look for saber pistol - obj = static_cast(EntityManager::GetEntityPointer(blade[1].eid)); + obj = static_cast(core.GetEntityPointer(blade[1].eid)); if (obj != nullptr) { @@ -415,7 +415,7 @@ void BLADE::GunFire() resm.EqMultiply(perMtx, *(CMatrix *)&lb.m); auto rp = perMtx * CVECTOR(lb.m[3][0], lb.m[3][1], lb.m[3][2]); - core.Send_Message(EntityManager::GetEntityId("particles"), "lsffffffl", PS_CREATEX, "gunfire", rp.x, rp.y, + core.Send_Message(core.GetEntityId("particles"), "lsffffffl", PS_CREATEX, "gunfire", rp.x, rp.y, rp.z, resm.Vz().x, resm.Vz().y, resm.Vz().z, 0); } else @@ -581,7 +581,7 @@ void BLADE::TIEITEM_INFO::Release() if (nItemIndex != -1) { nItemIndex = -1; - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); delete locatorName; locatorName = nullptr; } @@ -589,7 +589,7 @@ void BLADE::TIEITEM_INFO::Release() void BLADE::TIEITEM_INFO::DrawItem(VDX9RENDER *rs, unsigned int blendValue, MODEL *mdl, NODE *manNode) { - auto *obj = static_cast(EntityManager::GetEntityPointer(eid)); + auto *obj = static_cast(core.GetEntityPointer(eid)); if (obj != nullptr) { CMatrix perMtx; @@ -635,7 +635,7 @@ void BLADE::TIEITEM_INFO::DrawItem(VDX9RENDER *rs, unsigned int blendValue, MODE bool BLADE::TIEITEM_INFO::LoadItemModel(const char *mdlName, const char *locName) { - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); delete locatorName; locatorName = nullptr; @@ -656,10 +656,10 @@ bool BLADE::TIEITEM_INFO::LoadItemModel(const char *mdlName, const char *locName if (gs) gs->SetTexturePath("Ammo\\"); // Create a model - eid = EntityManager::CreateEntity("modelr"); + eid = core.CreateEntity("modelr"); if (!core.Send_Message(eid, "ls", MSG_MODEL_LOAD_GEO, path)) { - EntityManager::EraseEntity(eid); + core.EraseEntity(eid); if (gs) gs->SetTexturePath(""); return false; diff --git a/src/libs/blade/src/blade.h b/src/libs/blade/src/blade.h index 4c9741acc..ded347176 100644 --- a/src/libs/blade/src/blade.h +++ b/src/libs/blade/src/blade.h @@ -8,7 +8,6 @@ model binded to an animated locator ******************************************************************************/ #pragma once -#include "entity_manager.h" #include "collide.h" #include "dx9render.h" #include "model.h" diff --git a/src/libs/blot/src/blots.cpp b/src/libs/blot/src/blots.cpp index afb5b3c1a..8da1bad9a 100644 --- a/src/libs/blot/src/blots.cpp +++ b/src/libs/blot/src/blots.cpp @@ -58,8 +58,8 @@ bool Blots::Init() throw std::runtime_error("No service: dx9render"); // Layers ////core.LayerCreate("realize", true, false); - // EntityManager::SetLayerType(realize, EntityManager::Layer::Type::realize); - // EntityManager::AddToLayer(realize, GetId(), 1000); + // core.SetLayerType(realize, layer_type_t::realize); + // core.AddToLayer(realize, GetId(), 1000); textureID = rs->TextureCreate("blot.tga"); return true; // UNGUARD @@ -93,7 +93,7 @@ uint64_t Blots::ProcessMessage(MESSAGE &message) void Blots::Hit(MESSAGE &message) { // Model of a ship - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; // Position @@ -134,7 +134,7 @@ void Blots::Hit(MESSAGE &message) void Blots::AddBlot(int32_t i, int32_t rnd, const CVECTOR &lpos, const CVECTOR &dir, float time) { // Model of a ship - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; blot[i].isUsed = false; @@ -362,7 +362,7 @@ void Blots::Realize(uint32_t delta_time) updateBlot = 0; SaveBlot(updateBlot); // Model of a ship - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; // Distance from camera diff --git a/src/libs/collide/src/coll.cpp b/src/libs/collide/src/coll.cpp index b7f2433dd..134a950f4 100644 --- a/src/libs/collide/src/coll.cpp +++ b/src/libs/collide/src/coll.cpp @@ -7,7 +7,7 @@ entid_t last_trace_eid; //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- -LOCAL_COLLIDE *COLL::CreateLocalCollide(EntityManager::layer_index_t idx) +LOCAL_COLLIDE *COLL::CreateLocalCollide(layer_index_t idx) { return new LCOLL(idx); } @@ -17,7 +17,7 @@ LOCAL_COLLIDE *COLL::CreateLocalCollide(EntityManager::layer_index_t idx) //---------------------------------------------------------------------------------- float COLL::Trace(entid_t entity, const CVECTOR &src, const CVECTOR &dst) { - auto *cob = static_cast(EntityManager::GetEntityPointer(entity)); + auto *cob = static_cast(core.GetEntityPointer(entity)); if (static_cast(cob) == nullptr) return 2.0f; @@ -28,22 +28,20 @@ float COLL::Trace(entid_t entity, const CVECTOR &src, const CVECTOR &dst) //---------------------------------------------------------------------------------- // with enclusion list //---------------------------------------------------------------------------------- -float COLL::Trace(EntityManager::LayerIterators its, const CVECTOR &src, const CVECTOR &dst, - const entid_t *exclude_list, int32_t entities) +float COLL::Trace(entity_container_cref entities, const CVECTOR &src, const CVECTOR &dst, + const entid_t *exclude_list, int32_t exclude_num) { auto best_res = 2.0f; - for (auto it = its.first; it != its.second; ++it) + for (const auto eid : entities) { - const auto eid = *it; - int32_t e; - for (e = 0; e < entities; e++) + for (e = 0; e < exclude_num; e++) if (eid == exclude_list[e]) break; - if (e == entities) + if (e == exclude_num) { - auto *cob = static_cast(EntityManager::GetEntityPointer(eid)); + auto *cob = static_cast(core.GetEntityPointer(eid)); if (cob != nullptr) { const auto res = cob->Trace(src, dst); @@ -62,23 +60,21 @@ float COLL::Trace(EntityManager::LayerIterators its, const CVECTOR &src, const C //---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- -bool COLL::Clip(EntityManager::LayerIterators its, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, - float radius, ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t entities) +bool COLL::Clip(entity_container_cref entities, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, + float radius, ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t exclude_num) { auto retval = false; - for (auto it = its.first; it != its.second; ++it) + for (const auto eid : entities) { - const auto eid = *it; - int32_t e; - for (e = 0; e < entities; e++) + for (e = 0; e < exclude_num; e++) if (eid == exclude_list[e]) break; - if (e == entities) + if (e == exclude_num) { - auto *cob = static_cast(EntityManager::GetEntityPointer(eid)); + auto *cob = static_cast(core.GetEntityPointer(eid)); if (cob != nullptr) { last_trace_eid = eid; diff --git a/src/libs/collide/src/local_collide.cpp b/src/libs/collide/src/local_collide.cpp index edadf0d87..5eec0b610 100644 --- a/src/libs/collide/src/local_collide.cpp +++ b/src/libs/collide/src/local_collide.cpp @@ -1,6 +1,6 @@ #include "vcollide.h" -LCOLL::LCOLL(EntityManager::layer_index_t idx) : boxRadius(0) +LCOLL::LCOLL(layer_index_t idx) : boxRadius(0) { layerIndex_ = idx; col = static_cast(core.GetService("coll")); @@ -90,7 +90,7 @@ int32_t LCOLL::SetBox(const CVECTOR &boxSize, const CMatrix &transform, bool tes // F0(v0,v1,v2), F1(v0,v1,v2,v3)... addVerts = nullptr; - const auto its = EntityManager::GetEntityIdIterators(layerIndex_); + const auto its = core.GetEntityIds(layerIndex_); col->Clip(its, &plane[0], 6, boxCenter, boxRadius, AddPolyColl, nullptr, 0); return 0; } diff --git a/src/libs/collide/src/vcollide.h b/src/libs/collide/src/vcollide.h index 22fdd0cc5..884edab1f 100644 --- a/src/libs/collide/src/vcollide.h +++ b/src/libs/collide/src/vcollide.h @@ -7,14 +7,14 @@ class LCOLL : public LOCAL_COLLIDE { - EntityManager::layer_index_t layerIndex_; + layer_index_t layerIndex_; PLANE plane[6]; CVECTOR boxCenter; float boxRadius; COLLIDE *col; public: - LCOLL(EntityManager::layer_index_t idx); + LCOLL(layer_index_t idx); ~LCOLL() override; int32_t SetBox(const CVECTOR &boxSize, const CMatrix &transform, bool testOnly = false) override; const CVECTOR *GetFace(int32_t &numVertices) override; @@ -26,12 +26,12 @@ class COLL : public COLLIDE public: COLL() = default; ~COLL() override = default; - LOCAL_COLLIDE *CreateLocalCollide(EntityManager::layer_index_t idx) override; + LOCAL_COLLIDE *CreateLocalCollide(layer_index_t idx) override; float Trace(entid_t entity, const CVECTOR &src, const CVECTOR &dst) override; - float Trace(EntityManager::LayerIterators its, const CVECTOR &src, const CVECTOR &dst, const entid_t *exclude_list, - int32_t entities) override; - bool Clip(EntityManager::LayerIterators its, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, float radius, - ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t entities) override; + float Trace(entity_container_cref entities, const CVECTOR &src, const CVECTOR &dst, const entid_t *exclude_list, + int32_t exclude_num) override; + bool Clip(entity_container_cref entities, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, float radius, + ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t exclude_num) override; entid_t GetObjectID() override; }; diff --git a/src/libs/common/include/collide.h b/src/libs/common/include/collide.h index d27135495..56f574f5e 100644 --- a/src/libs/common/include/collide.h +++ b/src/libs/common/include/collide.h @@ -29,15 +29,15 @@ class COLLIDE : public SERVICE ~COLLIDE() override = default; // creates LocalCollide object which must be deleted after use - virtual LOCAL_COLLIDE *CreateLocalCollide(EntityManager::layer_index_t idx) = 0; + virtual LOCAL_COLLIDE *CreateLocalCollide(layer_index_t idx) = 0; virtual float Trace(entid_t entity, const CVECTOR &src, const CVECTOR &dst) = 0; - virtual float Trace(EntityManager::LayerIterators its, const CVECTOR &src, const CVECTOR &dst, - const entid_t *exclude_list, int32_t entities) = 0; + virtual float Trace(entity_container_cref entities, const CVECTOR &src, const CVECTOR &dst, + const entid_t *exclude_list, int32_t exclude_num) = 0; - virtual bool Clip(EntityManager::LayerIterators its, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, - float radius, ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t entities) = 0; + virtual bool Clip(entity_container_cref entities, const PLANE *planes, int32_t nplanes, const CVECTOR ¢er, + float radius, ADD_POLYGON_FUNC addpoly, const entid_t *exclude_list, int32_t exclude_num) = 0; virtual entid_t GetObjectID() = 0; }; diff --git a/src/libs/common/include/defines.h b/src/libs/common/include/defines.h index 7856c8647..cdedbc594 100644 --- a/src/libs/common/include/defines.h +++ b/src/libs/common/include/defines.h @@ -135,7 +135,7 @@ inline int ftoi(float f) } #define DELETE_Entity(x) \ { \ - EntityManager::EraseEntity(x); \ + core.EraseEntity(x); \ } #define RELEASE(x) \ { \ diff --git a/src/libs/core/include/core.h b/src/libs/core/include/core.h index cd8b523b3..9c9d9debd 100644 --- a/src/libs/core/include/core.h +++ b/src/libs/core/include/core.h @@ -1,12 +1,14 @@ #pragma once +#include + // common includes #include "message.h" -#include "entity_manager.h" #include "controls.h" #include "engine_version.hpp" #include "v_data.h" #include "v_file_service.h" +#include "shared/layers.h" struct IFUNCINFO; @@ -83,6 +85,22 @@ class Core virtual void stopFrameProcessing() = 0; + // Entity management + virtual void AddToLayer(layer_index_t index, entid_t id, priority_t priority) = 0; + virtual void EraseEntity(entid_t entity) = 0; + virtual entid_t CreateEntity(const char *name, ATTRIBUTES *attr = nullptr) = 0; + virtual entptr_t GetEntityPointer(entid_t entity) const = 0; + virtual entid_t GetEntityId(const char *name) const = 0; + virtual entity_container_cref GetEntityIds(layer_type_t index) const = 0; + virtual entity_container_cref GetEntityIds(layer_index_t index) const = 0; + virtual entity_container_cref GetEntityIds(const char *name) const = 0; + virtual void SetLayerType(layer_index_t index, layer_type_t type) = 0; + virtual void SetLayerFrozen(layer_index_t index, bool freeze) = 0; + virtual void RemoveFromLayer(layer_index_t index, entid_t id) = 0; + virtual hash_t GetClassCode(entid_t id) const = 0; + virtual bool IsLayerFrozen(layer_index_t index) const = 0; + + CONTROLS* Controls{}; }; diff --git a/src/libs/core/include/entity.h b/src/libs/core/include/entity.h index 8f447d517..b96bdfeef 100644 --- a/src/libs/core/include/entity.h +++ b/src/libs/core/include/entity.h @@ -9,6 +9,17 @@ class Entity; class MESSAGE; using entptr_t = Entity *; using entid_t = uint64_t; +using layer_index_t = uint8_t; +using priority_t = uint32_t; +using hash_t = uint32_t; +using entity_container_cref = const std::vector&; + +enum class layer_type_t : uint8_t +{ + common, + execute, + realize +}; constexpr auto max_ent_in_layer = 1024; constexpr auto max_layers_num = 32; // cannot exceed 32 diff --git a/src/libs/core/include/entity_manager.h b/src/libs/core/include/entity_manager.h deleted file mode 100644 index 3bca61655..000000000 --- a/src/libs/core/include/entity_manager.h +++ /dev/null @@ -1,136 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "entity.h" -#include "shared/layers.h" - -class EntityManager final -{ - using entid_index_t = uint32_t; - using entid_stamp_t = uint32_t; - using entity_index_t = uint32_t; - using priority_t = uint32_t; - using hash_t = uint32_t; - - public: - - using layer_index_t = uint8_t; - - // TODO: this is a workaround. i need to implement specific iterator returning only id - struct EntityInternalData - { - using layer_mask_t = uint32_t; - - bool deleted; - layer_mask_t mask; - priority_t priorities[max_layers_num]; - entptr_t ptr; - entid_t id; - hash_t hash; - }; - - struct Layer - { - enum Type : uint8_t - { - common, - execute, - realize - }; - - std::vector priorities; - std::vector entity_ids; - - Type type; - bool frozen; - }; - - private: - /* static array of layers */ - static std::array layers_; - - /* static array of entities and actual size */ - static std::pair, entity_index_t> entities_; - - /* stack for indices of erased entities: static constexpr array and top counter */ - static std::pair, entity_index_t> freeIndices_; - - /* static array for indices to delete */ - /* RATIONALE: - * Entities can be deleted inside destruction of another entity, therefore we shall either - * loop until there is no entity to delete (O(N^N) at worst) or use a stack for them. - */ - static std::pair, entity_index_t> deletedIndices_; - - /* actual erase */ - static void _erase(EntityInternalData &data); - - /* mark entity to delete */ - static void _EraseEntityNoCheck(entid_t entity); - -public: - using EntityVector = const std::vector; - using LayerIterators = std::pair; - using AllEntIterators = - std::pair; - - /* fully static constexpr class */ - EntityManager() = delete; - - static hash_t GetClassCode(entid_t id); - - /* layer functioning is fully static constexpr */ - static void AddToLayer(layer_index_t index, entid_t id, priority_t priority); - - static void RemoveFromLayer(layer_index_t index, entid_t id); - - static void RemoveFromLayer(layer_index_t index, EntityInternalData &data); - - static entid_t CreateEntity(const char *name, ATTRIBUTES *attr = nullptr); - - static void EraseEntity(entid_t entity); - - static void EraseAll(); - - static entptr_t GetEntityPointer(entid_t entity); - - static EntityVector GetEntityIdVector(Layer::Type type); - - // TODO: hash... - static EntityVector GetEntityIdVector(const char *name); - - static EntityVector GetEntityIdVector(uint32_t hash); - - static LayerIterators GetEntityIdIterators(layer_index_t index); - - /* this is (temporary) workaround solution */ - static AllEntIterators GetEntityIdIterators(); - - static entid_t GetEntityId(const char *name); - - static entid_t GetEntityId(uint32_t hash); - - static Layer::Type GetLayerType(layer_index_t index); - - static void SetLayerType(layer_index_t index, Layer::Type type); - - static void SetLayerFrozen(layer_index_t index, bool freeze); - - static bool IsLayerFrozen(layer_index_t index); - - static void PushFreeIndex(entity_index_t index); - - /* new lifecycle is started at the end of each frame. it's time to cleanup */ - static void NewLifecycle(); - - static EntityInternalData &GetEntityData(entid_t entity); - - static entid_t PushEntity(entptr_t ptr, hash_t hash); - - /* static constexpr asserts */ - static_assert(sizeof(std::chrono::milliseconds) == sizeof(entid_stamp_t) * 2); /* we are ok with half-precision */ -}; diff --git a/src/libs/core/src/core_impl.cpp b/src/libs/core/src/core_impl.cpp index 1d123093b..5d3100109 100644 --- a/src/libs/core/src/core_impl.cpp +++ b/src/libs/core/src/core_impl.cpp @@ -95,21 +95,21 @@ void CoreImpl::Init() Compiler = new COMPILER; /* TODO: place this outside CoreImpl */ - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(SEA_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(SEA_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(INTERFACE_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(INTERFACE_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(FADER_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(FADER_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(LIGHTER_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(LIGHTER_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(VIDEO_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(VIDEO_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(EDITOR_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(INFO_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::SetLayerType(SOUND_DEBUG_REALIZE, EntityManager::Layer::Type::realize); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.SetLayerType(SEA_EXECUTE, layer_type_t::execute); + core.SetLayerType(SEA_REALIZE, layer_type_t::realize); + core.SetLayerType(INTERFACE_EXECUTE, layer_type_t::execute); + core.SetLayerType(INTERFACE_REALIZE, layer_type_t::realize); + core.SetLayerType(FADER_EXECUTE, layer_type_t::execute); + core.SetLayerType(FADER_REALIZE, layer_type_t::realize); + core.SetLayerType(LIGHTER_EXECUTE, layer_type_t::execute); + core.SetLayerType(LIGHTER_REALIZE, layer_type_t::realize); + core.SetLayerType(VIDEO_EXECUTE, layer_type_t::execute); + core.SetLayerType(VIDEO_REALIZE, layer_type_t::realize); + core.SetLayerType(EDITOR_REALIZE, layer_type_t::realize); + core.SetLayerType(INFO_REALIZE, layer_type_t::realize); + core.SetLayerType(SOUND_DEBUG_REALIZE, layer_type_t::realize); } void CoreImpl::InitBase() @@ -196,7 +196,7 @@ bool CoreImpl::Run() if (Controls) ProcessControls(); - EntityManager::NewLifecycle(); + entity_manager_.NewLifecycle(); ProcessRunEnd(SECTION_ALL); @@ -343,7 +343,7 @@ void CoreImpl::SetTimeScale(float _scale) uint64_t CoreImpl::Send_Message(entid_t Destination, const char *Format, ...) { MESSAGE message; - auto *const ptr = EntityManager::GetEntityPointer(Destination); // check for valid destination + auto *const ptr = core.GetEntityPointer(Destination); // check for valid destination if (!ptr) return 0; @@ -524,10 +524,10 @@ void CoreImpl::ProcessExecute() ProcessRunStart(SECTION_EXECUTE); const auto deltatime = Timer.GetDeltaTime(); - const auto &entIds = EntityManager::GetEntityIdVector(EntityManager::Layer::Type::execute); + const auto &entIds = core.GetEntityIds(layer_type_t::execute); for (auto id : entIds) { - if (auto *ptr = EntityManager::GetEntityPointer(id)) + if (auto *ptr = core.GetEntityPointer(id)) { ptr->ProcessStage(Entity::Stage::execute, deltatime); } @@ -542,10 +542,10 @@ void CoreImpl::ProcessRealize() ProcessRunStart(SECTION_REALIZE); const auto deltatime = Timer.GetDeltaTime(); - const auto &entIds = EntityManager::GetEntityIdVector(EntityManager::Layer::Type::realize); + const auto &entIds = core.GetEntityIds(layer_type_t::realize); for (auto id : entIds) { - if (auto *ptr = EntityManager::GetEntityPointer(id)) + if (auto *ptr = core.GetEntityPointer(id)) { ptr->ProcessStage(Entity::Stage::realize, deltatime); } @@ -667,7 +667,7 @@ uint32_t CoreImpl::GetRDeltaTime() ATTRIBUTES *CoreImpl::Entity_GetAttributeClass(entid_t id_PTR, const char *name) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return nullptr; if (pE->AttributesPointer == nullptr) @@ -677,7 +677,7 @@ ATTRIBUTES *CoreImpl::Entity_GetAttributeClass(entid_t id_PTR, const char *name) const char *CoreImpl::Entity_GetAttribute(entid_t id_PTR, const char *name) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return nullptr; if (pE->AttributesPointer == nullptr) @@ -687,7 +687,7 @@ const char *CoreImpl::Entity_GetAttribute(entid_t id_PTR, const char *name) uint32_t CoreImpl::Entity_GetAttributeAsDword(entid_t id_PTR, const char *name, uint32_t def) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return def; if (pE->AttributesPointer == nullptr) @@ -697,7 +697,7 @@ uint32_t CoreImpl::Entity_GetAttributeAsDword(entid_t id_PTR, const char *name, FLOAT CoreImpl::Entity_GetAttributeAsFloat(entid_t id_PTR, const char *name, FLOAT def) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return def; if (pE->AttributesPointer == nullptr) @@ -707,7 +707,7 @@ FLOAT CoreImpl::Entity_GetAttributeAsFloat(entid_t id_PTR, const char *name, FLO bool CoreImpl::Entity_SetAttribute(entid_t id_PTR, const char *name, const char *attribute) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return false; if (pE->AttributesPointer == nullptr) @@ -717,7 +717,7 @@ bool CoreImpl::Entity_SetAttribute(entid_t id_PTR, const char *name, const char bool CoreImpl::Entity_SetAttributeUseDword(entid_t id_PTR, const char *name, uint32_t val) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return false; if (pE->AttributesPointer == nullptr) @@ -727,7 +727,7 @@ bool CoreImpl::Entity_SetAttributeUseDword(entid_t id_PTR, const char *name, uin bool CoreImpl::Entity_SetAttributeUseFloat(entid_t id_PTR, const char *name, FLOAT val) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return false; if (pE->AttributesPointer == nullptr) @@ -737,7 +737,7 @@ bool CoreImpl::Entity_SetAttributeUseFloat(entid_t id_PTR, const char *name, FLO void CoreImpl::Entity_SetAttributePointer(entid_t id_PTR, ATTRIBUTES *pA) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return; pE->AttributesPointer = pA; @@ -745,7 +745,7 @@ void CoreImpl::Entity_SetAttributePointer(entid_t id_PTR, ATTRIBUTES *pA) uint32_t CoreImpl::Entity_AttributeChanged(entid_t id_PTR, ATTRIBUTES *pA) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return 0; return pE->AttributeChanged(pA); @@ -753,7 +753,7 @@ uint32_t CoreImpl::Entity_AttributeChanged(entid_t id_PTR, ATTRIBUTES *pA) ATTRIBUTES *CoreImpl::Entity_GetAttributePointer(entid_t id_PTR) { - Entity *pE = EntityManager::GetEntityPointer(id_PTR); + Entity *pE = core.GetEntityPointer(id_PTR); if (pE == nullptr) return nullptr; return pE->AttributesPointer; @@ -761,7 +761,7 @@ ATTRIBUTES *CoreImpl::Entity_GetAttributePointer(entid_t id_PTR) void CoreImpl::EraseEntities() { - EntityManager::EraseAll(); + entity_manager_.EraseAll(); } void CoreImpl::ClearEvents() @@ -930,6 +930,71 @@ void CoreImpl::stopFrameProcessing() stopFrameProcessing_ = true; } +void CoreImpl::AddToLayer(layer_index_t index, entid_t id, priority_t priority) +{ + entity_manager_.AddToLayer(index, id, priority); +} + +void CoreImpl::EraseEntity(entid_t entity) +{ + entity_manager_.EraseEntity(entity); +} + +entid_t CoreImpl::CreateEntity(const char *name, ATTRIBUTES *attr) +{ + return entity_manager_.CreateEntity(name, attr); +} + +entptr_t CoreImpl::GetEntityPointer(entid_t id) const +{ + return entity_manager_.GetEntityPointer(id); +} + +entid_t CoreImpl::GetEntityId(const char *name) const +{ + return entity_manager_.GetEntityId(name); +} + +entity_container_cref CoreImpl::GetEntityIds(layer_type_t type) const +{ + return entity_manager_.GetEntityIds(type); +} + +entity_container_cref CoreImpl::GetEntityIds(layer_index_t index) const +{ + return entity_manager_.GetEntityIds(index); +} + +entity_container_cref CoreImpl::GetEntityIds(const char *name) const +{ + return entity_manager_.GetEntityIds(name); +} + +void CoreImpl::SetLayerType(layer_index_t index, layer_type_t type) +{ + entity_manager_.SetLayerType(index, type); +} + +void CoreImpl::SetLayerFrozen(layer_index_t index, bool freeze) +{ + entity_manager_.SetLayerFrozen(index, freeze); +} + +void CoreImpl::RemoveFromLayer(layer_index_t index, entid_t id) +{ + entity_manager_.RemoveFromLayer(index, id); +} + +hash_t CoreImpl::GetClassCode(entid_t id) const +{ + return entity_manager_.GetClassCode(id); +} + +bool CoreImpl::IsLayerFrozen(layer_index_t index) const +{ + return entity_manager_.IsLayerFrozen(index); +} + void CoreImpl:: collectCrashInfo() const { Compiler->CollectCallStack(); diff --git a/src/libs/core/src/core_impl.h b/src/libs/core/src/core_impl.h index 6307dbfbd..2d447f04c 100644 --- a/src/libs/core/src/core_impl.h +++ b/src/libs/core/src/core_impl.h @@ -3,6 +3,7 @@ #include "core_private.h" #include "compiler.h" +#include "entity_manager.h" #include "services_list.h" #include "timer.h" #include "v_module_api.h" @@ -11,12 +12,9 @@ #define ENGINE_SCRIPT_VERSION 54128 -class CoreImpl : public CorePrivate +class CoreImpl final : public CorePrivate { public: - CoreImpl() = default; - ~CoreImpl() = default; - void Init(); void InitBase(); @@ -120,6 +118,21 @@ class CoreImpl : public CorePrivate void stopFrameProcessing() override; + // Entity management + void AddToLayer(layer_index_t index, entid_t id, priority_t priority) override; + void EraseEntity(entid_t entity) override; + entid_t CreateEntity(const char *name, ATTRIBUTES *attr) override; + entptr_t GetEntityPointer(entid_t id) const override; + entid_t GetEntityId(const char *name) const override; + entity_container_cref GetEntityIds(layer_type_t type) const override; + entity_container_cref GetEntityIds(layer_index_t index) const override; + entity_container_cref GetEntityIds(const char *name) const override; + void SetLayerType(layer_index_t index, layer_type_t type) override; + void SetLayerFrozen(layer_index_t index, bool freeze) override; + void RemoveFromLayer(layer_index_t index, entid_t id) override; + hash_t GetClassCode(entid_t id) const override; + bool IsLayerFrozen(layer_index_t index) const override; + void collectCrashInfo() const; [[nodiscard]] bool initialized() const @@ -136,6 +149,8 @@ class CoreImpl : public CorePrivate private: void loadCompatibilitySettings(INIFILE &inifile); + EntityManager entity_manager_; + storm::ENGINE_VERSION targetVersion_ = storm::ENGINE_VERSION::LATEST; bool stopFrameProcessing_ = false; diff --git a/src/libs/core/src/entity_manager.cpp b/src/libs/core/src/entity_manager.cpp index bef2c8619..618e034aa 100644 --- a/src/libs/core/src/entity_manager.cpp +++ b/src/libs/core/src/entity_manager.cpp @@ -5,30 +5,10 @@ #include "v_module_api.h" -std::array EntityManager::layers_; - -/* static array of entities and actual size */ -std::pair, EntityManager::entity_index_t> - EntityManager::entities_; - -/* stack for indices of erased entities: static constexpr array and top counter */ -std::pair, EntityManager::entity_index_t> - EntityManager::freeIndices_; - -/* static array for indices to delete */ -/* RATIONALE: - * Entities can be deleted inside destruction of another entity, therefore we shall either - * loop until there is no entity to delete (O(N^N) at worst) or use a stack for them. - */ -std::pair, EntityManager::entity_index_t> - EntityManager::deletedIndices_; - -void EntityManager::_erase(EntityInternalData &data) +void EntityManager::Erase(EntityInternalData &data) { - auto &mask = data.mask; - - // remove from layers - for (unsigned i = 0; i < sizeof(mask) * 8; ++i) + // TODO: shift loop + for (layer_index_t i = 0; i < max_layers_num; ++i) { RemoveFromLayer(i, data); } @@ -36,9 +16,9 @@ void EntityManager::_erase(EntityInternalData &data) delete data.ptr; } -void EntityManager::_EraseEntityNoCheck(const entid_t entity) +void EntityManager::EraseEntityNoCheck(const entid_t id) { - const auto index = static_cast(entity); + const auto index = static_cast(id); auto &entData = entities_.first[index]; entData.deleted = true; @@ -48,25 +28,37 @@ void EntityManager::_EraseEntityNoCheck(const entid_t entity) deletedArr[deletedSize++] = index; } -EntityManager::hash_t EntityManager::GetClassCode(const entid_t id) +hash_t EntityManager::GetClassCode(const entid_t id) const { - const auto &entData = GetEntityData(id); - return entData.hash; + const auto idx = GetEntityDataIdx(id); + if (!EntIdxValid(idx)) + { + return {}; + } + + return entities_.first[idx].hash; } void EntityManager::AddToLayer(const layer_index_t index, const entid_t id, const priority_t priority) { - assert(index < max_layers_num); // valid index - // assert(entities_.first[static_cast(id)].mask & (1 << index)); // mask shall be set + assert(index < max_layers_num); + const auto idx = GetEntityDataIdx(id); + if (!EntIdxValid(idx)) + { + return; + } + + auto& data = entities_.first[idx]; - auto &entData = GetEntityData(id); // check if entity is already in layer - if (entData.mask & (1 << index)) + if (data.mask & (1 << index)) + { return; + } // set info about layer - entData.mask |= 1 << index; - entData.priorities[index] = priority; + data.mask |= 1 << index; + data.priorities[index] = priority; auto &layer = layers_[index]; auto &priorities = layer.priorities; @@ -85,7 +77,10 @@ void EntityManager::AddToLayer(const layer_index_t index, const entid_t id, cons void EntityManager::RemoveFromLayer(const layer_index_t index, const entid_t id) { - return RemoveFromLayer(index, GetEntityData(id)); + if (const auto idx = GetEntityDataIdx(id); EntIdxValid(idx)) + { + RemoveFromLayer(index, entities_.first[idx]); + } } void EntityManager::RemoveFromLayer(const layer_index_t index, EntityInternalData &data) @@ -166,7 +161,7 @@ entid_t EntityManager::CreateEntity(const char *name, ATTRIBUTES *attr) if (!ptr->Init()) { // delete if fail - _EraseEntityNoCheck(id); + EraseEntityNoCheck(id); return invalid_entity; } @@ -174,17 +169,29 @@ entid_t EntityManager::CreateEntity(const char *name, ATTRIBUTES *attr) return id; } -void EntityManager::EraseEntity(const entid_t entity) +void EntityManager::EraseEntity(const entid_t id) { - const auto &entData = GetEntityData(entity); - if (entData.ptr == nullptr) + const auto idx = GetEntityDataIdx(id); + if (!EntIdxValid(idx)) + { return; + } + + const auto &data = entities_.first[idx]; - // validate - if (entData.ptr->GetId() != entity) - return; /* already replaced by another entity */ + // data ptr deleted + if (data.ptr == nullptr) + { + return; + } - _EraseEntityNoCheck(entity); + // entity id mismatch + if (data.ptr->GetId() != id) + { + return; + } + + EraseEntityNoCheck(id); } void EntityManager::EraseAll() @@ -197,7 +204,7 @@ void EntityManager::EraseAll() if (index >= size) continue; - _erase(arr[index]); // release + Erase(arr[index]); // release arr[index] = {}; } @@ -206,17 +213,23 @@ void EntityManager::EraseAll() freeIndices_.second = 0; } -entptr_t EntityManager::GetEntityPointer(const entid_t entity) +entptr_t EntityManager::GetEntityPointer(const entid_t id) const { - const auto &entData = GetEntityData(entity); - return entData.deleted ? nullptr : entData.ptr; + const auto idx = GetEntityDataIdx(id); + if (!EntIdxValid(idx) || entities_.first[idx].deleted) + { + return nullptr; + } + + return entities_.first[idx].ptr; } -EntityManager::EntityVector EntityManager::GetEntityIdVector(const Layer::Type type) +entity_container_cref EntityManager::GetEntityIds(const layer_type_t type) const { - std::vector result; - // should be vector of layer iterators actually... special iterator would be cool here too. + // TODO:: cache + static std::vector result; result.reserve(entities_.first.size()); // TODO: investigate memory consumption + result.clear(); for (auto it = std::begin(layers_); it != std::end(layers_); ++it) { @@ -233,15 +246,16 @@ EntityManager::EntityVector EntityManager::GetEntityIdVector(const Layer::Type t return result; } -EntityManager::EntityVector EntityManager::GetEntityIdVector(const char *name) +entity_container_cref EntityManager::GetEntityIds(const char *name) const { - return GetEntityIdVector(MakeHashValue(name)); + return GetEntityIds(MakeHashValue(name)); } -EntityManager::EntityVector EntityManager::GetEntityIdVector(const uint32_t hash) +entity_container_cref EntityManager::GetEntityIds(const uint32_t hash) const { - std::vector result; - result.reserve(max_ent_num); // TODO: investigate memory consumption + static std::vector result; + result.reserve(entities_.first.size()); // TODO: investigate memory consumption + result.clear(); const auto &arr = entities_.first; const auto size = entities_.second; @@ -257,26 +271,19 @@ EntityManager::EntityVector EntityManager::GetEntityIdVector(const uint32_t hash return result; } -EntityManager::LayerIterators EntityManager::GetEntityIdIterators(const layer_index_t index) +entity_container_cref EntityManager::GetEntityIds(const layer_index_t index) const { assert(index < max_layers_num); - auto &layer = layers_[index]; - - return std::pair{std::begin(layer.entity_ids), std::end(layer.entity_ids)}; -} - -EntityManager::AllEntIterators EntityManager::GetEntityIdIterators() -{ - return std::pair{std::begin(entities_.first), std::begin(entities_.first) + entities_.second}; + return layers_[index].entity_ids; } -entid_t EntityManager::GetEntityId(const char *name) +entid_t EntityManager::GetEntityId(const char *name) const { return GetEntityId(MakeHashValue(name)); } -entid_t EntityManager::GetEntityId(const uint32_t hash) +entid_t EntityManager::GetEntityId(const uint32_t hash) const { const auto &arr = entities_.first; const auto size = entities_.second; @@ -292,14 +299,19 @@ entid_t EntityManager::GetEntityId(const uint32_t hash) return invalid_entity; } -EntityManager::Layer::Type EntityManager::GetLayerType(const layer_index_t index) +bool EntityManager::EntIdxValid(const size_t idx) +{ + return idx != invalid_entity_idx_t{}; +} + +layer_type_t EntityManager::GetLayerType(const layer_index_t index) const { assert(index < max_layers_num); return layers_[index].type; } -void EntityManager::SetLayerType(const layer_index_t index, const Layer::Type type) +void EntityManager::SetLayerType(const layer_index_t index, const layer_type_t type) { assert(index < max_layers_num); @@ -313,7 +325,7 @@ void EntityManager::SetLayerFrozen(const layer_index_t index, const bool freeze) layers_[index].frozen = freeze; } -bool EntityManager::IsLayerFrozen(const layer_index_t index) +bool EntityManager::IsLayerFrozen(const layer_index_t index) const { assert(index < max_layers_num); @@ -349,35 +361,37 @@ void EntityManager::NewLifecycle() if (arr[index].id == 0) continue; - _erase(arr[index]); // release + Erase(arr[index]); // release arr[index] = {}; // erase entity data PushFreeIndex(index); // push free index to stack instead of shifting } deletedSize = 0; // clear array of entities to delete } -EntityManager::EntityInternalData & EntityManager::GetEntityData(const entid_t entity) +size_t EntityManager::GetEntityDataIdx(const entid_t id) const { - static EntityInternalData null{.deleted = true}; - - const auto index = static_cast(entity); - - if (index >= entities_.second) /* calm down it's ok... */ - return null; + // index out of range + const auto index = static_cast(id); + if (index >= entities_.second) + { + return invalid_entity_idx_t{}; + } + // data ptr deleted auto &data = entities_.first[index]; - if (data.ptr == nullptr) - return null; /* THIS IS ALSO FUCKING OK */ + { + return invalid_entity_idx_t{}; + } - /* check if valid */ + // entity id mismatch const auto entid = data.ptr->GetId(); - if (entity != entid) + if (id != entid) { - return null; + return invalid_entity_idx_t{}; } - - return data; + + return index; } entid_t EntityManager::PushEntity(entptr_t ptr, hash_t hash) diff --git a/src/libs/core/src/entity_manager.h b/src/libs/core/src/entity_manager.h new file mode 100644 index 000000000..48b2bef33 --- /dev/null +++ b/src/libs/core/src/entity_manager.h @@ -0,0 +1,120 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "entity.h" + +class EntityManager final +{ + using entid_index_t = uint32_t; + using entid_stamp_t = uint32_t; + using entity_index_t = uint32_t; + using invalid_entity_idx_t = std::integral_constant::max()>; + + // we are ok with half-precision + static_assert(sizeof(std::chrono::milliseconds) == + sizeof(entid_stamp_t) * 2); + + + struct EntityInternalData + { + using layer_mask_t = uint32_t; + + bool deleted; + layer_mask_t mask; + priority_t priorities[max_layers_num]; + entptr_t ptr; + entid_t id; + hash_t hash; + }; + + public: + + struct Layer + { + std::vector priorities; + std::vector entity_ids; + + layer_type_t type; + bool frozen; + }; + + private: + /* array of layers */ + std::array layers_ {}; + + /* array of entities and actual size */ + std::pair, entity_index_t> entities_; + + /* stack for indices of erased entities: static constexpr array and top counter */ + std::pair, entity_index_t> freeIndices_; + + /* array for indices to delete + * + * Background: + * Entities can be deleted inside destruction of another entity, therefore we shall either + * loop until there is no entity to delete (O(N^N) at worst) or use a stack for them. + */ + std::pair, entity_index_t> deletedIndices_; + + /* actual erase */ + void Erase(EntityInternalData &data); + + /* mark entity to delete */ + void EraseEntityNoCheck(entid_t entity); + + void RemoveFromLayer(layer_index_t index, EntityInternalData &data); + + size_t GetEntityDataIdx(entid_t id) const; + + entid_t GetEntityId(uint32_t hash) const; + + static bool EntIdxValid(size_t idx); + +public: + + hash_t GetClassCode(entid_t id) const; + + void AddToLayer(layer_index_t index, entid_t id, priority_t priority); + + void RemoveFromLayer(layer_index_t index, entid_t id); + + entid_t CreateEntity(const char *name, ATTRIBUTES *attr = nullptr); + + void EraseEntity(entid_t entity); + + void EraseAll(); + + entptr_t GetEntityPointer(entid_t id) const; + + entity_container_cref GetEntityIds(layer_type_t type) const; + + // TODO: hash... + entity_container_cref GetEntityIds(const char *name) const; + + entity_container_cref GetEntityIds(uint32_t hash) const; + + entity_container_cref GetEntityIds(layer_index_t index) const; + + entid_t GetEntityId(const char *name) const; + + layer_type_t GetLayerType(layer_index_t index) const; + + void SetLayerType(layer_index_t index, layer_type_t type); + + void SetLayerFrozen(layer_index_t index, bool freeze); + + bool IsLayerFrozen(layer_index_t index) const; + + void PushFreeIndex(entity_index_t index); + + /* new lifecycle is started at the end of each frame. it's time to cleanup */ + void NewLifecycle(); + + entid_t PushEntity(entptr_t ptr, hash_t hash); +}; diff --git a/src/libs/core/src/internal_functions.cpp b/src/libs/core/src/internal_functions.cpp index b88313bfb..c61f51232 100644 --- a/src/libs/core/src/internal_functions.cpp +++ b/src/libs/core/src/internal_functions.cpp @@ -424,9 +424,9 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t Entity *pE; MESSAGE ms; uint32_t s_off; - - static EntityManager::EntityVector *entVec; - static EntityManager::EntityVector::const_iterator it; + + static std::remove_reference_t::const_iterator entity_iterator; + static std::remove_reference_t::const_iterator entity_iterator_end; pResult = nullptr; TempFloat1 = 0; @@ -701,14 +701,14 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV->Convert(VAR_STRING); pV->Get(pChar); - ent = EntityManager::GetEntityId(pChar); + ent = core.GetEntityId(pChar); pV2 = pV2->GetVarPointer(); pV2->Set(ent); pV2->SetType(VAR_AREFERENCE); pV2->SetAReference(core_internal.Entity_GetAttributePointer(ent)); - if (EntityManager::GetEntityPointer(ent)) + if (core.GetEntityPointer(ent)) TempLong1 = 1; else TempLong1 = 0; @@ -734,18 +734,19 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV->Convert(VAR_STRING); pV->Get(pChar); - - delete entVec; - entVec = new EntityManager::EntityVector(EntityManager::GetEntityIdVector(pChar)); - it = entVec->begin(); - ent = *it; + { + auto &&entities = core.GetEntityIds(pChar); + entity_iterator = std::cbegin(entities); + entity_iterator_end = std::cend(entities); + } + ent = *entity_iterator; pV2 = pV2->GetVarPointer(); pV2->Set(ent); pV2->SetType(VAR_AREFERENCE); pV2->SetAReference(core_internal.Entity_GetAttributePointer(ent)); - if (EntityManager::GetEntityPointer(ent)) + if (core.GetEntityPointer(ent)) TempLong1 = 1; else TempLong1 = 0; @@ -762,15 +763,15 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t break; } - ++it; - ent = it != entVec->end() ? *it : invalid_entity; + ++entity_iterator; + ent = entity_iterator != entity_iterator_end ? *entity_iterator : invalid_entity; pV2 = pV2->GetVarPointer(); pV2->Set(ent); pV2->SetType(VAR_AREFERENCE); pV2->SetAReference(core_internal.Entity_GetAttributePointer(ent)); - if (EntityManager::GetEntityPointer(ent)) + if (core.GetEntityPointer(ent)) TempLong1 = 1; else TempLong1 = 0; @@ -894,10 +895,10 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t } pV->Get(pChar); { - const auto entities = EntityManager::GetEntityIdVector(pChar); + const auto entities = core.GetEntityIds(pChar); for (auto ent : entities) { - EntityManager::EraseEntity(ent); + core.EraseEntity(ent); } } break; @@ -1201,7 +1202,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV2->SetType(VAR_AREFERENCE); pV2->SetAReference(core_internal.Entity_GetAttributePointer(ent)); - if(EntityManager::GetEntityPointer(ent)) TempLong1 = 1; + if(core.GetEntityPointer(ent)) TempLong1 = 1; else TempLong1 = 0; pV = SStack.Push(); pV->Set(TempLong1); @@ -1214,7 +1215,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV->Set(ent); pV->SetType(VAR_AREFERENCE); pV->SetAReference(core_internal.Entity_GetAttributePointer(ent)); - if(EntityManager::GetEntityPointer(ent)) TempLong1 = 1; + if(core.GetEntityPointer(ent)) TempLong1 = 1; else TempLong1 = 0; pV = SStack.Push(); pV->Set(TempLong1); @@ -1402,7 +1403,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t // pV2->Get(TempLong1); // if(TempLong1 == 0) core_internal.LayerSetRealize(pChar,false); // else core_internal.LayerSetRealize(pChar,true); - EntityManager::SetLayerType(TempLong1, EntityManager::Layer::Type::realize); + core.SetLayerType(TempLong1, layer_type_t::realize); break; case FUNC_LAYER_SET_EXECUTE: // pV2 = SStack.Pop(); if(!pV2){SetError(INVALID_FA);break;}; @@ -1416,7 +1417,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t // pV2->Get(TempLong1); // if(TempLong1 == 0) core_internal.LayerSetExecute(pChar,false); // else core_internal.LayerSetExecute(pChar,true); - EntityManager::SetLayerType(TempLong1, EntityManager::Layer::Type::execute); + core.SetLayerType(TempLong1, layer_type_t::execute); break; /*case FUNC_LAYER_SET_MESSAGES: pV2 = SStack.Pop(); if(!pV2){SetError(INVALID_FA);break;}; @@ -1448,7 +1449,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV->Get(TempLong2); pV2->Get(TempEid); pV3->Get(TempLong1); - EntityManager::AddToLayer(TempLong2, TempEid, TempLong1); + core.AddToLayer(TempLong2, TempEid, TempLong1); break; case FUNC_LAYER_DELOBJECT: pV2 = SStack.Pop(); @@ -1465,7 +1466,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t } pV->Get(TempLong2); pV2->Get(TempEid); - EntityManager::RemoveFromLayer(TempLong2, TempEid); + core.RemoveFromLayer(TempLong2, TempEid); break; case FUNC_LAYER_FREEZE: pV2 = SStack.Pop(); @@ -1482,7 +1483,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t } pV->Get(TempLong2); pV2->Get(TempLong1); - EntityManager::SetLayerFrozen(TempLong2, TempLong1); + core.SetLayerFrozen(TempLong2, TempLong1); break; case FUNC_IS_Entity_LOADED: @@ -1495,7 +1496,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t pV = pV->GetVarPointer(); pV->Get(TempEid); pV = SStack.Push(); - if (EntityManager::GetEntityPointer(TempEid) != nullptr) + if (core.GetEntityPointer(TempEid) != nullptr) TempLong1 = 1; else TempLong1 = 0; @@ -1565,7 +1566,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t } pV2->Get(pChar); - if (ent = EntityManager::CreateEntity(pChar, pV->GetAClass())) + if (ent = core.CreateEntity(pChar, pV->GetAClass())) { // core_internal.Entity_SetAttributePointer(&entid_t,pV->GetAClass()); pV->Set(ent); @@ -1591,7 +1592,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t break; } pV->Get(pChar); - if (ent = EntityManager::CreateEntity(pChar)) + if (ent = core.CreateEntity(pChar)) { pV = SStack.Push(); pV->Set(ent); @@ -1609,7 +1610,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t break; } pV->Get(ent); - EntityManager::EraseEntity(ent); + core.EraseEntity(ent); break; // case FUNC_DEL_EVENT_HANDLER: @@ -1842,7 +1843,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t CreateMessage(&ms, s_off, 1); uint64_t mresult = 0; - pE = EntityManager::GetEntityPointer(ent); + pE = core.GetEntityPointer(ent); if (pE) { ms.Move2Start(); diff --git a/src/libs/island/src/foam.cpp b/src/libs/island/src/foam.cpp index b7f15ff7f..57a206083 100644 --- a/src/libs/island/src/foam.cpp +++ b/src/libs/island/src/foam.cpp @@ -86,7 +86,7 @@ void CoastFoam::Realize(uint32_t Delta_Time) if (pSea == nullptr) { - pSea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + pSea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); if (pSea == nullptr) return; } diff --git a/src/libs/island/src/island.cpp b/src/libs/island/src/island.cpp index 7b6e07502..b63af1070 100644 --- a/src/libs/island/src/island.cpp +++ b/src/libs/island/src/island.cpp @@ -45,21 +45,21 @@ ISLAND::~ISLAND() void ISLAND::Uninit() { for (uint32_t i = 0; i < aSpheres.size(); i++) - EntityManager::EraseEntity(aSpheres[i]); + core.EraseEntity(aSpheres[i]); aSpheres.clear(); STORM_DELETE(pDepthMap); STORM_DELETE(pShadowMap); if (!bForeignModels) { - EntityManager::EraseEntity(model_id); - EntityManager::EraseEntity(seabed_id); + core.EraseEntity(model_id); + core.EraseEntity(seabed_id); } } bool ISLAND::Init() { - // EntityManager::AddToLayer("system_messages", GetId(), 1); + // core.AddToLayer("system_messages", GetId(), 1); SetDevice(); // calc optimization @@ -94,7 +94,7 @@ void ISLAND::Realize(uint32_t Delta_Time) if (bForeignModels) return; - auto *pModel = static_cast(EntityManager::GetEntityPointer(model_id)); + auto *pModel = static_cast(core.GetEntityPointer(model_id)); Assert(pModel); uint32_t bFogEnable; @@ -130,7 +130,7 @@ void ISLAND::Realize(uint32_t Delta_Time) if (aForts.size() && !AIFortEID) //~!@ { - AIFortEID = EntityManager::GetEntityId("AIFort"); + AIFortEID = core.GetEntityId("AIFort"); } pRS->GetRenderState(D3DRS_FOGDENSITY, (uint32_t *)&fOldFogDensity); @@ -169,7 +169,7 @@ void ISLAND::Realize(uint32_t Delta_Time) } for (uint32_t k = 0; k < aForts.size(); k++) { - auto *const ent = EntityManager::GetEntityPointer(aForts[k]); + auto *const ent = core.GetEntityPointer(aForts[k]); auto mOld = static_cast(ent)->mtx; static_cast(ent)->mtx = mOld * mTemp; @@ -191,7 +191,7 @@ void ISLAND::Realize(uint32_t Delta_Time) pRS->SetRenderState(D3DRS_FOGENABLE, false); // pRS->SetRenderState(D3DRS_AMBIENT, RGB(dwAmbient/4,dwAmbient/4,dwAmbient/4)); - auto *pSeaBed = static_cast(EntityManager::GetEntityPointer(seabed_id)); + auto *pSeaBed = static_cast(core.GetEntityPointer(seabed_id)); if (pSeaBed) pSeaBed->ProcessStage(Stage::realize, Delta_Time); } @@ -206,7 +206,7 @@ void ISLAND::Realize(uint32_t Delta_Time) uint32_t i; for (i = 0; i < aSpheres.size(); i++) { - auto *pModel = static_cast(EntityManager::GetEntityPointer(aSpheres[i])); + auto *pModel = static_cast(core.GetEntityPointer(aSpheres[i])); auto vPos = AIPath.GetPointPos(i); if (pModel) pModel->mtx.BuildPosition(vPos.x, 5.0f, vPos.z); @@ -298,7 +298,7 @@ void ISLAND::AddLocationModel(entid_t eid, const std::string_view &pIDStr, const bForeignModels = true; cModelsDir = pDir; cModelsID = pIDStr; - EntityManager::AddToLayer(ISLAND_TRACE, eid, 10); + core.AddToLayer(ISLAND_TRACE, eid, 10); } inline float ISLAND::GetDepthNoCheck(uint32_t iX, uint32_t iZ) @@ -396,7 +396,7 @@ bool ISLAND::ActivateCamomileTrace(CVECTOR &vSrc) fRes = Trace(vSrc, vDst); if (fRes > 1.0f) continue; - auto *pEnt = static_cast(EntityManager::GetEntityPointer(pCollide->GetObjectID())); + auto *pEnt = static_cast(core.GetEntityPointer(pCollide->GetObjectID())); Assert(pEnt); pEnt->GetCollideTriangle(trg); vCross = !((trg.vrt[1] - trg.vrt[0]) ^ (trg.vrt[2] - trg.vrt[0])); @@ -415,10 +415,10 @@ void ISLAND::CalcBoxParameters(CVECTOR &_vBoxCenter, CVECTOR &_vBoxSize) GEOS::INFO ginfo; float x1 = 1e+8f, x2 = -1e+8f, z1 = 1e+8f, z2 = -1e+8f; - const auto its = EntityManager::GetEntityIdIterators(ISLAND_TRACE); - for (auto it = its.first; it != its.second; ++it) + auto &&entities = core.GetEntityIds(ISLAND_TRACE); + for (auto ent_id : entities) { - MODEL *pM = static_cast(EntityManager::GetEntityPointer(*it)); + MODEL *pM = static_cast(core.GetEntityPointer(ent_id)); if (pM == nullptr) continue; @@ -450,7 +450,7 @@ void ISLAND::CalcBoxParameters(CVECTOR &_vBoxCenter, CVECTOR &_vBoxSize) bool ISLAND::CreateShadowMap(char *pDir, char *pName) { auto *const pWeather = - static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("Weather"))); + static_cast(core.GetEntityPointer(core.GetEntityId("Weather"))); if (pWeather == nullptr) { throw std::runtime_error("No found WEATHER entity!"); @@ -774,23 +774,23 @@ bool ISLAND::Mount(const std::string_view &fname, const std::string_view &fdir, //core.Trace("ISLAND: island %s, dynamicLightsOn = %d", std::string(fname).c_str(), dynamicLightsOn); // <--- - model_id = EntityManager::CreateEntity("MODELR"); + model_id = core.CreateEntity("MODELR"); core.Send_Message(model_id, "ls", MSG_MODEL_SET_LIGHT_PATH, static_cast(AttributesPointer->GetAttribute("LightingPath"))); core.Send_Message(model_id, "ls", MSG_MODEL_LOAD_GEO, pathStr.c_str()); // extract subobject(sea_bed) to another model - auto *pModel = static_cast(EntityManager::GetEntityPointer(model_id)); + auto *pModel = static_cast(core.GetEntityPointer(model_id)); NODE *pNode = pModel->FindNode(SEA_BED_NODE_NAME); if (pNode) seabed_id = pNode->Unlink2Model(); else core.Trace("Island: island %s has no sea bed, check me!", std::string(fname).c_str()); - EntityManager::AddToLayer(ISLAND_TRACE, model_id, 10); - EntityManager::AddToLayer(ISLAND_TRACE, seabed_id, 10); - EntityManager::AddToLayer(RAIN_DROPS, model_id, 100); + core.AddToLayer(ISLAND_TRACE, model_id, 10); + core.AddToLayer(ISLAND_TRACE, seabed_id, 10); + core.AddToLayer(RAIN_DROPS, model_id, 100); - auto *pSeaBedModel = static_cast(EntityManager::GetEntityPointer(seabed_id)); + auto *pSeaBedModel = static_cast(core.GetEntityPointer(seabed_id)); mIslandOld = pModel->mtx; if (pSeaBedModel) @@ -801,7 +801,7 @@ bool ISLAND::Mount(const std::string_view &fname, const std::string_view &fdir, sLightPath.Format("%s", AttributesPointer->GetAttribute("LightingPath")); sLightPath.CheckPath(); core.Send_Message(lighter_id, "ss", "LightPath", (char*)sLightPath);*/ - const auto lighter_id = EntityManager::GetEntityId("lighter"); + const auto lighter_id = core.GetEntityId("lighter"); core.Send_Message(lighter_id, "ssi", "AddModel", std::string(fname).c_str(), model_id); const std::string sSeaBedName = std::string(fname) + "_seabed"; core.Send_Message(lighter_id, "ssi", "AddModel", (char *)sSeaBedName.c_str(), seabed_id); @@ -816,9 +816,9 @@ bool ISLAND::Mount(const std::string_view &fname, const std::string_view &fdir, /*for (uint32_t i=0;iTrace(EntityManager::GetEntityIdIterators(ISLAND_TRACE), vSrc, vDst, nullptr, 0); + return pCollide->Trace(core.GetEntityIds(ISLAND_TRACE), vSrc, vDst, nullptr, 0); } // Path section diff --git a/src/libs/lighter/src/l_geometry.cpp b/src/libs/lighter/src/l_geometry.cpp index 523768792..edf78d656 100644 --- a/src/libs/lighter/src/l_geometry.cpp +++ b/src/libs/lighter/src/l_geometry.cpp @@ -93,7 +93,7 @@ void LGeometry::AddObject(const char *name, entid_t model) str[d++] = str[s]; } object[numObjects].model = model; - object[numObjects].m = static_cast(EntityManager::GetEntityPointer(model)); + object[numObjects].m = static_cast(core.GetEntityPointer(model)); if (!object[numObjects].m) { core.Trace("Location lighter: can't get pointer to model %s", name); @@ -112,7 +112,7 @@ bool LGeometry::Process(VDX9RENDER *rs, int32_t numLights) // Index in the final file int32_t cindex = 0; // Check - if (object[i].m != static_cast(EntityManager::GetEntityPointer(object[i].model))) + if (object[i].m != static_cast(core.GetEntityPointer(object[i].model))) { core.Trace("Location lighter: lost model!!!"); return false; diff --git a/src/libs/lighter/src/lighter.cpp b/src/libs/lighter/src/lighter.cpp index 571b68acd..476da769b 100644 --- a/src/libs/lighter/src/lighter.cpp +++ b/src/libs/lighter/src/lighter.cpp @@ -51,10 +51,10 @@ bool Lighter::Init() if (!rs) throw std::runtime_error("No service: dx9render"); // - EntityManager::SetLayerType(LIGHTER_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(LIGHTER_EXECUTE, GetId(), 1000); - EntityManager::SetLayerType(LIGHTER_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(LIGHTER_REALIZE, GetId(), 1000); + core.SetLayerType(LIGHTER_EXECUTE, layer_type_t::execute); + core.AddToLayer(LIGHTER_EXECUTE, GetId(), 1000); + core.SetLayerType(LIGHTER_REALIZE, layer_type_t::realize); + core.AddToLayer(LIGHTER_REALIZE, GetId(), 1000); // lightProcessor.SetParams(&geometry, &window, &lights, &octTree, rs); // window system diff --git a/src/libs/lighter/src/window.cpp b/src/libs/lighter/src/window.cpp index 95e8a66e8..b13ee2796 100644 --- a/src/libs/lighter/src/window.cpp +++ b/src/libs/lighter/src/window.cpp @@ -674,7 +674,7 @@ void Window::Reset(bool isActive) isList = false; isVisible = isActive; entid_t loc; - core.Send_Message(EntityManager::GetEntityId("location"), "ll", MSG_LOCATION_PAUSE, static_cast(isActive)); + core.Send_Message(core.GetEntityId("location"), "ll", MSG_LOCATION_PAUSE, static_cast(isActive)); slidID = -1; isPikerActive = false; isActiveMouseState = false; diff --git a/src/libs/location/src/blood.cpp b/src/libs/location/src/blood.cpp index bce28286f..c927f9278 100644 --- a/src/libs/location/src/blood.cpp +++ b/src/libs/location/src/blood.cpp @@ -166,13 +166,13 @@ void Blood::AddBlood(const CVECTOR &pos) auto cpos = pos; - const auto its = EntityManager::GetEntityIdIterators(BLOOD); + auto &&entities = core.GetEntityIds(BLOOD); auto src = pos; src.y += 1.f; auto dst = pos; dst.y -= 10.f; - auto fTrace = pCol->Trace(its, src, dst, nullptr, 0); + auto fTrace = pCol->Trace(entities, src, dst, nullptr, 0); if (fTrace <= 1.f) cpos.y = src.y + (dst.y - src.y) * fTrace; @@ -192,7 +192,7 @@ void Blood::AddBlood(const CVECTOR &pos) src.y += 1.5f; dst = cpos; dst.y -= 10.f; - fTrace = pCol->Trace(its, src, dst, nullptr, 0); + fTrace = pCol->Trace(entities, src, dst, nullptr, 0); if (fTrace <= 1.f) cpos.y = src.y + (dst.y - src.y) * fTrace; } @@ -225,9 +225,9 @@ void Blood::AddBlood(const CVECTOR &pos) p[5].D = -(cpos.x - BLOOD_RADIUS); // loop through the layer - for (auto it = its.first; it != its.second; ++it) + for (auto ent_id : entities) { - auto *m = static_cast(EntityManager::GetEntityPointer(*it)); + auto *m = static_cast(core.GetEntityPointer(ent_id)); if (!m) continue; auto *root = m->GetNode(0); @@ -237,7 +237,7 @@ void Blood::AddBlood(const CVECTOR &pos) // loop through the array of models for (int32_t n = 0; n < aModels.size(); n++) { - auto *m = static_cast(EntityManager::GetEntityPointer(aModels[n])); + auto *m = static_cast(core.GetEntityPointer(aModels[n])); if (!m) continue; auto *root = m->GetNode(0); diff --git a/src/libs/location/src/character.cpp b/src/libs/location/src/character.cpp index eaaa45d9d..b4f7f31ca 100644 --- a/src/libs/location/src/character.cpp +++ b/src/libs/location/src/character.cpp @@ -618,7 +618,7 @@ Character::Character() Character::~Character() { - auto *m = static_cast(EntityManager::GetEntityPointer(mdl)); + auto *m = static_cast(core.GetEntityPointer(mdl)); if (m) { auto *a = m->GetAnimation(); @@ -639,7 +639,7 @@ Character::~Character() m_nHandLightID = -1; // Removing from groups - core.Send_Message(EntityManager::GetEntityId("CharactersGroups"), "si", "UnloadCharacter", GetId()); + core.Send_Message(core.GetEntityId("CharactersGroups"), "si", "UnloadCharacter", GetId()); // Analyzing detectors // for(int32_t i = 0; i < numDetectors; i++) detector[i]->Exit(this); @@ -649,11 +649,11 @@ Character::~Character() // if (location && !isDeleted) location->supervisor.DelCharacter(this); - EntityManager::EraseEntity(shadow); - EntityManager::EraseEntity(waterrings); - EntityManager::EraseEntity(mdl); - EntityManager::EraseEntity(blade); - EntityManager::EraseEntity(sign); + core.EraseEntity(shadow); + core.EraseEntity(waterrings); + core.EraseEntity(mdl); + core.EraseEntity(blade); + core.EraseEntity(sign); delete characterID; } @@ -664,12 +664,12 @@ bool Character::Init() auto *const location = GetLocation(); if (!location) return false; - effects = EntityManager::GetEntityId("LocationEffects"); + effects = core.GetEntityId("LocationEffects"); soundService = static_cast(core.GetService("SoundService")); // register our appearance in the location location->supervisor.AddCharacter(this); // The sea - sea = EntityManager::GetEntityId("sea"); + sea = core.GetEntityId("sea"); // save the identifier const char *id = nullptr; if (AttributesPointer) @@ -680,7 +680,7 @@ bool Character::Init() characterID = new char[len]; strcpy_s(characterID, len, id); // Add to the group - core.Send_Message(EntityManager::GetEntityId("CharactersGroups"), "sis", "MoveCharacter", GetId(), group); + core.Send_Message(core.GetEntityId("CharactersGroups"), "sis", "MoveCharacter", GetId(), group); SetSignModel(); SetSignTechnique(); return PostInit(); @@ -1010,7 +1010,7 @@ void Character::SetSignModel() return; } signName = signModelName; - EntityManager::EraseEntity(sign); + core.EraseEntity(sign); if (!signModelName[0]) { return; @@ -1023,7 +1023,7 @@ void Character::SetSignModel() std::string path = "quest_signs\\"; path += signModelName; // Create and load the model - if (!(sign = EntityManager::CreateEntity("modelr"))) + if (!(sign = core.CreateEntity("modelr"))) { if (gs) gs->SetTexturePath(""); @@ -1044,8 +1044,8 @@ void Character::SetSignModel() if (gs) gs->SetTexturePath(""); - EntityManager::AddToLayer(REALIZE, sign, 20000); - EntityManager::AddToLayer(SUN_TRACE, sign, 10); + core.AddToLayer(REALIZE, sign, 20000); + core.AddToLayer(SUN_TRACE, sign, 10); } void Character::SetSignTechnique() @@ -1103,7 +1103,7 @@ void Character::ReadFightActions(ATTRIBUTES *at, ActionCharacter actions[4], int MODEL *Character::Model() const { - return static_cast(EntityManager::GetEntityPointer(mdl)); + return static_cast(core.GetEntityPointer(mdl)); } // Move model to point x, y, z @@ -1947,7 +1947,7 @@ void Character::Move(float dltTime) { if (fgtCurType >= fgt_attack_fast && fgtCurType <= fgt_attack_feintc) { - auto *eAttack = static_cast(EntityManager::GetEntityPointer(enemyAttack)); + auto *eAttack = static_cast(core.GetEntityPointer(enemyAttack)); if (eAttack) { isTurnLock = false; @@ -2124,7 +2124,7 @@ void Character::Move(float dltTime) curJumpFallTime += dltTime; if (isJumpSnd && priorityAction.name) { - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); if (sb && location->IsSwimming()) { seaY = sb->WaveXZ(curPos.x, curPos.z, nullptr); @@ -2207,7 +2207,7 @@ void Character::Move(float dltTime) if (swimChange <= 0.0f && location->IsSwimming()) { const bool old = isSwim; - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); isSwim = false; isRunDisable = false; if (sb) @@ -2424,7 +2424,7 @@ void Character::Update(float dltTime) { core.Event("Location_CharacterExitFromLocation", "e", GetId()); } - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } } } @@ -2457,7 +2457,7 @@ void Character::Update(float dltTime) } soundGrass = false; // - MODEL *signMdl = static_cast(EntityManager::GetEntityPointer(sign)); + MODEL *signMdl = static_cast(core.GetEntityPointer(sign)); if (signMdl) { CVECTOR dir = camPos - curPos; @@ -2505,7 +2505,7 @@ void Character::Update(float dltTime) if (curHeadLookState == HeadLookState::character) { - auto *targetChrPtr = static_cast(EntityManager::GetEntityPointer(headLookChrTarget)); + auto *targetChrPtr = static_cast(core.GetEntityPointer(headLookChrTarget)); if (targetChrPtr) { @@ -2650,7 +2650,7 @@ void Character::ActionEvent(const char *actionName, Animation *animation, int32_ animation->Player(0).SetPosition(1.0f); // check where we fell and play the animation after falling to the ground and into the water. - SEA_BASE *sb = static_cast(EntityManager::GetEntityPointer(sea)); + SEA_BASE *sb = static_cast(core.GetEntityPointer(sea)); if (sb) { if (sb->WaveXZ(curPos.x, curPos.z, nullptr) - curPos.y > CHARACTER_SEA_SWIM) @@ -2895,7 +2895,7 @@ void Character::PlayStep() return; if (isSwim) return; - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); auto *const location = GetLocation(); if (sb && location->IsSwimming()) { @@ -3060,9 +3060,9 @@ void Character::ReleaseSound(int32_t id) bool Character::zLoadModel(MESSAGE &message) { char mpath[300]; - EntityManager::EraseEntity(shadow); - EntityManager::EraseEntity(waterrings); - EntityManager::EraseEntity(mdl); + core.EraseEntity(shadow); + core.EraseEntity(waterrings); + core.EraseEntity(mdl); const std::string &name = message.String(); const std::string &ani = message.String(); // Path to textures @@ -3073,7 +3073,7 @@ bool Character::zLoadModel(MESSAGE &message) strcpy_s(mpath, "characters\\"); strcat_s(mpath, name.c_str()); // Create and load the model - if (!(mdl = EntityManager::CreateEntity("modelr"))) + if (!(mdl = core.CreateEntity("modelr"))) { if (gs) gs->SetTexturePath(""); @@ -3091,13 +3091,13 @@ bool Character::zLoadModel(MESSAGE &message) if (!core.Send_Message(mdl, "ls", MSG_MODEL_LOAD_ANI, ani.c_str()) != 0) { core.Trace("Character animation '%s' not loaded", ani.c_str()); - EntityManager::EraseEntity(mdl); + core.EraseEntity(mdl); return false; } - auto *m = static_cast(EntityManager::GetEntityPointer(mdl)); + auto *m = static_cast(core.GetEntityPointer(mdl)); if (!m) { - EntityManager::EraseEntity(mdl); + core.EraseEntity(mdl); return false; } Animation *a = m->GetAnimation(); @@ -3107,9 +3107,9 @@ bool Character::zLoadModel(MESSAGE &message) eventId = a->SetEvent(ae_end, 0, &eventListener); } m->SetRenderTuner(&tuner); - EntityManager::AddToLayer(REALIZE, mdl, 20); - EntityManager::AddToLayer(SUN_TRACE, mdl, 10); - if (shadow = EntityManager::CreateEntity("shadow")) + core.AddToLayer(REALIZE, mdl, 20); + core.AddToLayer(SUN_TRACE, mdl, 10); + if (shadow = core.CreateEntity("shadow")) { core.Send_Message(shadow, "li", 0, mdl); } @@ -3117,9 +3117,9 @@ bool Character::zLoadModel(MESSAGE &message) { core.Trace("Shadow not created!"); } - if (!EntityManager::GetEntityId("waterrings")) + if (!core.GetEntityId("waterrings")) { - waterrings = EntityManager::CreateEntity("waterrings"); + waterrings = core.CreateEntity("waterrings"); } UpdateActionsData(); return true; @@ -3226,9 +3226,9 @@ bool Character::zSetBlade(MESSAGE &message) const float t = message.Float(); const int32_t s = message.Long(); const int32_t e = message.Long(); - if (!EntityManager::GetEntityPointer(blade)) + if (!core.GetEntityPointer(blade)) { - if (!(blade = EntityManager::CreateEntity("blade"))) + if (!(blade = core.CreateEntity("blade"))) return false; } core.Send_Message(blade, "llisfll", MSG_BLADE_SET, nBladeIdx, mdl, name.c_str(), t, s, e); @@ -3244,9 +3244,9 @@ bool Character::zSetGun(MESSAGE &message) isGunSet = true; if (name.empty()) isGunSet = false; - if (!EntityManager::GetEntityPointer(blade)) + if (!core.GetEntityPointer(blade)) { - if (!(blade = EntityManager::CreateEntity("blade"))) + if (!(blade = core.CreateEntity("blade"))) return false; } core.Send_Message(blade, "lis", MSG_BLADE_GUNSET, mdl, name.c_str()); @@ -3283,7 +3283,7 @@ bool Character::zTurnByLoc(MESSAGE &message) bool Character::zTurnByChr(MESSAGE &message) { const entid_t chr = message.EntityID(); - auto *c = static_cast(EntityManager::GetEntityPointer(chr)); + auto *c = static_cast(core.GetEntityPointer(chr)); if (!c) return false; Turn(c->curPos.x - curPos.x, c->curPos.z - curPos.z); @@ -3302,7 +3302,7 @@ bool Character::zTurnByPoint(MESSAGE &message) bool Character::zDistByCharacter(MESSAGE &message, bool is2D) { const entid_t chr = message.EntityID(); - auto *c = static_cast(EntityManager::GetEntityPointer(chr)); + auto *c = static_cast(core.GetEntityPointer(chr)); if (!c) return false; const float dx = curPos.x - c->curPos.x; @@ -3331,9 +3331,9 @@ uint32_t Character::zExMessage(MESSAGE &message) i = message.Long(); const std::string &modelName = message.String(); const std::string &locatorName = message.String(); - if (!EntityManager::GetEntityPointer(blade)) + if (!core.GetEntityPointer(blade)) { - if (!(blade = EntityManager::CreateEntity("blade"))) + if (!(blade = core.CreateEntity("blade"))) return 0; UpdateWeapons(); } @@ -4992,7 +4992,7 @@ Character *Character::FindGunTarget(float &kDist, bool bOnlyEnemyTest, bool bAbo if (bOnlyEnemyTest || bAbortIfFriend) { chrGroup = static_cast( - EntityManager::GetEntityPointer(EntityManager::GetEntityId("CharactersGroups"))); + core.GetEntityPointer(core.GetEntityId("CharactersGroups"))); grp = chrGroup->FindGroupIndex(group); if (grp < 0) return nullptr; @@ -5122,7 +5122,7 @@ void Character::FindNearCharacters(MESSAGE &message) // Check visibility bool Character::CharactersVisibleTest(MESSAGE &message) { - auto *chr = static_cast(EntityManager::GetEntityPointer(message.EntityID())); + auto *chr = static_cast(core.GetEntityPointer(message.EntityID())); if (!chr) return false; return VisibleTest(chr); @@ -5160,18 +5160,18 @@ void Character::UpdateWeapons() { if (isFightWOWps) { - EntityManager::RemoveFromLayer(REALIZE, blade); + core.RemoveFromLayer(REALIZE, blade); } else { - EntityManager::AddToLayer(REALIZE, blade, 65550); + core.AddToLayer(REALIZE, blade, 65550); } } // Get direction towards the enemy to bounce on hit CVECTOR Character::GetEnemyDirForImpulse() { - auto *chr = static_cast(EntityManager::GetEntityPointer(enemyAttack)); + auto *chr = static_cast(core.GetEntityPointer(enemyAttack)); if (!chr) return CVECTOR(0.0f); CVECTOR dir = chr->curPos - curPos; @@ -5365,13 +5365,13 @@ int32_t Character::GetRandomIndexByObstacle(ObstacleZone *pZone, int32_t num) Location *Character::GetLocation() { - auto *const location = static_cast(EntityManager::GetEntityPointer(loc_id)); + auto *const location = static_cast(core.GetEntityPointer(loc_id)); if (location) return location; - loc_id = EntityManager::GetEntityId("location"); - return static_cast(EntityManager::GetEntityPointer(loc_id)); + loc_id = core.GetEntityId("location"); + return static_cast(core.GetEntityPointer(loc_id)); } bool Character::CheckShotOnlyEnemyTest() const diff --git a/src/libs/location/src/character_animation_kipper.cpp b/src/libs/location/src/character_animation_kipper.cpp index 0447ec24f..0d87e08e9 100644 --- a/src/libs/location/src/character_animation_kipper.cpp +++ b/src/libs/location/src/character_animation_kipper.cpp @@ -44,10 +44,10 @@ CharacterAnimationKipper::~CharacterAnimationKipper() bool CharacterAnimationKipper::Init() { // check that the it's the only one - const auto &entities = EntityManager::GetEntityIdVector("CharacterAnimationKipper"); + const auto &entities = core.GetEntityIds("CharacterAnimationKipper"); for (auto eid : entities) { - if (EntityManager::GetEntityPointer(eid) == this) + if (core.GetEntityPointer(eid) == this) continue; core.Trace("CharacterAnimationKipper::Init() -> CharacterAnimationKipper already created"); diff --git a/src/libs/location/src/characters_groups.cpp b/src/libs/location/src/characters_groups.cpp index c3cdd8d9c..77197ef61 100644 --- a/src/libs/location/src/characters_groups.cpp +++ b/src/libs/location/src/characters_groups.cpp @@ -128,14 +128,14 @@ int32_t CharactersGroups::String::GetLen(const char *str) bool CharactersGroups::Init() { // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - location = static_cast(EntityManager::GetEntityPointer(loc)); + const auto loc = core.GetEntityId("location"); + location = static_cast(core.GetEntityPointer(loc)); if (!location) return false; RegistryGroup(""); // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 10); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 10); return true; } @@ -185,7 +185,7 @@ void CharactersGroups::Execute(uint32_t delta_time) size_t n; for (n = 0; n < groups[i]->c.size(); n++) { - auto *cg = static_cast(EntityManager::GetEntityPointer(groups[i]->c[n])); + auto *cg = static_cast(core.GetEntityPointer(groups[i]->c[n])); if (cg && cg->IsSetBlade()) break; } @@ -330,7 +330,7 @@ bool CharactersGroups::AddEnemyTarget(Character *chr, Character *enemy, float ma // Looking among added for (int32_t i = 0; i < chr->numTargets; i++) { - if (enemy == EntityManager::GetEntityPointer(chr->grpTargets[i].chr)) + if (enemy == core.GetEntityPointer(chr->grpTargets[i].chr)) { chr->grpTargets[i].time = 0.0f; return true; @@ -376,7 +376,7 @@ bool CharactersGroups::RemoveInvalidTargets(Character *chr, Character *check) { auto isDelete = true; auto &trg = chr->grpTargets[i]; - auto *c = static_cast(EntityManager::GetEntityPointer(trg.chr)); + auto *c = static_cast(core.GetEntityPointer(trg.chr)); if (c && (trg.time < trg.timemax || trg.timemax < 0.0f)) { if (!c->IsDead()) @@ -537,10 +537,10 @@ bool CharactersGroups::MsgIsValidateTarget(MESSAGE &message) { const auto chr = message.EntityID(); const auto trg = message.EntityID(); - auto *c = static_cast(EntityManager::GetEntityPointer(chr)); + auto *c = static_cast(core.GetEntityPointer(chr)); if (!c) return false; - auto *en = static_cast(EntityManager::GetEntityPointer(trg)); + auto *en = static_cast(core.GetEntityPointer(trg)); if (!en) return false; CVECTOR vP1, vP2; @@ -555,7 +555,7 @@ bool CharactersGroups::MsgIsValidateTarget(MESSAGE &message) bool CharactersGroups::MsgGetOptimalTarget(MESSAGE &message) const { const auto chr = message.EntityID(); - auto *c = static_cast(EntityManager::GetEntityPointer(chr)); + auto *c = static_cast(core.GetEntityPointer(chr)); if (!c) return false; auto *vd = message.ScriptVariablePointer(); @@ -576,7 +576,7 @@ bool CharactersGroups::MsgGetOptimalTarget(MESSAGE &message) const for (int32_t i = 0; i < c->numTargets; i++) { // Character pointer - auto *nc = static_cast(EntityManager::GetEntityPointer(c->grpTargets[i].chr)); + auto *nc = static_cast(core.GetEntityPointer(c->grpTargets[i].chr)); if (!nc) continue; if (!nc->IsSetBlade()) @@ -615,7 +615,7 @@ bool CharactersGroups::MsgGetOptimalTarget(MESSAGE &message) const if (s < 0) s = 0; } - c = static_cast(EntityManager::GetEntityPointer(c->grpTargets[s].chr)); + c = static_cast(core.GetEntityPointer(c->grpTargets[s].chr)); // if(!c->IsSetBlade()) return false; if (c->AttributesPointer) { @@ -631,8 +631,8 @@ bool CharactersGroups::MsgGetOptimalTarget(MESSAGE &message) const // Is this character an enemy bool CharactersGroups::MsgIsEnemy(MESSAGE &message) { - const auto g1 = GetCharacterGroup(static_cast(EntityManager::GetEntityPointer(message.EntityID()))); - const auto g2 = GetCharacterGroup(static_cast(EntityManager::GetEntityPointer(message.EntityID()))); + const auto g1 = GetCharacterGroup(static_cast(core.GetEntityPointer(message.EntityID()))); + const auto g2 = GetCharacterGroup(static_cast(core.GetEntityPointer(message.EntityID()))); if (g1 < 0 || g2 < 0) return false; auto isSelf = false; @@ -680,9 +680,9 @@ void CharactersGroups::MsgAddTarget(MESSAGE &message) { // get characters auto eid = message.EntityID(); - auto *chr = static_cast(EntityManager::GetEntityPointer(eid)); + auto *chr = static_cast(core.GetEntityPointer(eid)); eid = message.EntityID(); - auto *enemy = static_cast(EntityManager::GetEntityPointer(eid)); + auto *enemy = static_cast(core.GetEntityPointer(eid)); if (!chr || !enemy) return; // Checking for hostility @@ -721,7 +721,7 @@ void CharactersGroups::MsgAddTarget(MESSAGE &message) void CharactersGroups::MsgUpdChrTrg(MESSAGE &message) { const auto eid = message.EntityID(); - auto *chr = static_cast(EntityManager::GetEntityPointer(eid)); + auto *chr = static_cast(core.GetEntityPointer(eid)); if (chr) CharacterVisibleCheck(chr); } @@ -930,7 +930,7 @@ bool CharactersGroups::MsgSetAlarmDown(MESSAGE &message) bool CharactersGroups::MoveCharacterToGroup(MESSAGE &message) { const auto eid = message.EntityID(); - auto *chr = static_cast(EntityManager::GetEntityPointer(eid)); + auto *chr = static_cast(core.GetEntityPointer(eid)); if (!chr) return false; // create a group @@ -1033,7 +1033,7 @@ void CharactersGroups::MsgSetAlarmReaction(MESSAGE &message) // Remove character from all groups void CharactersGroups::RemoveCharacterFromAllGroups(entid_t chr) { - auto *const ch = chr ? static_cast(EntityManager::GetEntityPointer(chr)) : nullptr; + auto *const ch = chr ? static_cast(core.GetEntityPointer(chr)) : nullptr; // Remove the character from the previous group for (int32_t i = 0; i < numGroups; i++) { @@ -1041,7 +1041,7 @@ void CharactersGroups::RemoveCharacterFromAllGroups(entid_t chr) auto &cid = g->c; for (size_t j = 0; j < g->c.size();) { - auto *c = static_cast(EntityManager::GetEntityPointer(cid[j])); + auto *c = static_cast(core.GetEntityPointer(cid[j])); if (c == nullptr || c == ch) { cid[j] = cid.back(); diff --git a/src/libs/location/src/fader.cpp b/src/libs/location/src/fader.cpp index cbc9ea6d0..c3902ca16 100644 --- a/src/libs/location/src/fader.cpp +++ b/src/libs/location/src/fader.cpp @@ -55,13 +55,13 @@ bool Fader::Init() { // check that it's the only one - const auto &entities = EntityManager::GetEntityIdVector("Fader"); + const auto &entities = core.GetEntityIds("Fader"); for (auto eid : entities) { if (eid == GetId()) continue; - if (fadeIn == static_cast(EntityManager::GetEntityPointer(eid))->fadeIn) + if (fadeIn == static_cast(core.GetEntityPointer(eid))->fadeIn) { core.Trace("Fader::Init() -> Fader already created, %s", fadeIn ? "fade in phase" : "fade out phase"); } @@ -69,10 +69,10 @@ bool Fader::Init() // return false; } // Layers - EntityManager::SetLayerType(FADER_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(FADER_REALIZE, GetId(), -256); - EntityManager::SetLayerType(FADER_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(FADER_EXECUTE, GetId(), -256); + core.SetLayerType(FADER_REALIZE, layer_type_t::realize); + core.AddToLayer(FADER_REALIZE, GetId(), -256); + core.SetLayerType(FADER_EXECUTE, layer_type_t::execute); + core.AddToLayer(FADER_EXECUTE, GetId(), -256); // DX9 render rs = static_cast(core.GetService("dx9render")); @@ -263,7 +263,7 @@ void Fader::Execute(uint32_t delta_time) { deleteMe++; if (deleteMe >= 3) - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } if (eventStart) { diff --git a/src/libs/location/src/grass.cpp b/src/libs/location/src/grass.cpp index f68e52631..37bccf382 100644 --- a/src/libs/location/src/grass.cpp +++ b/src/libs/location/src/grass.cpp @@ -97,11 +97,11 @@ bool Grass::Init() { // Layers // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 1000); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 1000); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 1000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 1000); // boal shader selection --> isGrassLightsOn = 1; @@ -393,7 +393,7 @@ void Grass::Realize(uint32_t delta_time) // Fog uint32_t dwOldFogDensity; rs->GetRenderState(D3DRS_FOGDENSITY, &dwOldFogDensity); - entid_t eidIsland = EntityManager::GetEntityId("ISLAND"); + entid_t eidIsland = core.GetEntityId("ISLAND"); if (eidIsland) { auto fIslandFogDensity = static_cast(dwOldFogDensity); diff --git a/src/libs/location/src/lights.cpp b/src/libs/location/src/lights.cpp index 90eeb30e2..1fed8d31d 100644 --- a/src/libs/location/src/lights.cpp +++ b/src/libs/location/src/lights.cpp @@ -137,10 +137,10 @@ bool Lights::Init() return false; } // start executing - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 10); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), -1000); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 10); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), -1000); return true; } @@ -257,7 +257,7 @@ void Lights::Realize(uint32_t delta_time) // Visibility if (collide) { - const auto dist = collide->Trace(EntityManager::GetEntityIdIterators(SUN_TRACE), pos, + const auto dist = collide->Trace(core.GetEntityIds(SUN_TRACE), pos, CVECTOR(ls.pos.x, ls.pos.y, ls.pos.z), lampModels, numLampModels); isVisible = dist > 1.0f; } @@ -404,7 +404,7 @@ void Lights::AddLight(int32_t index, const CVECTOR &pos) lights[numLights].intensity = 0; // Send a message to the lighter - if (const auto eid = EntityManager::GetEntityId("Lighter")) + if (const auto eid = core.GetEntityId("Lighter")) { core.Send_Message(eid, "sffffffffffs", "AddLight", pos.x, pos.y, pos.z, types[index].color.r, types[index].color.g, types[index].color.b, types[index].dxLight.Attenuation0, diff --git a/src/libs/location/src/lizards.cpp b/src/libs/location/src/lizards.cpp index 7f2cd544d..1d3595164 100644 --- a/src/libs/location/src/lizards.cpp +++ b/src/libs/location/src/lizards.cpp @@ -25,8 +25,8 @@ Lizards::~Lizards() bool Lizards::Init() { // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - auto *location = (Location *)EntityManager::GetEntityPointer(loc); + const auto loc = core.GetEntityId("location"); + auto *location = (Location *)core.GetEntityPointer(loc); if (!location) return false; // init lizards @@ -34,8 +34,8 @@ bool Lizards::Init() lizard[i].Init(location); // Execution // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 100000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 100000); return true; } diff --git a/src/libs/location/src/loc_crabs.cpp b/src/libs/location/src/loc_crabs.cpp index 8a29ffb8d..6b1b35853 100644 --- a/src/libs/location/src/loc_crabs.cpp +++ b/src/libs/location/src/loc_crabs.cpp @@ -23,14 +23,14 @@ LocCrabs::~LocCrabs() bool LocCrabs::Init() { // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - auto *location = (Location *)EntityManager::GetEntityPointer(loc); + const auto loc = core.GetEntityId("location"); + auto *location = (Location *)core.GetEntityPointer(loc); if (!location) return false; // Execution // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 100000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 100000); return true; } @@ -43,8 +43,8 @@ uint64_t LocCrabs::ProcessMessage(MESSAGE &message) if (num > sizeof(crab) / sizeof(LocCrab)) num = sizeof(crab) / sizeof(LocCrab); // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - auto *location = (Location *)EntityManager::GetEntityPointer(loc); + const auto loc = core.GetEntityId("location"); + auto *location = (Location *)core.GetEntityPointer(loc); if (!location) return 0; // start crabs diff --git a/src/libs/location/src/loc_eagle.cpp b/src/libs/location/src/loc_eagle.cpp index 3e049bd6c..31ec19394 100644 --- a/src/libs/location/src/loc_eagle.cpp +++ b/src/libs/location/src/loc_eagle.cpp @@ -31,15 +31,15 @@ LocEagle::LocEagle() LocEagle::~LocEagle() { - EntityManager::EraseEntity(mdl); + core.EraseEntity(mdl); } // Initialization bool LocEagle::Init() { // The point we fly around - const auto loc = EntityManager::GetEntityId("location"); - auto *location = static_cast(EntityManager::GetEntityPointer(loc)); + const auto loc = core.GetEntityId("location"); + auto *location = static_cast(core.GetEntityPointer(loc)); if (!location) return false; cnt = location->GetPtcData().middle + CVECTOR(0.0f, 30.0f, 0.0f); @@ -51,9 +51,9 @@ bool LocEagle::Init() return false; } // Model - if (!(mdl = EntityManager::CreateEntity("modelr"))) + if (!(mdl = core.CreateEntity("modelr"))) return false; - EntityManager::AddToLayer(REALIZE, mdl, 20); + core.AddToLayer(REALIZE, mdl, 20); gs->SetTexturePath("Animals\\"); if (!core.Send_Message(mdl, "ls", MSG_MODEL_LOAD_GEO, "Animals\\eagle")) { @@ -65,7 +65,7 @@ bool LocEagle::Init() if (!core.Send_Message(mdl, "ls", MSG_MODEL_LOAD_ANI, "eagle")) return false; // Start playing the animation - auto *m = static_cast(EntityManager::GetEntityPointer(mdl)); + auto *m = static_cast(core.GetEntityPointer(mdl)); if (!m) return false; auto *ani = m->GetAnimation(); @@ -77,8 +77,8 @@ bool LocEagle::Init() return false; // include in the execution list // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 10); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 10); return true; } @@ -86,7 +86,7 @@ bool LocEagle::Init() void LocEagle::Execute(uint32_t delta_time) { // Model - auto *m = static_cast(EntityManager::GetEntityPointer(mdl)); + auto *m = static_cast(core.GetEntityPointer(mdl)); if (!m) return; // Updating position diff --git a/src/libs/location/src/loc_life.cpp b/src/libs/location/src/loc_life.cpp index 4d9bdb62e..66b103bf4 100644 --- a/src/libs/location/src/loc_life.cpp +++ b/src/libs/location/src/loc_life.cpp @@ -30,7 +30,7 @@ LocLife::LocLife() LocLife::~LocLife() { - EntityManager::EraseEntity(model); + core.EraseEntity(model); } //============================================================================================ @@ -38,9 +38,9 @@ LocLife::~LocLife() bool LocLife::Init(Location *loc) { Assert(loc); - if (!(model = EntityManager::CreateEntity("modelr"))) + if (!(model = core.CreateEntity("modelr"))) return false; - EntityManager::AddToLayer(REALIZE, model, 20); + core.AddToLayer(REALIZE, model, 20); // Path to textures auto *gs = static_cast(core.GetService("geometry")); if (!gs) @@ -68,7 +68,7 @@ bool LocLife::Init(Location *loc) FindPos(); ay = rand() * (6.28f / RAND_MAX); // Animation - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) { location = nullptr; @@ -101,7 +101,7 @@ void LocLife::Update(float dltTime) location->DrawLine(pos, 0xff00ff00, pos + CVECTOR(sinf(ay), 0.0f, cosf(ay)) * 0.5f, 0xff00ff00); } // Model and location information - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; auto *const ani = m->GetAnimation(); @@ -160,7 +160,7 @@ void LocLife::Update(float dltTime) int32_t LocLife::FindPos() { - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return -1; auto &ptc = location->GetPtcData(); @@ -199,7 +199,7 @@ int32_t LocLife::FindPos() void LocLife::StartMove() { // Model - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; // Start playing the animation @@ -213,7 +213,7 @@ void LocLife::StartMove() void LocLife::StopMove() { node = -1; - auto *m = static_cast(EntityManager::GetEntityPointer(model)); + auto *m = static_cast(core.GetEntityPointer(model)); if (!m) return; // Start playing the animation diff --git a/src/libs/location/src/loc_rats.cpp b/src/libs/location/src/loc_rats.cpp index fe07ded37..1fca9f63c 100644 --- a/src/libs/location/src/loc_rats.cpp +++ b/src/libs/location/src/loc_rats.cpp @@ -29,14 +29,14 @@ LocRats::~LocRats() bool LocRats::Init() { // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - auto *location = (Location *)EntityManager::GetEntityPointer(loc); + const auto loc = core.GetEntityId("location"); + auto *location = (Location *)core.GetEntityPointer(loc); if (!location) return false; // Execution // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 100000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 100000); return true; } @@ -49,8 +49,8 @@ uint64_t LocRats::ProcessMessage(MESSAGE &message) if (num > sizeof(rat) / sizeof(LocRat)) num = sizeof(rat) / sizeof(LocRat); // Location Pointer - const auto loc = EntityManager::GetEntityId("location"); - auto *location = (Location *)EntityManager::GetEntityPointer(loc); + const auto loc = core.GetEntityId("location"); + auto *location = (Location *)core.GetEntityPointer(loc); if (!location) return 0; // Init rats diff --git a/src/libs/location/src/location.cpp b/src/libs/location/src/location.cpp index 3b27393c9..7b2f7d5e5 100644 --- a/src/libs/location/src/location.cpp +++ b/src/libs/location/src/location.cpp @@ -66,16 +66,16 @@ Location::~Location() auto *const atr = AttributesPointer->FindAClass(AttributesPointer, "locators"); if (atr) AttributesPointer->DeleteAttributeClassX(atr); - // EntityManager::EraseEntity(cubeShotMaker); - EntityManager::EraseEntity(lighter); - EntityManager::EraseEntity(lizards); - EntityManager::EraseEntity(rats); - EntityManager::EraseEntity(crabs); - EntityManager::EraseEntity(eagle); - EntityManager::EraseEntity(grass); - EntityManager::EraseEntity(lightsid); - EntityManager::EraseEntity(loceffectsid); - EntityManager::EraseEntity(blood); + // core.EraseEntity(cubeShotMaker); + core.EraseEntity(lighter); + core.EraseEntity(lizards); + core.EraseEntity(rats); + core.EraseEntity(crabs); + core.EraseEntity(eagle); + core.EraseEntity(grass); + core.EraseEntity(lightsid); + core.EraseEntity(loceffectsid); + core.EraseEntity(blood); for (int32_t i = 0; i < numLocators; i++) delete locators[i]; @@ -92,20 +92,20 @@ bool Location::Init() rs->SetRenderState(D3DRS_LIGHTING, FALSE); // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 10); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 10); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 100000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 100000); - lightsid = EntityManager::CreateEntity("Lights"); - loceffectsid = EntityManager::CreateEntity("LocationEffects"); + lightsid = core.CreateEntity("Lights"); + loceffectsid = core.CreateEntity("LocationEffects"); enemyBarsTexture = rs->TextureCreate("LocEfx\\state_bars.tga"); - lighter = EntityManager::CreateEntity("Lighter"); - // cubeShotMaker = EntityManager::CreateEntity("CubeShotMakerCam"); + lighter = core.CreateEntity("Lighter"); + // cubeShotMaker = core.CreateEntity("CubeShotMakerCam"); return true; } @@ -127,7 +127,7 @@ void Location::Execute(uint32_t delta_time) message[i].alpha -= dltTime * 0.4f; } // Updating data for grass - auto *grs = static_cast(EntityManager::GetEntityPointer(grass)); + auto *grs = static_cast(core.GetEntityPointer(grass)); if (grs) { grs->characters.resize(supervisor.character.size()); @@ -206,7 +206,7 @@ void Location::Realize(uint32_t delta_time) void Location::Update(uint32_t delta_time) { - lights = static_cast(EntityManager::GetEntityPointer(lightsid)); + lights = static_cast(core.GetEntityPointer(lightsid)); const uint32_t max_delta_time = 500; const auto maxDltTime = 0.1f; @@ -254,7 +254,7 @@ uint64_t Location::ProcessMessage(MESSAGE &message) return 0; if (!model.IsValidateIndex(lastLoadStaticModel)) return 0; - if (!EntityManager::GetEntityPointer(model.ID(lastLoadStaticModel))) + if (!core.GetEntityPointer(model.ID(lastLoadStaticModel))) return 0; message.ScriptVariablePointer()->Set(model.ID(lastLoadStaticModel)); return 1; @@ -298,7 +298,7 @@ uint64_t Location::ProcessMessage(MESSAGE &message) case MSG_LOCATION_MODEL_LAMPS: if (lastLoadStaticModel < 0) return 0; - lights = static_cast(EntityManager::GetEntityPointer(lightsid)); + lights = static_cast(core.GetEntityPointer(lightsid)); if (!lights) return 0; return lights->AddLampModel(model.ID(lastLoadStaticModel)); @@ -418,7 +418,7 @@ uint64_t Location::ProcessMessage(MESSAGE &message) supervisor.DelSavePositions(false); break; case MSG_LOCATION_ADD_LIGHT: { - lights = static_cast(EntityManager::GetEntityPointer(lightsid)); + lights = static_cast(core.GetEntityPointer(lightsid)); if (!lights) return false; const std::string &name = message.String(); @@ -471,7 +471,7 @@ bool Location::CheckIfLocatorExists(const char *lName) int32_t Location::LoadStaticModel(const char *modelName, const char *tech, int32_t level, bool useDynamicLights) { - lights = static_cast(EntityManager::GetEntityPointer(lightsid)); + lights = static_cast(core.GetEntityPointer(lightsid)); const auto im = model.CreateModel(modelName, tech, level, true, useDynamicLights ? GetLights() : nullptr); if (im < 0) return -1; @@ -495,10 +495,10 @@ int32_t Location::LoadStaticModel(const char *modelName, const char *tech, int32 return -1; } // Add the model to special layers - EntityManager::AddToLayer(SHADOW, mdl->GetId(), 10); - EntityManager::AddToLayer(SUN_TRACE, mdl->GetId(), 10); - EntityManager::AddToLayer(BLOOD, mdl->GetId(), 100); - EntityManager::AddToLayer(RAIN_DROPS, mdl->GetId(), 100); + core.AddToLayer(SHADOW, mdl->GetId(), 10); + core.AddToLayer(SUN_TRACE, mdl->GetId(), 10); + core.AddToLayer(BLOOD, mdl->GetId(), 100); + core.AddToLayer(RAIN_DROPS, mdl->GetId(), 100); // Reading out all locators GEOS::INFO ginfo; GEOS::LABEL label; @@ -578,11 +578,11 @@ bool Location::LoadJumpPatch(const char *modelName) bool Location::LoadGrass(const char *modelName, const char *texture) { - EntityManager::EraseEntity(grass); + core.EraseEntity(grass); if (!modelName || !modelName[0]) return true; - grass = EntityManager::CreateEntity("Grass"); - auto *grs = static_cast(EntityManager::GetEntityPointer(grass)); + grass = core.CreateEntity("Grass"); + auto *grs = static_cast(core.GetEntityPointer(grass)); if (!grs) return false; if (texture && texture[0]) @@ -596,7 +596,7 @@ bool Location::LoadGrass(const char *modelName, const char *texture) if (grs->LoadData(nm)) return true; core.Trace("Can't load grass data file: %s", nm); - EntityManager::EraseEntity(grass); + core.EraseEntity(grass); return false; } @@ -608,7 +608,7 @@ bool Location::MessageEx(const char *name, MESSAGE &message) } else if (storm::iEquals(name, "AddFlys")) { - const auto effects = EntityManager::GetEntityId("LocationEffects"); + const auto effects = core.GetEntityId("LocationEffects"); const auto x = message.Float(); const auto y = message.Float(); const auto z = message.Float(); @@ -617,7 +617,7 @@ bool Location::MessageEx(const char *name, MESSAGE &message) } else if (storm::iEquals(name, "DelFlys")) { - const auto effects = EntityManager::GetEntityId("LocationEffects"); + const auto effects = core.GetEntityId("LocationEffects"); core.Send_Message(effects, "s", "DelFlys"); return true; } @@ -639,30 +639,30 @@ bool Location::MessageEx(const char *name, MESSAGE &message) } else if (storm::iEquals(name, "AddEagle")) { - eagle = EntityManager::CreateEntity("LocEagle"); + eagle = core.CreateEntity("LocEagle"); return true; } else if (storm::iEquals(name, "AddLizards")) { - lizards = EntityManager::CreateEntity("Lizards"); + lizards = core.CreateEntity("Lizards"); return true; } else if (storm::iEquals(name, "AddRats")) { - rats = EntityManager::CreateEntity("LocRats"); + rats = core.CreateEntity("LocRats"); if (!core.Send_Message(rats, "l", message.Long())) { - EntityManager::EraseEntity(rats); + core.EraseEntity(rats); return false; } return true; } else if (storm::iEquals(name, "AddCrabs")) { - crabs = EntityManager::CreateEntity("LocCrabs"); + crabs = core.CreateEntity("LocCrabs"); if (!core.Send_Message(crabs, "l", message.Long())) { - EntityManager::EraseEntity(crabs); + core.EraseEntity(crabs); return false; } @@ -670,11 +670,11 @@ bool Location::MessageEx(const char *name, MESSAGE &message) } else if (storm::iEquals(name, "AddBlood")) { - if (!EntityManager::GetEntityPointer(blood)) + if (!core.GetEntityPointer(blood)) { - blood = EntityManager::CreateEntity("Blood"); - EntityManager::AddToLayer(EXECUTE, blood, 65540); - EntityManager::AddToLayer(REALIZE, blood, 65540); + blood = core.CreateEntity("Blood"); + core.AddToLayer(EXECUTE, blood, 65540); + core.AddToLayer(REALIZE, blood, 65540); } CVECTOR vPos; vPos.x = message.Float(); @@ -710,7 +710,7 @@ bool Location::MessageEx(const char *name, MESSAGE &message) int32_t layer = message.Long(); const int32_t n = model.FindModel(modelname.c_str()); if (n >= 0) - // EntityManager::AddToLayer(realize, model.RealizerID(n), layer); + // core.AddToLayer(realize, model.RealizerID(n), layer); core.Send_Message(model.RealizerID(n), "ll", 2, 1); } else if (storm::iEquals(name, "SetGrassParams")) diff --git a/src/libs/location/src/location_camera.cpp b/src/libs/location/src/location_camera.cpp index 793068fea..ace14faca 100644 --- a/src/libs/location/src/location_camera.cpp +++ b/src/libs/location/src/location_camera.cpp @@ -89,18 +89,18 @@ bool LocationCamera::Init() throw std::runtime_error("No service: dx9render"); // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 0); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 0); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 100000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 100000); // The sea - sea = EntityManager::GetEntityId("sea"); + sea = core.GetEntityId("sea"); // try to get the location - loc = EntityManager::GetEntityId("location"); + loc = core.GetEntityId("location"); rs->SetPerspective(cameraPerspective); // rs->SetPerspective(1.0f); @@ -317,7 +317,7 @@ void LocationCamera::Realize(uint32_t delta_time) isTeleport = false; } auto realPos = camPos; - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); if (sb && wmode != cwm_free && location->IsSwimming()) { const auto seaY = sb->WaveXZ(camPos.x, camPos.z) + 1.0f; @@ -360,7 +360,7 @@ uint64_t LocationCamera::ProcessMessage(MESSAGE &message) { case MSG_CAMERA_SETTARGET: chr = message.EntityID(); - if (EntityManager::GetEntityPointer(chr) == nullptr) + if (core.GetEntityPointer(chr) == nullptr) { core.Trace("LocationCamera -> MSG_CAMERA_SETTARGET -> invalidate character id"); return 0; @@ -478,7 +478,7 @@ uint32_t LocationCamera::AttributeChanged(ATTRIBUTES *apnt) bool LocationCamera::Set() { // Character pointer - auto *c = static_cast(EntityManager::GetEntityPointer(chr)); + auto *c = static_cast(core.GetEntityPointer(chr)); if (!c) return false; // Character characteristics @@ -491,7 +491,7 @@ bool LocationCamera::Set() lheight = height * lookHeight; chradius = c->GetRadius(); character = c; - location = static_cast(EntityManager::GetEntityPointer(loc)); + location = static_cast(core.GetEntityPointer(loc)); return location != nullptr; } diff --git a/src/libs/location/src/location_effects.cpp b/src/libs/location/src/location_effects.cpp index 1f7e141e4..1a232f9c3 100644 --- a/src/libs/location/src/location_effects.cpp +++ b/src/libs/location/src/location_effects.cpp @@ -74,12 +74,12 @@ bool LocationEffects::Init() throw std::runtime_error("No service: dx9render"); // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 10); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 10); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), 1000000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), 1000000); splashesTxt = rs->TextureCreate("LocEfx\\chrsplprt.tga"); flyTex = rs->TextureCreate("LocEfx\\firefly.tga"); diff --git a/src/libs/location/src/location_script_lib.cpp b/src/libs/location/src/location_script_lib.cpp index a48e97377..39a0bd9ac 100644 --- a/src/libs/location/src/location_script_lib.cpp +++ b/src/libs/location/src/location_script_lib.cpp @@ -199,13 +199,13 @@ uint32_t slNativeFindLaodLocation(VS_STACK *pS) if (!pReturn) return IFUNCRESULT_FAILED; // Looking for a location - const auto loc = EntityManager::GetEntityId("location"); + const auto loc = core.GetEntityId("location"); if (!loc) { pReturn->Set(-1); return IFUNCRESULT_OK; } - Entity *l = EntityManager::GetEntityPointer(loc); + Entity *l = core.GetEntityPointer(loc); if (!l || !l->AttributesPointer) { pReturn->Set(-1); diff --git a/src/libs/location/src/model_array.cpp b/src/libs/location/src/model_array.cpp index 9d1c5e804..863282a9f 100644 --- a/src/libs/location/src/model_array.cpp +++ b/src/libs/location/src/model_array.cpp @@ -58,23 +58,23 @@ int32_t ModelArray::CreateModel(const char *modelName, const char *technique, in } // Create a model entid_t id, idModelRealizer; - if (!(id = EntityManager::CreateEntity("modelr"))) + if (!(id = core.CreateEntity("modelr"))) return -1; - if (!(idModelRealizer = EntityManager::CreateEntity("LocModelRealizer"))) + if (!(idModelRealizer = core.CreateEntity("LocModelRealizer"))) { - EntityManager::EraseEntity(id); + core.EraseEntity(id); return -1; } core.Send_Message(idModelRealizer, "lip", 1, id, pLights); - // if(isVisible) EntityManager::AddToLayer(realize, idModelRealizer, level); - EntityManager::AddToLayer(REALIZE, idModelRealizer, level); + // if(isVisible) core.AddToLayer(realize, idModelRealizer, level); + core.AddToLayer(REALIZE, idModelRealizer, level); core.Send_Message(idModelRealizer, "ll", 2, isVisible); - auto *m = static_cast(EntityManager::GetEntityPointer(id)); + auto *m = static_cast(core.GetEntityPointer(id)); if (!m) { gs->SetTexturePath(""); - EntityManager::EraseEntity(id); - EntityManager::EraseEntity(idModelRealizer); + core.EraseEntity(id); + core.EraseEntity(idModelRealizer); return -1; } // Loading @@ -83,8 +83,8 @@ int32_t ModelArray::CreateModel(const char *modelName, const char *technique, in if (!core.Send_Message(id, "ls", MSG_MODEL_LOAD_GEO, resPath.c_str())) { gs->SetTexturePath(""); - EntityManager::EraseEntity(id); - EntityManager::EraseEntity(idModelRealizer); + core.EraseEntity(id); + core.EraseEntity(idModelRealizer); return -1; } gs->SetTexturePath(""); @@ -140,8 +140,8 @@ void ModelArray::DeleteModel(int32_t modelIndex) delete model[modelIndex].reflection; model[modelIndex].reflection = nullptr; // Delete the model - EntityManager::EraseEntity(model[modelIndex].modelrealizer); - EntityManager::EraseEntity(model[modelIndex].id); + core.EraseEntity(model[modelIndex].modelrealizer); + core.EraseEntity(model[modelIndex].id); numModels--; if (modelIndex != numModels) model[modelIndex] = model[numModels]; @@ -209,14 +209,14 @@ entid_t ModelArray::RealizerID(int32_t modelIndex) MODEL *ModelArray::operator[](int32_t modelIndex) { Assert(modelIndex >= 0 && modelIndex < numModels); - return static_cast(EntityManager::GetEntityPointer(model[modelIndex].id)); + return static_cast(core.GetEntityPointer(model[modelIndex].id)); } // Getting animation by index Animation *ModelArray::GetAnimation(int32_t modelIndex) { Assert(modelIndex >= 0 && modelIndex < numModels); - auto *m = static_cast(EntityManager::GetEntityPointer(model[modelIndex].id)); + auto *m = static_cast(core.GetEntityPointer(model[modelIndex].id)); if (!m) return nullptr; return m->GetAnimation(); @@ -304,7 +304,7 @@ void ModelArray::Update(float dltTime) if (model[i].rotator) { CMatrix mtr(model[i].rotator->rx * dltTime, model[i].rotator->ry * dltTime, model[i].rotator->rz * dltTime); - auto *mdl = static_cast(EntityManager::GetEntityPointer(model[i].id)); + auto *mdl = static_cast(core.GetEntityPointer(model[i].id)); if (mdl) mdl->mtx = CMatrix(mtr, mdl->mtx); } @@ -417,7 +417,7 @@ bool ModelArray::VisibleTest(const CVECTOR &p1, const CVECTOR &p2) { if (model[i].isVisible) { - auto *mdl = static_cast(EntityManager::GetEntityPointer(model[i].id)); + auto *mdl = static_cast(core.GetEntityPointer(model[i].id)); if (mdl->Trace(p1, p2) < 1.0f) return false; } @@ -434,7 +434,7 @@ float ModelArray::Trace(const CVECTOR &src, const CVECTOR &dst) { if (model[i].isVisible) { - auto *mdl = static_cast(EntityManager::GetEntityPointer(model[i].id)); + auto *mdl = static_cast(core.GetEntityPointer(model[i].id)); const auto km = mdl->Trace(src, dst); if (k > km) { @@ -458,7 +458,7 @@ void ModelArray::Clip(PLANE *p, int32_t numPlanes, CVECTOR &cnt, float rad, bool { if (model[i].isVisible) { - auto *mdl = static_cast(EntityManager::GetEntityPointer(model[i].id)); + auto *mdl = static_cast(core.GetEntityPointer(model[i].id)); mdl->Clip(p, numPlanes, cnt, rad, fnc); } } diff --git a/src/libs/location/src/model_realizer.cpp b/src/libs/location/src/model_realizer.cpp index 89da1e9d1..7ab1ff4e9 100644 --- a/src/libs/location/src/model_realizer.cpp +++ b/src/libs/location/src/model_realizer.cpp @@ -39,7 +39,7 @@ void LocModelRealizer::Realize(uint32_t delta_time) const { if (!bShow) return; - auto *pE = EntityManager::GetEntityPointer(eid_model); + auto *pE = core.GetEntityPointer(eid_model); if (pE) { BOOL bLight0Enable; diff --git a/src/libs/location/src/np_character.cpp b/src/libs/location/src/np_character.cpp index a909cd944..5c12f783a 100644 --- a/src/libs/location/src/np_character.cpp +++ b/src/libs/location/src/np_character.cpp @@ -88,7 +88,7 @@ NPCharacter::~NPCharacter() bool NPCharacter::PostInit() { - charactersGroups = EntityManager::GetEntityId("CharactersGroups"); + charactersGroups = core.GetEntityId("CharactersGroups"); float tmp; int32_t tmpBool; VDATA *vd; @@ -281,7 +281,7 @@ void NPCharacter::Update(float dltTime) if (!id) id = ""; const char *fid = nullptr; - auto *chr = static_cast(EntityManager::GetEntityPointer(task.target)); + auto *chr = static_cast(core.GetEntityPointer(task.target)); if (chr) { if (chr->AttributesPointer) @@ -456,7 +456,7 @@ bool NPCharacter::SetNewTask(NPCTask tsk, MESSAGE &message) SetFightMode(false); SetRunMode(true); task.target = message.EntityID(); - return (EntityManager::GetEntityPointer(task.target) != nullptr); + return (core.GetEntityPointer(task.target) != nullptr); case npct_dead: CmdStay(); Dead(); @@ -468,7 +468,7 @@ bool NPCharacter::SetNewTask(NPCTask tsk, MESSAGE &message) bool NPCharacter::InitFollowChartacter(entid_t eid) { task.target = eid; - auto c = static_cast(EntityManager::GetEntityPointer(eid)); + auto c = static_cast(core.GetEntityPointer(eid)); if (c) { const char *id = c->AttributesPointer->GetAttribute("id"); @@ -494,7 +494,7 @@ bool NPCharacter::InitFightChartacter(entid_t eid) void NPCharacter::UpdateFollowCharacter(float dltTime) { // goal - auto *c = static_cast(EntityManager::GetEntityPointer(task.target)); + auto *c = static_cast(core.GetEntityPointer(task.target)); if (!c || c->deadName != nullptr || c->liveValue < 0) { const NPCTask tsk = task.task; @@ -535,7 +535,7 @@ void NPCharacter::UpdateFollowCharacter(float dltTime) void NPCharacter::UpdateEscapeCharacter(float dltTime) { // The character we are running from - auto *c = static_cast(EntityManager::GetEntityPointer(task.target)); + auto *c = static_cast(core.GetEntityPointer(task.target)); if (!c || c->deadName != nullptr || c->liveValue < 0) { const NPCTask tsk = task.task; @@ -564,7 +564,7 @@ void NPCharacter::UpdateFightCharacter(float dltTime) SetFightMode(true); // goal - auto *c = static_cast(EntityManager::GetEntityPointer(task.target)); + auto *c = static_cast(core.GetEntityPointer(task.target)); if (!c || c->deadName != nullptr || c->liveValue < 0 || c == this) { const NPCTask tsk = task.task; @@ -847,7 +847,7 @@ void NPCharacter::DoFightActionAnalysisNone(float dltTime, NPCharacter *enemy) if (vd) vd->Get(isAdaptive); // Correcting taking into account the presence of groups - auto chrGroup = static_cast(EntityManager::GetEntityPointer(charactersGroups)); + auto chrGroup = static_cast(core.GetEntityPointer(charactersGroups)); if (!chrGroup) isAdaptive = false; // If we want to hit and the mode is not adaptive, then just hit diff --git a/src/libs/location/src/np_character.h b/src/libs/location/src/np_character.h index 247629c22..dc6570a4f 100644 --- a/src/libs/location/src/np_character.h +++ b/src/libs/location/src/np_character.h @@ -211,7 +211,7 @@ inline Character *NPCharacter::GetAttackedCharacter() const { if (task.task != npct_fight) return nullptr; - return static_cast(EntityManager::GetEntityPointer(task.target)); + return static_cast(core.GetEntityPointer(task.target)); } // Check event diff --git a/src/libs/location/src/player.cpp b/src/libs/location/src/player.cpp index 41229fc57..cf674df56 100644 --- a/src/libs/location/src/player.cpp +++ b/src/libs/location/src/player.cpp @@ -37,8 +37,8 @@ Player::Player() Player::~Player() { entid_t peid; - if (peid = EntityManager::GetEntityId("ShootGunParticles")) - EntityManager::EraseEntity(peid); + if (peid = core.GetEntityId("ShootGunParticles")) + core.EraseEntity(peid); } bool Player::PostInit() @@ -46,7 +46,7 @@ bool Player::PostInit() auto *const location = GetLocation(); if (!location->supervisor.player) location->supervisor.player = this; - baterfl = EntityManager::GetEntityId("Animals"); + baterfl = core.GetEntityId("Animals"); return NPCharacter::PostInit(); } @@ -66,9 +66,9 @@ void Player::Move(float dltTime) if (!locCam) { entid_t lcam; - if (lcam = EntityManager::GetEntityId("LocationCamera")) + if (lcam = core.GetEntityId("LocationCamera")) { - locCam = static_cast(EntityManager::GetEntityPointer(lcam)); + locCam = static_cast(core.GetEntityPointer(lcam)); } } else @@ -306,7 +306,7 @@ void Player::Update(float dltTime) activatedDialog = aDialog; core.Send_Message(baterfl, "lff", MSG_ANIMALS_BUTTERFLIES_XYZ, curPos.x, curPos.z); // go through characters in search of enemies to the player - if (const auto eid = EntityManager::GetEntityId("CharactersGroups")) + if (const auto eid = core.GetEntityId("CharactersGroups")) { auto *const location = GetLocation(); for (size_t i = 0; i < location->supervisor.character.size(); i++) @@ -659,7 +659,7 @@ Player *Player::FindAttackCharacter() // filter out uninteresting if (isEnemy) // ~!~ { - if (chr->task.task != npct_fight || EntityManager::GetEntityPointer(chr->task.target) != this) + if (chr->task.task != npct_fight || core.GetEntityPointer(chr->task.target) != this) continue; } if (isFgt) @@ -677,7 +677,7 @@ Player *Player::FindAttackCharacter() } /* if(chr->task.task == npct_fight && - EntityManager::GetEntityPointer(chr->task.target) == this) + core.GetEntityPointer(chr->task.target) == this) { j = -1; isEnemy = true; @@ -686,7 +686,7 @@ Player *Player::FindAttackCharacter() // skip non-enemies if constexpr (!isEnemy) // ~!~ { - if (const auto eid = EntityManager::GetEntityId("CharactersGroups")) + if (const auto eid = core.GetEntityId("CharactersGroups")) { if (!core.Send_Message(eid, "sii", "IsEnemy", GetId(), chr->GetId())) continue; @@ -723,7 +723,7 @@ Player *Player::FindAttackCharacter() void Player::FireFromShootgun() { kSMReload = 0.0f; - if (const auto peid = EntityManager::GetEntityId("sound")) + if (const auto peid = core.GetEntityId("sound")) { core.Send_Message(peid, "lsllll", MSG_SOUND_PLAY, "OBJECTS\\sgboom.wav", 4, false, false, false); } @@ -751,7 +751,7 @@ void Player::FireFromShootgun() ChrsDmg chrs[16]; int32_t numChrs = 0; - const auto ids = EntityManager::GetEntityIdIterators(SUN_TRACE); + const auto ids = core.GetEntityIds(SUN_TRACE); for (int32_t i = 0; i < 6; i++) { // Get the position where the buckshot will fall @@ -767,7 +767,7 @@ void Player::FireFromShootgun() auto dir = !(src - dst); dst = src + (dst - src) * dist; // Got somewhere - auto *const e = EntityManager::GetEntityPointer(collide->GetObjectID()); + auto *const e = core.GetEntityPointer(collide->GetObjectID()); if (e && e != this) { int32_t nm; diff --git a/src/libs/location/src/supervisor.cpp b/src/libs/location/src/supervisor.cpp index f484901a9..254339804 100644 --- a/src/libs/location/src/supervisor.cpp +++ b/src/libs/location/src/supervisor.cpp @@ -34,7 +34,7 @@ Supervisor::~Supervisor() for (size_t i = 0; i < character.size(); i++) { character[i].c->AlreadySTORM_DELETE(); - EntityManager::EraseEntity(character[i].c->GetId()); + core.EraseEntity(character[i].c->GetId()); } } @@ -240,7 +240,7 @@ void Supervisor::PostUpdate(float dltTime) break; const auto dlt = time - character[curUpdate].lastTime; character[curUpdate].lastTime = time; - if (EntityManager::GetEntityPointer(character[curUpdate].c->GetId())) + if (core.GetEntityPointer(character[curUpdate].c->GetId())) { core.Event("CharacterUpdate", "if", character[curUpdate].c->GetId(), dlt); } diff --git a/src/libs/location/src/wide_screen.cpp b/src/libs/location/src/wide_screen.cpp index 9290ec4e4..0c9e7cffa 100644 --- a/src/libs/location/src/wide_screen.cpp +++ b/src/libs/location/src/wide_screen.cpp @@ -31,8 +31,8 @@ bool WideScreen::Init() { // Layers // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(REALIZE, GetId(), -257); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(REALIZE, GetId(), -257); rs = static_cast(core.GetService("dx9render")); if (!rs) throw std::runtime_error("No service: dx9render"); @@ -59,7 +59,7 @@ void WideScreen::Realize(uint32_t delta_time) state += dlt * delta_time * 0.001f; if (state < 0.0f) { - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); return; } if (state > 1.0f) diff --git a/src/libs/locator/src/blast.cpp b/src/libs/locator/src/blast.cpp index 9cbcc04c8..2cbe02ebc 100644 --- a/src/libs/locator/src/blast.cpp +++ b/src/libs/locator/src/blast.cpp @@ -51,7 +51,7 @@ bool BLAST::Init() AddGeometry(name, RandomNum * rand() / RAND_MAX + 1); } - Splash = EntityManager::GetEntityId("BallSplash"); + Splash = core.GetEntityId("BallSplash"); return true; } @@ -110,10 +110,10 @@ void BLAST::ProcessTime(uint32_t DT) uint32_t n; float res; - if (!EntityManager::GetEntityPointer(sea_eid)) + if (!core.GetEntityPointer(sea_eid)) { - sea_eid = EntityManager::GetEntityId("sea"); - pSea = static_cast(EntityManager::GetEntityPointer(sea_eid)); + sea_eid = core.GetEntityId("sea"); + pSea = static_cast(core.GetEntityPointer(sea_eid)); } const auto Delta_Time = static_cast(DT); //*0.1; @@ -168,7 +168,7 @@ void BLAST::ProcessTime(uint32_t DT) } if (bStop) - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } uint64_t BLAST::ProcessMessage(MESSAGE &message) diff --git a/src/libs/locator/src/locator.cpp b/src/libs/locator/src/locator.cpp index 49e87a9f9..5d0abbb49 100644 --- a/src/libs/locator/src/locator.cpp +++ b/src/libs/locator/src/locator.cpp @@ -34,9 +34,9 @@ bool LOCATOR::Init() bool LOCATOR::VerifyParticles() { - ParticlesID = EntityManager::GetEntityId("particles"); + ParticlesID = core.GetEntityId("particles"); if (!ParticlesID) - ParticlesID = EntityManager::CreateEntity("particles"); + ParticlesID = core.CreateEntity("particles"); return static_cast(ParticlesID); } @@ -333,7 +333,7 @@ uint64_t LOCATOR::ProcessMessage(MESSAGE &message) { if(!core.FindClass(&ParticlesID,"particles",0)) { - if(!EntityManager::CreateEntity(&ParticlesID,"particles")) return 0; + if(!core.CreateEntity(&ParticlesID,"particles")) return 0; } for(stringIndex = 0; (stringIndex = geo->FindLabelG(stringIndex, groupID)) >= 0; stringIndex++) { @@ -348,7 +348,7 @@ uint64_t LOCATOR::ProcessMessage(MESSAGE &message) { if(!core.FindClass(&ParticlesID,"particles",0)) { - if(!EntityManager::CreateEntity(&ParticlesID,"particles")) return 0; + if(!core.CreateEntity(&ParticlesID,"particles")) return 0; } for(stringIndex = 0; (stringIndex = geo->FindLabelG(stringIndex, groupID)) >= 0; stringIndex++) { diff --git a/src/libs/mast/src/mast.cpp b/src/libs/mast/src/mast.cpp index 7701eaa1e..9b67cac1c 100644 --- a/src/libs/mast/src/mast.cpp +++ b/src/libs/mast/src/mast.cpp @@ -113,13 +113,13 @@ void MAST::Execute(uint32_t Delta_Time) } } doMove(Delta_Time); - auto *mdl = static_cast(EntityManager::GetEntityPointer(model_id)); + auto *mdl = static_cast(core.GetEntityPointer(model_id)); if (mdl) mdl->Update(); } else { - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } // UNGUARD } @@ -137,7 +137,7 @@ void MAST::Realize(uint32_t Delta_Time) } MODEL *mdl; - if ((mdl = static_cast(EntityManager::GetEntityPointer(model_id))) != nullptr) + if ((mdl = static_cast(core.GetEntityPointer(model_id))) != nullptr) { RenderService->SetRenderState(D3DRS_LIGHTING, true); mdl->ProcessStage(Stage::realize, Delta_Time); @@ -196,22 +196,22 @@ void MAST::Mount(entid_t modelEI, entid_t shipEI, NODE *mastNodePointer) m_pMastNode = mastNodePointer; if (mastNodePointer == nullptr) return; - auto *oldmdl = static_cast(EntityManager::GetEntityPointer(modelEI)); + auto *oldmdl = static_cast(core.GetEntityPointer(modelEI)); if (oldmdl == nullptr) return; // do not bring down anything if there is no old model oldmodel_id = modelEI; ship_id = shipEI; - const auto ropeEI = EntityManager::GetEntityId("rope"); - const auto sailEI = EntityManager::GetEntityId("sail"); - const auto flagEI = EntityManager::GetEntityId("flag"); - const auto vantEI = EntityManager::GetEntityId("vant"); - const auto vantlEI = EntityManager::GetEntityId("vantl"); - const auto vantzEI = EntityManager::GetEntityId("vantz"); + const auto ropeEI = core.GetEntityId("rope"); + const auto sailEI = core.GetEntityId("sail"); + const auto flagEI = core.GetEntityId("flag"); + const auto vantEI = core.GetEntityId("vant"); + const auto vantlEI = core.GetEntityId("vantl"); + const auto vantzEI = core.GetEntityId("vantz"); // find the attributes VAI_OBJBASE *pVAI = nullptr; - pVAI = static_cast(EntityManager::GetEntityPointer(shipEI)); + pVAI = static_cast(core.GetEntityPointer(shipEI)); ATTRIBUTES *pA = nullptr; if (pVAI != nullptr) pA = pVAI->GetACharacter(); @@ -247,7 +247,7 @@ void MAST::Mount(entid_t modelEI, entid_t shipEI, NODE *mastNodePointer) core.Send_Message(vantlEI, "lip", MSG_VANT_DEL_MAST, modelEI, mastNodePointer); if (vantzEI) core.Send_Message(vantzEI, "lip", MSG_VANT_DEL_MAST, modelEI, mastNodePointer); - auto mdl = static_cast(EntityManager::GetEntityPointer(model_id)); + auto mdl = static_cast(core.GetEntityPointer(model_id)); if (mdl != nullptr) for (i = 0; i < 10000; i++) { @@ -301,7 +301,7 @@ void MAST::Mount(entid_t modelEI, entid_t shipEI, NODE *mastNodePointer) // set the initial parameters of the mast movement SHIP_BASE *sb; - sb = static_cast(EntityManager::GetEntityPointer(shipEI)); + sb = static_cast(core.GetEntityPointer(shipEI)); if (sb) { mm.ang = sb->State.vAng; @@ -328,13 +328,13 @@ void MAST::Mount(entid_t modelEI, entid_t shipEI, NODE *mastNodePointer) float minDist = 10000.f; SHIP_BASE *minDstShip; - const auto &ships = EntityManager::GetEntityIdVector("ship"); + const auto &ships = core.GetEntityIds("ship"); for (auto ship : ships) { if (ship == ship_id) continue; - auto *sb = static_cast(EntityManager::GetEntityPointer(ship)); + auto *sb = static_cast(core.GetEntityPointer(ship)); const float tmpDist = ~(sb->State.vPos - mm.mov); if (tmpDist < minDist) { @@ -493,7 +493,7 @@ void MAST::doMove(uint32_t DeltaTime) float dtime = DELTA_TIME(static_cast(DeltaTime)); float rtime = DELTA_TIME_ROTATE(static_cast(DeltaTime)); - auto *mdl = static_cast(EntityManager::GetEntityPointer(model_id)); // geometry model of the mast + auto *mdl = static_cast(core.GetEntityPointer(model_id)); // geometry model of the mast if (mdl != nullptr) { if (bFallUnderWater) // if the mast is already sinking @@ -546,10 +546,10 @@ void MAST::doMove(uint32_t DeltaTime) { bNextClass = false; // collision with the island - entid_t findEI = EntityManager::GetEntityId("ISLAND"); - if (findEI && EntityManager::GetEntityPointer(findEI) != nullptr) + entid_t findEI = core.GetEntityId("ISLAND"); + if (findEI && core.GetEntityPointer(findEI) != nullptr) { - auto modEI = static_cast(EntityManager::GetEntityPointer(findEI))->GetModelEID(); + auto modEI = static_cast(core.GetEntityPointer(findEI))->GetModelEID(); CVECTOR dp; int tmp; @@ -575,12 +575,12 @@ void MAST::doMove(uint32_t DeltaTime) } } // collision with the ship - const auto &ships = EntityManager::GetEntityIdVector("ship"); + const auto &ships = core.GetEntityIds("ship"); for (auto ship : ships) { - if (EntityManager::GetEntityPointer(ship) == nullptr) + if (core.GetEntityPointer(ship) == nullptr) continue; - auto modEI = static_cast(EntityManager::GetEntityPointer(ship))->GetModelEID(); + auto modEI = static_cast(core.GetEntityPointer(ship))->GetModelEID(); CVECTOR dp; int tmp; float yAng; @@ -673,7 +673,7 @@ int MAST::GetSlide(entid_t mod, CVECTOR &pbeg, CVECTOR &pend, CVECTOR &dp, CVECT vb.y -= hVal; ve.y -= hVal; hVal = 0; - auto *pmdl = static_cast(EntityManager::GetEntityPointer(mod)); + auto *pmdl = static_cast(core.GetEntityPointer(mod)); if (pmdl) { NODE *pnod = pmdl->GetCollideNode(); @@ -721,16 +721,16 @@ void MAST::AllRelease() } // delete sail group - core.Send_Message(EntityManager::GetEntityId("sail"), "li", MSG_SAIL_DEL_GROUP, GetId()); + core.Send_Message(core.GetEntityId("sail"), "li", MSG_SAIL_DEL_GROUP, GetId()); // remove flag group - core.Send_Message(EntityManager::GetEntityId("flag"), "li", MSG_FLAG_DEL_GROUP, model_id); + core.Send_Message(core.GetEntityId("flag"), "li", MSG_FLAG_DEL_GROUP, model_id); // announce deleting core.Send_Message(ship_id, "lp", MSG_MAST_DELGEOMETRY, m_pMastNode); // delete model - EntityManager::EraseEntity(model_id); + core.EraseEntity(model_id); m_pMastNode = nullptr; } @@ -786,7 +786,7 @@ void HULL::Execute(uint32_t Delta_Time) } else { - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } } @@ -799,7 +799,7 @@ void HULL::Realize(uint32_t Delta_Time) } MODEL *mdl; - if ((mdl = static_cast(EntityManager::GetEntityPointer(model_id))) != nullptr) + if ((mdl = static_cast(core.GetEntityPointer(model_id))) != nullptr) { RenderService->SetRenderState(D3DRS_LIGHTING, true); mdl->ProcessStage(Stage::realize, Delta_Time); @@ -830,17 +830,17 @@ void HULL::Mount(entid_t modelEI, entid_t shipEI, NODE *hullNodePointer) if (hullNodePointer == nullptr) return; - auto *oldmdl = static_cast(EntityManager::GetEntityPointer(modelEI)); + auto *oldmdl = static_cast(core.GetEntityPointer(modelEI)); if (oldmdl == nullptr) return; // do not bring down anything if there is no old model oldmodel_id = modelEI; ship_id = shipEI; - const auto ropeEI = EntityManager::GetEntityId("rope"); + const auto ropeEI = core.GetEntityId("rope"); // find attributes VAI_OBJBASE *pVAI = nullptr; - pVAI = static_cast(EntityManager::GetEntityPointer(shipEI)); + pVAI = static_cast(core.GetEntityPointer(shipEI)); ATTRIBUTES *pA = nullptr; if (pVAI != nullptr) pA = pVAI->GetACharacter(); @@ -859,7 +859,7 @@ void HULL::Mount(entid_t modelEI, entid_t shipEI, NODE *hullNodePointer) // create new model bModel = true; model_id = hullNodePointer->Unlink2Model(); - auto mdl = static_cast(EntityManager::GetEntityPointer(model_id)); + auto mdl = static_cast(core.GetEntityPointer(model_id)); if (mdl != nullptr) for (i = 0; i < 10000; i++) @@ -898,6 +898,6 @@ void HULL::AllRelease() } // delete model - EntityManager::EraseEntity(model_id); + core.EraseEntity(model_id); m_pHullNode = nullptr; } diff --git a/src/libs/model/src/model.cpp b/src/libs/model/src/model.cpp index 83c2e0bd1..8d64c95c8 100644 --- a/src/libs/model/src/model.cpp +++ b/src/libs/model/src/model.cpp @@ -333,7 +333,7 @@ uint64_t MODELR::ProcessMessage(MESSAGE &message) { delete root; root = nullptr; - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); return 0; } // CVECTOR tmp; diff --git a/src/libs/model/src/node.cpp b/src/libs/model/src/node.cpp index 8a3b24e90..3170facd0 100644 --- a/src/libs/model/src/node.cpp +++ b/src/libs/model/src/node.cpp @@ -517,8 +517,8 @@ void NODER::Link(NODE *node) //------------------------------------------------------------------- entid_t NODER::Unlink2Model() { - const entid_t id = EntityManager::CreateEntity("modelr"); - auto *mdl = static_cast(EntityManager::GetEntityPointer(id)); + const entid_t id = core.CreateEntity("modelr"); + auto *mdl = static_cast(core.GetEntityPointer(id)); // link node to as root mdl->root = this; @@ -546,7 +546,7 @@ entid_t NODER::Unlink2Model() //------------------------------------------------------------------- void NODER::Link(entid_t id, bool transform) { - auto *mdl = static_cast(EntityManager::GetEntityPointer(id)); + auto *mdl = static_cast(core.GetEntityPointer(id)); if (mdl == nullptr) return; @@ -566,7 +566,7 @@ void NODER::Link(entid_t id, bool transform) // prevent self-deleting mdl->root = nullptr; // delete model - EntityManager::EraseEntity(id); + core.EraseEntity(id); } //------------------------------------------------------------------- diff --git a/src/libs/particles/src/k2_wrapper/particles.cpp b/src/libs/particles/src/k2_wrapper/particles.cpp index 1100804c3..09f592670 100644 --- a/src/libs/particles/src/k2_wrapper/particles.cpp +++ b/src/libs/particles/src/k2_wrapper/particles.cpp @@ -24,8 +24,8 @@ PARTICLES::~PARTICLES() bool PARTICLES::Init() { - EntityManager::AddToLayer(REALIZE, GetId(), 0xfffff); - EntityManager::AddToLayer(EXECUTE, GetId(), 0); + core.AddToLayer(REALIZE, GetId(), 0xfffff); + core.AddToLayer(EXECUTE, GetId(), 0); pService = static_cast(core.GetService("ParticleService")); Assert(pService); diff --git a/src/libs/renderer/src/s_device.cpp b/src/libs/renderer/src/s_device.cpp index ff097f6a7..02505e588 100644 --- a/src/libs/renderer/src/s_device.cpp +++ b/src/libs/renderer/src/s_device.cpp @@ -9,7 +9,6 @@ #include "v_s_stack.h" #include "storm/fs.h" -#include #include #include @@ -78,24 +77,30 @@ namespace void InvokeEntitiesLostRender() { - const auto its = EntityManager::GetEntityIdIterators(); - for (auto it = its.first; it != its.second; ++it) + for (layer_index_t i{}; i < max_layers_num; ++i) { - if (!it->deleted && it->ptr != nullptr) + auto &&entities = core.GetEntityIds(i); + for (auto ent_id : entities) { - it->ptr->ProcessStage(Entity::Stage::lost_render); + if (const auto ptr = core.GetEntityPointer(ent_id)) + { + ptr->ProcessStage(Entity::Stage::lost_render); + } } } } void InvokeEntitiesRestoreRender() { - const auto its = EntityManager::GetEntityIdIterators(); - for (auto it = its.first; it != its.second; ++it) + for (layer_index_t i{}; i < max_layers_num; ++i) { - if (!it->deleted && it->ptr != nullptr) + auto &&entities = core.GetEntityIds(i); + for (auto ent_id : entities) { - it->ptr->ProcessStage(Entity::Stage::restore_render); + if (const auto ptr = core.GetEntityPointer(ent_id)) + { + ptr->ProcessStage(Entity::Stage::restore_render); + } } } } @@ -3844,7 +3849,7 @@ CVideoTexture *DX9RENDER::GetVideoTexture(const char *sVideoName) { if (pVTLcur->hash == newHash && storm::iEquals(pVTLcur->name, sVideoName)) { - if (EntityManager::GetEntityPointer(pVTLcur->videoTexture_id)) + if (core.GetEntityPointer(pVTLcur->videoTexture_id)) { pVTLcur->ref++; return pVTLcur->VideoTexture; @@ -3870,15 +3875,15 @@ CVideoTexture *DX9RENDER::GetVideoTexture(const char *sVideoName) if ((pVTLcur->name = new char[len]) == nullptr) throw std::runtime_error("memory allocate error"); strcpy_s(pVTLcur->name, len, sVideoName); - const entid_t ei = EntityManager::CreateEntity("TextureSequence"); - pVTLcur->VideoTexture = static_cast(EntityManager::GetEntityPointer(ei)); + const entid_t ei = core.CreateEntity("TextureSequence"); + pVTLcur->VideoTexture = static_cast(core.GetEntityPointer(ei)); if (pVTLcur->VideoTexture != nullptr) { pVTLcur->videoTexture_id = ei; if (pVTLcur->VideoTexture->Initialize(this, sVideoName, true) == nullptr) { delete pVTLcur; - EntityManager::EraseEntity(ei); + core.EraseEntity(ei); } else { @@ -3889,7 +3894,7 @@ CVideoTexture *DX9RENDER::GetVideoTexture(const char *sVideoName) else { delete pVTLcur; - EntityManager::EraseEntity(ei); + core.EraseEntity(ei); } return retVal; @@ -3912,7 +3917,7 @@ void DX9RENDER::ReleaseVideoTexture(CVideoTexture *pVTexture) pVTL = cur->next; else prev->next = cur->next; - EntityManager::EraseEntity(cur->videoTexture_id); + core.EraseEntity(cur->videoTexture_id); delete cur->name; delete cur; break; @@ -3926,7 +3931,7 @@ void DX9RENDER::PlayToTexture() VideoTextureEntity *cur = pVTL; while (cur != nullptr) { - if (EntityManager::GetEntityPointer(pVTL->videoTexture_id)) + if (core.GetEntityPointer(pVTL->videoTexture_id)) { cur->VideoTexture->FrameUpdate(); cur = cur->next; diff --git a/src/libs/rigging/src/flag.cpp b/src/libs/rigging/src/flag.cpp index 125ace144..33e4ff49f 100644 --- a/src/libs/rigging/src/flag.cpp +++ b/src/libs/rigging/src/flag.cpp @@ -96,9 +96,9 @@ void FLAG::Execute(uint32_t Delta_Time) } // get the wind value - if (const auto ei = EntityManager::GetEntityId("weather")) + if (const auto ei = core.GetEntityId("weather")) { - auto *wb = static_cast(EntityManager::GetEntityPointer(ei)); + auto *wb = static_cast(core.GetEntityPointer(ei)); globalWind.ang.x = wb->GetFloat(whf_wind_angle); globalWind.ang.z = cosf(globalWind.ang.x); globalWind.ang.x = sinf(globalWind.ang.x); @@ -151,7 +151,7 @@ uint64_t FLAG::ProcessMessage(MESSAGE &message) const auto eidModel = message.EntityID(); const auto nNation = message.Long(); - MODEL *host_mdl = static_cast(EntityManager::GetEntityPointer(eidModel)); + MODEL *host_mdl = static_cast(core.GetEntityPointer(eidModel)); if (host_mdl == nullptr) { core.Trace("Missing INIT message to FLAG: bad MODEL"); @@ -181,7 +181,7 @@ uint64_t FLAG::ProcessMessage(MESSAGE &message) entid_t eidShip = message.EntityID(); gdata[groupQuantity - 1].ship_id = eidShip; gdata[groupQuantity - 1].char_attributes = - ((VAI_OBJBASE *)EntityManager::GetEntityPointer(gdata[groupQuantity - 1].ship_id))->GetACharacter(); + ((VAI_OBJBASE *)core.GetEntityPointer(gdata[groupQuantity - 1].ship_id))->GetACharacter(); } NODE *nod; @@ -218,7 +218,7 @@ uint64_t FLAG::ProcessMessage(MESSAGE &message) int32_t nNation = message.Long(); MODEL *host_mdl; - host_mdl = (MODEL *)EntityManager::GetEntityPointer(eidModel); + host_mdl = (MODEL *)core.GetEntityPointer(eidModel); if (host_mdl == nullptr) { core.Trace("Missing INIT message to FLAG: bad MODEL"); diff --git a/src/libs/rigging/src/rope.cpp b/src/libs/rigging/src/rope.cpp index cd3ffa05d..a32e2857b 100644 --- a/src/libs/rigging/src/rope.cpp +++ b/src/libs/rigging/src/rope.cpp @@ -158,7 +158,7 @@ void ROPE::Realize(uint32_t Delta_Time) if ((~(gdata[i].pMatWorld->Pos() - cp)) * pr < fMaxRopeDist) // if the distance to the ship is not more than the maximum { - static_cast(EntityManager::GetEntityPointer(gdata[i].shipEI)) + static_cast(core.GetEntityPointer(gdata[i].shipEI)) ->SetLightAndFog(true); RenderService->SetTransform(D3DTS_WORLD, *gdata[i].pMatWorld); @@ -166,7 +166,7 @@ void ROPE::Realize(uint32_t Delta_Time) RenderService->SetMaterial(mat); RenderService->DrawBuffer(vBuf, sizeof(ROPEVERTEX), iBuf, 0, nVert, gdata[i].st, gdata[i].nt); - static_cast(EntityManager::GetEntityPointer(gdata[i].shipEI)) + static_cast(core.GetEntityPointer(gdata[i].shipEI)) ->RestoreLightAndFog(); } while (RenderService->TechniqueExecuteNext()) @@ -199,7 +199,7 @@ uint64_t ROPE::ProcessMessage(MESSAGE &message) case MSG_ROPE_INIT: { const auto tmp_shipEI = message.EntityID(); const auto tmp_modelEI = message.EntityID(); - auto *mdl = static_cast(EntityManager::GetEntityPointer(tmp_modelEI)); + auto *mdl = static_cast(core.GetEntityPointer(tmp_modelEI)); if (mdl == nullptr) { core.Trace("WARNING!!! Missing INIT message to ROPE - bad ship model"); @@ -729,9 +729,9 @@ void ROPE::AddLabel(GEOS::LABEL &lbl, NODE *nod, bool bDontSage) rd->angRot = 0.f; rd->vDeep = 0.f; - if (const auto sailEI = EntityManager::GetEntityId("sail")) + if (const auto sailEI = core.GetEntityId("sail")) { - auto *mdl = static_cast(EntityManager::GetEntityPointer(gdata[rd->HostGroup].modelEI)); + auto *mdl = static_cast(core.GetEntityPointer(gdata[rd->HostGroup].modelEI)); if (mdl == nullptr) rd->btie = rd->etie = false; else @@ -962,7 +962,7 @@ void ROPE::SetAdd(int firstNum) { const int32_t gn = rlist[rn]->HostGroup; const char *pcModlName = nullptr; - auto *pMdl = static_cast(EntityManager::GetEntityPointer(gdata[gn].modelEI)); + auto *pMdl = static_cast(core.GetEntityPointer(gdata[gn].modelEI)); if (pMdl && pMdl->GetNode(0)) pcModlName = pMdl->GetNode(0)->GetName(); diff --git a/src/libs/rigging/src/sail.cpp b/src/libs/rigging/src/sail.cpp index 8b99b8fd9..47b2d3814 100644 --- a/src/libs/rigging/src/sail.cpp +++ b/src/libs/rigging/src/sail.cpp @@ -276,17 +276,17 @@ void SAIL::Execute(uint32_t Delta_Time) if (nTmpMastNum >= 0) { MODEL *pTmpMdl = nullptr; - if ((pTmpMdl = static_cast(EntityManager::GetEntityPointer(gdata[0].modelEI))) != nullptr) + if ((pTmpMdl = static_cast(core.GetEntityPointer(gdata[0].modelEI))) != nullptr) { char pcTmpMastName[256]; sprintf_s(pcTmpMastName, "mast%d", nTmpMastNum); if (auto *nod = pTmpMdl->FindNode(pcTmpMastName)) { entid_t eiMastTmp; - if (eiMastTmp = EntityManager::CreateEntity("MAST")) + if (eiMastTmp = core.CreateEntity("MAST")) { - EntityManager::AddToLayer(SEA_EXECUTE, eiMastTmp, 2 + 1); - EntityManager::AddToLayer(SEA_REALIZE, eiMastTmp, 31 + 1); + core.AddToLayer(SEA_EXECUTE, eiMastTmp, 2 + 1); + core.AddToLayer(SEA_REALIZE, eiMastTmp, 31 + 1); core.Send_Message(eiMastTmp, "lpii", MSG_MAST_SETGEOMETRY, nod, gdata[0].shipEI, gdata[0].modelEI); } @@ -354,9 +354,9 @@ void SAIL::Execute(uint32_t Delta_Time) } // get the wind value - if (const auto ei = EntityManager::GetEntityId("weather")) + if (const auto ei = core.GetEntityId("weather")) { - auto wb = static_cast(EntityManager::GetEntityPointer(ei)); + auto wb = static_cast(core.GetEntityPointer(ei)); globalWind.ang.x = wb->GetFloat(whf_wind_angle); globalWind.ang.z = cosf(globalWind.ang.x); globalWind.ang.x = sinf(globalWind.ang.x); @@ -371,7 +371,7 @@ void SAIL::Execute(uint32_t Delta_Time) if (gdata[i].bDeleted) continue; MODEL *cmod; - cmod = static_cast(EntityManager::GetEntityPointer(gdata[i].modelEI)); + cmod = static_cast(core.GetEntityPointer(gdata[i].modelEI)); if (cmod == nullptr) continue; gdata[i].boxCenter = gdata[i].boxSize = slist[gdata[i].sailIdx[0]]->ss.boundSphere.rc; @@ -466,7 +466,7 @@ void SAIL::Execute(uint32_t Delta_Time) if (gdata[i].bYesShip) { ATTRIBUTES *pA = - static_cast(EntityManager::GetEntityPointer(gdata[i].shipEI))->GetACharacter(); + static_cast(core.GetEntityPointer(gdata[i].shipEI))->GetACharacter(); core.Event("Ship_SailsMoveSound", "al", pA, static_cast(gdata[i].bFinalSailDo)); } } @@ -509,7 +509,7 @@ void SAIL::Execute(uint32_t Delta_Time) if (gdata[i].bYesShip) { - auto *pVai = static_cast(EntityManager::GetEntityPointer(gdata[i].shipEI)); + auto *pVai = static_cast(core.GetEntityPointer(gdata[i].shipEI)); if (pVai != nullptr && pVai->GetACharacter() != nullptr) { ATTRIBUTES *pA = pVai->GetACharacter()->GetAttributeClass("Ship"); @@ -616,9 +616,9 @@ void SAIL::Realize(uint32_t Delta_Time) RenderService->UnLockIndexBuffer(sg.indxBuf); if (gdata[j].bYesShip) { - static_cast(EntityManager::GetEntityPointer(gdata[j].shipEI)) + static_cast(core.GetEntityPointer(gdata[j].shipEI)) ->SetLightAndFog(true); - static_cast(EntityManager::GetEntityPointer(gdata[j].shipEI))->SetLights(); + static_cast(core.GetEntityPointer(gdata[j].shipEI))->SetLights(); } if (slist[i]->ss.nholeIndx != 0) { @@ -634,8 +634,8 @@ void SAIL::Realize(uint32_t Delta_Time) } if (gdata[j].bYesShip) { - static_cast(EntityManager::GetEntityPointer(gdata[j].shipEI))->UnSetLights(); - static_cast(EntityManager::GetEntityPointer(gdata[j].shipEI)) + static_cast(core.GetEntityPointer(gdata[j].shipEI))->UnSetLights(); + static_cast(core.GetEntityPointer(gdata[j].shipEI)) ->RestoreLightAndFog(); } } @@ -704,7 +704,7 @@ uint64_t SAIL::ProcessMessage(MESSAGE &message) } MODEL *mdl; - if ((mdl = static_cast(EntityManager::GetEntityPointer(gdata[groupQuantity - 1].modelEI))) != nullptr) + if ((mdl = static_cast(core.GetEntityPointer(gdata[groupQuantity - 1].modelEI))) != nullptr) { GEOS::INFO gi; GEOS::LABEL gl; @@ -773,7 +773,7 @@ uint64_t SAIL::ProcessMessage(MESSAGE &message) CVECTOR epos; if (so->ss.turningSail && posNum != 0) // setting for turning sails only - if (tmpEI = EntityManager::GetEntityId("rope")) + if (tmpEI = core.GetEntityId("rope")) if (so->sailtrope.rrs[0] == nullptr) { so->sailtrope.rrs[0] = new ROTATEROPEDSAIL; @@ -792,7 +792,7 @@ uint64_t SAIL::ProcessMessage(MESSAGE &message) bpos = so->ss.hardPoints[1]; break; } - static_cast(EntityManager::GetEntityPointer(tmpEI)) + static_cast(core.GetEntityPointer(tmpEI)) ->GetEndPoint(&epos, so->sailtrope.rrs[0]->ropenum, gdata[so->HostNum].modelEI); so->sailtrope.rrs[0]->r1 = sqrtf(~(*pos - bpos)); so->sailtrope.rrs[0]->r2 = sqrtf(~(*pos - epos)); @@ -826,7 +826,7 @@ uint64_t SAIL::ProcessMessage(MESSAGE &message) break; } so->sailtrope.rrs[1]->r1 = sqrtf(~(*pos - bpos)); - static_cast(EntityManager::GetEntityPointer(tmpEI)) + static_cast(core.GetEntityPointer(tmpEI)) ->GetEndPoint(&epos, so->sailtrope.rrs[1]->ropenum, gdata[so->HostNum].modelEI); so->sailtrope.rrs[1]->r2 = sqrtf(~(*pos - epos)); if (so->ss.eSailType != SAIL_TREANGLE) @@ -1202,7 +1202,7 @@ void SAIL::SetAllSails(int groupNum) if (gdata[groupNum].bYesShip && !gdata[groupNum].bDeleted) { ATTRIBUTES *pACh = - static_cast(EntityManager::GetEntityPointer(gdata[groupNum].shipEI))->GetACharacter(); + static_cast(core.GetEntityPointer(gdata[groupNum].shipEI))->GetACharacter(); ATTRIBUTES *pA = nullptr; // start installing textures on the sails if (pACh != nullptr) @@ -1567,7 +1567,7 @@ void SAIL::FirstRun() SetAllSails(); entid_t ropeEI; - if (ropeEI = EntityManager::GetEntityId("rope")) + if (ropeEI = core.GetEntityId("rope")) // position calculation according to the position of the ropes for (sn = wFirstIndx; sn < sailQuantity; sn++) { @@ -1579,7 +1579,7 @@ void SAIL::FirstRun() { const int tieNum = slist[sn]->sailtrope.rrs[i]->tiePoint; CVECTOR endVect; - static_cast(EntityManager::GetEntityPointer(ropeEI)) + static_cast(core.GetEntityPointer(ropeEI)) ->GetEndPoint(&endVect, slist[sn]->sailtrope.rrs[i]->ropenum, gdata[slist[sn]->HostNum].modelEI); CVECTOR medVect; @@ -1647,7 +1647,7 @@ float SAIL::Cannon_Trace(int32_t iBallOwner, const CVECTOR &src, const CVECTOR & { const CVECTOR damagePoint = src + (dst - src) * retVal; auto *pvai = - static_cast(EntityManager::GetEntityPointer(gdata[slist[traceSail]->HostNum].shipEI)); + static_cast(core.GetEntityPointer(gdata[slist[traceSail]->HostNum].shipEI)); ATTRIBUTES *pA = nullptr; if (pvai != nullptr) pA = pvai->GetACharacter(); @@ -1759,7 +1759,7 @@ void SAIL::DoSailToNewHost(entid_t newModelEI, entid_t newHostEI, int grNum, NOD // remove the only sail together with the group { // write down the value of the state of the sails = 0 for the ship - auto *pVai = static_cast(EntityManager::GetEntityPointer(gdata[oldg].shipEI)); + auto *pVai = static_cast(core.GetEntityPointer(gdata[oldg].shipEI)); if (pVai && pVai->GetACharacter()) { ATTRIBUTES *pA = pVai->GetACharacter()->GetAttributeClass("Ship"); @@ -1957,9 +1957,9 @@ void SAIL::SetAddSails(int firstSail) void SAIL::DoNoRopeSailToNewHost(entid_t newModel, entid_t newHost, entid_t oldHost) { entid_t rope_id; - if (!(rope_id = EntityManager::GetEntityId("rope"))) + if (!(rope_id = core.GetEntityId("rope"))) return; // no ropes, no concert - auto *rb = static_cast(EntityManager::GetEntityPointer(rope_id)); + auto *rb = static_cast(core.GetEntityPointer(rope_id)); if (rb == nullptr) return; @@ -1972,14 +1972,14 @@ void SAIL::DoNoRopeSailToNewHost(entid_t newModel, entid_t newHost, entid_t oldH return; // new root NODE - auto nmdl = static_cast(EntityManager::GetEntityPointer(newModel)); + auto nmdl = static_cast(core.GetEntityPointer(newModel)); if (nmdl == nullptr) return; NODE *nroot = nmdl->GetNode(0); if (nroot == nullptr) return; - auto *omdl = static_cast(EntityManager::GetEntityPointer(gdata[ogn].modelEI)); + auto *omdl = static_cast(core.GetEntityPointer(gdata[ogn].modelEI)); if (omdl == nullptr) return; @@ -2162,7 +2162,7 @@ int SAIL::FindGroupForCharacter(int chrIdx) const { if (gdata[gn].bDeleted || !gdata[gn].bYesShip) continue; - ATTRIBUTES *pA = static_cast(EntityManager::GetEntityPointer(gdata[gn].shipEI))->GetACharacter(); + ATTRIBUTES *pA = static_cast(core.GetEntityPointer(gdata[gn].shipEI))->GetACharacter(); if (pA != nullptr) if (static_cast(pA->GetAttributeAsDword("index", -1)) == chrIdx) return gn; @@ -2174,7 +2174,7 @@ int SAIL::GetCharacterForGroup(int grNum) const { ATTRIBUTES *pA = nullptr; if (gdata[grNum].bYesShip) - pA = static_cast(EntityManager::GetEntityPointer(gdata[grNum].shipEI))->GetACharacter(); + pA = static_cast(core.GetEntityPointer(gdata[grNum].shipEI))->GetACharacter(); if (pA != nullptr) return static_cast(pA->GetAttributeAsDword("index", -1)); return -1; diff --git a/src/libs/rigging/src/sailone.cpp b/src/libs/rigging/src/sailone.cpp index 981582875..649d53852 100644 --- a/src/libs/rigging/src/sailone.cpp +++ b/src/libs/rigging/src/sailone.cpp @@ -65,9 +65,9 @@ SAILONE::SAILONE() SAILONE::~SAILONE() { ROPE_BASE *prb = nullptr; - const auto eid = EntityManager::GetEntityId("rope"); + const auto eid = core.GetEntityId("rope"); if (eid) - prb = static_cast(EntityManager::GetEntityPointer(eid)); + prb = static_cast(core.GetEntityPointer(eid)); if (prb != nullptr && (sailtrope.pnttie[0] || sailtrope.pnttie[1] || sailtrope.pnttie[2] || sailtrope.pnttie[3])) prb->DoDeleteUntie(pp->gdata[HostNum].modelEI, hostNode, groupNum); @@ -1226,7 +1226,7 @@ void SAILONE::TurnSail(float fTurnStep) if (sailtrope.pnttie[3]) *sailtrope.pPos[3] = ss.hardPoints[1]; } - else if (ropeEI = EntityManager::GetEntityId("rope")) + else if (ropeEI = core.GetEntityId("rope")) { auto bChange = false; for (auto i = 0; i < 2; i++) @@ -1234,7 +1234,7 @@ void SAILONE::TurnSail(float fTurnStep) { auto tieNum = sailtrope.rrs[i]->tiePoint; CVECTOR endVect; - static_cast(EntityManager::GetEntityPointer(ropeEI)) + static_cast(core.GetEntityPointer(ropeEI)) ->GetEndPoint(&endVect, sailtrope.rrs[i]->ropenum, pp->gdata[HostNum].modelEI); CVECTOR medVect; medVect = ss.hardPoints[tieNum]; @@ -1663,7 +1663,7 @@ float SAILONE::SSailTrace(CVECTOR &src, CVECTOR &dst, bool bCannonTrace) SetGeometry(); if (pp->gdata[HostNum].bDeleted != true && pp->gdata[HostNum].bYesShip) { - auto *pVai = static_cast(EntityManager::GetEntityPointer(pp->gdata[HostNum].shipEI)); + auto *pVai = static_cast(core.GetEntityPointer(pp->gdata[HostNum].shipEI)); auto charIdx = -1; if (pVai != nullptr && pVai->GetACharacter() != nullptr) charIdx = pVai->GetACharacter()->GetAttributeAsDword("index"); @@ -1722,7 +1722,7 @@ float SAILONE::TSailTrace(CVECTOR &src, CVECTOR &dst, bool bCannonTrace) CalculateMirrorSailIndex(); // new triangulation for sail reflection if (pp->gdata[HostNum].bDeleted != true && pp->gdata[HostNum].bYesShip) { - auto *pVai = static_cast(EntityManager::GetEntityPointer(pp->gdata[HostNum].shipEI)); + auto *pVai = static_cast(core.GetEntityPointer(pp->gdata[HostNum].shipEI)); auto charIdx = -1; if (pVai != nullptr && pVai->GetACharacter() != nullptr) charIdx = pVai->GetACharacter()->GetAttributeAsDword("index"); @@ -1988,10 +1988,10 @@ void SAILONE::SetTurnLimits() return; if (sailtrope.rrs[0] == nullptr) return; - const auto ropeEI = EntityManager::GetEntityId("rope"); + const auto ropeEI = core.GetEntityId("rope"); if (!ropeEI) return; - auto *prbase = static_cast(EntityManager::GetEntityPointer(ropeEI)); + auto *prbase = static_cast(core.GetEntityPointer(ropeEI)); if (prbase == nullptr) return; diff --git a/src/libs/rigging/src/script_func.cpp b/src/libs/rigging/src/script_func.cpp index 265fba0c8..eec42055e 100644 --- a/src/libs/rigging/src/script_func.cpp +++ b/src/libs/rigging/src/script_func.cpp @@ -20,9 +20,9 @@ uint32_t _ShipSailState(VS_STACK *pS) return IFUNCRESULT_FAILED; // find sail class - if (const auto eid = EntityManager::GetEntityId("SAIL")) + if (const auto eid = core.GetEntityId("SAIL")) { - const int32_t n = static_cast(EntityManager::GetEntityPointer(eid))->GetSailStateForCharacter(nChrIdx); + const int32_t n = static_cast(core.GetEntityPointer(eid))->GetSailStateForCharacter(nChrIdx); pVR->Set(n); } else @@ -173,9 +173,9 @@ uint32_t _RandomHole2Sail(VS_STACK *pS) return IFUNCRESULT_FAILED; SAILONE_BASE *pSail = nullptr; - if (const auto ei = EntityManager::GetEntityId("sail")) + if (const auto ei = core.GetEntityId("sail")) { - pSail = static_cast(EntityManager::GetEntityPointer(ei)) + pSail = static_cast(core.GetEntityPointer(ei)) ->FindSailForCharacter(_chrIdx, _reyName, _groupNum); } @@ -235,9 +235,9 @@ uint32_t _DeleteOneSailHole(VS_STACK *pS) sscanf(_groupName, "%d", &_groupNum); SAILONE_BASE *pSail = nullptr; - if (const auto ei = EntityManager::GetEntityId("sail")) + if (const auto ei = core.GetEntityId("sail")) { - pSail = static_cast(EntityManager::GetEntityPointer(ei)) + pSail = static_cast(core.GetEntityPointer(ei)) ->FindSailForCharacter(_chrIdx, _reyName, _groupNum); } diff --git a/src/libs/rigging/src/vant.cpp b/src/libs/rigging/src/vant.cpp index 86895fedd..66aac9f03 100644 --- a/src/libs/rigging/src/vant.cpp +++ b/src/libs/rigging/src/vant.cpp @@ -126,14 +126,14 @@ void VANT_BASE::Realize(uint32_t Delta_Time) for (auto gn = 0; gn < groupQuantity; gn++) if (gdata[gn].nIndx && nVert && (~(gdata[gn].pMatWorld->Pos() - cp)) * pr < fVantMaxDist) { - static_cast(EntityManager::GetEntityPointer(gdata[gn].shipEI))->SetLightAndFog(true); - static_cast(EntityManager::GetEntityPointer(gdata[gn].shipEI))->SetLights(); + static_cast(core.GetEntityPointer(gdata[gn].shipEI))->SetLightAndFog(true); + static_cast(core.GetEntityPointer(gdata[gn].shipEI))->SetLights(); RenderService->SetTransform(D3DTS_WORLD, *gdata[gn].pMatWorld); RenderService->DrawBuffer(vBuf, sizeof(VANTVERTEX), iBuf, 0, nVert, gdata[gn].sIndx, gdata[gn].nIndx); - static_cast(EntityManager::GetEntityPointer(gdata[gn].shipEI))->UnSetLights(); - static_cast(EntityManager::GetEntityPointer(gdata[gn].shipEI))->RestoreLightAndFog(); + static_cast(core.GetEntityPointer(gdata[gn].shipEI))->UnSetLights(); + static_cast(core.GetEntityPointer(gdata[gn].shipEI))->RestoreLightAndFog(); //_asm rdtsc _asm sub eax,rtm _asm mov rtm,eax } while (RenderService->TechniqueExecuteNext()) @@ -170,7 +170,7 @@ uint64_t VANT_BASE::ProcessMessage(MESSAGE &message) gdata[groupQuantity - 1].shipEI = message.EntityID(); gdata[groupQuantity - 1].model_id = message.EntityID(); MODEL *mdl; - mdl = static_cast(EntityManager::GetEntityPointer(gdata[groupQuantity - 1].model_id)); + mdl = static_cast(core.GetEntityPointer(gdata[groupQuantity - 1].model_id)); if (mdl == nullptr) throw std::runtime_error("Bad Vant INIT"); diff --git a/src/libs/sailors/src/sailors.cpp b/src/libs/sailors/src/sailors.cpp index d2e83fead..b9d3025ac 100644 --- a/src/libs/sailors/src/sailors.cpp +++ b/src/libs/sailors/src/sailors.cpp @@ -42,7 +42,7 @@ void ShipMan::Free() const { // GUARD_SAILORS(ShipMan::Free()) - EntityManager::EraseEntity(this->modelID); + core.EraseEntity(this->modelID); // UN//GUARD_SAILORS }; @@ -720,7 +720,7 @@ void ShipWalk::CreateNewMan(SailorsPoints &sailorsPoints) const int current = shipMan.size() - 1; - shipMan[current].modelID = EntityManager::CreateEntity("MODELR"); + shipMan[current].modelID = core.CreateEntity("MODELR"); switch (rand() % 6) // 6 different character types { @@ -746,7 +746,7 @@ void ShipWalk::CreateNewMan(SailorsPoints &sailorsPoints) core.Send_Message(shipMan[current].modelID, "ls", MSG_MODEL_LOAD_ANI, "Lo_Man"); - shipMan[current].model = static_cast(EntityManager::GetEntityPointer(shipMan[current].modelID)); + shipMan[current].model = static_cast(core.GetEntityPointer(shipMan[current].modelID)); shipMan[current].SetAnimation(0, shipState); if (sailorsPoints.points.count) @@ -785,14 +785,14 @@ bool ShipWalk::Init(entid_t _shipID, int editorMode, const char *shipType) bHide = false; shipID = _shipID; - const auto seaID = EntityManager::GetEntityId("sea"); - shipState.sea = static_cast(EntityManager::GetEntityPointer(seaID)); + const auto seaID = core.GetEntityId("sea"); + shipState.sea = static_cast(core.GetEntityPointer(seaID)); if (!editorMode) { // Game mode - ship created - ship = static_cast(EntityManager::GetEntityPointer(_shipID)); + ship = static_cast(core.GetEntityPointer(_shipID)); shipModel = ship->GetModel(); // Load points @@ -1053,8 +1053,8 @@ bool Sailors::Init() rs = static_cast(core.GetService("dx9render")); - EntityManager::SetLayerType(SEA_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(SEA_REALIZE, GetId(), 65530); + core.SetLayerType(SEA_REALIZE, layer_type_t::realize); + core.AddToLayer(SEA_REALIZE, GetId(), 65530); // UN//GUARD_SAILORS diff --git a/src/libs/sailors/src/sailors_editor.cpp b/src/libs/sailors/src/sailors_editor.cpp index a8d04fa62..a321bb55d 100644 --- a/src/libs/sailors/src/sailors_editor.cpp +++ b/src/libs/sailors/src/sailors_editor.cpp @@ -19,29 +19,29 @@ SailorsEditor::SailorsEditor() SailorsEditor::~SailorsEditor() { - EntityManager::EraseEntity(sailors); - EntityManager::EraseEntity(shipID); + core.EraseEntity(sailors); + core.EraseEntity(shipID); }; bool SailorsEditor::Init() { rs = static_cast(core.GetService("dx9render")); - sailors = EntityManager::CreateEntity("Sailors"); + sailors = core.CreateEntity("Sailors"); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(EXECUTE, GetId(), 0); + core.SetLayerType(EXECUTE, layer_type_t::execute); + core.AddToLayer(EXECUTE, GetId(), 0); - EntityManager::SetLayerType(EDITOR_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(EDITOR_REALIZE, GetId(), 100000); + core.SetLayerType(EDITOR_REALIZE, layer_type_t::realize); + core.AddToLayer(EDITOR_REALIZE, GetId(), 100000); LoadFromIni("SailorsEditor.ini"); - shipID = EntityManager::CreateEntity("MODELR"); + shipID = core.CreateEntity("MODELR"); core.Send_Message(shipID, "ls", MSG_MODEL_LOAD_GEO, _shipName.c_str()); - EntityManager::AddToLayer(EDITOR_REALIZE, shipID, 100000); - model = static_cast(EntityManager::GetEntityPointer(shipID)); + core.AddToLayer(EDITOR_REALIZE, shipID, 100000); + model = static_cast(core.GetEntityPointer(shipID)); model->mtx.BuildMatrix(CVECTOR(0.0f), CVECTOR(0.0f, 0.0f, 0.0f)); @@ -50,7 +50,7 @@ bool SailorsEditor::Init() ctrl = core.Controls->CreateControl("DeltaMouseV"); core.Controls->MapControl(ctrl, 257); - menu.sailrs = static_cast(EntityManager::GetEntityPointer(sailors)); + menu.sailrs = static_cast(core.GetEntityPointer(sailors)); menu.sailrs->editorMode = true; diff --git a/src/libs/sea/src/env_map.cpp b/src/libs/sea/src/env_map.cpp index cd025cc3f..2e821644a 100644 --- a/src/libs/sea/src/env_map.cpp +++ b/src/libs/sea/src/env_map.cpp @@ -92,13 +92,12 @@ bool SEA::SunRoad_Render2() // Render scene here. // uint32_t dwSkyCode = MakeHashValue("sky"); - if (!EntityManager::IsLayerFrozen(SEA_REFLECTION2)) + if (!core.IsLayerFrozen(SEA_REFLECTION2)) { - const auto its = EntityManager::GetEntityIdIterators(SEA_SUNROAD); - for (auto it = its.first; it != its.second; ++it) + auto &&entities = core.GetEntityIds(SEA_SUNROAD); + for (auto ent_id : entities) { - const auto ent_id = *it; - const auto hash = EntityManager::GetClassCode(ent_id); + const auto hash = core.GetClassCode(ent_id); if (hash != dwShipCode && hash != dwSailCode && hash != dwIslandCode) { core.Send_Message(ent_id, "ll", MSG_SEA_SUNROAD_DRAW, static_cast(bSimpleSea)); @@ -173,16 +172,19 @@ bool SEA::EnvMap_Render2() // rs->SetView(mView); // Render scene here. - auto its = EntityManager::GetEntityIdIterators(SEA_REFLECTION); - for (auto it = its.first; it != its.second; ++it) { - core.Send_Message(*it, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + auto &&entities = core.GetEntityIds(SEA_REFLECTION); + for (auto ent_id : entities) + { + core.Send_Message(ent_id, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + } } - - its = EntityManager::GetEntityIdIterators(SEA_REFLECTION2); - for (auto it = its.first; it != its.second; ++it) { - core.Send_Message(*it, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + auto &&entities = core.GetEntityIds(SEA_REFLECTION2); + for (auto ent_id : entities) + { + core.Send_Message(ent_id, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + } } rs->EndScene(); @@ -240,13 +242,12 @@ bool SEA::SunRoad_Render() rs->SetView(mView); // Render scene here. - if (!EntityManager::IsLayerFrozen(SEA_REFLECTION2)) + if (!core.IsLayerFrozen(SEA_REFLECTION2)) { - const auto its = EntityManager::GetEntityIdIterators(SEA_SUNROAD); - for (auto it = its.first; it != its.second; ++it) + auto &&entities = core.GetEntityIds(SEA_SUNROAD); + for (auto ent_id : entities) { - const auto ent_id = *it; - const auto hash = EntityManager::GetClassCode(ent_id); + const auto hash = core.GetClassCode(ent_id); if (hash != dwShipCode && hash != dwSailCode && hash != dwIslandCode) { core.Send_Message(ent_id, "ll", MSG_SEA_SUNROAD_DRAW, static_cast(bSimpleSea)); @@ -298,16 +299,19 @@ bool SEA::EnvMap_Render() rs->SetView(mView); // Render scene here. - auto its = EntityManager::GetEntityIdIterators(SEA_REFLECTION); - for (auto it = its.first; it != its.second; ++it) { - core.Send_Message(*it, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + auto &&entities = core.GetEntityIds(SEA_REFLECTION); + for (auto ent_id : entities) + { + core.Send_Message(ent_id, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + } } - - its = EntityManager::GetEntityIdIterators(SEA_REFLECTION2); - for (auto it = its.first; it != its.second; ++it) { - core.Send_Message(*it, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + auto &&entities = core.GetEntityIds(SEA_REFLECTION2); + for (auto ent_id : entities) + { + core.Send_Message(ent_id, "ll", MSG_SEA_REFLECTION_DRAW, static_cast(bSimpleSea)); + } } rs->EndScene(); diff --git a/src/libs/sea_ai/src/ai_balls.cpp b/src/libs/sea_ai/src/ai_balls.cpp index 48bf51a07..3d34f8299 100644 --- a/src/libs/sea_ai/src/ai_balls.cpp +++ b/src/libs/sea_ai/src/ai_balls.cpp @@ -148,7 +148,7 @@ void AIBalls::AddBall(ATTRIBUTES *pABall) if (aBallTypes[i].sParticleName.size()) { entid_t eidParticle; - if (eidParticle = EntityManager::GetEntityId("particles")) + if (eidParticle = core.GetEntityId("particles")) { pBall->pParticle = (VPARTICLE_SYSTEM *)core.Send_Message( eidParticle, "lsffffffl", PS_CREATE_RIC, (char *)aBallTypes[i].sParticleName.c_str(), pBall->vPos.x, @@ -163,12 +163,12 @@ void AIBalls::Execute(uint32_t Delta_Time) CVECTOR vSrc, vDst; entid_t EID; - if (!pIsland && (EID = EntityManager::GetEntityId("island"))) - pIsland = static_cast(EntityManager::GetEntityPointer(EID)); - if (!pSail && (EID = EntityManager::GetEntityId("sail"))) - pSail = static_cast(EntityManager::GetEntityPointer(EID)); - if (!pSea && (EID = EntityManager::GetEntityId("sea"))) - pSea = static_cast(EntityManager::GetEntityPointer(EID)); + if (!pIsland && (EID = core.GetEntityId("island"))) + pIsland = static_cast(core.GetEntityPointer(EID)); + if (!pSail && (EID = core.GetEntityId("sail"))) + pSail = static_cast(core.GetEntityPointer(EID)); + if (!pSea && (EID = core.GetEntityId("sea"))) + pSea = static_cast(core.GetEntityPointer(EID)); aBallRects.clear(); @@ -240,11 +240,11 @@ void AIBalls::Execute(uint32_t Delta_Time) // sail trace if (pSail) pSail->Cannon_Trace(pBall->iBallOwner, vSrc, vDst); - - const auto its = EntityManager::GetEntityIdIterators(SHIP_CANNON_TRACE); - for (auto it = its.first; it != its.second; ++it) + + auto &&entities = core.GetEntityIds(SHIP_CANNON_TRACE); + for (auto ent_id : entities) { - auto *pShip = static_cast(EntityManager::GetEntityPointer(*it)); + auto *pShip = static_cast(core.GetEntityPointer(ent_id)); fRes = pShip->Cannon_Trace(pBall->iBallOwner, vSrc, vDst); if (fRes <= 1.0f) break; @@ -491,7 +491,7 @@ void AIBalls::Load(CSaveLoad *pSL) if (pB.pParticle) { pB.pParticle = nullptr; - if (auto eidParticle = EntityManager::GetEntityId("particles")) + if (auto eidParticle = core.GetEntityId("particles")) { pB.pParticle = (VPARTICLE_SYSTEM *)core.Send_Message( eidParticle, "lsffffffl", PS_CREATE_RIC, (char *)aBallType.sParticleName.c_str(), pB.vPos.x, diff --git a/src/libs/sea_ai/src/ai_cannon.cpp b/src/libs/sea_ai/src/ai_cannon.cpp index efa4e0912..126a5fa02 100644 --- a/src/libs/sea_ai/src/ai_cannon.cpp +++ b/src/libs/sea_ai/src/ai_cannon.cpp @@ -83,7 +83,7 @@ float AICannon::CalcHeightFireAngle(float _fSpeedV0, const CVECTOR &vOur, const VAI_OBJBASE *AICannon::GetAIObjPointer() const { - return static_cast(EntityManager::GetEntityPointer(GetParentEID())); + return static_cast(core.GetEntityPointer(GetParentEID())); } float AICannon::GetDirY() const diff --git a/src/libs/sea_ai/src/ai_fort.cpp b/src/libs/sea_ai/src/ai_fort.cpp index f747bdcf9..ed9c55171 100644 --- a/src/libs/sea_ai/src/ai_fort.cpp +++ b/src/libs/sea_ai/src/ai_fort.cpp @@ -117,7 +117,7 @@ void AIFort::Realize(uint32_t Delta_Time) float fCurrentImmersion = 0.0f; if (core.FindClass(&eidIsland, "Island", 0)) { - ISLAND_BASE * pIsland = (ISLAND_BASE *)EntityManager::GetEntityPointer(eidIsland); + ISLAND_BASE * pIsland = (ISLAND_BASE *)core.GetEntityPointer(eidIsland); fCurrentImmersion = pIsland->GetCurrentImmersion(); }*/ @@ -218,8 +218,8 @@ bool AIFort::AddFort(ATTRIBUTES *pIslandAP, ATTRIBUTES *pFortLabelAP, ATTRIBUTES const auto bLights = (pALights) ? pALights->GetAttributeAsDword() != 0 : false; const auto bFlares = (pAFlares) ? pAFlares->GetAttributeAsDword() != 0 : false; - const auto eidTmp = EntityManager::GetEntityId("shiplights"); - pShipsLights = static_cast(EntityManager::GetEntityPointer(eidTmp)); + const auto eidTmp = core.GetEntityId("shiplights"); + pShipsLights = static_cast(core.GetEntityPointer(eidTmp)); Assert(pShipsLights); pShipsLights->AddLights(&pFort->tmpObject, pFort->GetModel(), bLights, bFlares); @@ -267,7 +267,7 @@ AIFort::AI_FORT *AIFort::FindFort(entid_t eidModel) { for (auto &aFort : aForts) { - if (EntityManager::GetEntityPointer(aFort->GetModelEID()) == EntityManager::GetEntityPointer(eidModel)) + if (core.GetEntityPointer(aFort->GetModelEID()) == core.GetEntityPointer(eidModel)) return aFort; } return nullptr; @@ -335,10 +335,10 @@ bool AIFort::ScanFortForCannons(AI_FORT *pFort, const char *pModelsDir, const ch const auto pathStr = path.string(); // MessageBoxA(NULL, (LPCSTR)path.c_str(), "", MB_OK); //~!~ // sLocatorsName.Format("%s\\%s", pModelsDir, pLocatorsName); - model_id = EntityManager::CreateEntity("MODELR"); + model_id = core.CreateEntity("MODELR"); core.Send_Message(model_id, "ls", MSG_MODEL_LOAD_GEO, (char *)pathStr.c_str()); - auto *pModel = static_cast(EntityManager::GetEntityPointer(model_id)); + auto *pModel = static_cast(core.GetEntityPointer(model_id)); Assert(pModel); // search and add cannons & culverins @@ -380,7 +380,7 @@ bool AIFort::ScanFortForCannons(AI_FORT *pFort, const char *pModelsDir, const ch dwIdx++; } - EntityManager::EraseEntity(model_id); + core.EraseEntity(model_id); return true; } @@ -414,7 +414,7 @@ float AIFort::Trace(const CVECTOR &vSrc, const CVECTOR &vDst) auto fBestDistance = 1e10f; for (uint32_t i = 0; i < GetNumForts(); i++) { - auto *pModel = static_cast(EntityManager::GetEntityPointer(GetFort(i)->GetModelEID())); + auto *pModel = static_cast(core.GetEntityPointer(GetFort(i)->GetModelEID())); Assert(pModel); const auto fRes = pModel->Trace(vSrc, vDst); if (fRes > 1.0f) @@ -436,7 +436,7 @@ float AIFort::Cannon_Trace(int32_t iBallOwner, const CVECTOR &vSrc, const CVECTO float fBestRes = 2.0; for (uint32_t i = 0; i < GetNumForts(); i++) { - auto *pModel = static_cast(EntityManager::GetEntityPointer(GetFort(i)->GetModelEID())); + auto *pModel = static_cast(core.GetEntityPointer(GetFort(i)->GetModelEID())); const float fRes = pModel->Trace(vSrc, vDst); if (fRes < fBestRes) diff --git a/src/libs/sea_ai/src/ai_fort.h b/src/libs/sea_ai/src/ai_fort.h index 7c8168d4d..044fb4b4b 100644 --- a/src/libs/sea_ai/src/ai_fort.h +++ b/src/libs/sea_ai/src/ai_fort.h @@ -123,7 +123,7 @@ class AIFort : public VAI_OBJBASE MODEL *GetModel() const { - return static_cast(EntityManager::GetEntityPointer(GetModelEID())); + return static_cast(core.GetEntityPointer(GetModelEID())); } void SetModelEID(entid_t _eidModel) diff --git a/src/libs/sea_ai/src/ai_group.cpp b/src/libs/sea_ai/src/ai_group.cpp index 7286be374..ed025f433 100644 --- a/src/libs/sea_ai/src/ai_group.cpp +++ b/src/libs/sea_ai/src/ai_group.cpp @@ -235,7 +235,7 @@ void AIGroup::SailMainGroup(CVECTOR vPos, float fAngle, ATTRIBUTES *pACharacter) Assert(pMG); AIGroup *pG1 = FindGroup(pACharacter); - const auto eidSea = EntityManager::GetEntityId("sea"); + const auto eidSea = core.GetEntityId("sea"); for (auto pAIShip : pMG->aGroupShips) { diff --git a/src/libs/sea_ai/src/ai_helper.cpp b/src/libs/sea_ai/src/ai_helper.cpp index 31d18ee86..9a062dbe3 100644 --- a/src/libs/sea_ai/src/ai_helper.cpp +++ b/src/libs/sea_ai/src/ai_helper.cpp @@ -47,7 +47,7 @@ bool AIHelper::SetDevice() bool AIHelper::Init() const { - pIsland = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("island"))); + pIsland = static_cast(core.GetEntityPointer(core.GetEntityId("island"))); return true; } diff --git a/src/libs/sea_ai/src/ai_sea_goods.cpp b/src/libs/sea_ai/src/ai_sea_goods.cpp index 5c6f9cf32..d2966655c 100644 --- a/src/libs/sea_ai/src/ai_sea_goods.cpp +++ b/src/libs/sea_ai/src/ai_sea_goods.cpp @@ -44,7 +44,7 @@ void AISeaGoods::Execute(uint32_t dwDeltaTime) const auto fDeltaTime = static_cast(dwDeltaTime) * 0.001f; if (!pSea) - pSea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + pSea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); if (!pSea) return; @@ -75,10 +75,10 @@ void AISeaGoods::Execute(uint32_t dwDeltaTime) aShips.clear(); // enumerate ships - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ent : entities) { - aShips.push_back(static_cast(EntityManager::GetEntityPointer(ent))); + aShips.push_back(static_cast(core.GetEntityPointer(ent))); } // check ships diff --git a/src/libs/sea_ai/src/ai_ship.cpp b/src/libs/sea_ai/src/ai_ship.cpp index b9dd1e8ee..a451725f6 100644 --- a/src/libs/sea_ai/src/ai_ship.cpp +++ b/src/libs/sea_ai/src/ai_ship.cpp @@ -237,7 +237,7 @@ void AIShip::CreateShip(entid_t _eidShip, ATTRIBUTES *_pACharacter, ATTRIBUTES * pAShipBase = _pAShipBase; eidShip = _eidShip; - Assert(EntityManager::GetEntityPointer(eidShip)); + Assert(core.GetEntityPointer(eidShip)); auto *pObj = GetAIObjShipPointer(); Assert(pObj); SetACharacter(_pACharacter); @@ -704,7 +704,7 @@ void AIShip::Save(CSaveLoad *pSL) const void AIShip::Load(CSaveLoad *pSL) { // create ship - eidShip = EntityManager::CreateEntity("Ship"); + eidShip = core.CreateEntity("Ship"); GetShipBasePointer()->Load(pSL); SetACharacter(pSL->LoadAPointer("character")); diff --git a/src/libs/sea_ai/src/ai_ship.h b/src/libs/sea_ai/src/ai_ship.h index f6faa5226..0f760929b 100644 --- a/src/libs/sea_ai/src/ai_ship.h +++ b/src/libs/sea_ai/src/ai_ship.h @@ -328,7 +328,7 @@ class AIShip : public VAI_INNEROBJ Entity *GetShipPointer() const { - return EntityManager::GetEntityPointer(GetShipEID()); + return core.GetEntityPointer(GetShipEID()); }; SHIP_BASE *GetShipBasePointer() const diff --git a/src/libs/sea_ai/src/ai_ship_move_controller.cpp b/src/libs/sea_ai/src/ai_ship_move_controller.cpp index 6a4b2f7e6..7d0d403ac 100644 --- a/src/libs/sea_ai/src/ai_ship_move_controller.cpp +++ b/src/libs/sea_ai/src/ai_ship_move_controller.cpp @@ -3,9 +3,9 @@ AIShipMoveController::AIShipMoveController(AIShip *pShip) { - // EntityManager::CreateEntity(&eidSphere,"modelr"); + // core.CreateEntity(&eidSphere,"modelr"); // core.Send_Message(eidSphere,"ls",MSG_MODEL_LOAD_GEO,"mirror"); - // EntityManager::AddToLayer("sea_realize",eidSphere,10000); + // core.AddToLayer("sea_realize",eidSphere,10000); fMoveTime = FRAND(2.0f); dwCurPnt = 0; vDeflectForce = 0.0f; @@ -28,8 +28,8 @@ void AIShipMoveController::Execute(float fDeltaTime) // return; // entid_t eid; // core.FindClass(&eid,"sea",0); - // SEA_BASE * pSea = (SEA_BASE*)EntityManager::GetEntityPointer(eid); - // MODEL* pModel = (MODEL*)EntityManager::GetEntityPointer(eidSphere); + // SEA_BASE * pSea = (SEA_BASE*)core.GetEntityPointer(eid); + // MODEL* pModel = (MODEL*)core.GetEntityPointer(eidSphere); // pModel->mtx.BuildPosition(100.0f,pSea->WaveXZ(100.0f,200.0f),200.0f); // pModel->mtx.m[3][3] = 1.0f / 0.1f; diff --git a/src/libs/sea_ai/src/sea_ai.cpp b/src/libs/sea_ai/src/sea_ai.cpp index c12bdaaac..b399ae8cb 100644 --- a/src/libs/sea_ai/src/sea_ai.cpp +++ b/src/libs/sea_ai/src/sea_ai.cpp @@ -359,7 +359,7 @@ void SEA_AI::Save(const char *pStr) SL.CreateWrite(); Helper.Save(&SL); - core.Send_Message(EntityManager::GetEntityId("SEA_CAMERAS"), "lp", AI_MESSAGE_SEASAVE, &SL); + core.Send_Message(core.GetEntityId("SEA_CAMERAS"), "lp", AI_MESSAGE_SEASAVE, &SL); AIBalls::pAIBalls->Save(&SL); @@ -380,7 +380,7 @@ void SEA_AI::Load(const char *pStr) SL.CreateLoad(); Helper.Load(&SL); - core.Send_Message(EntityManager::GetEntityId("SEA_CAMERAS"), "lp", AI_MESSAGE_SEALOAD, &SL); + core.Send_Message(core.GetEntityId("SEA_CAMERAS"), "lp", AI_MESSAGE_SEALOAD, &SL); AIBalls::pAIBalls->Load(&SL); diff --git a/src/libs/sea_cameras/src/common_camera.h b/src/libs/sea_cameras/src/common_camera.h index 6e602e6c7..af45048d9 100644 --- a/src/libs/sea_cameras/src/common_camera.h +++ b/src/libs/sea_cameras/src/common_camera.h @@ -24,10 +24,10 @@ class COMMON_CAMERA : public Entity { Assert(pACharacter); // get entity id from loaded ships - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ship : entities) { - auto *pObj = static_cast(EntityManager::GetEntityPointer(ship)); + auto *pObj = static_cast(core.GetEntityPointer(ship)); if (pObj->GetACharacter() == pACharacter) { SetEID(pObj->GetModelEID()); @@ -40,7 +40,7 @@ class COMMON_CAMERA : public Entity MODEL *GetModelPointer() const { - return static_cast(EntityManager::GetEntityPointer(eidObject)); + return static_cast(core.GetEntityPointer(eidObject)); } void SetAIObj(VAI_OBJBASE *_pAIObj) diff --git a/src/libs/sea_cameras/src/free_camera.cpp b/src/libs/sea_cameras/src/free_camera.cpp index 7052fab51..6fe7d1058 100644 --- a/src/libs/sea_cameras/src/free_camera.cpp +++ b/src/libs/sea_cameras/src/free_camera.cpp @@ -35,7 +35,7 @@ bool FREE_CAMERA::Init() { // GUARD(FREE_CAMERA::FREE_CAMERA()) // core.LayerCreate("realize",true,false); - // EntityManager::AddToLayer("system_messages",GetId(),1); + // core.AddToLayer("system_messages",GetId(),1); SetDevice(); // UNGUARD return true; @@ -48,9 +48,9 @@ void FREE_CAMERA::SetDevice() pCollide = static_cast(core.GetService("COLL")); Assert(pCollide); - /*EntityManager::CreateEntity(&sphere,"modelr"); + /*core.CreateEntity(&sphere,"modelr"); core.Send_Message(sphere,"ls",MSG_MODEL_LOAD_GEO,"mirror"); - EntityManager::AddToLayer(realize,sphere,10000);*/ + core.AddToLayer(realize,sphere,10000);*/ } bool FREE_CAMERA::CreateState(ENTITY_STATE_GEN *state_gen) const @@ -78,7 +78,7 @@ void FREE_CAMERA::Execute(uint32_t Delta_Time) pRS->GetCamera(vPos, vAng, persp); if (!pIslandBase) - pIslandBase = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("island"))); + pIslandBase = static_cast(core.GetEntityPointer(core.GetEntityId("island"))); if (!pIslandBase) return; @@ -149,11 +149,11 @@ void FREE_CAMERA::Move(uint32_t DeltaTime) { vRes = vPos + fRes * (vDst - vPos); entid_t ent = pCollide->GetObjectID(); - MODELR *pEntity = (MODELR*)EntityManager::GetEntityPointer(ent); + MODELR *pEntity = (MODELR*)core.GetEntityPointer(ent); } - MODEL* pModel = (MODEL*)EntityManager::GetEntityPointer(sphere); + MODEL* pModel = (MODEL*)core.GetEntityPointer(sphere); pModel->mtx.BuildPosition(vRes.x,vRes.y,vRes.z); delete pVW;*/ } diff --git a/src/libs/sea_cameras/src/sea_cameras.cpp b/src/libs/sea_cameras/src/sea_cameras.cpp index a6904e19c..412a30f4b 100644 --- a/src/libs/sea_cameras/src/sea_cameras.cpp +++ b/src/libs/sea_cameras/src/sea_cameras.cpp @@ -46,7 +46,7 @@ uint64_t SEA_CAMERAS::ProcessMessage(MESSAGE &message) { case AI_CAMERAS_ADD_CAMERA: { const auto eidCamera = message.EntityID(); - auto *pCamera = static_cast(EntityManager::GetEntityPointer(eidCamera)); + auto *pCamera = static_cast(core.GetEntityPointer(eidCamera)); // if (CamerasArray.Find(pCamera) == INVALID_ARRAY_INDEX) CamerasArray.Add(pCamera); const auto it = std::find(CamerasArray.begin(), CamerasArray.end(), pCamera); if (it == CamerasArray.end()) @@ -58,7 +58,7 @@ uint64_t SEA_CAMERAS::ProcessMessage(MESSAGE &message) case AI_CAMERAS_SET_CAMERA: { const auto eidCamera = message.EntityID(); auto *const pACharacter = message.AttributePointer(); - auto *pCamera = static_cast(EntityManager::GetEntityPointer(eidCamera)); + auto *pCamera = static_cast(core.GetEntityPointer(eidCamera)); // if (CamerasArray.Find(pCamera) == INVALID_ARRAY_INDEX) CamerasArray.Add(pCamera); const auto it = std::find(CamerasArray.begin(), CamerasArray.end(), pCamera); if (it == CamerasArray.end()) diff --git a/src/libs/sea_cameras/src/ship_camera.cpp b/src/libs/sea_cameras/src/ship_camera.cpp index 42b98fa0c..92c9bcab0 100644 --- a/src/libs/sea_cameras/src/ship_camera.cpp +++ b/src/libs/sea_cameras/src/ship_camera.cpp @@ -26,7 +26,7 @@ void SHIP_CAMERA::SetDevices() pRS = static_cast(core.GetService("dx9render")); Assert(pRS); - pSea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + pSea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); } void SHIP_CAMERA::Execute(uint32_t dwDeltaTime) @@ -216,10 +216,10 @@ uint32_t SHIP_CAMERA::AttributeChanged(ATTRIBUTES *pAttr) void SHIP_CAMERA::ShipsCollision(CVECTOR &pos) { - for (const auto &entities = EntityManager::GetEntityIdVector("ship"); const auto ent : entities) + for (const auto &entities = core.GetEntityIds("ship"); const auto ent : entities) { // Object pointer - auto *ship = static_cast(EntityManager::GetEntityPointer(ent)); + auto *ship = static_cast(core.GetEntityPointer(ent)); if (!ship) break; if (ship == GetAIObj()) @@ -264,8 +264,8 @@ bool SHIP_CAMERA::IslandCollision(CVECTOR &pos) { if (lIlsInitCnt < 10) { - if (const auto island_id = EntityManager::GetEntityId("island")) - pIsland = static_cast(EntityManager::GetEntityPointer(island_id)); + if (const auto island_id = core.GetEntityId("island")) + pIsland = static_cast(core.GetEntityPointer(island_id)); lIlsInitCnt++; if (pIsland == nullptr) return false; @@ -274,7 +274,7 @@ bool SHIP_CAMERA::IslandCollision(CVECTOR &pos) return false; } // Model - auto *mdl = static_cast(EntityManager::GetEntityPointer(pIsland->GetModelEID())); + auto *mdl = static_cast(core.GetEntityPointer(pIsland->GetModelEID())); if (mdl == nullptr) return false; // Find direction, distance diff --git a/src/libs/sea_creatures/src/sharks.cpp b/src/libs/sea_creatures/src/sharks.cpp index 23cc11307..45cedb6d4 100644 --- a/src/libs/sea_creatures/src/sharks.cpp +++ b/src/libs/sea_creatures/src/sharks.cpp @@ -65,7 +65,7 @@ Sharks::Shark::Shark() : fforce(), spos(), angs(), vBase(0), model(0) Sharks::Shark::~Shark() { - EntityManager::EraseEntity(model); + core.EraseEntity(model); } bool Sharks::Shark::Init(float vp_x, float vp_z, bool isLoadModel) @@ -81,7 +81,7 @@ bool Sharks::Shark::Init(float vp_x, float vp_z, bool isLoadModel) if (!isLoadModel) return true; // Loading the model - if (!(model = EntityManager::CreateEntity("modelr"))) + if (!(model = core.CreateEntity("modelr"))) return false; // Path to textures auto *gs = static_cast(core.GetService("geometry")); @@ -95,18 +95,18 @@ bool Sharks::Shark::Init(float vp_x, float vp_z, bool isLoadModel) { gs->SetTexturePath(""); core.Trace("Shark model 'shark' not loaded"); - EntityManager::EraseEntity(model); + core.EraseEntity(model); return false; } gs->SetTexturePath(""); if (!core.Send_Message(model, "ls", MSG_MODEL_LOAD_ANI, "shark")) { core.Trace("Shark animation 'shark' not loaded"); - EntityManager::EraseEntity(model); + core.EraseEntity(model); return false; } // Set the default animation - auto *mdl = static_cast(EntityManager::GetEntityPointer(model)); + auto *mdl = static_cast(core.GetEntityPointer(model)); if (!mdl || !mdl->GetAnimation()) return false; mdl->GetAnimation()->SetEvent(ae_end, 0, this); @@ -176,7 +176,7 @@ inline void Sharks::Shark::ShipApply(float x, float z, float r2) inline void Sharks::Shark::Coordination(float cam_x, float cam_z, float dltTime, SEA_BASE *sb, ISLAND_BASE *ib) { // get a model - auto *mdl = static_cast(EntityManager::GetEntityPointer(model)); + auto *mdl = static_cast(core.GetEntityPointer(model)); if (!mdl) return; // Repulsion force @@ -367,7 +367,7 @@ inline void Sharks::Shark::IslandCollision(ISLAND_BASE *ib, int32_t numPnt, floa const auto step = 2.0f * SHARK_PI / numPnt; auto vx = 0.0f; auto vz = 0.0f; - auto *mdl = static_cast(EntityManager::GetEntityPointer(ib->GetSeabedEID())); + auto *mdl = static_cast(core.GetEntityPointer(ib->GetSeabedEID())); if (!mdl) return; for (int32_t i = 0; i < numPnt; i++) @@ -442,7 +442,7 @@ void Sharks::Shark::Event(Animation *animation, int32_t index, int32_t eventID, int32_t Sharks::Shark::GenerateTrack(uint16_t *inds, Vertex *vrt, uint16_t base, SEA_BASE *sb) { // get a model - auto *mdl = static_cast(EntityManager::GetEntityPointer(model)); + auto *mdl = static_cast(core.GetEntityPointer(model)); if (!mdl) return 0; auto k = mdl->mtx.Pos().y; @@ -519,7 +519,7 @@ Sharks::Sharks() : sea(0), island(0), indeces{}, vrt{} Sharks::~Sharks() { - EntityManager::EraseEntity(periscope.model); + core.EraseEntity(periscope.model); if (rs) rs->TextureRelease(trackTx); } @@ -539,12 +539,12 @@ bool Sharks::Init() const int32_t eprt = AttributesPointer->GetAttributeAsDword("executeParticles", 77); const int32_t rprt = AttributesPointer->GetAttributeAsDword("realizeParticles", 100000); // Set the execution layers - EntityManager::AddToLayer(SEA_EXECUTE, GetId(), eprt); - EntityManager::AddToLayer(SEA_REALIZE, GetId(), rprt); + core.AddToLayer(SEA_EXECUTE, GetId(), eprt); + core.AddToLayer(SEA_REALIZE, GetId(), rprt); for (int32_t i = 0; i < numShakes; i++) { - EntityManager::AddToLayer(SEA_EXECUTE, shark[i].model, emdl); - EntityManager::AddToLayer(SEA_REALIZE, shark[i].model, rmdl); + core.AddToLayer(SEA_EXECUTE, shark[i].model, emdl); + core.AddToLayer(SEA_REALIZE, shark[i].model, rmdl); } // Load the texture trackTx = rs->TextureCreate("Animals\\SharkTrack.tga"); @@ -602,11 +602,11 @@ void Sharks::Execute(uint32_t delta_time) shark[i].Repulsion(shark[j]); // take into account ships - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ent : entities) { // Object pointer - auto *ship = static_cast(EntityManager::GetEntityPointer(ent)); + auto *ship = static_cast(core.GetEntityPointer(ent)); if (!ship) break; // Ship position @@ -619,19 +619,19 @@ void Sharks::Execute(uint32_t delta_time) shark[i].ShipApply(shipPos.x, shipPos.z, rd2); } // The sea - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); if (!sb) { - sea = EntityManager::GetEntityId("sea"); - sb = static_cast(EntityManager::GetEntityPointer(sea)); + sea = core.GetEntityId("sea"); + sb = static_cast(core.GetEntityPointer(sea)); if (!sb) return; } - auto *ib = static_cast(EntityManager::GetEntityPointer(island)); + auto *ib = static_cast(core.GetEntityPointer(island)); if (!ib) { - island = EntityManager::GetEntityId("island"); - ib = static_cast(EntityManager::GetEntityPointer(island)); + island = core.GetEntityId("island"); + ib = static_cast(core.GetEntityPointer(island)); if (!ib) return; } @@ -654,7 +654,7 @@ void Sharks::Execute(uint32_t delta_time) if (periscope.pos.y > 0.0f) periscope.pos.y = 0.0f; } - auto *mdl = static_cast(EntityManager::GetEntityPointer(periscope.model)); + auto *mdl = static_cast(core.GetEntityPointer(periscope.model)); if (mdl) { mdl->mtx.BuildMatrix(CVECTOR(0.0f, periscope.ay, 0.0f), periscope.pos + CVECTOR(0.0f, 1.0f, 0.0f)); @@ -664,7 +664,7 @@ void Sharks::Execute(uint32_t delta_time) if (periscope.time < 0.0f) { periscope.time = -1.0f; - EntityManager::EraseEntity(periscope.model); + core.EraseEntity(periscope.model); } } else @@ -692,7 +692,7 @@ void Sharks::Execute(uint32_t delta_time) bool Sharks::LoadPeriscopeModel() { - if (!(periscope.model = EntityManager::CreateEntity("modelr"))) + if (!(periscope.model = core.CreateEntity("modelr"))) return false; auto *gs = static_cast(core.GetService("geometry")); if (!gs) @@ -701,23 +701,23 @@ bool Sharks::LoadPeriscopeModel() if (!core.Send_Message(periscope.model, "ls", MSG_MODEL_LOAD_GEO, "Animals\\periscope")) { gs->SetTexturePath(""); - EntityManager::EraseEntity(periscope.model); + core.EraseEntity(periscope.model); return false; } gs->SetTexturePath(""); - auto *mdl = static_cast(EntityManager::GetEntityPointer(periscope.model)); + auto *mdl = static_cast(core.GetEntityPointer(periscope.model)); if (!mdl) { - EntityManager::EraseEntity(periscope.model); + core.EraseEntity(periscope.model); return false; } - EntityManager::AddToLayer(SEA_REALIZE, periscope.model, 10); + core.AddToLayer(SEA_REALIZE, periscope.model, 10); return true; } void Sharks::Realize(uint32_t delta_time) { - auto *sb = static_cast(EntityManager::GetEntityPointer(sea)); + auto *sb = static_cast(core.GetEntityPointer(sea)); if (!sb) return; int32_t num = 0; @@ -735,7 +735,7 @@ void Sharks::Realize(uint32_t delta_time) } /* - ISLAND_BASE * ib = (ISLAND_BASE *)EntityManager::GetEntityPointer(island); + ISLAND_BASE * ib = (ISLAND_BASE *)core.GetEntityPointer(island); if(!ib) return; float maxRad = 0.0f; int32_t s = 30; diff --git a/src/libs/sea_foam/src/seafoam.cpp b/src/libs/sea_foam/src/seafoam.cpp index 276360b88..76ae64271 100644 --- a/src/libs/sea_foam/src/seafoam.cpp +++ b/src/libs/sea_foam/src/seafoam.cpp @@ -40,12 +40,12 @@ bool SEAFOAM::Init() /*if (core.IsNetActive()) { NetFindClass(false, &seaID, "NetSea"); - sea = (SEA_BASE*) EntityManager::GetEntityPointer(seaID); + sea = (SEA_BASE*) core.GetEntityPointer(seaID); } else*/ { - seaID = EntityManager::GetEntityId("sea"); - sea = static_cast(EntityManager::GetEntityPointer(seaID)); + seaID = core.GetEntityId("sea"); + sea = static_cast(core.GetEntityPointer(seaID)); } renderer = static_cast(core.GetService("dx9render")); @@ -55,7 +55,7 @@ bool SEAFOAM::Init() InitializeShipFoam(); - // EntityManager::CreateEntity(&arrowModel,"MODELR"); + // core.CreateEntity(&arrowModel,"MODELR"); // core.Send_Message(arrowModel,"ls",MSG_MODEL_LOAD_GEO, "fish01"); carcassTexture = renderer->TextureCreate("seafoam_2.tga"); @@ -66,7 +66,7 @@ bool SEAFOAM::Init() //-------------------------------------------------------------------- void SEAFOAM::InitializeShipFoam() { - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ent : entities) { AddShip(ent); @@ -77,7 +77,7 @@ void SEAFOAM::AddShip(entid_t pShipEID) { auto *foamInfo = &shipFoamInfo[shipsCount++]; - foamInfo->ship = static_cast(EntityManager::GetEntityPointer(pShipEID)); + foamInfo->ship = static_cast(core.GetEntityPointer(pShipEID)); foamInfo->shipModel = foamInfo->ship->GetModel(); foamInfo->shipModel->GetNode(0)->geo->GetInfo(foamInfo->hullInfo); foamInfo->enabled = true; @@ -357,7 +357,7 @@ void SEAFOAM::InterpolateRightParticle(tShipFoamInfo &_shipFoamInfo, int z, uint //-------------------------------------------------------------------- void SEAFOAM::RealizeShipFoam_Particles(tShipFoamInfo &_shipFoamInfo, uint32_t _dTime) { - // MODEL *arrow = (MODEL*)EntityManager::GetEntityPointer(arrowModel); + // MODEL *arrow = (MODEL*)core.GetEntityPointer(arrowModel); for (auto z = 0; z < TRACE_STEPS_Z; ++z) { @@ -577,7 +577,7 @@ uint32_t SEAFOAM::AttributeChanged(ATTRIBUTES *pA) { if (NetFindClass(false, &shipID, "NetShip")) do { - Entity * pE = EntityManager::GetEntityPointer(shipID); + Entity * pE = core.GetEntityPointer(shipID); if (pE->GetNetID() == dwShipNetID) { AddShip(&shipID); diff --git a/src/libs/sea_foam/src/seafoam_ps.cpp b/src/libs/sea_foam/src/seafoam_ps.cpp index 12fb6ca65..faf4c027a 100644 --- a/src/libs/sea_foam/src/seafoam_ps.cpp +++ b/src/libs/sea_foam/src/seafoam_ps.cpp @@ -443,7 +443,7 @@ void SEAFOAM_PS::Execute(uint32_t DeltaTime) if(bLinkEmitter) { COLLISION_OBJECT * pLink; - pLink = (COLLISION_OBJECT *)EntityManager::GetEntityPointer(LinkObject); + pLink = (COLLISION_OBJECT *)core.GetEntityPointer(LinkObject); if(pLink) { Emitter = pLink->mtx * LinkPos; @@ -462,7 +462,7 @@ void SEAFOAM_PS::LayOnSurface(uint32_t index) COLLISION_OBJECT *pLink; CVECTOR from, to; float dist; - pLink = static_cast(EntityManager::GetEntityPointer(SurfaceID)); + pLink = static_cast(core.GetEntityPointer(SurfaceID)); if (pLink == nullptr) return; from = Particle[index].pos; @@ -484,7 +484,7 @@ void SEAFOAM_PS::Realize(uint32_t DeltaTime) if (bLinkEmitter) { COLLISION_OBJECT *pLink; - pLink = static_cast(EntityManager::GetEntityPointer(LinkObject)); + pLink = static_cast(core.GetEntityPointer(LinkObject)); if (pLink) { Emitter = pLink->mtx * LinkPos; @@ -853,7 +853,7 @@ void SEAFOAM_PS::LinkToObject(entid_t id, CVECTOR _LinkPos) LinkDirPos = LinkPos + LinkDir; COLLISION_OBJECT *pLink; - pLink = static_cast(EntityManager::GetEntityPointer(LinkObject)); + pLink = static_cast(core.GetEntityPointer(LinkObject)); if (pLink) Emitter = pLink->mtx * LinkPos; diff --git a/src/libs/sea_operator/src/sea_operator.cpp b/src/libs/sea_operator/src/sea_operator.cpp index d9b9b2666..e2c642da9 100644 --- a/src/libs/sea_operator/src/sea_operator.cpp +++ b/src/libs/sea_operator/src/sea_operator.cpp @@ -31,8 +31,8 @@ SEA_OPERATOR::~SEA_OPERATOR() bool SEA_OPERATOR::Init() { - EntityManager::AddToLayer(REALIZE, GetId(), 1); - EntityManager::AddToLayer(EXECUTE, GetId(), 0); + core.AddToLayer(REALIZE, GetId(), 1); + core.AddToLayer(EXECUTE, GetId(), 0); renderer = static_cast(core.GetService("dx9render")); @@ -62,7 +62,7 @@ uint64_t SEA_OPERATOR::ProcessMessage(MESSAGE &message) break; const auto firedShip = message.EntityID(); - if (myShip != static_cast(EntityManager::GetEntityPointer(firedShip))) + if (myShip != static_cast(core.GetEntityPointer(firedShip))) break; const std::string &bortName = message.String(); @@ -154,9 +154,9 @@ void SEA_OPERATOR::Execute(uint32_t _dTime) void SEA_OPERATOR::FirstInit() { - sea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + sea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ent : entities) { SetIfMyShip(ent); @@ -223,7 +223,7 @@ void SEA_OPERATOR::StartNewAction() void SEA_OPERATOR::SetIfMyShip(entid_t _shipID) { - auto *ship = static_cast(EntityManager::GetEntityPointer(_shipID)); + auto *ship = static_cast(core.GetEntityPointer(_shipID)); if (!ship) return; auto *attr = ship->GetACharacter(); @@ -267,7 +267,7 @@ void SEA_OPERATOR::HandleShipFire(entid_t _shipID, const char *_bortName, const using std::chrono::system_clock; auto bort = BORT_FRONT; - auto *ship = static_cast(EntityManager::GetEntityPointer(_shipID)); + auto *ship = static_cast(core.GetEntityPointer(_shipID)); if (!strcmp(_bortName, "cannonf")) bort = BORT_FRONT; diff --git a/src/libs/shadow/src/shadow.cpp b/src/libs/shadow/src/shadow.cpp index e7eacf003..da2df2ad7 100644 --- a/src/libs/shadow/src/shadow.cpp +++ b/src/libs/shadow/src/shadow.cpp @@ -48,7 +48,7 @@ bool Shadow::Init() if (col == nullptr) throw std::runtime_error("No service: COLLIDE"); - EntityManager::AddToLayer(REALIZE, GetId(), 900); + core.AddToLayer(REALIZE, GetId(), 900); rs = static_cast(core.GetService("dx9render")); if (!rs) @@ -134,7 +134,7 @@ bool AddPoly(const CVECTOR *vr, int32_t nverts) //------------------------------------------------------------------------------------ void Shadow::Realize(uint32_t Delta_Time) { - auto *obj = static_cast(EntityManager::GetEntityPointer(entity)); + auto *obj = static_cast(core.GetEntityPointer(entity)); if (!obj) return; @@ -148,7 +148,7 @@ void Shadow::Realize(uint32_t Delta_Time) pV = core.Event("EWhr_GetFogDensity"); auto fogDensity = pV->GetFloat(); - // MODEL *obj = (MODEL*)EntityManager::GetEntityPointer(entity); + // MODEL *obj = (MODEL*)core.GetEntityPointer(entity); auto *node = obj->GetNode(0); GEOS::INFO gi; node->geo->GetInfo(gi); @@ -191,7 +191,7 @@ void Shadow::Realize(uint32_t Delta_Time) rs->GetTransform(D3DTS_PROJECTION, visPoj); FindPlanes(visView, visPoj); - const auto its = EntityManager::GetEntityIdIterators(SHADOW); + const auto its = core.GetEntityIds(SHADOW); CVECTOR hdest = headPos + !(headPos - light_pos) * 100.0f; float ray = col->Trace(its, headPos, hdest, nullptr, 0); diff --git a/src/libs/ship/src/fire_place.cpp b/src/libs/ship/src/fire_place.cpp index 0f052aa94..91192444b 100644 --- a/src/libs/ship/src/fire_place.cpp +++ b/src/libs/ship/src/fire_place.cpp @@ -24,7 +24,7 @@ FirePlace::~FirePlace() bool FirePlace::CreateParticle(const char *pParticleSmokeName, const char *pParticleFireName) { - if (const auto eidParticle = EntityManager::GetEntityId("particles")) + if (const auto eidParticle = core.GetEntityId("particles")) { const auto vPos = GetPos(); pParticleSmoke = (VPARTICLE_SYSTEM *)core.Send_Message( @@ -38,7 +38,7 @@ bool FirePlace::CreateParticle(const char *pParticleSmokeName, const char *pPart void FirePlace::DeleteParticle() { - if (const auto eidParticle = EntityManager::GetEntityId("particles")) + if (const auto eidParticle = core.GetEntityId("particles")) { if (pParticleSmoke && core.Send_Message(eidParticle, "lp", PS_VALIDATE_PARTICLE, pParticleSmoke)) { diff --git a/src/libs/ship/src/ship.cpp b/src/libs/ship/src/ship.cpp index 01835d233..d3fcb8cf6 100644 --- a/src/libs/ship/src/ship.cpp +++ b/src/libs/ship/src/ship.cpp @@ -69,18 +69,18 @@ SHIP::SHIP() SHIP::~SHIP() { - EntityManager::EraseEntity(GetModelEID()); + core.EraseEntity(GetModelEID()); core.Send_Message(sail_id, "li", MSG_SAIL_DEL_GROUP, GetId()); core.Send_Message(rope_id, "li", MSG_ROPE_DEL_GROUP, GetModelEID()); core.Send_Message(flag_id, "li", MSG_FLAG_DEL_GROUP, GetModelEID()); core.Send_Message(vant_id, "li", MSG_VANT_DEL_GROUP, GetModelEID()); core.Send_Message(vantl_id, "li", MSG_VANT_DEL_GROUP, GetModelEID()); core.Send_Message(vantz_id, "li", MSG_VANT_DEL_GROUP, GetModelEID()); - EntityManager::EraseEntity(blots_id); + core.EraseEntity(blots_id); - if (const auto eidTmp = EntityManager::GetEntityId("ShipTracks")) + if (const auto eidTmp = core.GetEntityId("ShipTracks")) { - auto *pST = static_cast(EntityManager::GetEntityPointer(eidTmp)); + auto *pST = static_cast(core.GetEntityPointer(eidTmp)); if (pST) pST->DelShip(this); } @@ -144,13 +144,13 @@ void SHIP::LoadServices() pCollide = static_cast(core.GetService("coll")); Assert(pCollide); - touch_id = EntityManager::GetEntityId("touch"); + touch_id = core.GetEntityId("touch"); - pIsland = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("island"))); - if (sea_id = EntityManager::GetEntityId("sea")) - pSea = static_cast(EntityManager::GetEntityPointer(sea_id)); + pIsland = static_cast(core.GetEntityPointer(core.GetEntityId("island"))); + if (sea_id = core.GetEntityId("sea")) + pSea = static_cast(core.GetEntityPointer(sea_id)); - FirePlace::eidSound = EntityManager::GetEntityId("sound"); + FirePlace::eidSound = core.GetEntityId("sound"); } CVECTOR SHIP::ShipRocking(float fDeltaTime) @@ -515,9 +515,9 @@ void SHIP::SetDead() vCurDeadDir = 0.0f; bDead = true; - EntityManager::RemoveFromLayer(SEA_REFLECTION2, GetId()); + core.RemoveFromLayer(SEA_REFLECTION2, GetId()); - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) pShipsLights->SetDead(this); } } @@ -720,8 +720,8 @@ void SHIP::Execute(uint32_t DeltaTime) core.Send_Message(vantl_id, "li", MSG_VANT_DEL_GROUP, GetModelEID()); core.Send_Message(vantz_id, "li", MSG_VANT_DEL_GROUP, GetModelEID()); - EntityManager::RemoveFromLayer(RealizeLayer, GetId()); - EntityManager::RemoveFromLayer(SHIP_CANNON_TRACE, GetId()); + core.RemoveFromLayer(RealizeLayer, GetId()); + core.RemoveFromLayer(SHIP_CANNON_TRACE, GetId()); core.Event(SHIP_DELETE, "li", GetIndex(GetACharacter()), GetId()); } } @@ -775,11 +775,11 @@ void SHIP::Execute(uint32_t DeltaTime) v2 = matrix * pM->vDst; auto id = GetId(); - fShipRes = pCollide->Trace(EntityManager::GetEntityIdIterators(MAST_SHIP_TRACE), v1, v2, &id, 1); + fShipRes = pCollide->Trace(core.GetEntityIds(MAST_SHIP_TRACE), v1, v2, &id, 1); if (fShipRes <= 1.0f) { auto *pACollideCharacter = GetACharacter(); - auto *pShip = static_cast(EntityManager::GetEntityPointer(pCollide->GetObjectID())); + auto *pShip = static_cast(core.GetEntityPointer(pCollide->GetObjectID())); if (pShip) pACollideCharacter = pShip->GetACharacter(); pV = core.Event(SHIP_MAST_DAMAGE, "llffffaa", SHIP_MAST_TOUCH_SHIP, pM->iMastNum, v1.x, v1.y, v1.z, @@ -788,7 +788,7 @@ void SHIP::Execute(uint32_t DeltaTime) } id = GetModelEID(); - fIslRes = pCollide->Trace(EntityManager::GetEntityIdIterators(MAST_ISLAND_TRACE), v1, v2, &id, 1); + fIslRes = pCollide->Trace(core.GetEntityIds(MAST_ISLAND_TRACE), v1, v2, &id, 1); if (fIslRes <= 1.0f) { pV = core.Event(SHIP_MAST_DAMAGE, "llffffa", SHIP_MAST_TOUCH_ISLAND, pM->iMastNum, v1.x, v1.y, v1.z, @@ -896,10 +896,10 @@ void SHIP::Execute(uint32_t DeltaTime) void SHIP::MastFall(mast_t* pM) { if (pM && pM->pNode && pM->fDamage >= 1.0f) { entid_t ent; - ent = EntityManager::CreateEntity("mast"); + ent = core.CreateEntity("mast"); core.Send_Message(ent, "lpii", MSG_MAST_SETGEOMETRY, pM->pNode, GetId(), GetModelEID()); - EntityManager::AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); - EntityManager::AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); + core.AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); + core.AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); pShipsLights->KillMast(this, pM->pNode, false); @@ -920,10 +920,10 @@ void SHIP::HullFall(hull_t *pM) if (pM && pM->pNode && pM->fDamage >= 1.0f) { entid_t ent; - ent = EntityManager::CreateEntity("hull"); + ent = core.CreateEntity("hull"); core.Send_Message(ent, "lpii", MSG_HULL_SETGEOMETRY, pM->pNode, GetId(), GetModelEID()); - EntityManager::AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); - EntityManager::AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); + core.AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); + core.AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); char str[256]; sprintf_s(str, "%s", pM->pNode->GetName()); @@ -973,11 +973,11 @@ void SHIP::MastFall(mast_t *pM) if (bOk) { entid_t ent; - ent = EntityManager::CreateEntity("mast"); + ent = core.CreateEntity("mast"); core.Send_Message(ent, "lpii", MSG_MAST_SETGEOMETRY, pMast->pNode, GetId(), GetModelEID()); - EntityManager::AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); - EntityManager::AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + core.AddToLayer(ExecuteLayer, ent, iShipPriorityExecute + 1); + core.AddToLayer(RealizeLayer, ent, iShipPriorityRealize + 1); + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { pShipsLights->KillMast(this, pMast->pNode, false); } @@ -1115,7 +1115,7 @@ void SHIP::Realize(uint32_t dtime) void SHIP::SetLights() { - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { pShipsLights->SetLights(this); } @@ -1123,7 +1123,7 @@ void SHIP::SetLights() void SHIP::UnSetLights() { - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { pShipsLights->UnSetLights(this); } @@ -1131,7 +1131,7 @@ void SHIP::UnSetLights() void SHIP::Fire(const CVECTOR &vPos) { - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { pShipsLights->AddDynamicLights(this, vPos); } @@ -1237,9 +1237,9 @@ uint64_t SHIP::ProcessMessage(MESSAGE &message) } break; case MSG_SHIP_RESET_TRACK: { - if (const auto eidTmp = EntityManager::GetEntityId("ShipTracks")) + if (const auto eidTmp = core.GetEntityId("ShipTracks")) { - auto *pST = static_cast(EntityManager::GetEntityPointer(eidTmp)); + auto *pST = static_cast(core.GetEntityPointer(eidTmp)); pST->ResetTrack(this); } } @@ -1271,13 +1271,13 @@ uint64_t SHIP::ProcessMessage(MESSAGE &message) const auto bLigths = message.Long() != 0; const auto bFlares = message.Long() != 0; const auto bNow = message.Long() != 0; - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) pShipsLights->SetLightsOff(this, fTime, bLigths, bFlares, bNow); } break; case MSG_MAST_DELGEOMETRY: { auto *const pNode = (NODE *)message.Pointer(); - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { pShipsLights->KillMast(this, pNode, true); } @@ -1290,13 +1290,13 @@ uint64_t SHIP::ProcessMessage(MESSAGE &message) // boal 20.08.06 redrawing the flag --> case MSG_SHIP_FLAG_REFRESH: core.Send_Message(flag_id, "li", MSG_FLAG_DEL_GROUP, GetModelEID()); - if (flag_id = EntityManager::GetEntityId("flag")) + if (flag_id = core.GetEntityId("flag")) core.Send_Message(flag_id, "lili", MSG_FLAG_INIT, GetModelEID(), GetNation(GetACharacter()), GetId()); break; // boal 20.08.06 redrawing the flag <-- case MSG_SHIP_LIGHTSRESET: { const auto bLight = message.Long() != 0; - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) pShipsLights->ResetLights(this, bLight); break; } @@ -1385,13 +1385,13 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) core.Event("Ship_StartLoad", "a", GetACharacter()); core.Event(SEA_GET_LAYERS, "i", GetId()); - EntityManager::AddToLayer(SEA_REFLECTION2, GetId(), 100); - EntityManager::AddToLayer(RAIN_DROPS, GetId(), 100); + core.AddToLayer(SEA_REFLECTION2, GetId(), 100); + core.AddToLayer(RAIN_DROPS, GetId(), 100); - EntityManager::AddToLayer(RealizeLayer, GetId(), iShipPriorityRealize); - EntityManager::AddToLayer(ExecuteLayer, GetId(), iShipPriorityExecute); + core.AddToLayer(RealizeLayer, GetId(), iShipPriorityRealize); + core.AddToLayer(ExecuteLayer, GetId(), iShipPriorityExecute); - EntityManager::AddToLayer(SHIP_CANNON_TRACE, GetId(), iShipPriorityExecute); + core.AddToLayer(SHIP_CANNON_TRACE, GetId(), iShipPriorityExecute); const char *pName = GetAShip()->GetAttribute("Name"); if (!pName) @@ -1429,40 +1429,40 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) char temp_str[1024]; sprintf_s(temp_str, "ships\\%s\\%s", cShipIniName, cShipIniName); - model_id = EntityManager::CreateEntity("MODELR"); + model_id = core.CreateEntity("MODELR"); core.Send_Message(GetModelEID(), "ls", MSG_MODEL_LOAD_GEO, temp_str); - EntityManager::AddToLayer(HULL_TRACE, GetModelEID(), 10); - EntityManager::AddToLayer(SUN_TRACE, GetModelEID(), 10); - EntityManager::AddToLayer(MAST_SHIP_TRACE, GetId(), 10); + core.AddToLayer(HULL_TRACE, GetModelEID(), 10); + core.AddToLayer(SUN_TRACE, GetModelEID(), 10); + core.AddToLayer(MAST_SHIP_TRACE, GetId(), 10); // sails - if (sail_id = EntityManager::GetEntityId("sail")) + if (sail_id = core.GetEntityId("sail")) core.Send_Message(sail_id, "liil", MSG_SAIL_INIT, GetId(), GetModelEID(), GetSpeed() ? 1 : 0); // ropes - if (rope_id = EntityManager::GetEntityId("rope")) + if (rope_id = core.GetEntityId("rope")) core.Send_Message(rope_id, "lii", MSG_ROPE_INIT, GetId(), GetModelEID()); // flags - if (flag_id = EntityManager::GetEntityId("flag")) + if (flag_id = core.GetEntityId("flag")) core.Send_Message(flag_id, "lili", MSG_FLAG_INIT, GetModelEID(), GetNation(GetACharacter()), GetId()); // vants - if (vant_id = EntityManager::GetEntityId("vant")) + if (vant_id = core.GetEntityId("vant")) core.Send_Message(vant_id, "lii", MSG_VANT_INIT, GetId(), GetModelEID()); - if (vantl_id = EntityManager::GetEntityId("vantl")) + if (vantl_id = core.GetEntityId("vantl")) core.Send_Message(vantl_id, "lii", MSG_VANT_INIT, GetId(), GetModelEID()); - if (vantz_id = EntityManager::GetEntityId("vantz")) + if (vantz_id = core.GetEntityId("vantz")) core.Send_Message(vantz_id, "lii", MSG_VANT_INIT, GetId(), GetModelEID()); // blots - if (blots_id = EntityManager::CreateEntity("blots")) + if (blots_id = core.CreateEntity("blots")) { core.Send_Message(blots_id, "lia", MSG_BLOTS_SETMODEL, GetModelEID(), GetACharacter()); - EntityManager::AddToLayer(RealizeLayer, blots_id, iShipPriorityRealize + 4); - EntityManager::AddToLayer(ExecuteLayer, blots_id, iShipPriorityExecute + 4); + core.AddToLayer(RealizeLayer, blots_id, iShipPriorityRealize + 4); + core.AddToLayer(ExecuteLayer, blots_id, iShipPriorityExecute + 4); } LoadShipParameters(); @@ -1531,9 +1531,9 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) } // Add lights and flares - if (shipLights = EntityManager::GetEntityId("shiplights")) + if (shipLights = core.GetEntityId("shiplights")) { - const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights)); + const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights)); pShipsLights->AddLights(this, GetModel(), bLights, bFlares); pShipsLights->ProcessStage(Stage::execute, 0); @@ -1550,7 +1550,7 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) if(bLights && bFlares) { - const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights)); + const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights)); pShipsLights->ResetLights(this, bLights); } @@ -1559,7 +1559,7 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) // add masts BuildMasts(); - if (const auto pShipsLights = static_cast(EntityManager::GetEntityPointer(shipLights))) + if (const auto pShipsLights = static_cast(core.GetEntityPointer(shipLights))) { for (int32_t i = 0; i < iNumMasts; i++) { @@ -1583,9 +1583,9 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) strcpy_s(temp_str, pAUpperShipModel->GetThisAttr()); bModelUpperShip = true; - model_uppership_id = EntityManager::CreateEntity("MODELR"); + model_uppership_id = core.CreateEntity("MODELR"); core.Send_Message(model_uppership_id, "ls", MSG_MODEL_LOAD_GEO, temp_str); - pModelUpperShip = static_cast(EntityManager::GetEntityPointer(model_uppership_id)); + pModelUpperShip = static_cast(core.GetEntityPointer(model_uppership_id)); } // event to script @@ -1593,9 +1593,9 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip) core.Event("Ship_EndLoad", "a", GetACharacter()); // add to ship tracks - if (const auto eidTmp = EntityManager::GetEntityId("ShipTracks")) + if (const auto eidTmp = core.GetEntityId("ShipTracks")) { - auto *pST = static_cast(EntityManager::GetEntityPointer(eidTmp)); + auto *pST = static_cast(core.GetEntityPointer(eidTmp)); if (pST) pST->AddShip(this); } @@ -1822,7 +1822,7 @@ entid_t SHIP::GetModelEID() const MODEL *SHIP::GetModel() const { - return static_cast(EntityManager::GetEntityPointer(GetModelEID())); + return static_cast(core.GetEntityPointer(GetModelEID())); } CMatrix *SHIP::GetMatrix() @@ -1892,11 +1892,11 @@ void SHIP::SetACharacter(ATTRIBUTES *pAP) if (bMounted) { - EntityManager::EraseEntity(blots_id); - blots_id = EntityManager::CreateEntity("blots"); + core.EraseEntity(blots_id); + blots_id = core.CreateEntity("blots"); core.Send_Message(blots_id, "lia", MSG_BLOTS_SETMODEL, GetModelEID(), GetACharacter()); - EntityManager::AddToLayer(RealizeLayer, blots_id, iShipPriorityRealize + 4); - EntityManager::AddToLayer(ExecuteLayer, blots_id, iShipPriorityExecute + 4); + core.AddToLayer(RealizeLayer, blots_id, iShipPriorityRealize + 4); + core.AddToLayer(ExecuteLayer, blots_id, iShipPriorityExecute + 4); } } diff --git a/src/libs/ship/src/ship.h b/src/libs/ship/src/ship.h index c36641e3a..695fcbedf 100644 --- a/src/libs/ship/src/ship.h +++ b/src/libs/ship/src/ship.h @@ -66,7 +66,7 @@ class SHIP : public SHIP_BASE }; // init parameters - inline static EntityManager::layer_index_t RealizeLayer, ExecuteLayer; + inline static layer_index_t RealizeLayer, ExecuteLayer; char cShipIniName[256]; int32_t iShipPriorityExecute, iShipPriorityRealize; float fGravity; diff --git a/src/libs/ship/src/ship_lights.cpp b/src/libs/ship/src/ship_lights.cpp index 7e49cc126..1023d1ed9 100644 --- a/src/libs/ship/src/ship_lights.cpp +++ b/src/libs/ship/src/ship_lights.cpp @@ -42,7 +42,7 @@ bool ShipLights::Init() Assert(pRS); pCollide = static_cast(core.GetService("coll")); Assert(pCollide); - pSea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + pSea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); return true; } @@ -502,10 +502,10 @@ void ShipLights::Execute(uint32_t dwDeltaTime) L.bVisible = true; float fDistance = - pCollide->Trace(EntityManager::GetEntityIdIterators(SAILS_TRACE), L.vCurPos, vCamPos, nullptr, 0); + pCollide->Trace(core.GetEntityIds(SAILS_TRACE), L.vCurPos, vCamPos, nullptr, 0); L.fFlareAlphaMax = (fDistance >= 1.0f) ? 1.0f : 0.2f; - const auto its = EntityManager::GetEntityIdIterators(SUN_TRACE); + const auto its = core.GetEntityIds(SUN_TRACE); fDistance = pCollide->Trace(its, L.vCurPos, vCamPos, nullptr, 0); const float fLen = fDistance * sqrtf(~(vCamPos - L.vCurPos)); L.bVisible = fDistance >= 1.0f || (fLen < 0.6f); diff --git a/src/libs/ship/src/ship_utils.cpp b/src/libs/ship/src/ship_utils.cpp index 59cadae79..32ccf567d 100644 --- a/src/libs/ship/src/ship_utils.cpp +++ b/src/libs/ship/src/ship_utils.cpp @@ -15,7 +15,7 @@ BOOL SHIP::BuildContour(CVECTOR *vContour, int32_t &iNumVContour) float fY, fRight, fLeft, fUp, fDown, fRes, fZMax, fZMin, fZStep, fZMinStep; auto bDefaultContour = false; - bool bRes = EntityManager::GetEntityPointer(model_id); + bool bRes = core.GetEntityPointer(model_id); Assert(bRes); CMatrix mTemp; @@ -215,9 +215,9 @@ bool SHIP::BuildMasts() pM->fDamage = 1.0f; pM->bBroken = true; entid_t ent; - ent = EntityManager::CreateEntity("mast"); + ent = core.CreateEntity("mast"); core.Send_Message(ent, "lpii", MSG_MAST_SETGEOMETRY, pNode, GetId(), GetModelEID()); - EntityManager::EraseEntity(ent); + core.EraseEntity(ent); // iIdx--; } else @@ -283,9 +283,9 @@ bool SHIP::BuildHulls() pM->fDamage = 1.0f; pM->bBroken = true; entid_t ent; - ent = EntityManager::CreateEntity("hull"); + ent = core.CreateEntity("hull"); core.Send_Message(ent, "lpii", MSG_HULL_SETGEOMETRY, pNode, GetId(), GetModelEID()); - EntityManager::EraseEntity(ent); + core.EraseEntity(ent); // iIdx--; } else diff --git a/src/libs/ship/src/track.cpp b/src/libs/ship/src/track.cpp index 499617be2..718f7a6ac 100644 --- a/src/libs/ship/src/track.cpp +++ b/src/libs/ship/src/track.cpp @@ -24,8 +24,8 @@ bool ShipTracks::Init() ShipTrack::pRS = static_cast(core.GetService("dx9render")); Assert(ShipTrack::pRS); - if (sea_id = EntityManager::GetEntityId("sea")) - ShipTrack::pSea = static_cast(EntityManager::GetEntityPointer(sea_id)); + if (sea_id = core.GetEntityId("sea")) + ShipTrack::pSea = static_cast(core.GetEntityPointer(sea_id)); return true; } diff --git a/src/libs/sink_effect/src/seps.cpp b/src/libs/sink_effect/src/seps.cpp index f05f5a02c..1a5c9baaf 100644 --- a/src/libs/sink_effect/src/seps.cpp +++ b/src/libs/sink_effect/src/seps.cpp @@ -503,7 +503,7 @@ void SEPS_PS::Execute(uint32_t DeltaTime) if(bLinkEmitter) { COLLISION_OBJECT * pLink; - pLink = (COLLISION_OBJECT *)EntityManager::GetEntityPointer(LinkObject); + pLink = (COLLISION_OBJECT *)core.GetEntityPointer(LinkObject); if(pLink) { Emitter = pLink->mtx * LinkPos; @@ -522,7 +522,7 @@ void SEPS_PS::LayOnSurface(uint32_t index) COLLISION_OBJECT *pLink; CVECTOR from, to; float dist; - pLink = static_cast(EntityManager::GetEntityPointer(SurfaceID)); + pLink = static_cast(core.GetEntityPointer(SurfaceID)); if (pLink == nullptr) return; from = Particle[index].pos; @@ -544,7 +544,7 @@ void SEPS_PS::Realize(uint32_t DeltaTime) if (bLinkEmitter) { COLLISION_OBJECT *pLink; - pLink = static_cast(EntityManager::GetEntityPointer(LinkObject)); + pLink = static_cast(core.GetEntityPointer(LinkObject)); if (pLink) { Emitter = pLink->mtx * LinkPos; @@ -915,7 +915,7 @@ void SEPS_PS::LinkToObject(entid_t id, CVECTOR _LinkPos) LinkDirPos = LinkPos + LinkDir; COLLISION_OBJECT *pLink; - pLink = static_cast(EntityManager::GetEntityPointer(LinkObject)); + pLink = static_cast(core.GetEntityPointer(LinkObject)); if (pLink) Emitter = pLink->mtx * LinkPos; diff --git a/src/libs/sink_effect/src/sink_effect.cpp b/src/libs/sink_effect/src/sink_effect.cpp index afc8be9a8..3d5b0bdcd 100644 --- a/src/libs/sink_effect/src/sink_effect.cpp +++ b/src/libs/sink_effect/src/sink_effect.cpp @@ -24,7 +24,7 @@ bool SINKEFFECT::Init() { // GUARD(SINKEFFECT::Init) - sea = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea"))); + sea = static_cast(core.GetEntityPointer(core.GetEntityId("sea"))); renderer = static_cast(core.GetService("dx9render")); @@ -48,18 +48,18 @@ uint64_t SINKEFFECT::ProcessMessage(MESSAGE &message) auto *const attrs = message.AttributePointer(); if (attrs) { - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto ent : entities) { /* - shipBase = (SHIP_BASE *) EntityManager::GetEntityPointer(shipID); + shipBase = (SHIP_BASE *) core.GetEntityPointer(shipID); if (shipBase->GetACharacter() == attrs) { TryToAddSink(shipBase->GetPos(), shipBase->GetBoxsize().z / 2.0f); return outValue; }*/ - auto *shipBase = static_cast(EntityManager::GetEntityPointer(ent)); + auto *shipBase = static_cast(core.GetEntityPointer(ent)); if (shipBase->GetACharacter() == attrs) { TryToAddSink(shipBase->GetPos(), shipBase->GetBoxsize().z / 2.0f); diff --git a/src/libs/sink_effect/src/t_flotsam.cpp b/src/libs/sink_effect/src/t_flotsam.cpp index d91d99d33..9048f807a 100644 --- a/src/libs/sink_effect/src/t_flotsam.cpp +++ b/src/libs/sink_effect/src/t_flotsam.cpp @@ -22,7 +22,7 @@ TFlotsam::~TFlotsam() if (!modelsInitialized) for (auto i = 0; i < sink_effect::FLOTSAM_MODELS_COUNT; i++) - EntityManager::EraseEntity(modelIDs[i]); + core.EraseEntity(modelIDs[i]); } //-------------------------------------------------------------------- @@ -57,9 +57,9 @@ void TFlotsam::Initialize(SEA_BASE *_sea) for (auto i = 0; i < sink_effect::FLOTSAM_MODELS_COUNT; i++) { - modelIDs[i] = EntityManager::CreateEntity("MODELR"); + modelIDs[i] = core.CreateEntity("MODELR"); core.Send_Message(modelIDs[i], "ls", MSG_MODEL_LOAD_GEO, modelNames[i]); - models[i] = static_cast(EntityManager::GetEntityPointer(modelIDs[i])); + models[i] = static_cast(core.GetEntityPointer(modelIDs[i])); } } @@ -115,7 +115,7 @@ void TFlotsam::Realize(uint32_t _dTime) pos.y = y; const CVECTOR ang(0.0f, angY, 0.0f); MODEL *model; - model = static_cast(EntityManager::GetEntityPointer(ModelID)); + model = static_cast(core.GetEntityPointer(ModelID)); if (model) { model->mtx.BuildMatrix(ang, pos); diff --git a/src/libs/sound/src/sound.cpp b/src/libs/sound/src/sound.cpp index f07aa1ee3..59ea833da 100644 --- a/src/libs/sound/src/sound.cpp +++ b/src/libs/sound/src/sound.cpp @@ -31,7 +31,7 @@ bool SOUND::Init() core.Trace("!SOUND: Can`t create sound service"); renderer = static_cast(core.GetService("dx9render")); - EntityManager::AddToLayer(REALIZE, GetId(), -1); + core.AddToLayer(REALIZE, GetId(), -1); return true; // UNGUARD diff --git a/src/libs/sound_service/src/debug_entity.cpp b/src/libs/sound_service/src/debug_entity.cpp index daad19a2c..a0eb045b7 100644 --- a/src/libs/sound_service/src/debug_entity.cpp +++ b/src/libs/sound_service/src/debug_entity.cpp @@ -38,6 +38,6 @@ void SoundVisualisationEntity::SetMasterSoundService(SoundService *pSoundService void SoundVisualisationEntity::Wakeup() const { // core.LayerCreate("sound_debug_realize", true , false); - EntityManager::SetLayerType(SOUND_DEBUG_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(SOUND_DEBUG_REALIZE, GetId(), -1); + core.SetLayerType(SOUND_DEBUG_REALIZE, layer_type_t::realize); + core.AddToLayer(SOUND_DEBUG_REALIZE, GetId(), -1); } diff --git a/src/libs/sound_service/src/sound_service.cpp b/src/libs/sound_service/src/sound_service.cpp index 4a3a944fa..8d222306b 100644 --- a/src/libs/sound_service/src/sound_service.cpp +++ b/src/libs/sound_service/src/sound_service.cpp @@ -1131,11 +1131,11 @@ void SoundService::InitAliases() void SoundService::CreateEntityIfNeed() { - auto Debugentid_t = EntityManager::GetEntityId("SoundVisualisationEntity"); + auto Debugentid_t = core.GetEntityId("SoundVisualisationEntity"); if (!Debugentid_t) { - Debugentid_t = EntityManager::CreateEntity("SoundVisualisationEntity"); - auto *pDebugEntity = static_cast(EntityManager::GetEntityPointer(Debugentid_t)); + Debugentid_t = core.CreateEntity("SoundVisualisationEntity"); + auto *pDebugEntity = static_cast(core.GetEntityPointer(Debugentid_t)); pDebugEntity->SetMasterSoundService(this); pDebugEntity->Wakeup(); } diff --git a/src/libs/tornado/src/debris.cpp b/src/libs/tornado/src/debris.cpp index 99ea8621d..ff31dc96c 100644 --- a/src/libs/tornado/src/debris.cpp +++ b/src/libs/tornado/src/debris.cpp @@ -31,7 +31,7 @@ Debris::Debris(Pillar &_pillar) : pillar(_pillar) Debris::~Debris() { for (int32_t i = 0; i < numModels; i++) - EntityManager::EraseEntity(mdl[i].mdl->GetId()); + core.EraseEntity(mdl[i].mdl->GetId()); } void Debris::Init() @@ -158,9 +158,9 @@ void Debris::AddModel(const char *modelName, float prt, float spd) return; // Create a model entid_t id; - if (!(id = EntityManager::CreateEntity("modelr"))) + if (!(id = core.CreateEntity("modelr"))) return; - auto *m = static_cast(EntityManager::GetEntityPointer(id)); + auto *m = static_cast(core.GetEntityPointer(id)); if (!m) return; // Path to textures @@ -176,7 +176,7 @@ void Debris::AddModel(const char *modelName, float prt, float spd) catch (...) { gs->SetTexturePath(""); - EntityManager::EraseEntity(id); + core.EraseEntity(id); return; } gs->SetTexturePath(""); @@ -221,11 +221,11 @@ bool Debris::IsShip() { const CVECTOR p(pillar.GetX(0.0f), 0.0f, pillar.GetZ(0.0f)); CVECTOR pos; - const auto &entities = EntityManager::GetEntityIdVector("ship"); + const auto &entities = core.GetEntityIds("ship"); for (auto id : entities) { // Object pointer - auto *ship = static_cast(EntityManager::GetEntityPointer(id)); + auto *ship = static_cast(core.GetEntityPointer(id)); if (!ship) break; // Tornado position in the ship system diff --git a/src/libs/tornado/src/tornado.cpp b/src/libs/tornado/src/tornado.cpp index ff5ffe783..2098987c4 100644 --- a/src/libs/tornado/src/tornado.cpp +++ b/src/libs/tornado/src/tornado.cpp @@ -55,11 +55,11 @@ Tornado::~Tornado() bool Tornado::Init() { // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); + core.SetLayerType(EXECUTE, layer_type_t::execute); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(EXECUTE, GetId(), 70000); - EntityManager::AddToLayer(REALIZE, GetId(), 70000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(EXECUTE, GetId(), 70000); + core.AddToLayer(REALIZE, GetId(), 70000); // DX9 render rs = static_cast(core.GetService("dx9render")); @@ -114,7 +114,7 @@ void Tornado::Execute(uint32_t delta_time) { galhpa = 0.0f; core.Event("TornadoDelete"); - EntityManager::EraseEntity(GetId()); + core.EraseEntity(GetId()); } } else diff --git a/src/libs/tornado/src/tornado_particles.cpp b/src/libs/tornado/src/tornado_particles.cpp index aa4a47cec..b0f461d2e 100644 --- a/src/libs/tornado/src/tornado_particles.cpp +++ b/src/libs/tornado/src/tornado_particles.cpp @@ -50,7 +50,7 @@ TornadoParticles::~TornadoParticles() void TornadoParticles::SetSea() { - seaID = EntityManager::GetEntityId("sea"); + seaID = core.GetEntityId("sea"); } void TornadoParticles::Update(float dltTime) @@ -59,7 +59,7 @@ void TornadoParticles::Update(float dltTime) auto seaLevel = 0.0f; if (txtGroundPrts >= 0 || txtPillarPrts >= 0) { - auto *sea = static_cast(EntityManager::GetEntityPointer(seaID)); + auto *sea = static_cast(core.GetEntityPointer(seaID)); if (sea) { seaLevel = sea->WaveXZ(pillar.GetX(0.0f), pillar.GetZ(0.0f)); diff --git a/src/libs/touch/src/touch.cpp b/src/libs/touch/src/touch.cpp index 14e2271a7..2eb32015a 100644 --- a/src/libs/touch/src/touch.cpp +++ b/src/libs/touch/src/touch.cpp @@ -85,7 +85,7 @@ void TOUCH::Execute(uint32_t dwCoreDeltaTime) int32_t i; entid_t ent; if (!pIslandBase) - pIslandBase = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("island"))); + pIslandBase = static_cast(core.GetEntityPointer(core.GetEntityId("island"))); // std::this_thread::sleep_for(std::chrono::milliseconds(150)); @@ -95,7 +95,7 @@ void TOUCH::Execute(uint32_t dwCoreDeltaTime) return; for (i = 0; i < iNumShips; i++) { - pShips[i]->pShip = static_cast(EntityManager::GetEntityPointer(pShips[i]->eID)); + pShips[i]->pShip = static_cast(core.GetEntityPointer(pShips[i]->eID)); if (pShips[i]->pShip && !pShips[i]->iNumVContour) { pShips[i]->pShip->BuildContour(&pShips[i]->vContour[0], pShips[i]->iNumVContour); diff --git a/src/libs/water_rings/src/water_rings.cpp b/src/libs/water_rings/src/water_rings.cpp index 34ade379a..403f37b85 100644 --- a/src/libs/water_rings/src/water_rings.cpp +++ b/src/libs/water_rings/src/water_rings.cpp @@ -24,10 +24,10 @@ bool WaterRings::Init() { // GUARD(WaterRings::Init()) - EntityManager::AddToLayer(REALIZE, GetId(), 65551); + core.AddToLayer(REALIZE, GetId(), 65551); - const auto seaID = EntityManager::GetEntityId("sea"); - sea = static_cast(EntityManager::GetEntityPointer(seaID)); + const auto seaID = core.GetEntityId("sea"); + sea = static_cast(core.GetEntityPointer(seaID)); renderService = static_cast(core.GetService("dx9render")); if (!renderService) diff --git a/src/libs/weather/src/lightning.cpp b/src/libs/weather/src/lightning.cpp index 4c20c0a62..518123e36 100644 --- a/src/libs/weather/src/lightning.cpp +++ b/src/libs/weather/src/lightning.cpp @@ -165,7 +165,7 @@ void LIGHTNING::CalcFlashPower(lightning_t *pL) const for (uint32_t i = 0; i < 3; i++) { const auto fRes = - pCollide->Trace(EntityManager::GetEntityIdIterators(SUN_TRACE), vCamPos, vTrace[i], nullptr, 0); + pCollide->Trace(core.GetEntityIds(SUN_TRACE), vCamPos, vTrace[i], nullptr, 0); if (fRes <= 1.0f) fPower -= 0.31f; } diff --git a/src/libs/weather/src/planets.cpp b/src/libs/weather/src/planets.cpp index 537544d06..665fb30f5 100644 --- a/src/libs/weather/src/planets.cpp +++ b/src/libs/weather/src/planets.cpp @@ -93,10 +93,10 @@ void Astronomy::PLANETS::Realize(double dDeltaTime, double dHour) { if ((fFadeTime > 0.f && fPlanetFade < 1.f) || (fFadeTime < 0.f && fPlanetFade > 0.f)) { - if (const auto eid = EntityManager::GetEntityId("weather")) + if (const auto eid = core.GetEntityId("weather")) { auto fTime = - static_cast(EntityManager::GetEntityPointer(eid))->GetFloat(whf_time_counter); + static_cast(core.GetEntityPointer(eid))->GetFloat(whf_time_counter); if (fFadeTime > 0.f) fPlanetFade = (fTime - fFadeTimeStart) / fFadeTime; if (fFadeTime < 0.f) diff --git a/src/libs/weather/src/rain.cpp b/src/libs/weather/src/rain.cpp index 6082238e8..4216bef3a 100644 --- a/src/libs/weather/src/rain.cpp +++ b/src/libs/weather/src/rain.cpp @@ -83,9 +83,9 @@ void RAIN::GenerateRain() uint32_t i; entid_t ent; - if (!(ent = EntityManager::GetEntityId("weather"))) + if (!(ent = core.GetEntityId("weather"))) throw std::runtime_error("No found WEATHER entity!"); - pWeather = static_cast(EntityManager::GetEntityPointer(ent)); + pWeather = static_cast(core.GetEntityPointer(ent)); Assert(pWeather); Release(); @@ -233,8 +233,8 @@ void RAIN::RealizeDrops(uint32_t Delta_Time) entid_t sea_id; SEA_BASE *pSea = nullptr; - if (sea_id = EntityManager::GetEntityId("sea")) - pSea = static_cast(EntityManager::GetEntityPointer(sea_id)); + if (sea_id = core.GetEntityId("sea")) + pSea = static_cast(core.GetEntityPointer(sea_id)); fDropsDeltaTime += fDeltaTime; @@ -245,8 +245,7 @@ void RAIN::RealizeDrops(uint32_t Delta_Time) if (fDropsDeltaTime < 0.0f) fDropsDeltaTime = 0.0f; - const auto its = EntityManager::GetEntityIdIterators(RAIN_DROPS); - if (its.first != its.second) + if (auto && entities = core.GetEntityIds(RAIN_DROPS); !entities.empty()) { for (int32_t i = 0; i < iNumNewDrops1 + iNumNewDrops2; i++) { @@ -268,7 +267,7 @@ void RAIN::RealizeDrops(uint32_t Delta_Time) vSrc = CVECTOR(vCamPos.x + fR * sinf(fA), vCamPos.y + 75.0f, vCamPos.z + fR * cosf(fA)); vDst = CVECTOR(vSrc.x, vCamPos.y - 75.0f, vSrc.z); - auto fTest1 = cs->Trace(its, vSrc, vDst, nullptr, 0); + auto fTest1 = cs->Trace(entities, vSrc, vDst, nullptr, 0); auto fTest2 = 2.0f; if (pSea) @@ -284,9 +283,9 @@ void RAIN::RealizeDrops(uint32_t Delta_Time) // check - if it's a ship entid_t eid = cs->GetObjectID(); - if (EntityManager::GetClassCode(eid) == dwShipName) + if (core.GetClassCode(eid) == dwShipName) { - pShip = static_cast(EntityManager::GetEntityPointer(eid)); + pShip = static_cast(core.GetEntityPointer(eid)); } } else if (fTest2 <= 1.0f) @@ -333,7 +332,7 @@ void RAIN::RealizeDrops(uint32_t Delta_Time) for (int32_t i = 0; i < aShips.size(); i++) { - if (!EntityManager::GetEntityPointer(aShips[i].eid)) + if (!core.GetEntityPointer(aShips[i].eid)) { aShips[i].pShip = nullptr; } diff --git a/src/libs/weather/src/sky.cpp b/src/libs/weather/src/sky.cpp index f22cb20f9..e96fb0f8e 100644 --- a/src/libs/weather/src/sky.cpp +++ b/src/libs/weather/src/sky.cpp @@ -365,12 +365,12 @@ void SKY::Realize(uint32_t Delta_Time) entid_t eid; if (!pAstronomy) - if (eid = EntityManager::GetEntityId("Astronomy")) - pAstronomy = static_cast(EntityManager::GetEntityPointer(eid)); + if (eid = core.GetEntityId("Astronomy")) + pAstronomy = static_cast(core.GetEntityPointer(eid)); if (!pSunGlow) - if (eid = EntityManager::GetEntityId("SUNGLOW")) - pSunGlow = static_cast(EntityManager::GetEntityPointer(eid)); + if (eid = core.GetEntityId("SUNGLOW")) + pSunGlow = static_cast(core.GetEntityPointer(eid)); if (pAstronomy || pSunGlow) { @@ -561,9 +561,9 @@ void SKY::UpdateTimeFactor() // fTimeFactor += core.GetDeltaTime() * 0.00005f; entid_t eid; - if (!(eid = EntityManager::GetEntityId("weather"))) + if (!(eid = core.GetEntityId("weather"))) return; - fTimeFactor = static_cast(EntityManager::GetEntityPointer(eid))->GetFloat(whf_time_counter); + fTimeFactor = static_cast(core.GetEntityPointer(eid))->GetFloat(whf_time_counter); fTimeFactor *= (1.f / 24.f) * aSkyDirArray.size(); if (static_cast(fTimeFactor) >= static_cast(aSkyDirArray.size())) diff --git a/src/libs/weather/src/stars.cpp b/src/libs/weather/src/stars.cpp index 6e5ddf555..af288299b 100644 --- a/src/libs/weather/src/stars.cpp +++ b/src/libs/weather/src/stars.cpp @@ -234,10 +234,10 @@ void Astronomy::STARS::Realize(double dDeltaTime, double dHour) if ((fFadeTime > 0.f && fFadeValue < 1.f) || (fFadeTime < 0.f && fFadeValue > 0.f)) { entid_t eid; - if (eid = EntityManager::GetEntityId("weather")) + if (eid = core.GetEntityId("weather")) { auto fTime = - static_cast(EntityManager::GetEntityPointer(eid))->GetFloat(whf_time_counter); + static_cast(core.GetEntityPointer(eid))->GetFloat(whf_time_counter); if (fTime > fFadeTimeStart) { auto fOldFadeValue = fFadeValue; diff --git a/src/libs/weather/src/sun_glow.cpp b/src/libs/weather/src/sun_glow.cpp index e27d71b05..fd8b5d685 100644 --- a/src/libs/weather/src/sun_glow.cpp +++ b/src/libs/weather/src/sun_glow.cpp @@ -58,13 +58,13 @@ void SUNGLOW::SetDevice() pCollide = static_cast(core.GetService("COLL")); Assert(pCollide); - if (!(ent = EntityManager::GetEntityId("weather"))) + if (!(ent = core.GetEntityId("weather"))) throw std::runtime_error("No found WEATHER entity!"); - pWeather = static_cast(EntityManager::GetEntityPointer(ent)); + pWeather = static_cast(core.GetEntityPointer(ent)); Assert(pWeather); - if (ent = EntityManager::GetEntityId("sky")) - pSky = static_cast(EntityManager::GetEntityPointer(ent)); + if (ent = core.GetEntityId("sky")) + pSky = static_cast(core.GetEntityPointer(ent)); else pSky = nullptr; @@ -152,9 +152,9 @@ void SUNGLOW::Execute(uint32_t Delta_Time) } } -float SUNGLOW::LayerTrace(CVECTOR &vSrc, EntityManager::LayerIterators its) const +float SUNGLOW::LayerTrace(CVECTOR &vSrc, entity_container_cref its) const { - if (its.first == its.second) + if (its.empty()) return 2.0f; CVECTOR vDst; @@ -198,8 +198,8 @@ void SUNGLOW::Realize(uint32_t Delta_Time) bVisible = true; fMinAlphaValue = 0.0f; - auto fSunTrace = LayerTrace(vCamPos, EntityManager::GetEntityIdIterators(SUN_TRACE)); - auto fSailTrace = LayerTrace(vCamPos, EntityManager::GetEntityIdIterators(SAILS_TRACE)); + auto fSunTrace = LayerTrace(vCamPos, core.GetEntityIds(SUN_TRACE)); + auto fSailTrace = LayerTrace(vCamPos, core.GetEntityIds(SAILS_TRACE)); if (fSunTrace <= 1.0f || fSailTrace <= 1.0f) bVisible = false; @@ -742,7 +742,7 @@ float SUNGLOW::GetSunFadeoutFactor(const CVECTOR &vSunPos, float fSunSize) // get a pointer to the sky if (!pSky) { - pSky = static_cast(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sky"))); + pSky = static_cast(core.GetEntityPointer(core.GetEntityId("sky"))); } return pSky ? pSky->CalculateAlphaForSun(vSunPos, fSunSize) : 1.0f; } diff --git a/src/libs/weather/src/sun_glow.h b/src/libs/weather/src/sun_glow.h index 804b09e54..638f5adfe 100644 --- a/src/libs/weather/src/sun_glow.h +++ b/src/libs/weather/src/sun_glow.h @@ -124,7 +124,7 @@ class SUNGLOW : public Entity float fBottomClip; - float LayerTrace(CVECTOR &vSrc, EntityManager::LayerIterators its) const; + float LayerTrace(CVECTOR &vSrc, entity_container_cref its) const; void GenerateSunGlow(); void DrawReflection() const; void Release(); diff --git a/src/libs/weather/src/water_flare.cpp b/src/libs/weather/src/water_flare.cpp index c08c54203..5b0212955 100644 --- a/src/libs/weather/src/water_flare.cpp +++ b/src/libs/weather/src/water_flare.cpp @@ -27,8 +27,8 @@ bool WATERFLARE::Init() { // GUARD(bool WATERFLARE::Init()) - EntityManager::AddToLayer(REALIZE, GetId(), -1); - EntityManager::AddToLayer(EXECUTE, GetId(), -1); + core.AddToLayer(REALIZE, GetId(), -1); + core.AddToLayer(EXECUTE, GetId(), -1); SetDevice(); @@ -45,9 +45,9 @@ void WATERFLARE::SetDevice() throw std::runtime_error("No service: dx9render"); entid_t ent; - if (!(ent = EntityManager::GetEntityId("weather"))) + if (!(ent = core.GetEntityId("weather"))) throw std::runtime_error("No found WEATHER entity!"); - pWeather = static_cast(EntityManager::GetEntityPointer(ent)); + pWeather = static_cast(core.GetEntityPointer(ent)); // UNGUARD } diff --git a/src/libs/worldmap/src/world_map.cpp b/src/libs/worldmap/src/world_map.cpp index d5faac018..b3509950c 100644 --- a/src/libs/worldmap/src/world_map.cpp +++ b/src/libs/worldmap/src/world_map.cpp @@ -139,11 +139,11 @@ bool WorldMap::Init() // GUARD(LocationCamera::Init()) // Layers // core.LayerCreate("execute", true, false); - EntityManager::SetLayerType(EXECUTE, EntityManager::Layer::Type::execute); + core.SetLayerType(EXECUTE, layer_type_t::execute); // core.LayerCreate("realize", true, false); - EntityManager::SetLayerType(REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(EXECUTE, GetId(), 10000); - EntityManager::AddToLayer(REALIZE, GetId(), 10000); + core.SetLayerType(REALIZE, layer_type_t::realize); + core.AddToLayer(EXECUTE, GetId(), 10000); + core.AddToLayer(REALIZE, GetId(), 10000); // DX9 render rs = static_cast(core.GetService("dx9render")); diff --git a/src/libs/xinterface/src/aviplayer/aviplayer.cpp b/src/libs/xinterface/src/aviplayer/aviplayer.cpp index a68801a3a..5781a8ea8 100644 --- a/src/libs/xinterface/src/aviplayer/aviplayer.cpp +++ b/src/libs/xinterface/src/aviplayer/aviplayer.cpp @@ -56,12 +56,12 @@ bool CAviPlayer::Init() } // core.LayerCreate("vRealize",true,false); - EntityManager::SetLayerType(VIDEO_REALIZE, EntityManager::Layer::Type::realize); - EntityManager::AddToLayer(VIDEO_REALIZE, GetId(), -1); + core.SetLayerType(VIDEO_REALIZE, layer_type_t::realize); + core.AddToLayer(VIDEO_REALIZE, GetId(), -1); // core.LayerCreate("vExecute",true,false); - EntityManager::SetLayerType(VIDEO_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::AddToLayer(VIDEO_EXECUTE, GetId(), 1); + core.SetLayerType(VIDEO_EXECUTE, layer_type_t::execute); + core.AddToLayer(VIDEO_EXECUTE, GetId(), 1); if (!GetInterfaces()) { diff --git a/src/libs/xinterface/src/back_scene/back_scene.cpp b/src/libs/xinterface/src/back_scene/back_scene.cpp index f68763929..593640c58 100644 --- a/src/libs/xinterface/src/back_scene/back_scene.cpp +++ b/src/libs/xinterface/src/back_scene/back_scene.cpp @@ -10,7 +10,7 @@ InterfaceBackScene::LightParam::~LightParam() bUse = false; if (pModel) { - EntityManager::EraseEntity(eiModel); + core.EraseEntity(eiModel); pModel = nullptr; } } @@ -69,9 +69,9 @@ void InterfaceBackScene::LightParam::UpdateParams(float fTime) InterfaceBackScene::MenuDescr::~MenuDescr() { - EntityManager::EraseEntity(eiActive); + core.EraseEntity(eiActive); pActive = nullptr; - EntityManager::EraseEntity(eiPassive); + core.EraseEntity(eiPassive); pPassive = nullptr; } @@ -90,9 +90,9 @@ void InterfaceBackScene::MenuDescr::Set(CMatrix *pMtx, const char *pcActiveName, // create active model if (pcActiveName) { - eiActive = EntityManager::CreateEntity("MODELR"); + eiActive = core.CreateEntity("MODELR"); core.Send_Message(eiActive, "ls", MSG_MODEL_LOAD_GEO, pcActiveName); - pActive = static_cast(EntityManager::GetEntityPointer(eiActive)); + pActive = static_cast(core.GetEntityPointer(eiActive)); if (pActive && pMtx) { pActive->mtx = *pMtx; @@ -108,9 +108,9 @@ void InterfaceBackScene::MenuDescr::Set(CMatrix *pMtx, const char *pcActiveName, // create passive model if (pcPassiveName) { - eiPassive = EntityManager::CreateEntity("MODELR"); + eiPassive = core.CreateEntity("MODELR"); core.Send_Message(eiPassive, "ls", MSG_MODEL_LOAD_GEO, pcPassiveName); - pPassive = static_cast(EntityManager::GetEntityPointer(eiPassive)); + pPassive = static_cast(core.GetEntityPointer(eiPassive)); if (pPassive && pMtx) { pPassive->mtx = *pMtx; @@ -151,8 +151,8 @@ InterfaceBackScene::InterfaceBackScene() InterfaceBackScene::~InterfaceBackScene() { RestoreLight(); - EntityManager::EraseEntity(m_eiModel); - EntityManager::EraseEntity(m_eiLocators); + core.EraseEntity(m_eiModel); + core.EraseEntity(m_eiLocators); m_pLocators = nullptr; m_pModel = nullptr; ReleaseMenuList(); @@ -401,12 +401,12 @@ void InterfaceBackScene::LoadModel(const char *pcModelName) // delete all if (m_pModel) { - EntityManager::EraseEntity(m_eiModel); + core.EraseEntity(m_eiModel); m_pModel = nullptr; } if (m_pLocators) { - EntityManager::EraseEntity(m_eiLocators); + core.EraseEntity(m_eiLocators); m_pLocators = nullptr; } auto *pGeo = static_cast(core.GetService("Geometry")); @@ -414,18 +414,18 @@ void InterfaceBackScene::LoadModel(const char *pcModelName) pGeo->SetTexturePath( (std::string("MainMenu\\") + XINTERFACE::pThis->StringService()->GetLanguage() + "\\").c_str()); // create model - m_eiModel = EntityManager::CreateEntity("MODELR"); + m_eiModel = core.CreateEntity("MODELR"); core.Send_Message(m_eiModel, "ls", MSG_MODEL_LOAD_GEO, pcModelName); - m_pModel = static_cast(EntityManager::GetEntityPointer(m_eiModel)); + m_pModel = static_cast(core.GetEntityPointer(m_eiModel)); if (pGeo) pGeo->SetTexturePath(""); - EntityManager::AddToLayer(SUN_TRACE, m_eiModel, 0); - EntityManager::AddToLayer(RAIN_DROPS, m_eiModel, 100); + core.AddToLayer(SUN_TRACE, m_eiModel, 0); + core.AddToLayer(RAIN_DROPS, m_eiModel, 100); // create locators - m_eiLocators = EntityManager::CreateEntity("MODELR"); + m_eiLocators = core.CreateEntity("MODELR"); const auto sLocName = std::string(pcModelName) + "_locators"; core.Send_Message(m_eiLocators, "ls", MSG_MODEL_LOAD_GEO, sLocName.c_str()); - m_pLocators = static_cast(EntityManager::GetEntityPointer(m_eiLocators)); + m_pLocators = static_cast(core.GetEntityPointer(m_eiLocators)); } void InterfaceBackScene::SetCameraPosition(const char *pcLocatorName) @@ -704,9 +704,9 @@ void InterfaceBackScene::InitLight(ATTRIBUTES *pAParam) if (pGeo) pGeo->SetTexturePath("MainMenu\\"); // create model - pLight->eiModel = EntityManager::CreateEntity("MODELR"); + pLight->eiModel = core.CreateEntity("MODELR"); core.Send_Message(pLight->eiModel, "ls", MSG_MODEL_LOAD_GEO, pcFonarModel); - pLight->pModel = static_cast(EntityManager::GetEntityPointer(pLight->eiModel)); + pLight->pModel = static_cast(core.GetEntityPointer(pLight->eiModel)); if (pGeo) pGeo->SetTexturePath(""); if (pLight->pModel) @@ -907,9 +907,9 @@ void InterfaceBackScene::InitAniModel(ATTRIBUTES *pAParam) if (pGeo) pGeo->SetTexturePath("MainMenu\\"); // create model - pObj->ei = EntityManager::CreateEntity("MODELR"); + pObj->ei = core.CreateEntity("MODELR"); core.Send_Message(pObj->ei, "ls", MSG_MODEL_LOAD_GEO, pcMdlName); - pObj->pModel = static_cast(EntityManager::GetEntityPointer(pObj->ei)); + pObj->pModel = static_cast(core.GetEntityPointer(pObj->ei)); if (pGeo) pGeo->SetTexturePath(""); @@ -957,9 +957,9 @@ void InterfaceBackScene::InitStaticModel(ATTRIBUTES *pAParam) if (pGeo) pGeo->SetTexturePath("MainMenu\\"); // create model - pObj->ei = EntityManager::CreateEntity("MODELR"); + pObj->ei = core.CreateEntity("MODELR"); core.Send_Message(pObj->ei, "ls", MSG_MODEL_LOAD_GEO, pcMdlName); - pObj->pModel = static_cast(EntityManager::GetEntityPointer(pObj->ei)); + pObj->pModel = static_cast(core.GetEntityPointer(pObj->ei)); if (pGeo) pGeo->SetTexturePath(""); diff --git a/src/libs/xinterface/src/back_scene/back_scene.h b/src/libs/xinterface/src/back_scene/back_scene.h index 214c739bd..b214d8505 100644 --- a/src/libs/xinterface/src/back_scene/back_scene.h +++ b/src/libs/xinterface/src/back_scene/back_scene.h @@ -1,5 +1,6 @@ #pragma once +#include "core.h" #include "../xdefines.h" #include "entity.h" #include "matrix.h" @@ -159,7 +160,7 @@ class InterfaceBackScene : public Entity ~AniModelDescr() { - EntityManager::EraseEntity(ei); + core.EraseEntity(ei); pModel = nullptr; } }; diff --git a/src/libs/xinterface/src/nodes/xi_formt_text.cpp b/src/libs/xinterface/src/nodes/xi_formt_text.cpp index a9f92e998..5ad6952c6 100644 --- a/src/libs/xinterface/src/nodes/xi_formt_text.cpp +++ b/src/libs/xinterface/src/nodes/xi_formt_text.cpp @@ -1458,7 +1458,7 @@ void CXI_FORMATEDTEXT::ControlSyncronouseNodes() { for (int32_t n = 0; n < static_cast(m_asSyncNodes.size()); n++) { - CINODE *pNode = static_cast(EntityManager::GetEntityPointer(g_idInterface)) + CINODE *pNode = static_cast(core.GetEntityPointer(g_idInterface)) ->FindNode(m_asSyncNodes[n].c_str(), nullptr); if (!pNode) continue; @@ -1618,7 +1618,7 @@ void CXI_FORMATEDTEXT::ScrollerUpdate() if (!m_sScrollerName) return; CINODE *pNode = - static_cast(EntityManager::GetEntityPointer(g_idInterface))->FindNode(m_sScrollerName, nullptr); + static_cast(core.GetEntityPointer(g_idInterface))->FindNode(m_sScrollerName, nullptr); if (!pNode) return; diff --git a/src/libs/xinterface/src/nodes/xi_scroller.cpp b/src/libs/xinterface/src/nodes/xi_scroller.cpp index e12dbdb4f..1a46ea67a 100644 --- a/src/libs/xinterface/src/nodes/xi_scroller.cpp +++ b/src/libs/xinterface/src/nodes/xi_scroller.cpp @@ -167,7 +167,7 @@ void CXI_SCROLLER::MakeOwnedControl() { for (int32_t n = 0; n < static_cast(m_asOwnedNodes.size()); n++) { - auto *const pNode = static_cast(EntityManager::GetEntityPointer(g_idInterface)) + auto *const pNode = static_cast(core.GetEntityPointer(g_idInterface)) ->FindNode(m_asOwnedNodes[n].c_str(), nullptr); if (!pNode) continue; @@ -219,7 +219,7 @@ float CXI_SCROLLER::GetOwnedStep() CINODE *pNode = nullptr; for (int32_t n = 0; n < static_cast(m_asOwnedNodes.size()); n++) { - pNode = static_cast(EntityManager::GetEntityPointer(g_idInterface)) + pNode = static_cast(core.GetEntityPointer(g_idInterface)) ->FindNode(m_asOwnedNodes[n].c_str(), nullptr); if (pNode) break; diff --git a/src/libs/xinterface/src/nodes/xi_video_rect.cpp b/src/libs/xinterface/src/nodes/xi_video_rect.cpp index 34ca6fedb..f5e37fb08 100644 --- a/src/libs/xinterface/src/nodes/xi_video_rect.cpp +++ b/src/libs/xinterface/src/nodes/xi_video_rect.cpp @@ -18,7 +18,7 @@ void CXI_VIDEORECT::Draw(bool bSelected, uint32_t Delta_Time) { if (m_bUse) { - if (auto *const ptr = EntityManager::GetEntityPointer(m_eiVideo)) + if (auto *const ptr = core.GetEntityPointer(m_eiVideo)) { auto *const pTex = static_cast(ptr)->GetCurrentVideoTexture(); if (pTex != nullptr) @@ -75,7 +75,7 @@ void CXI_VIDEORECT::LoadIni(INIFILE *ini1, const char *name1, INIFILE *ini2, con void CXI_VIDEORECT::ReleaseAll() { - EntityManager::EraseEntity(m_eiVideo); + core.EraseEntity(m_eiVideo); } void CXI_VIDEORECT::ChangePosition(XYRECT &rNewPos) @@ -121,17 +121,17 @@ uint32_t CXI_VIDEORECT::MessageProc(int32_t msgcode, MESSAGE &message) void CXI_VIDEORECT::StartVideoPlay(const char *videoFileName) { - if (EntityManager::GetEntityPointer(m_eiVideo)) + if (core.GetEntityPointer(m_eiVideo)) { - EntityManager::EraseEntity(m_eiVideo); + core.EraseEntity(m_eiVideo); } if (videoFileName == nullptr) return; - m_eiVideo = EntityManager::CreateEntity("CAviPlayer"); + m_eiVideo = core.CreateEntity("CAviPlayer"); m_rectTex.bottom = 1.f - m_rectTex.bottom; m_rectTex.top = 1.f - m_rectTex.top; - if (auto *const ptr = EntityManager::GetEntityPointer(m_eiVideo)) + if (auto *const ptr = core.GetEntityPointer(m_eiVideo)) static_cast(ptr)->SetShowVideo(false); core.Send_Message(m_eiVideo, "ll", MSG_SET_VIDEO_FLAGS, m_dwFlags); core.Send_Message(m_eiVideo, "ls", MSG_SET_VIDEO_PLAY, videoFileName); diff --git a/src/libs/xinterface/src/xdefines.h b/src/libs/xinterface/src/xdefines.h index 6ac161e3d..6f458d021 100644 --- a/src/libs/xinterface/src/xdefines.h +++ b/src/libs/xinterface/src/xdefines.h @@ -6,7 +6,6 @@ #include "shared/interface/messages.h" #include "string_service.h" #include "vx_service.h" -#include #define ALPHA(x) ((x) >> 24) #define RED(x) (((x) >> 16) & 0xFF) diff --git a/src/libs/xinterface/src/xinterface.cpp b/src/libs/xinterface/src/xinterface.cpp index 597b9044b..f2d0a8fa0 100644 --- a/src/libs/xinterface/src/xinterface.cpp +++ b/src/libs/xinterface/src/xinterface.cpp @@ -222,8 +222,8 @@ void XINTERFACE::SetDevice() } } - EntityManager::SetLayerType(INTERFACE_EXECUTE, EntityManager::Layer::Type::execute); - EntityManager::SetLayerType(INTERFACE_REALIZE, EntityManager::Layer::Type::realize); + core.SetLayerType(INTERFACE_EXECUTE, layer_type_t::execute); + core.SetLayerType(INTERFACE_REALIZE, layer_type_t::realize); // core.SystemMessages(GetId(),true); if (AttributesPointer) @@ -2679,7 +2679,7 @@ bool XINTERFACE::SFLB_DoSaveFileData(const char *saveName, const char *saveData) return false; entid_t ei; - if (!(ei = EntityManager::GetEntityId("SCRSHOTER"))) + if (!(ei = core.GetEntityId("SCRSHOTER"))) return false; int32_t textureId = core.Send_Message(ei, "l", MSG_SCRSHOT_MAKE); if (textureId == -1)