]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Task/fix nightvision huds (#26726)
authorPrPleGoo <PrPleGoo@users.noreply.github.com>
Thu, 4 Apr 2024 23:05:01 +0000 (01:05 +0200)
committerGitHub <noreply@github.com>
Thu, 4 Apr 2024 23:05:01 +0000 (01:05 +0200)
* StatusIcon: add field to set if icon should be rendered with shading

* set/unset shader based on icon field

* set new field to true for hud icons

* re-shade health bars

Content.Client/Overlays/EntityHealthBarOverlay.cs
Content.Client/StatusIcon/StatusIconOverlay.cs
Content.Shared/StatusIcon/StatusIconPrototype.cs
Resources/Prototypes/StatusEffects/health.yml
Resources/Prototypes/StatusEffects/hunger.yml
Resources/Prototypes/StatusEffects/job.yml
Resources/Prototypes/StatusEffects/security.yml

index 9e562b5dd37cb776c4f128be4aaef42106f42a24..c1c0ae93ec1114bce4539cf0a63219c6f33fea67 100644 (file)
@@ -19,7 +19,6 @@ namespace Content.Client.Overlays;
 /// </summary>
 public sealed class EntityHealthBarOverlay : Overlay
 {
-    [Dependency] private readonly IPrototypeManager _prototype = default!;
     private readonly IEntityManager _entManager;
     private readonly SharedTransformSystem _transform;
     private readonly MobStateSystem _mobStateSystem;
@@ -27,17 +26,14 @@ public sealed class EntityHealthBarOverlay : Overlay
     private readonly ProgressColorSystem _progressColor;
     public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
     public HashSet<string> DamageContainers = new();
-    private readonly ShaderInstance _shader;
 
     public EntityHealthBarOverlay(IEntityManager entManager)
     {
-        IoCManager.InjectDependencies(this);
         _entManager = entManager;
         _transform = _entManager.System<SharedTransformSystem>();
         _mobStateSystem = _entManager.System<MobStateSystem>();
         _mobThresholdSystem = _entManager.System<MobThresholdSystem>();
         _progressColor = _entManager.System<ProgressColorSystem>();
-        _shader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
     }
 
     protected override void Draw(in OverlayDrawArgs args)
@@ -50,8 +46,6 @@ public sealed class EntityHealthBarOverlay : Overlay
         var scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale));
         var rotationMatrix = Matrix3.CreateRotation(-rotation);
 
-        handle.UseShader(_shader);
-
         var query = _entManager.AllEntityQueryEnumerator<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>();
         while (query.MoveNext(out var uid,
             out var mobThresholdsComponent,
@@ -122,7 +116,6 @@ public sealed class EntityHealthBarOverlay : Overlay
             handle.DrawRect(pixelDarken, Black.WithAlpha(128));
         }
 
-        handle.UseShader(null);
         handle.SetTransform(Matrix3.Identity);
     }
 
index 156212c55d3876f71a1488c7ecd85f664ee7ffa8..56107cbc02570259acc0040cb593df2a87abc8d9 100644 (file)
@@ -3,9 +3,9 @@ using Content.Shared.StatusIcon.Components;
 using Robust.Client.GameObjects;
 using Robust.Client.Graphics;
 using Robust.Shared.Enums;
-using System.Numerics;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Timing;
+using System.Numerics;
 
 namespace Content.Client.StatusIcon;
 
@@ -18,7 +18,7 @@ public sealed class StatusIconOverlay : Overlay
     private readonly SpriteSystem _sprite;
     private readonly TransformSystem _transform;
     private readonly StatusIconSystem _statusIcon;
-    private readonly ShaderInstance _shader;
+    private readonly ShaderInstance _unshadedShader;
 
     public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
 
@@ -29,7 +29,7 @@ public sealed class StatusIconOverlay : Overlay
         _sprite = _entity.System<SpriteSystem>();
         _transform = _entity.System<TransformSystem>();
         _statusIcon = _entity.System<StatusIconSystem>();
-        _shader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
+        _unshadedShader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
     }
 
     protected override void Draw(in OverlayDrawArgs args)
@@ -42,8 +42,6 @@ public sealed class StatusIconOverlay : Overlay
         var scaleMatrix = Matrix3.CreateScale(new Vector2(1, 1));
         var rotationMatrix = Matrix3.CreateRotation(-eyeRot);
 
-        handle.UseShader(_shader);
-
         var query = _entity.AllEntityQueryEnumerator<StatusIconComponent, SpriteComponent, TransformComponent, MetaDataComponent>();
         while (query.MoveNext(out var uid, out var comp, out var sprite, out var xform, out var meta))
         {
@@ -111,11 +109,16 @@ public sealed class StatusIconOverlay : Overlay
 
                 }
 
+                if (proto.IsShaded)
+                    handle.UseShader(null);
+                else
+                    handle.UseShader(_unshadedShader);
+
                 var position = new Vector2(xOffset, yOffset);
                 handle.DrawTexture(texture, position);
             }
-        }
 
-        handle.UseShader(null);
+            handle.UseShader(null);
+        }
     }
 }
index 428ca950823734fa8779827e812a40aff46f613e..145b443051cbccac26a2ecddbca56d86fd9601e9 100644 (file)
@@ -46,6 +46,12 @@ public partial class StatusIconData : IComparable<StatusIconData>
     /// </summary>
     [DataField]
     public int Offset = 0;
+
+    /// <summary>
+    /// Sets if the icon should be rendered with or without the effect of lighting.
+    /// </summary>
+    [DataField]
+    public bool IsShaded = false;
 }
 
 /// <summary>
index 12c16e57f05517d5cfd384414ceb971c96148755..562dbb336d81124a231baf479f3da7f758e94969 100644 (file)
@@ -1,32 +1,35 @@
 - type: statusIcon
-  id: HealthIconFine
+  id: HealthIcon
+  abstract: true
   priority: 1
+  locationPreference: Right
+  isShaded: true
+
+- type: statusIcon
+  parent: HealthIcon
+  id: HealthIconFine
   icon:
     sprite: /Textures/Interface/Misc/health_icons.rsi
     state: Fine
-  locationPreference: Right
 
 - type: statusIcon
   id: HealthIconCritical
-  priority: 1
+  parent: HealthIcon
   icon:
     sprite: /Textures/Interface/Misc/health_icons.rsi
     state: Critical
-  locationPreference: Right
 
 - type: statusIcon
   id: HealthIconDead
-  priority: 1
+  parent: HealthIcon
   icon:
     sprite: /Textures/Interface/Misc/health_icons.rsi
     state: Dead
-  locationPreference: Right
 
 - type: statusIcon
   id: HealthIconRotting
-  priority: 1
+  parent: HealthIcon
   icon:
     sprite: /Textures/Interface/Misc/health_icons.rsi
     state: Rotting
-  locationPreference: Right
 
index 6436665713215ccf220b5524a3b9a47df2470595..9af246e06ee6eca7209be42db6c2d390eda2a303 100644 (file)
@@ -1,49 +1,57 @@
 #Hunger
 - type: statusIcon
-  id: HungerIconOverfed
+  id: HungerIcon
+  abstract: true
   priority: 5
+  locationPreference: Right
+  isShaded: true
+
+- type: statusIcon
+  id: HungerIconOverfed
+  parent: HungerIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: overfed
-  locationPreference: Right
 
 - type: statusIcon
   id: HungerIconPeckish
-  priority: 5
+  parent: HungerIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: peckish
-  locationPreference: Right
 
 - type: statusIcon
   id: HungerIconStarving
-  priority: 5
+  parent: HungerIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: starving
-  locationPreference: Right
 
 #Thirst
 - type: statusIcon
-  id: ThirstIconOverhydrated
+  id: ThirstIcon
+  abstract: true
   priority: 5
+  locationPreference: Left
+  isShaded: true
+
+- type: statusIcon
+  id: ThirstIconOverhydrated
+  parent: ThirstIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: overhydrated
-  locationPreference: Left
 
 - type: statusIcon
   id: ThirstIconThirsty
-  priority: 5
+  parent: ThirstIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: thirsty
-  locationPreference: Left
 
 - type: statusIcon
   id: ThirstIconParched
-  priority: 5
+  parent: ThirstIcon
   icon:
     sprite: /Textures/Interface/Misc/food_icons.rsi
     state: parched
-  locationPreference: Left
index 0811877ab5bd581d1149f52d140401bcba0c107f..aec3f5e69d525888fc260c3663086b291af78ac5 100644 (file)
@@ -3,6 +3,7 @@
   abstract: true
   priority: 1
   locationPreference: Right
+  isShaded: true
 
 - type: statusIcon
   parent: JobIcon
index 51d087104d52216f9930e2d1ef880e9cde7ebaa8..ca25f746f2585f69f8e181e75f40f3b09c064198 100644 (file)
@@ -4,6 +4,7 @@
   priority: 2
   offset: 1
   locationPreference: Right
+  isShaded: true
 
 - type: statusIcon
   parent: SecurityIcon