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
This commit is contained in:
PrPleGoo
2024-04-05 01:05:01 +02:00
committed by GitHub
parent bb1cb18aaf
commit d314a41e4f
7 changed files with 49 additions and 34 deletions

View File

@@ -19,7 +19,6 @@ namespace Content.Client.Overlays;
/// </summary> /// </summary>
public sealed class EntityHealthBarOverlay : Overlay public sealed class EntityHealthBarOverlay : Overlay
{ {
[Dependency] private readonly IPrototypeManager _prototype = default!;
private readonly IEntityManager _entManager; private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform; private readonly SharedTransformSystem _transform;
private readonly MobStateSystem _mobStateSystem; private readonly MobStateSystem _mobStateSystem;
@@ -27,17 +26,14 @@ public sealed class EntityHealthBarOverlay : Overlay
private readonly ProgressColorSystem _progressColor; private readonly ProgressColorSystem _progressColor;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
public HashSet<string> DamageContainers = new(); public HashSet<string> DamageContainers = new();
private readonly ShaderInstance _shader;
public EntityHealthBarOverlay(IEntityManager entManager) public EntityHealthBarOverlay(IEntityManager entManager)
{ {
IoCManager.InjectDependencies(this);
_entManager = entManager; _entManager = entManager;
_transform = _entManager.System<SharedTransformSystem>(); _transform = _entManager.System<SharedTransformSystem>();
_mobStateSystem = _entManager.System<MobStateSystem>(); _mobStateSystem = _entManager.System<MobStateSystem>();
_mobThresholdSystem = _entManager.System<MobThresholdSystem>(); _mobThresholdSystem = _entManager.System<MobThresholdSystem>();
_progressColor = _entManager.System<ProgressColorSystem>(); _progressColor = _entManager.System<ProgressColorSystem>();
_shader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
} }
protected override void Draw(in OverlayDrawArgs args) 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 scaleMatrix = Matrix3.CreateScale(new Vector2(scale, scale));
var rotationMatrix = Matrix3.CreateRotation(-rotation); var rotationMatrix = Matrix3.CreateRotation(-rotation);
handle.UseShader(_shader);
var query = _entManager.AllEntityQueryEnumerator<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>(); var query = _entManager.AllEntityQueryEnumerator<MobThresholdsComponent, MobStateComponent, DamageableComponent, SpriteComponent>();
while (query.MoveNext(out var uid, while (query.MoveNext(out var uid,
out var mobThresholdsComponent, out var mobThresholdsComponent,
@@ -122,7 +116,6 @@ public sealed class EntityHealthBarOverlay : Overlay
handle.DrawRect(pixelDarken, Black.WithAlpha(128)); handle.DrawRect(pixelDarken, Black.WithAlpha(128));
} }
handle.UseShader(null);
handle.SetTransform(Matrix3.Identity); handle.SetTransform(Matrix3.Identity);
} }

View File

@@ -3,9 +3,9 @@ using Content.Shared.StatusIcon.Components;
using Robust.Client.GameObjects; using Robust.Client.GameObjects;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using System.Numerics;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using System.Numerics;
namespace Content.Client.StatusIcon; namespace Content.Client.StatusIcon;
@@ -18,7 +18,7 @@ public sealed class StatusIconOverlay : Overlay
private readonly SpriteSystem _sprite; private readonly SpriteSystem _sprite;
private readonly TransformSystem _transform; private readonly TransformSystem _transform;
private readonly StatusIconSystem _statusIcon; private readonly StatusIconSystem _statusIcon;
private readonly ShaderInstance _shader; private readonly ShaderInstance _unshadedShader;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV; public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
@@ -29,7 +29,7 @@ public sealed class StatusIconOverlay : Overlay
_sprite = _entity.System<SpriteSystem>(); _sprite = _entity.System<SpriteSystem>();
_transform = _entity.System<TransformSystem>(); _transform = _entity.System<TransformSystem>();
_statusIcon = _entity.System<StatusIconSystem>(); _statusIcon = _entity.System<StatusIconSystem>();
_shader = _prototype.Index<ShaderPrototype>("unshaded").Instance(); _unshadedShader = _prototype.Index<ShaderPrototype>("unshaded").Instance();
} }
protected override void Draw(in OverlayDrawArgs args) 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 scaleMatrix = Matrix3.CreateScale(new Vector2(1, 1));
var rotationMatrix = Matrix3.CreateRotation(-eyeRot); var rotationMatrix = Matrix3.CreateRotation(-eyeRot);
handle.UseShader(_shader);
var query = _entity.AllEntityQueryEnumerator<StatusIconComponent, SpriteComponent, TransformComponent, MetaDataComponent>(); 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)) 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); var position = new Vector2(xOffset, yOffset);
handle.DrawTexture(texture, position); handle.DrawTexture(texture, position);
} }
}
handle.UseShader(null); handle.UseShader(null);
} }
} }
}

View File

@@ -46,6 +46,12 @@ public partial class StatusIconData : IComparable<StatusIconData>
/// </summary> /// </summary>
[DataField] [DataField]
public int Offset = 0; 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> /// <summary>

View File

@@ -1,32 +1,35 @@
- type: statusIcon - type: statusIcon
id: HealthIconFine id: HealthIcon
abstract: true
priority: 1 priority: 1
locationPreference: Right
isShaded: true
- type: statusIcon
parent: HealthIcon
id: HealthIconFine
icon: icon:
sprite: /Textures/Interface/Misc/health_icons.rsi sprite: /Textures/Interface/Misc/health_icons.rsi
state: Fine state: Fine
locationPreference: Right
- type: statusIcon - type: statusIcon
id: HealthIconCritical id: HealthIconCritical
priority: 1 parent: HealthIcon
icon: icon:
sprite: /Textures/Interface/Misc/health_icons.rsi sprite: /Textures/Interface/Misc/health_icons.rsi
state: Critical state: Critical
locationPreference: Right
- type: statusIcon - type: statusIcon
id: HealthIconDead id: HealthIconDead
priority: 1 parent: HealthIcon
icon: icon:
sprite: /Textures/Interface/Misc/health_icons.rsi sprite: /Textures/Interface/Misc/health_icons.rsi
state: Dead state: Dead
locationPreference: Right
- type: statusIcon - type: statusIcon
id: HealthIconRotting id: HealthIconRotting
priority: 1 parent: HealthIcon
icon: icon:
sprite: /Textures/Interface/Misc/health_icons.rsi sprite: /Textures/Interface/Misc/health_icons.rsi
state: Rotting state: Rotting
locationPreference: Right

View File

@@ -1,49 +1,57 @@
#Hunger #Hunger
- type: statusIcon - type: statusIcon
id: HungerIconOverfed id: HungerIcon
abstract: true
priority: 5 priority: 5
locationPreference: Right
isShaded: true
- type: statusIcon
id: HungerIconOverfed
parent: HungerIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: overfed state: overfed
locationPreference: Right
- type: statusIcon - type: statusIcon
id: HungerIconPeckish id: HungerIconPeckish
priority: 5 parent: HungerIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: peckish state: peckish
locationPreference: Right
- type: statusIcon - type: statusIcon
id: HungerIconStarving id: HungerIconStarving
priority: 5 parent: HungerIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: starving state: starving
locationPreference: Right
#Thirst #Thirst
- type: statusIcon - type: statusIcon
id: ThirstIconOverhydrated id: ThirstIcon
abstract: true
priority: 5 priority: 5
locationPreference: Left
isShaded: true
- type: statusIcon
id: ThirstIconOverhydrated
parent: ThirstIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: overhydrated state: overhydrated
locationPreference: Left
- type: statusIcon - type: statusIcon
id: ThirstIconThirsty id: ThirstIconThirsty
priority: 5 parent: ThirstIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: thirsty state: thirsty
locationPreference: Left
- type: statusIcon - type: statusIcon
id: ThirstIconParched id: ThirstIconParched
priority: 5 parent: ThirstIcon
icon: icon:
sprite: /Textures/Interface/Misc/food_icons.rsi sprite: /Textures/Interface/Misc/food_icons.rsi
state: parched state: parched
locationPreference: Left

View File

@@ -3,6 +3,7 @@
abstract: true abstract: true
priority: 1 priority: 1
locationPreference: Right locationPreference: Right
isShaded: true
- type: statusIcon - type: statusIcon
parent: JobIcon parent: JobIcon

View File

@@ -4,6 +4,7 @@
priority: 2 priority: 2
offset: 1 offset: 1
locationPreference: Right locationPreference: Right
isShaded: true
- type: statusIcon - type: statusIcon
parent: SecurityIcon parent: SecurityIcon