Improves Medical Hud interface and functionality (#26027)

* Improvements to the medical hud interface

* Adds an icon for SSD players

* Indentation fix

* Update sprites, changes direction and adds new status icon.

* Adds decomposing icon

* Code cleaning

* Changes Crit Icon sprite

* Simplifies the decision structure

* Changes copyright line

* Changes Critical Icon sprite

* Makes the Critical Icon border darker

* Changes sprites to /tg/ station

* Updates copyright

* Makes Dead Icon animation slight faster

* Code cleaning

* Remove some unused imports

* Code cleaning and rename icon

* Minor code cleaning
This commit is contained in:
DoutorWhite
2024-03-18 10:56:12 -03:00
committed by GitHub
parent 29887636e5
commit 8d40bc36a9
8 changed files with 78 additions and 13 deletions

View File

@@ -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;
@@ -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();
@@ -45,18 +44,20 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo
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))
{
@@ -66,10 +67,16 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem<ShowHealthIconsCo
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;