move IsDead to the DestroyableComponent

This commit is contained in:
jadebenn
2024-12-24 23:00:49 -06:00
parent 6ed6efa921
commit 81b4f84d03
17 changed files with 24 additions and 30 deletions

View File

@@ -1378,7 +1378,7 @@ void Entity::OnCollisionPhantom(const LWOOBJID otherEntity) {
}
}
if (!other->GetIsDead()) {
if (!other->GetComponent<DestroyableComponent>()->GetIsDead()) {
if (GetComponent<BaseCombatAIComponent>() != nullptr) {
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity);
@@ -1606,13 +1606,6 @@ void Entity::AddQuickBuildCompleteCallback(const std::function<void(Entity* user
}
}
bool Entity::GetIsDead() const {
DestroyableComponent* dest = GetComponent<DestroyableComponent>();
if (dest && dest->GetArmor() == 0 && dest->GetHealth() == 0) return true;
return false;
}
void Entity::AddLootItem(const Loot::Info& info) {
if (!IsPlayer()) return;

View File

@@ -82,8 +82,6 @@ public:
const std::vector<LDFBaseData*>& GetNetworkSettings() const { return m_NetworkSettings; }
bool GetIsDead() const;
bool GetPlayerReadyForUpdates() const { return m_PlayerIsReadyForUpdates; }
bool GetIsGhostingCandidate() const;

View File

@@ -227,7 +227,7 @@ void BasicAttackBehavior::DoBehaviorCalculation(BehaviorContext* context, RakNet
bitStream.Write(armorDamageDealt);
bitStream.Write(healthDamageDealt);
bitStream.Write(targetEntity->GetIsDead());
bitStream.Write(targetEntity->GetComponent<DestroyableComponent>()->GetIsDead());
}
bitStream.Write(successState);

View File

@@ -116,7 +116,7 @@ void TacArcBehavior::Calculate(BehaviorContext* context, RakNet::BitStream& bitS
for (auto validTarget : validTargets) {
if (targets.size() >= this->m_maxTargets) break;
if (std::find(targets.begin(), targets.end(), validTarget) != targets.end()) continue;
if (validTarget->GetIsDead()) continue;
if (validTarget->GetComponent<DestroyableComponent>()->GetIsDead()) continue;
const auto targetPos = validTarget->GetPosition();

View File

@@ -193,7 +193,7 @@ void BaseCombatAIComponent::Update(const float deltaTime) {
m_SoftTimer -= deltaTime;
}
if (m_Disabled || m_Parent->GetIsDead())
if (m_Disabled || m_Parent->GetComponent<DestroyableComponent>()->GetIsDead())
return;
bool stunnedThisFrame = m_Stunned;
CalculateCombat(deltaTime); // Putting this here for now

View File

@@ -160,7 +160,7 @@ void GameMessageHandler::HandleMessage(RakNet::BitStream& inStream, const System
}
//Kill player if health == 0
if (entity->GetIsDead()) {
if (entity->GetComponent<DestroyableComponent>()->GetIsDead()) {
entity->Smash(entity->GetObjectID());
}