diff --git a/Content.Client/Overlays/ShowHealthIconsSystem.cs b/Content.Client/Overlays/ShowHealthIconsSystem.cs index 6ed9d6a41d..a546cf4d82 100644 --- a/Content.Client/Overlays/ShowHealthIconsSystem.cs +++ b/Content.Client/Overlays/ShowHealthIconsSystem.cs @@ -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 DamageContainers = new(); - [ValidatePrototypeId] - private const string HealthIconFine = "HealthIconFine"; - public override void Initialize() { base.Initialize(); @@ -45,18 +44,20 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem entity, ref GetStatusIconsEvent args) { if (!IsActive || args.InContainer) return; - var healthIcons = DecideHealthIcons(damageableComponent); + var healthIcons = DecideHealthIcons(entity); args.StatusIcons.AddRange(healthIcons); } - private IReadOnlyList DecideHealthIcons(DamageableComponent damageableComponent) + private IReadOnlyList DecideHealthIcons(Entity entity) { + var damageableComponent = entity.Comp; + if (damageableComponent.DamageContainerID == null || !DamageContainers.Contains(damageableComponent.DamageContainerID)) { @@ -66,10 +67,16 @@ public sealed class ShowHealthIconsSystem : EquipmentHudSystem(); // 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(HealthIconFine, out var healthyIcon)) + if (damageableComponent?.DamageContainerID == "Biological") { - result.Add(healthyIcon); + if (TryComp(entity, out var state)) + { + // Since there is no MobState for a rotting mob, we have to deal with this case first. + if (HasComp(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; diff --git a/Content.Shared/Damage/Components/DamageableComponent.cs b/Content.Shared/Damage/Components/DamageableComponent.cs index f8ba661a66..be66d51e3b 100644 --- a/Content.Shared/Damage/Components/DamageableComponent.cs +++ b/Content.Shared/Damage/Components/DamageableComponent.cs @@ -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; @@ -62,7 +65,18 @@ namespace Content.Shared.Damage public FixedPoint2 TotalDamage; [DataField("radiationDamageTypes", customTypeSerializer: typeof(PrototypeIdListSerializer))] - public List RadiationDamageTypeIDs = new() {"Radiation"}; + public List RadiationDamageTypeIDs = new() { "Radiation" }; + + [DataField] + public Dictionary> HealthIcons = new() + { + { MobState.Alive, "HealthIconFine" }, + { MobState.Critical, "HealthIconCritical" }, + { MobState.Dead, "HealthIconDead" }, + }; + + [DataField] + public ProtoId RottingIcon = "HealthIconRotting"; } [Serializable, NetSerializable] diff --git a/Resources/Prototypes/StatusEffects/health.yml b/Resources/Prototypes/StatusEffects/health.yml index 0a1df020c0..12c16e57f0 100644 --- a/Resources/Prototypes/StatusEffects/health.yml +++ b/Resources/Prototypes/StatusEffects/health.yml @@ -4,4 +4,29 @@ icon: sprite: /Textures/Interface/Misc/health_icons.rsi state: Fine - locationPreference: Right \ No newline at end of file + 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 + diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/Critical.png b/Resources/Textures/Interface/Misc/health_icons.rsi/Critical.png new file mode 100644 index 0000000000..779874eaae Binary files /dev/null and b/Resources/Textures/Interface/Misc/health_icons.rsi/Critical.png differ diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png b/Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png new file mode 100644 index 0000000000..beceebd05c Binary files /dev/null and b/Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png differ diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png b/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png index 8d07f93496..45725aa73c 100644 Binary files a/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png and b/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png differ diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png b/Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png new file mode 100644 index 0000000000..8965b1308d Binary files /dev/null and b/Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png differ diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json b/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json index 9bc6327145..fb584d6b7f 100644 --- a/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json +++ b/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json @@ -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" } ] -} \ No newline at end of file +}