Make it possible to hide full health bars below a total damage threshold (#28127)

* Make it possible to hide full health bars below a total damage threshold

* Fix not setting state
This commit is contained in:
DrSmugleaf
2024-05-25 14:07:27 -07:00
committed by GitHub
parent f84e87a010
commit 436344c36d
3 changed files with 29 additions and 23 deletions

View File

@@ -1,5 +1,4 @@
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Inventory;
@@ -229,12 +228,12 @@ namespace Content.Shared.Damage
{
if (_netMan.IsServer)
{
args.State = new DamageableComponentState(component.Damage.DamageDict, component.DamageModifierSetId);
args.State = new DamageableComponentState(component.Damage.DamageDict, component.DamageModifierSetId, component.HealthBarThreshold);
}
else
{
// avoid mispredicting damage on newly spawned entities.
args.State = new DamageableComponentState(component.Damage.DamageDict.ShallowClone(), component.DamageModifierSetId);
args.State = new DamageableComponentState(component.Damage.DamageDict.ShallowClone(), component.DamageModifierSetId, component.HealthBarThreshold);
}
}
@@ -268,6 +267,7 @@ namespace Content.Shared.Damage
}
component.DamageModifierSetId = state.ModifierSetId;
component.HealthBarThreshold = state.HealthBarThreshold;
// Has the damage actually changed?
DamageSpecifier newDamage = new() { DamageDict = new(state.DamageDict) };