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) { if (GetComponent<BaseCombatAIComponent>() != nullptr) {
const auto index = std::find(m_TargetsInPhantom.begin(), m_TargetsInPhantom.end(), otherEntity); 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) { void Entity::AddLootItem(const Loot::Info& info) {
if (!IsPlayer()) return; if (!IsPlayer()) return;

View File

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

View File

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

View File

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

View File

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

View File

@ -16,7 +16,7 @@ void BaseEnemyApe::OnStartup(Entity* self) {
void BaseEnemyApe::OnDie(Entity* self, Entity* killer) { void BaseEnemyApe::OnDie(Entity* self, Entity* killer) {
auto* anchor = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"QB")); auto* anchor = Game::entityManager->GetEntity(self->GetVar<LWOOBJID>(u"QB"));
if (anchor != nullptr && !anchor->GetIsDead()) { if (anchor != nullptr && !anchor->GetComponent<DestroyableComponent>()->GetIsDead()) {
anchor->Smash(self->GetObjectID(), eKillType::SILENT); anchor->Smash(self->GetObjectID(), eKillType::SILENT);
} }
} }

View File

@ -152,13 +152,13 @@ void AmSkullkinDrill::FreezePlayer(Entity* self, Entity* player, bool bFreeze) {
auto StateChangeType = eStateChangeType::POP; auto StateChangeType = eStateChangeType::POP;
if (bFreeze) { if (bFreeze) {
if (player->GetIsDead()) { if (player->GetComponent<DestroyableComponent>()->GetIsDead()) {
return; return;
} }
StateChangeType = eStateChangeType::PUSH; StateChangeType = eStateChangeType::PUSH;
} else { } else {
if (player->GetIsDead()) { if (player->GetComponent<DestroyableComponent>()->GetIsDead()) {
// //
} }
} }

View File

@ -54,7 +54,7 @@ void AgSurvivalBuffStation::OnTimerDone(Entity* self, std::string timerName) {
auto team = self->GetVar<std::vector<LWOOBJID>>(u"BuilderTeam"); auto team = self->GetVar<std::vector<LWOOBJID>>(u"BuilderTeam");
for (auto memberID : team) { for (auto memberID : team) {
auto member = Game::entityManager->GetEntity(memberID); auto member = Game::entityManager->GetEntity(memberID);
if (member != nullptr && !member->GetIsDead()) { if (member != nullptr && !member->GetComponent<DestroyableComponent>()->GetIsDead()) {
GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition()); GameMessages::SendDropClientLoot(member, self->GetObjectID(), powerupToDrop, 0, self->GetPosition());
} }
} }

View File

@ -315,7 +315,7 @@ bool BaseSurvivalServer::CheckAllPlayersDead() {
for (const auto& playerID : state.players) { for (const auto& playerID : state.players) {
auto* player = Game::entityManager->GetEntity(playerID); auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr || player->GetIsDead()) { if (player == nullptr || player->GetComponent<DestroyableComponent>()->GetIsDead()) {
deadPlayers++; deadPlayers++;
} }
} }

View File

@ -310,7 +310,7 @@ bool BaseWavesServer::CheckAllPlayersDead() {
for (const auto& playerID : state.players) { for (const auto& playerID : state.players) {
auto* player = Game::entityManager->GetEntity(playerID); auto* player = Game::entityManager->GetEntity(playerID);
if (player == nullptr || player->GetIsDead()) { if (player == nullptr || player->GetComponent<DestroyableComponent>()->GetIsDead()) {
deadPlayers++; deadPlayers++;
} }
} }
@ -431,7 +431,7 @@ void BaseWavesServer::SpawnWave(Entity* self) {
for (const auto& playerID : state.players) { for (const auto& playerID : state.players) {
auto* player = Game::entityManager->GetEntity(playerID); auto* player = Game::entityManager->GetEntity(playerID);
if (player && player->GetIsDead()) { if (player && player->GetComponent<DestroyableComponent>()->GetIsDead()) {
player->Resurrect(); player->Resurrect();
} }
} }
@ -501,7 +501,7 @@ bool BaseWavesServer::UpdateSpawnedEnemies(Entity* self, LWOOBJID enemyID, uint3
for (const auto& playerID : state.players) { for (const auto& playerID : state.players) {
auto* player = Game::entityManager->GetEntity(playerID); auto* player = Game::entityManager->GetEntity(playerID);
if (player != nullptr && !player->GetIsDead()) { if (player != nullptr && !player->GetComponent<DestroyableComponent>()->GetIsDead()) {
SetActivityValue(self, playerID, 1, currentTime); SetActivityValue(self, playerID, 1, currentTime);
SetActivityValue(self, playerID, 2, state.waveNumber); SetActivityValue(self, playerID, 2, state.waveNumber);

View File

@ -1,9 +1,9 @@
#include "ActPlayerDeathTrigger.h" #include "ActPlayerDeathTrigger.h"
#include "DestroyableComponent.h"
#include "Entity.h" #include "Entity.h"
void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { void ActPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
if (!target->IsPlayer() || target->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready if (!target->IsPlayer() || target->GetComponent<DestroyableComponent>()->GetIsDead() || !target->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
target->Smash(self->GetObjectID(), eKillType::SILENT); target->Smash(self->GetObjectID(), eKillType::SILENT);
} }

View File

@ -1,4 +1,5 @@
#include "ActSharkPlayerDeathTrigger.h" #include "ActSharkPlayerDeathTrigger.h"
#include "DestroyableComponent.h"
#include "MissionComponent.h" #include "MissionComponent.h"
#include "eMissionTaskType.h" #include "eMissionTaskType.h"
#include "Entity.h" #include "Entity.h"
@ -11,7 +12,7 @@ void ActSharkPlayerDeathTrigger::OnFireEventServerSide(Entity* self, Entity* sen
missionComponent->Progress(eMissionTaskType::SCRIPT, 8419); missionComponent->Progress(eMissionTaskType::SCRIPT, 8419);
if (sender->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready if (sender->GetComponent<DestroyableComponent>()->GetIsDead() || !sender->GetPlayerReadyForUpdates()) return; //Don't kill already dead players or players not ready
if (sender->GetCharacter()) { if (sender->GetCharacter()) {
sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death"); sender->Smash(self->GetObjectID(), eKillType::VIOLENT, u"big-shark-death");

View File

@ -1,8 +1,9 @@
#include "AgShipPlayerDeathTrigger.h" #include "AgShipPlayerDeathTrigger.h"
#include "DestroyableComponent.h"
#include "Entity.h" #include "Entity.h"
void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) { void AgShipPlayerDeathTrigger::OnCollisionPhantom(Entity* self, Entity* target) {
if (target->GetLOT() == 1 && !target->GetIsDead()) { if (target->GetLOT() == 1 && !target->GetComponent<DestroyableComponent>()->GetIsDead()) {
target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death"); target->Smash(self->GetObjectID(), eKillType::VIOLENT, u"electro-shock-death");
} }
} }

View File

@ -1,4 +1,5 @@
#include "TriggerGas.h" #include "TriggerGas.h"
#include "DestroyableComponent.h"
#include "InventoryComponent.h" #include "InventoryComponent.h"
#include "SkillComponent.h" #include "SkillComponent.h"
#include "Entity.h" #include "Entity.h"
@ -28,7 +29,7 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
if (timerName != this->m_TimerName) return; if (timerName != this->m_TimerName) return;
auto players = self->GetVar<std::vector<Entity*>>(u"players"); auto players = self->GetVar<std::vector<Entity*>>(u"players");
for (auto player : players) { for (auto player : players) {
if (player->GetIsDead() || !player){ if (player->GetComponent<DestroyableComponent>()->GetIsDead() || !player){
auto position = std::find(players.begin(), players.end(), player); auto position = std::find(players.begin(), players.end(), player);
if (position != players.end()) players.erase(position); if (position != players.end()) players.erase(position);
continue; continue;
@ -46,4 +47,3 @@ void TriggerGas::OnTimerDone(Entity* self, std::string timerName) {
self->SetVar(u"players", players); self->SetVar(u"players", players);
self->AddTimer(this->m_TimerName, this->m_Time); self->AddTimer(this->m_TimerName, this->m_Time);
} }

View File

@ -1,6 +1,7 @@
#include "PetDigBuild.h" #include "PetDigBuild.h"
#include "EntityManager.h" #include "EntityManager.h"
#include "EntityInfo.h" #include "EntityInfo.h"
#include "DestroyableComponent.h"
#include "MissionComponent.h" #include "MissionComponent.h"
#include "eMissionState.h" #include "eMissionState.h"
@ -45,7 +46,7 @@ void PetDigBuild::OnDie(Entity* self, Entity* killer) {
return; return;
// If the quick build expired and the treasure was not collected, hide the treasure // If the quick build expired and the treasure was not collected, hide the treasure
if (!treasure->GetIsDead()) { if (!treasure->GetComponent<DestroyableComponent>()->GetIsDead()) {
treasure->Smash(self->GetObjectID(), eKillType::SILENT); treasure->Smash(self->GetObjectID(), eKillType::SILENT);
} }
} }

View File

@ -27,7 +27,7 @@ void NsConcertInstrument::OnQuickBuildNotifyState(Entity* self, eQuickBuildState
} }
void NsConcertInstrument::OnQuickBuildComplete(Entity* self, Entity* target) { void NsConcertInstrument::OnQuickBuildComplete(Entity* self, Entity* target) {
if (!target->GetIsDead()) { if (!target->GetComponent<DestroyableComponent>()->GetIsDead()) {
self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID()); self->SetVar<LWOOBJID>(u"activePlayer", target->GetObjectID());
self->AddCallbackTimer(0.2f, [self, target]() { self->AddCallbackTimer(0.2f, [self, target]() {