From bea5f133ed244dec4890fe0d64f49db889be2bb9 Mon Sep 17 00:00:00 2001 From: sleepyyapril <123355664+sleepyyapril@users.noreply.github.com> Date: Sun, 17 Nov 2024 22:17:27 -0400 Subject: [PATCH] Hotfix Stamina System (#1245) # Description Goal of this PR is to fix the stamina system, as was caused by #1220. --- # Changelog :cl: - fix: Fixed stamina system Co-authored-by: sleepyyapril --- Content.Shared/Damage/Systems/StaminaSystem.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Damage/Systems/StaminaSystem.cs b/Content.Shared/Damage/Systems/StaminaSystem.cs index 40d1c77314f..4f0b0061916 100644 --- a/Content.Shared/Damage/Systems/StaminaSystem.cs +++ b/Content.Shared/Damage/Systems/StaminaSystem.cs @@ -84,7 +84,8 @@ private void OnShutdown(EntityUid uid, StaminaComponent component, ComponentShut { RemCompDeferred(uid); } - _alerts.ClearAlert(uid, component.StaminaAlert); + + SetStaminaAlert(uid); } private void OnStartup(EntityUid uid, StaminaComponent component, ComponentStartup args) @@ -229,7 +230,10 @@ private void OnCollide(EntityUid uid, StaminaDamageOnCollideComponent component, private void SetStaminaAlert(EntityUid uid, StaminaComponent? component = null) { if (!Resolve(uid, ref component, false) || component.Deleted) + { + _alerts.ClearAlert(uid, "Stamina"); return; + } var severity = ContentHelpers.RoundToLevels(MathF.Max(0f, component.CritThreshold - component.StaminaDamage), component.CritThreshold, 7); _alerts.ShowAlert(uid, component.StaminaAlert, (short) severity); @@ -420,7 +424,6 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null) component.NextUpdate = _timing.CurTime; _movementSpeed.RefreshMovementSpeedModifiers(uid); SetStaminaAlert(uid, component); - RemComp(uid); Dirty(uid, component); _adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit"); } @@ -430,4 +433,4 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null) /// Raised before stamina damage is dealt to allow other systems to cancel it. /// [ByRefEvent] -public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false); +public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false); \ No newline at end of file