2024-01-12 19:18:28 +00:00
|
|
|
#include "GhostComponent.h"
|
|
|
|
|
2024-01-14 19:10:13 +00:00
|
|
|
GhostComponent::GhostComponent(Entity* parent) : Component(parent) {
|
2024-01-29 07:53:12 +00:00
|
|
|
m_GhostReferencePoint = NiPoint3Constant::ZERO;
|
|
|
|
m_GhostOverridePoint = NiPoint3Constant::ZERO;
|
2024-01-14 19:10:13 +00:00
|
|
|
m_GhostOverride = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GhostComponent::~GhostComponent() {
|
|
|
|
for (auto& observedEntity : m_ObservedEntities) {
|
2024-02-11 20:28:25 +00:00
|
|
|
if (observedEntity == LWOOBJID_EMPTY) continue;
|
2024-01-14 19:10:13 +00:00
|
|
|
|
|
|
|
auto* entity = Game::entityManager->GetGhostCandidate(observedEntity);
|
|
|
|
if (!entity) continue;
|
|
|
|
|
|
|
|
entity->SetObservers(entity->GetObservers() - 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GhostComponent::SetGhostReferencePoint(const NiPoint3& value) {
|
|
|
|
m_GhostReferencePoint = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GhostComponent::SetGhostOverridePoint(const NiPoint3& value) {
|
|
|
|
m_GhostOverridePoint = value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GhostComponent::AddLimboConstruction(LWOOBJID objectId) {
|
|
|
|
m_LimboConstructions.insert(objectId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GhostComponent::RemoveLimboConstruction(LWOOBJID objectId) {
|
|
|
|
m_LimboConstructions.erase(objectId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GhostComponent::ConstructLimboEntities() {
|
|
|
|
for (const auto& objectId : m_LimboConstructions) {
|
|
|
|
auto* entity = Game::entityManager->GetEntity(objectId);
|
|
|
|
if (!entity) continue;
|
|
|
|
|
|
|
|
Game::entityManager->ConstructEntity(entity, m_Parent->GetSystemAddress());
|
|
|
|
}
|
|
|
|
|
|
|
|
m_LimboConstructions.clear();
|
|
|
|
}
|
|
|
|
|
2024-02-11 20:28:25 +00:00
|
|
|
void GhostComponent::ObserveEntity(LWOOBJID id) {
|
2024-01-14 19:10:13 +00:00
|
|
|
m_ObservedEntities.insert(id);
|
|
|
|
}
|
|
|
|
|
2024-02-11 20:28:25 +00:00
|
|
|
bool GhostComponent::IsObserved(LWOOBJID id) {
|
2024-01-14 19:10:13 +00:00
|
|
|
return m_ObservedEntities.contains(id);
|
|
|
|
}
|
|
|
|
|
2024-02-11 20:28:25 +00:00
|
|
|
void GhostComponent::GhostEntity(LWOOBJID id) {
|
2024-01-14 19:10:13 +00:00
|
|
|
m_ObservedEntities.erase(id);
|
|
|
|
}
|