Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
[core] rework entity_manager pt.1
Browse files Browse the repository at this point in the history
  • Loading branch information
espkk committed May 26, 2022
1 parent 6b5a727 commit e7ff927
Show file tree
Hide file tree
Showing 126 changed files with 1,231 additions and 1,121 deletions.
4 changes: 2 additions & 2 deletions src/libs/animals/src/animals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/libs/animals/src/t_butterflies.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/animals/src/t_butterfly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions src/libs/animals/src/t_butterfly.h
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/libs/animals/src/t_fish_schools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TFishSchools::~TFishSchools()
delete fishSchools[i];
}

EntityManager::EraseEntity(fishSchoolModel);
core.EraseEntity(fishSchoolModel);
}

//--------------------------------------------------------------------
Expand All @@ -44,7 +44,7 @@ void TFishSchools::Init()
if (!renderService)
throw std::runtime_error("!FishSchools: No service 'dx9render'");

sea = static_cast<SEA_BASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea")));
sea = static_cast<SEA_BASE *>(core.GetEntityPointer(core.GetEntityId("sea")));
if (!sea)
{
enabled = false;
Expand All @@ -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);
}

Expand Down Expand Up @@ -122,14 +122,14 @@ void TFishSchools::Realize(uint32_t _dTime)
float cameraPersp;
renderService->GetCamera(cameraPos, cameraAng, cameraPersp);
*/
sea = static_cast<SEA_BASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea")));
sea = static_cast<SEA_BASE *>(core.GetEntityPointer(core.GetEntityId("sea")));
if (!sea)
{
enabled = false;
return;
}

auto *fishSchool = static_cast<MODEL *>(EntityManager::GetEntityPointer(fishSchoolModel));
auto *fishSchool = static_cast<MODEL *>(core.GetEntityPointer(fishSchoolModel));
if (!fishSchool)
return;

Expand Down
6 changes: 3 additions & 3 deletions src/libs/animals/src/t_seagulls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ TSeagulls::TSeagulls() : enabled(true), count(0), frightened(false)
//--------------------------------------------------------------------
TSeagulls::~TSeagulls()
{
EntityManager::EraseEntity(seagullModel);
core.EraseEntity(seagullModel);
}

//--------------------------------------------------------------------
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -203,7 +203,7 @@ void TSeagulls::Realize(uint32_t _dTime)
if (!count)
Add(cameraPos.x, cameraPos.y, cameraPos.z);

auto *seagull = static_cast<MODEL *>(EntityManager::GetEntityPointer(seagullModel));
auto *seagull = static_cast<MODEL *>(core.GetEntityPointer(seagullModel));
if (!seagull)
return;

Expand Down
4 changes: 2 additions & 2 deletions src/libs/ball_splash/src/ball_splash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ bool BALLSPLASH::Init()
{
// GUARD(BALLSPLASH::Init)

sea = static_cast<SEA_BASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("sea")));
sea = static_cast<SEA_BASE *>(core.GetEntityPointer(core.GetEntityId("sea")));

renderer = static_cast<VDX9RENDER *>(core.GetService("dx9render"));

// EntityManager::CreateEntity(&arrowModel,"MODELR");
// core.CreateEntity(&arrowModel,"MODELR");
// core.Send_Message(arrowModel,"ls",MSG_MODEL_LOAD_GEO, "fish01");
InitializeSplashes();

Expand Down
18 changes: 9 additions & 9 deletions src/libs/battle_interface/src/item_entity/item_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<MODEL *>(EntityManager::GetEntityPointer(m_eidModel));
m_pModel = static_cast<MODEL *>(core.GetEntityPointer(m_eidModel));
SetModelToPosition(m_mtxpos);
SetTechnique(pcTechnique);
}
Expand All @@ -133,7 +133,7 @@ void ItemEntity::Release()
{
if (m_pModel)
{
EntityManager::EraseEntity(m_eidModel);
core.EraseEntity(m_eidModel);
m_pModel = nullptr;
}
DeleteParticle();
Expand Down Expand Up @@ -165,7 +165,7 @@ bool ItemEntity::TieToLocator(entid_t mdlEID, const char *pcLocName)
{
m_eidTieModel = mdlEID;
m_sTieLocName = pcLocName;
auto *pMdl = static_cast<MODEL *>(EntityManager::GetEntityPointer(mdlEID));
auto *pMdl = static_cast<MODEL *>(core.GetEntityPointer(mdlEID));
if (pMdl)
{
m_pMdlNode = pMdl->GetNode(0);
Expand Down Expand Up @@ -198,7 +198,7 @@ void ItemEntity::EndEventProcess()

void ItemEntity::DrawIntoLocator()
{
auto *pMdl = static_cast<MODEL *>(EntityManager::GetEntityPointer(m_eidTieModel));
auto *pMdl = static_cast<MODEL *>(core.GetEntityPointer(m_eidTieModel));
if (!pMdl)
{
UnTieFromLocator();
Expand Down Expand Up @@ -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<MODEL *>(EntityManager::GetEntityPointer(mdlEID));
auto *pMdl = static_cast<MODEL *>(core.GetEntityPointer(mdlEID));
if (!pMdl)
return;
auto *a = pMdl->GetAnimation();
Expand Down Expand Up @@ -287,7 +287,7 @@ void ItemEntity::EventListener::Event(Animation *animation, int32_t playerIndex,
}
if (!m_bStartWaiting && m_sEndEvent == eventName)
{
auto *pMdl = static_cast<MODEL *>(EntityManager::GetEntityPointer(m_eidListenedModel));
auto *pMdl = static_cast<MODEL *>(core.GetEntityPointer(m_eidListenedModel));
if (pMdl)
{
auto *a = pMdl->GetAnimation();
Expand All @@ -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();
Expand All @@ -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))
Expand Down
6 changes: 3 additions & 3 deletions src/libs/battle_interface/src/sea/battle_navigator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1346,10 +1346,10 @@ void BATTLE_NAVIGATOR::SetIsland()
float islSize = 0;

MODEL *pM = nullptr;
auto *pIsl = static_cast<ISLAND_BASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("ISLAND")));
auto *pIsl = static_cast<ISLAND_BASE *>(core.GetEntityPointer(core.GetEntityId("ISLAND")));
if (pIsl != nullptr)
{
pM = static_cast<MODEL *>(EntityManager::GetEntityPointer(pIsl->GetModelEID()));
pM = static_cast<MODEL *>(core.GetEntityPointer(pIsl->GetModelEID()));
}
if (pM != nullptr)
{
Expand Down Expand Up @@ -1541,7 +1541,7 @@ void BATTLE_NAVIGATOR::UpdateWindParam()
{
if (!m_wb && !m_pAWeather)
{
m_wb = static_cast<WEATHER_BASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("weather")));
m_wb = static_cast<WEATHER_BASE *>(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);
Expand Down
6 changes: 3 additions & 3 deletions src/libs/battle_interface/src/sea/ship_pointer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VAI_OBJBASE *>(EntityManager::GetEntityPointer(ship));
auto ps = static_cast<VAI_OBJBASE *>(core.GetEntityPointer(ship));
if (ps != nullptr && ps->GetACharacter() != nullptr)
{
if (static_cast<int32_t>(ps->GetACharacter()->GetAttributeAsDword("index", -2)) == chrIdx)
Expand All @@ -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 )
Expand Down
12 changes: 6 additions & 6 deletions src/libs/battle_interface/src/sea/ships_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<VAI_OBJBASE *>(EntityManager::GetEntityPointer(ship));
auto *vob = static_cast<VAI_OBJBASE *>(core.GetEntityPointer(ship));
if (vob == nullptr)
continue;
auto *pA = vob->GetACharacter();
Expand All @@ -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)
Expand Down Expand Up @@ -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<VAI_OBJBASE *>(EntityManager::GetEntityPointer(ship));
auto *vob = static_cast<VAI_OBJBASE *>(core.GetEntityPointer(ship));
if (vob == nullptr)
continue;
auto *pA = vob->GetACharacter();
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/battle_interface/src/spyglass/spyglass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ VAI_OBJBASE *ISPYGLASS::GetFort()
{
if (!m_pFortObj)
{
m_pFortObj = static_cast<VAI_OBJBASE *>(EntityManager::GetEntityPointer(EntityManager::GetEntityId("AIFORT")));
m_pFortObj = static_cast<VAI_OBJBASE *>(core.GetEntityPointer(core.GetEntityId("AIFORT")));
}
return m_pFortObj;
}
Loading

0 comments on commit e7ff927

Please sign in to comment.