Rename some variables in Component

And add more virtuals
This commit is contained in:
David Markowitz
2023-06-06 18:59:53 -07:00
parent b589755655
commit 716a5fcf37
54 changed files with 602 additions and 580 deletions

View File

@@ -65,10 +65,10 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
// Get aggro and tether radius from settings and use this if it is present. Only overwrite the
// radii if it is greater than the one in the database.
if (m_Parent) {
auto aggroRadius = m_Parent->GetVar<float>(u"aggroRadius");
if (m_OwningEntity) {
auto aggroRadius = m_OwningEntity->GetVar<float>(u"aggroRadius");
m_AggroRadius = aggroRadius != 0 ? aggroRadius : m_AggroRadius;
auto tetherRadius = m_Parent->GetVar<float>(u"tetherRadius");
auto tetherRadius = m_OwningEntity->GetVar<float>(u"tetherRadius");
m_HardTetherRadius = tetherRadius != 0 ? tetherRadius : m_HardTetherRadius;
}
@@ -120,14 +120,14 @@ BaseCombatAIComponent::BaseCombatAIComponent(Entity* parent, const uint32_t id):
}
//Create a phantom physics volume so we can detect when we're aggro'd.
m_dpEntity = new dpEntity(m_Parent->GetObjectID(), m_AggroRadius);
m_dpEntityEnemy = new dpEntity(m_Parent->GetObjectID(), m_AggroRadius, false);
m_dpEntity = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius);
m_dpEntityEnemy = new dpEntity(m_OwningEntity->GetObjectID(), m_AggroRadius, false);
m_dpEntity->SetCollisionGroup(collisionGroup);
m_dpEntityEnemy->SetCollisionGroup(collisionGroup);
m_dpEntity->SetPosition(m_Parent->GetPosition());
m_dpEntityEnemy->SetPosition(m_Parent->GetPosition());
m_dpEntity->SetPosition(m_OwningEntity->GetPosition());
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
dpWorld::Instance().AddEntity(m_dpEntity);
dpWorld::Instance().AddEntity(m_dpEntityEnemy);
@@ -146,17 +146,17 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
//First, we need to process physics:
if (!m_dpEntity) return;
m_dpEntity->SetPosition(m_Parent->GetPosition()); //make sure our position is synced with our dpEntity
m_dpEntityEnemy->SetPosition(m_Parent->GetPosition());
m_dpEntity->SetPosition(m_OwningEntity->GetPosition()); //make sure our position is synced with our dpEntity
m_dpEntityEnemy->SetPosition(m_OwningEntity->GetPosition());
//Process enter events
for (auto en : m_dpEntity->GetNewObjects()) {
m_Parent->OnCollisionPhantom(en->GetObjectID());
m_OwningEntity->OnCollisionPhantom(en->GetObjectID());
}
//Process exit events
for (auto en : m_dpEntity->GetRemovedObjects()) {
m_Parent->OnCollisionLeavePhantom(en->GetObjectID());
m_OwningEntity->OnCollisionLeavePhantom(en->GetObjectID());
}
// Check if we should stop the tether effect
@@ -165,31 +165,31 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
const auto& info = m_MovementAI->GetInfo();
if (m_Target != LWOOBJID_EMPTY || (NiPoint3::DistanceSquared(
m_StartPosition,
m_Parent->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
m_OwningEntity->GetPosition()) < 20 * 20 && m_TetherTime <= 0)
) {
GameMessages::SendStopFXEffect(m_Parent, true, "tether");
GameMessages::SendStopFXEffect(m_OwningEntity, true, "tether");
m_TetherEffectActive = false;
}
}
if (m_SoftTimer <= 0.0f) {
EntityManager::Instance()->SerializeEntity(m_Parent);
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
m_SoftTimer = 5.0f;
} else {
m_SoftTimer -= deltaTime;
}
if (m_Disabled || m_Parent->GetIsDead())
if (m_Disabled || m_OwningEntity->GetIsDead())
return;
bool stunnedThisFrame = m_Stunned;
CalculateCombat(deltaTime); // Putting this here for now
if (m_StartPosition == NiPoint3::ZERO) {
m_StartPosition = m_Parent->GetPosition();
m_StartPosition = m_OwningEntity->GetPosition();
}
m_MovementAI = m_Parent->GetComponent<MovementAIComponent>();
m_MovementAI = m_OwningEntity->GetComponent<MovementAIComponent>();
if (m_MovementAI == nullptr) {
return;
@@ -243,7 +243,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
bool hadRemainingDowntime = m_SkillTime > 0.0f;
if (m_SkillTime > 0.0f) m_SkillTime -= deltaTime;
auto* rebuild = m_Parent->GetComponent<RebuildComponent>();
auto* rebuild = m_OwningEntity->GetComponent<RebuildComponent>();
if (rebuild != nullptr) {
const auto state = rebuild->GetState();
@@ -253,7 +253,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
}
}
auto* skillComponent = m_Parent->GetComponent<SkillComponent>();
auto* skillComponent = m_OwningEntity->GetComponent<SkillComponent>();
if (skillComponent == nullptr) {
return;
@@ -287,7 +287,7 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
}
if (!m_TetherEffectActive && m_OutOfCombat && (m_OutOfCombatTime -= deltaTime) <= 0) {
auto* destroyableComponent = m_Parent->GetComponent<DestroyableComponent>();
auto* destroyableComponent = m_OwningEntity->GetComponent<DestroyableComponent>();
if (destroyableComponent != nullptr && destroyableComponent->HasFaction(4)) {
auto serilizationRequired = false;
@@ -305,10 +305,10 @@ void BaseCombatAIComponent::CalculateCombat(const float deltaTime) {
}
if (serilizationRequired) {
EntityManager::Instance()->SerializeEntity(m_Parent);
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
}
GameMessages::SendPlayFXEffect(m_Parent->GetObjectID(), 6270, u"tether", "tether");
GameMessages::SendPlayFXEffect(m_OwningEntity->GetObjectID(), 6270, u"tether", "tether");
m_TetherEffectActive = true;
@@ -496,10 +496,10 @@ LWOOBJID BaseCombatAIComponent::FindTarget() {
std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
std::vector<LWOOBJID> targets;
for (auto id : m_Parent->GetTargetsInPhantom()) {
for (auto id : m_OwningEntity->GetTargetsInPhantom()) {
auto* other = EntityManager::Instance()->GetEntity(id);
const auto distance = Vector3::DistanceSquared(m_Parent->GetPosition(), other->GetPosition());
const auto distance = Vector3::DistanceSquared(m_OwningEntity->GetPosition(), other->GetPosition());
if (distance > m_AggroRadius * m_AggroRadius) continue;
@@ -510,7 +510,7 @@ std::vector<LWOOBJID> BaseCombatAIComponent::GetTargetWithinAggroRange() const {
}
bool BaseCombatAIComponent::IsMech() {
switch (m_Parent->GetLOT()) {
switch (m_OwningEntity->GetLOT()) {
case 6253:
return true;
@@ -535,7 +535,7 @@ void BaseCombatAIComponent::SetAiState(AiState newState) {
if (newState == this->m_State) return;
this->m_State = newState;
m_DirtyStateOrTarget = true;
EntityManager::Instance()->SerializeEntity(m_Parent);
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
}
bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
@@ -553,10 +553,10 @@ bool BaseCombatAIComponent::IsEnemy(LWOOBJID target) const {
return false;
}
auto* referenceDestroyable = m_Parent->GetComponent<DestroyableComponent>();
auto* referenceDestroyable = m_OwningEntity->GetComponent<DestroyableComponent>();
if (referenceDestroyable == nullptr) {
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_Parent->GetObjectID());
Game::logger->Log("BaseCombatAIComponent", "Invalid reference destroyable component on (%llu)!", m_OwningEntity->GetObjectID());
return false;
}
@@ -588,7 +588,7 @@ void BaseCombatAIComponent::SetTarget(const LWOOBJID target) {
if (this->m_Target == target) return;
m_Target = target;
m_DirtyStateOrTarget = true;
EntityManager::Instance()->SerializeEntity(m_Parent);
EntityManager::Instance()->SerializeEntity(m_OwningEntity);
}
Entity* BaseCombatAIComponent::GetTargetEntity() const {
@@ -597,7 +597,7 @@ Entity* BaseCombatAIComponent::GetTargetEntity() const {
void BaseCombatAIComponent::Taunt(LWOOBJID offender, float threat) {
// Can't taunt self
if (offender == m_Parent->GetObjectID())
if (offender == m_OwningEntity->GetObjectID())
return;
m_ThreatEntries[offender] += threat;
@@ -788,7 +788,7 @@ void BaseCombatAIComponent::LookAt(const NiPoint3& point) {
return;
}
m_Parent->SetRotation(NiQuaternion::LookAt(m_Parent->GetPosition(), point));
m_OwningEntity->SetRotation(NiQuaternion::LookAt(m_OwningEntity->GetPosition(), point));
}
void BaseCombatAIComponent::SetDisabled(bool value) {