From: PrPleGoo Date: Thu, 4 Apr 2024 23:05:01 +0000 (+0200) Subject: Task/fix nightvision huds (#26726) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d314a41e4f5c166de5e59504090117435f6ba0c2;p=space-station-14.git Task/fix nightvision huds (#26726) * 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 --- diff --git a/Content.Client/Overlays/EntityHealthBarOverlay.cs b/Content.Client/Overlays/EntityHealthBarOverlay.cs index 9e562b5dd3..c1c0ae93ec 100644 --- a/Content.Client/Overlays/EntityHealthBarOverlay.cs +++ b/Content.Client/Overlays/EntityHealthBarOverlay.cs @@ -19,7 +19,6 @@ namespace Content.Client.Overlays; /// 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 DamageContainers = new(); - private readonly ShaderInstance _shader; public EntityHealthBarOverlay(IEntityManager entManager) { - IoCManager.InjectDependencies(this); _entManager = entManager; _transform = _entManager.System(); _mobStateSystem = _entManager.System(); _mobThresholdSystem = _entManager.System(); _progressColor = _entManager.System(); - _shader = _prototype.Index("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(); 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); } diff --git a/Content.Client/StatusIcon/StatusIconOverlay.cs b/Content.Client/StatusIcon/StatusIconOverlay.cs index 156212c55d..56107cbc02 100644 --- a/Content.Client/StatusIcon/StatusIconOverlay.cs +++ b/Content.Client/StatusIcon/StatusIconOverlay.cs @@ -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(); _transform = _entity.System(); _statusIcon = _entity.System(); - _shader = _prototype.Index("unshaded").Instance(); + _unshadedShader = _prototype.Index("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(); 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); + } } } diff --git a/Content.Shared/StatusIcon/StatusIconPrototype.cs b/Content.Shared/StatusIcon/StatusIconPrototype.cs index 428ca95082..145b443051 100644 --- a/Content.Shared/StatusIcon/StatusIconPrototype.cs +++ b/Content.Shared/StatusIcon/StatusIconPrototype.cs @@ -46,6 +46,12 @@ public partial class StatusIconData : IComparable /// [DataField] public int Offset = 0; + + /// + /// Sets if the icon should be rendered with or without the effect of lighting. + /// + [DataField] + public bool IsShaded = false; } /// diff --git a/Resources/Prototypes/StatusEffects/health.yml b/Resources/Prototypes/StatusEffects/health.yml index 12c16e57f0..562dbb336d 100644 --- a/Resources/Prototypes/StatusEffects/health.yml +++ b/Resources/Prototypes/StatusEffects/health.yml @@ -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 diff --git a/Resources/Prototypes/StatusEffects/hunger.yml b/Resources/Prototypes/StatusEffects/hunger.yml index 6436665713..9af246e06e 100644 --- a/Resources/Prototypes/StatusEffects/hunger.yml +++ b/Resources/Prototypes/StatusEffects/hunger.yml @@ -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 diff --git a/Resources/Prototypes/StatusEffects/job.yml b/Resources/Prototypes/StatusEffects/job.yml index 0811877ab5..aec3f5e69d 100644 --- a/Resources/Prototypes/StatusEffects/job.yml +++ b/Resources/Prototypes/StatusEffects/job.yml @@ -3,6 +3,7 @@ abstract: true priority: 1 locationPreference: Right + isShaded: true - type: statusIcon parent: JobIcon diff --git a/Resources/Prototypes/StatusEffects/security.yml b/Resources/Prototypes/StatusEffects/security.yml index 51d087104d..ca25f746f2 100644 --- a/Resources/Prototypes/StatusEffects/security.yml +++ b/Resources/Prototypes/StatusEffects/security.yml @@ -4,6 +4,7 @@ priority: 2 offset: 1 locationPreference: Right + isShaded: true - type: statusIcon parent: SecurityIcon