Skip to content

Commit

Permalink
Mirror: Improves Medical Hud interface and functionality (#253)
Browse files Browse the repository at this point in the history
## Mirror of PR #26027: [Improves Medical Hud interface and
functionality](space-wizards/space-station-14#26027)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `8d40bc36a93d3d5c6d3ece6c662ac9747f7837ae`

PR opened by <img
src="https://avatars.githubusercontent.com/u/68350815?v=4"
width="16"/><a href="https://github.com/DoutorWhite"> DoutorWhite</a> at
2024-03-12 07:00:06 UTC

---

PR changed 8 files with 78 additions and 13 deletions.

The PR had the following labels:
- Changes: Sprites
- Status: Awaiting Changes


---

<details open="true"><summary><h1>Original Body</h1></summary>

> ## About the PR
> 
> There are some changes to the Medical Hud interface: The icon has been
changed and now there is one for each mob state, making it easier to
recognize whether the mob is rotting, dead or crit.
> 
> ## Why / Balance
> 
> It's more visually pleasing and helps with discerning mob states.
> 
> ## Technical details
> 
> There is a decision structure for determining which icon is
appropriate for the mob's state. It's the only relevant code change.
> 
> ## Media
> 
> ![Captura de tela 2024-03-13
230527](https://github.com/space-wizards/space-station-14/assets/68350815/9df6e598-94b7-4efa-81c6-020bf3a724e1)
> 
> - [X] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> 
> **Changelog**
> 
> 🆑
> - add: Introduce new health status icons.
> - tweak: Enhance the Medical HUD to display the health status of
players and mobs using the newly added icons.


</details>

Co-authored-by: SimpleStation14 <Unknown>
  • Loading branch information
SimpleStation14 authored May 12, 2024
1 parent 7f1bd0f commit 999ef0c
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 13 deletions.
25 changes: 16 additions & 9 deletions Content.Client/Overlays/ShowHealthIconsSystem.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Content.Shared.Atmos.Rotting;
using Content.Shared.Damage;
using Content.Shared.Inventory.Events;
using Content.Shared.Mobs.Components;
using Content.Shared.Overlays;
using Content.Shared.StatusIcon;
using Content.Shared.StatusIcon.Components;
Expand All @@ -17,9 +19,6 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo

public HashSet<string> DamageContainers = new();

[ValidatePrototypeId<StatusIconPrototype>]
private const string HealthIconFine = "HealthIconFine";

public override void Initialize()
{
base.Initialize();
Expand All @@ -45,18 +44,20 @@ protected override void DeactivateInternal()
DamageContainers.Clear();
}

private void OnGetStatusIconsEvent(EntityUid uid, DamageableComponent damageableComponent, ref GetStatusIconsEvent args)
private void OnGetStatusIconsEvent(Entity<DamageableComponent> entity, ref GetStatusIconsEvent args)
{
if (!IsActive || args.InContainer)
return;

var healthIcons = DecideHealthIcons(damageableComponent);
var healthIcons = DecideHealthIcons(entity);

args.StatusIcons.AddRange(healthIcons);
}

private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent damageableComponent)
private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(Entity<DamageableComponent> entity)
{
var damageableComponent = entity.Comp;

if (damageableComponent.DamageContainerID == null ||
!DamageContainers.Contains(damageableComponent.DamageContainerID))
{
Expand All @@ -66,10 +67,16 @@ private IReadOnlyList<StatusIconPrototype> DecideHealthIcons(DamageableComponent
var result = new List<StatusIconPrototype>();

// Here you could check health status, diseases, mind status, etc. and pick a good icon, or multiple depending on whatever.
if (damageableComponent?.DamageContainerID == "Biological" &&
_prototypeMan.TryIndex<StatusIconPrototype>(HealthIconFine, out var healthyIcon))
if (damageableComponent?.DamageContainerID == "Biological")
{
result.Add(healthyIcon);
if (TryComp<MobStateComponent>(entity, out var state))
{
// Since there is no MobState for a rotting mob, we have to deal with this case first.
if (HasComp<RottingComponent>(entity) && _prototypeMan.TryIndex(damageableComponent.RottingIcon, out var rottingIcon))
result.Add(rottingIcon);
else if (damageableComponent.HealthIcons.TryGetValue(state.CurrentState, out var value) && _prototypeMan.TryIndex(value, out var icon))
result.Add(icon);
}
}

return result;
Expand Down
16 changes: 15 additions & 1 deletion Content.Shared/Damage/Components/DamageableComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Mobs;
using Content.Shared.StatusIcon;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
Expand Down Expand Up @@ -62,7 +65,18 @@ public sealed partial class DamageableComponent : Component
public FixedPoint2 TotalDamage;

[DataField("radiationDamageTypes", customTypeSerializer: typeof(PrototypeIdListSerializer<DamageTypePrototype>))]
public List<string> RadiationDamageTypeIDs = new() {"Radiation"};
public List<string> RadiationDamageTypeIDs = new() { "Radiation" };

[DataField]
public Dictionary<MobState, ProtoId<StatusIconPrototype>> HealthIcons = new()
{
{ MobState.Alive, "HealthIconFine" },
{ MobState.Critical, "HealthIconCritical" },
{ MobState.Dead, "HealthIconDead" },
};

[DataField]
public ProtoId<StatusIconPrototype> RottingIcon = "HealthIconRotting";
}

[Serializable, NetSerializable]
Expand Down
27 changes: 26 additions & 1 deletion Resources/Prototypes/StatusEffects/health.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,29 @@
icon:
sprite: /Textures/Interface/Misc/health_icons.rsi
state: Fine
locationPreference: Right
locationPreference: Right

- type: statusIcon
id: HealthIconCritical
priority: 1
icon:
sprite: /Textures/Interface/Misc/health_icons.rsi
state: Critical
locationPreference: Right

- type: statusIcon
id: HealthIconDead
priority: 1
icon:
sprite: /Textures/Interface/Misc/health_icons.rsi
state: Dead
locationPreference: Right

- type: statusIcon
id: HealthIconRotting
priority: 1
icon:
sprite: /Textures/Interface/Misc/health_icons.rsi
state: Rotting
locationPreference: Right

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 21 additions & 2 deletions Resources/Textures/Interface/Misc/health_icons.rsi/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@
"y": 8
},
"license": "CC-BY-SA-3.0",
"copyright": "https://github.com/tgstation/tgstation/blob/master/icons/mob/huds/hud.dmi",
"copyright": "Taken from /tg/station at commit https://github.com/tgstation/tgstation/commit/20ae083f140ac5b4da7e8bc40f95349001b6c086",
"states": [
{
"name": "Fine"
},
{
"name": "Critical"
},
{
"name": "Dead",
"delays": [
[
0.125,
0.125,
0.125,
0.125,
0.125,
0.125
]
]
},
{
"name": "Rotting"
}
]
}
}

0 comments on commit 999ef0c

Please sign in to comment.