]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Improves Medical Hud interface and functionality (#26027)
authorDoutorWhite <68350815+DoutorWhite@users.noreply.github.com>
Mon, 18 Mar 2024 13:56:12 +0000 (10:56 -0300)
committerGitHub <noreply@github.com>
Mon, 18 Mar 2024 13:56:12 +0000 (00:56 +1100)
* 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

Content.Client/Overlays/ShowHealthIconsSystem.cs
Content.Shared/Damage/Components/DamageableComponent.cs
Resources/Prototypes/StatusEffects/health.yml
Resources/Textures/Interface/Misc/health_icons.rsi/Critical.png [new file with mode: 0644]
Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png [new file with mode: 0644]
Resources/Textures/Interface/Misc/health_icons.rsi/Fine.png
Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png [new file with mode: 0644]
Resources/Textures/Interface/Misc/health_icons.rsi/meta.json

index 6ed9d6a41db956eb056fcb4ea3f119f057af7f43..a546cf4d8281ae2559bdc11a3456ecd9797ef67a 100644 (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;
index f8ba661a6659b2ba5a4a50035f29bbf96adc00fe..be66d51e3bcf1b7a4f36b57d936dbbdad812a136 100644 (file)
@@ -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<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]
index 0a1df020c056d689dcf1228dd6780f1319d617bb..12c16e57f05517d5cfd384414ceb971c96148755 100644 (file)
@@ -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 (file)
index 0000000..779874e
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 (file)
index 0000000..beceebd
Binary files /dev/null and b/Resources/Textures/Interface/Misc/health_icons.rsi/Dead.png differ
index 8d07f93496e64642ba31441fa4f9881f5ca27c42..45725aa73c819040ef7f9209ce2df68bff32c47b 100644 (file)
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 (file)
index 0000000..8965b13
Binary files /dev/null and b/Resources/Textures/Interface/Misc/health_icons.rsi/Rotting.png differ
index 9bc63271451309f1af273d88808f92aad8318b86..fb584d6b7f37c8fe1033ae69c0c4097d66fffe54 100644 (file)
@@ -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
+}