EntityManager: ranges and cleanup

Use LWOOBJID for ghosting entities
use ranges::views::values for associative container iteration
remove dead code
comment magic numbers
little bit of optimization (not enough to be game changing or take the time to measure, they are free speedups anyways, we take those)
use cstdint types
This commit is contained in:
David Markowitz
2024-02-09 05:33:37 -08:00
parent dc29f5962d
commit 199c6f745d
4 changed files with 61 additions and 92 deletions

View File

@@ -8,7 +8,7 @@ GhostComponent::GhostComponent(Entity* parent) : Component(parent) {
GhostComponent::~GhostComponent() {
for (auto& observedEntity : m_ObservedEntities) {
if (observedEntity == 0) continue;
if (observedEntity == LWOOBJID_EMPTY) continue;
auto* entity = Game::entityManager->GetGhostCandidate(observedEntity);
if (!entity) continue;
@@ -44,14 +44,14 @@ void GhostComponent::ConstructLimboEntities() {
m_LimboConstructions.clear();
}
void GhostComponent::ObserveEntity(int32_t id) {
void GhostComponent::ObserveEntity(LWOOBJID id) {
m_ObservedEntities.insert(id);
}
bool GhostComponent::IsObserved(int32_t id) {
bool GhostComponent::IsObserved(LWOOBJID id) {
return m_ObservedEntities.contains(id);
}
void GhostComponent::GhostEntity(int32_t id) {
void GhostComponent::GhostEntity(LWOOBJID id) {
m_ObservedEntities.erase(id);
}

View File

@@ -33,18 +33,18 @@ public:
void ConstructLimboEntities();
void ObserveEntity(const int32_t id);
void ObserveEntity(const LWOOBJID id);
bool IsObserved(const int32_t id);
bool IsObserved(const LWOOBJID id);
void GhostEntity(const int32_t id);
void GhostEntity(const LWOOBJID id);
private:
NiPoint3 m_GhostReferencePoint;
NiPoint3 m_GhostOverridePoint;
std::unordered_set<int32_t> m_ObservedEntities;
std::unordered_set<LWOOBJID> m_ObservedEntities;
std::unordered_set<LWOOBJID> m_LimboConstructions;