From 8d40bc36a93d3d5c6d3ece6c662ac9747f7837ae Mon Sep 17 00:00:00 2001 From: DoutorWhite <68350815+DoutorWhite@users.noreply.github.com> Date: Mon, 18 Mar 2024 10:56:12 -0300 Subject: [PATCH] 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 --- .../Overlays/ShowHealthIconsSystem.cs | 25 ++++++++++------ .../Damage/Components/DamageableComponent.cs | 16 ++++++++++- Resources/Prototypes/StatusEffects/health.yml | 27 +++++++++++++++++- .../Misc/health_icons.rsi/Critical.png | Bin 0 -> 125 bytes .../Interface/Misc/health_icons.rsi/Dead.png | Bin 0 -> 214 bytes .../Interface/Misc/health_icons.rsi/Fine.png | Bin 1120 -> 139 bytes .../Misc/health_icons.rsi/Rotting.png | Bin 0 -> 135 bytes .../Interface/Misc/health_icons.rsi/meta.json | 23 +++++++++++++-- 8 files changed, 78 insertions(+), 13 deletions(-) create mode 100644 Resources/Textures/Interface/Misc/health_icons.rsi/Critical.png create mode 100644 Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png create mode 100644 Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png diff --git a/Content.Client/Overlays/ShowHealthIconsSystem.cs b/Content.Client/Overlays/ShowHealthIconsSystem.cs index 6ed9d6a41db..a546cf4d828 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 @@ protected override void DeactivateInternal() DamageContainers.Clear(); } - private void OnGetStatusIconsEvent(EntityUid uid, DamageableComponent damageableComponent, ref GetStatusIconsEvent args) + private void OnGetStatusIconsEvent(Entity 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 @@ private IReadOnlyList DecideHealthIcons(DamageableComponent var result = new List(); // 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 f8ba661a665..be66d51e3bc 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 @@ public sealed partial class DamageableComponent : Component 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 0a1df020c05..12c16e57f05 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 0000000000000000000000000000000000000000..779874eaaeb3c64047fc7f01bc618725d36d2e7b GIT binary patch literal 125 zcmeAS@N?(olHy`uVBq!ia0vp^93afW1|*O0@9PFqE}kxqArezt`*({nC~z?IhaZ}G z=j7Z1HJzG&89UT`g_;<4tQ4ML#j;?>N@Iq%dv-aiswuB@JlEN=PImjkukq#1-&{|z Y1hPvq8@V+r1I=UbboFyt=akR{06Re@u>b%7 literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..beceebd05cf3cb07497ad0a16f286074c94c1a12 GIT binary patch literal 214 zcmeAS@N?(olHy`uVBq!ia0vp^20+Zg!3HGvYuC5~skxpmjv*Gk$tej52?hoqew=S$ zjoGoGxp2d2V=0M>KlKHVnanELSb3S*fS~Q5&iNLd4~d7E*KiefK4vB>{Ma|bSQ(T LtDnm{r-UW|I{QlO literal 0 HcmV?d00001 diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png b/Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png index 8d07f93496e64642ba31441fa4f9881f5ca27c42..45725aa73c819040ef7f9209ce2df68bff32c47b 100644 GIT binary patch delta 111 zcmV-#0FeLS2#W!bBWM6pNklx zuRG~JIs=e2m=F=xB@K56;J6+D?sHGiXtQLc*JP4<1C|XfH_PrvFB=U0Z@#wF7|rZT Ry&?br002ovPDHLkV1fYBDqa8p delta 1100 zcmV-S1he~#0pJLbBYy*qdQ@0+Qek%>aB^>EX>4U6ba`-PAZ2)IW&i+q+O3yslIti8 zh5u_6vjj^*JeGqERLu@%`E$U;d318SZ`+|_up+}jpOCw${`YUAfAEn-BRLDvC+`=0 zTyjY=265Rxd(Vp-*GF5wf3nl@gTSQdb-(p>`e)ef{y=ckzJEU3DQt6|I48QTJSWt? zvS2X%;+#ljxAVNGG@r}vLHhizW!h}-UhiE%Fp6P56_To~3$C%RqW!Cy(Fa^v1x~C9 zW2b)D<$dhv7`_DW7`?=9$4(yeCBDS2wGvya z`|h&yh?J+fsejv6#t4opLaF01j~4JXjKgRNEnQj zX~#sZ_0(lv;t?z8lAbk?(aH5Iya0sTjH!+Ijz$l8vwu8*RS>ih=7T0M*rDQ7I2F?Gh%86G*Wvg+zqTm2f=xTZC4NT1DZ zw)rh=aZ6h+QncXs7heLESW?NAD^jVtYSq_JV@)+Ty81k~6%oWh+L z2)fE*jSqHra)0DT=KhMCd?H63-4*1hqnqTua(hFq6DCzp3cZQWYxs1U3c|4uJm zAZF&#c`-u^T_EP3M<>M$Ep&mHr#$+dn1?*3vvuf}$8@$1-9*s^#c?nG7Zk@Kims{H zy{D4^000SaNLh0L01m_e01m_fl`9S#00007bV*G` z2j>S25iSD9jze_-002`-L_t&-(}j=04S*mJ1m}n?SQ15G2|TtK5-fotu(5@FKU;{YL>opGFfn^~8v>a(U&hhEXg8khrrPvMef+**P SP(L960000|*$lNmf+{an^LB{Ts5NEt6f literal 0 HcmV?d00001 diff --git a/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json b/Resources/Textures/Interface/Misc/health_icons.rsi/meta.json index 9bc63271451..fb584d6b7f3 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 +}