Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix Stamina System #1245

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Content.Shared/Damage/Systems/StaminaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ private void OnShutdown(EntityUid uid, StaminaComponent component, ComponentShut
{
RemCompDeferred<ActiveStaminaComponent>(uid);
}
_alerts.ClearAlert(uid, component.StaminaAlert);

SetStaminaAlert(uid);
}

private void OnStartup(EntityUid uid, StaminaComponent component, ComponentStartup args)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -420,7 +424,6 @@ private void ExitStamCrit(EntityUid uid, StaminaComponent? component = null)
component.NextUpdate = _timing.CurTime;
_movementSpeed.RefreshMovementSpeedModifiers(uid);
SetStaminaAlert(uid, component);
RemComp<ActiveStaminaComponent>(uid);
Dirty(uid, component);
_adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
}
Expand All @@ -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.
/// </summary>
[ByRefEvent]
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);
Loading