resimmed offmed

This commit is contained in:
Janet Blackquill
2025-10-06 01:55:42 -04:00
parent 847154b320
commit 173f24590f
84 changed files with 1210 additions and 1004 deletions

View File

@@ -18,6 +18,7 @@ public sealed class HeartrateOverlay : Overlay
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IPrototypeManager _prototype = default!;
private readonly HeartSystem _heart;
private readonly SharedTransformSystem _transform;
private readonly SpriteSystem _sprite;
private readonly StatusIconSystem _statusIcon;
@@ -32,6 +33,7 @@ public sealed class HeartrateOverlay : Overlay
private static readonly SpriteSpecifier HudPoor = new SpriteSpecifier.Rsi(new("/Textures/_Offbrand/heart_rate_hud.rsi"), "hud_poor");
private static readonly SpriteSpecifier HudBad = new SpriteSpecifier.Rsi(new("/Textures/_Offbrand/heart_rate_hud.rsi"), "hud_bad");
private static readonly SpriteSpecifier HudDanger = new SpriteSpecifier.Rsi(new("/Textures/_Offbrand/heart_rate_hud.rsi"), "hud_danger");
private static readonly IReadOnlyList<SpriteSpecifier> Severities = new List<SpriteSpecifier>() { HudGood, HudOkay, HudPoor, HudBad, HudDanger };
public HeartrateOverlay()
{
@@ -40,19 +42,17 @@ public sealed class HeartrateOverlay : Overlay
_transform = _entityManager.System<SharedTransformSystem>();
_sprite = _entityManager.System<SpriteSystem>();
_statusIcon = _entityManager.System<StatusIconSystem>();
_heart = _entityManager.System<HeartSystem>();
}
private SpriteSpecifier GetIcon(Entity<HeartrateComponent> ent)
{
var strain = ent.Comp.Strain;
return strain.Double() switch {
_ when !ent.Comp.Running => HudStopped,
>= 4 => HudDanger,
>= 3 => HudBad,
>= 2 => HudPoor,
>= 1 => HudOkay,
_ => HudGood,
};
if (!ent.Comp.Running)
return HudStopped;
var max = 4;
var severity = Math.Min((int)Math.Round(max * _heart.Strain(ent)), max);
return Severities[severity];
}
protected override void Draw(in OverlayDrawArgs args)