Added check to prevent accidental sentinel passive proc (#396)

* Added check to prevent accidental sentinel passive proc

Added a boolean to check if the player is at zero armor already and if so, do not trigger the passive ability.

* Renamed variable and condensed armor check
This commit is contained in:
David Markowitz 2022-02-05 03:59:07 -08:00 committed by GitHub
parent fe178bf745
commit 6ba9eea993
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -245,6 +245,9 @@ void DestroyableComponent::SetMaxHealth(float value, bool playAnim) {
void DestroyableComponent::SetArmor(int32_t value) { void DestroyableComponent::SetArmor(int32_t value) {
m_DirtyHealth = true; m_DirtyHealth = true;
// If Destroyable Component already has zero armor do not trigger the passive ability again.
bool hadArmor = m_iArmor > 0;
auto* characterComponent = m_Parent->GetComponent<CharacterComponent>(); auto* characterComponent = m_Parent->GetComponent<CharacterComponent>();
if (characterComponent != nullptr) { if (characterComponent != nullptr) {
characterComponent->TrackArmorDelta(value - m_iArmor); characterComponent->TrackArmorDelta(value - m_iArmor);
@ -253,7 +256,7 @@ void DestroyableComponent::SetArmor(int32_t value) {
m_iArmor = value; m_iArmor = value;
auto* inventroyComponent = m_Parent->GetComponent<InventoryComponent>(); auto* inventroyComponent = m_Parent->GetComponent<InventoryComponent>();
if (m_iArmor == 0 && inventroyComponent != nullptr) { if (m_iArmor == 0 && inventroyComponent != nullptr && hadArmor) {
inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor); inventroyComponent->TriggerPassiveAbility(PassiveAbilityTrigger::SentinelArmor);
} }
} }