From 42dce359e5ff27cfe0e9d8dcf2ed3944c9ce68a4 Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Fri, 2 May 2025 00:07:47 +0200 Subject: [PATCH] Add noir glasses (#36923) hardboiled --- .../Overlays/BlackAndWhiteOverlay.cs | 47 ++++++++++++++++++ .../Overlays/BlackAndWhiteOverlaySystem.cs | 34 +++++++++++++ .../Inventory/InventorySystem.Relay.cs | 1 + .../Overlays/BlackAndWhiteOverlayComponent.cs | 10 ++++ .../Catalog/Fills/Lockers/security.yml | 3 +- .../Entities/Clothing/Eyes/glasses.yml | 21 ++++++++ .../Eyes/Glasses/noir.rsi/equipped-EYES.png | Bin 0 -> 321 bytes .../Clothing/Eyes/Glasses/noir.rsi/icon.png | Bin 0 -> 279 bytes .../Clothing/Eyes/Glasses/noir.rsi/meta.json | 18 +++++++ 9 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 Content.Client/Overlays/BlackAndWhiteOverlay.cs create mode 100644 Content.Client/Overlays/BlackAndWhiteOverlaySystem.cs create mode 100644 Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs create mode 100644 Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/equipped-EYES.png create mode 100644 Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/icon.png create mode 100644 Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/meta.json diff --git a/Content.Client/Overlays/BlackAndWhiteOverlay.cs b/Content.Client/Overlays/BlackAndWhiteOverlay.cs new file mode 100644 index 0000000000..aae2b63acf --- /dev/null +++ b/Content.Client/Overlays/BlackAndWhiteOverlay.cs @@ -0,0 +1,47 @@ +using Robust.Client.Graphics; +using Robust.Client.Player; +using Robust.Shared.Enums; +using Robust.Shared.Prototypes; + +namespace Content.Client.Overlays; + +public sealed partial class BlackAndWhiteOverlay : Overlay +{ + [Dependency] private readonly IEntityManager _entityManager = default!; + [Dependency] private readonly IPrototypeManager _prototypeManager = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; + + public override OverlaySpace Space => OverlaySpace.WorldSpace; + public override bool RequestScreenTexture => true; + private readonly ShaderInstance _greyscaleShader; + + public BlackAndWhiteOverlay() + { + IoCManager.InjectDependencies(this); + _greyscaleShader = _prototypeManager.Index("GreyscaleFullscreen").InstanceUnique(); + ZIndex = 10; // draw this over the DamageOverlay, RainbowOverlay etc. + } + + protected override bool BeforeDraw(in OverlayDrawArgs args) + { + if (!_entityManager.TryGetComponent(_playerManager.LocalEntity, out EyeComponent? eyeComp)) + return false; + + if (args.Viewport.Eye != eyeComp.Eye) + return false; + + return true; + } + + protected override void Draw(in OverlayDrawArgs args) + { + if (ScreenTexture == null) + return; + + var handle = args.WorldHandle; + _greyscaleShader.SetParameter("SCREEN_TEXTURE", ScreenTexture); + handle.UseShader(_greyscaleShader); + handle.DrawRect(args.WorldBounds, Color.White); + handle.UseShader(null); + } +} diff --git a/Content.Client/Overlays/BlackAndWhiteOverlaySystem.cs b/Content.Client/Overlays/BlackAndWhiteOverlaySystem.cs new file mode 100644 index 0000000000..09c282d10a --- /dev/null +++ b/Content.Client/Overlays/BlackAndWhiteOverlaySystem.cs @@ -0,0 +1,34 @@ +using Content.Shared.Inventory.Events; +using Content.Shared.Overlays; +using Robust.Client.Graphics; +using Robust.Client.Player; + +namespace Content.Client.Overlays; + +public sealed partial class BlackAndWhiteOverlaySystem : EquipmentHudSystem +{ + [Dependency] private readonly IOverlayManager _overlayMan = default!; + + private BlackAndWhiteOverlay _overlay = default!; + + public override void Initialize() + { + base.Initialize(); + + _overlay = new(); + } + + protected override void UpdateInternal(RefreshEquipmentHudEvent component) + { + base.UpdateInternal(component); + + _overlayMan.AddOverlay(_overlay); + } + + protected override void DeactivateInternal() + { + base.DeactivateInternal(); + + _overlayMan.RemoveOverlay(_overlay); + } +} diff --git a/Content.Shared/Inventory/InventorySystem.Relay.cs b/Content.Shared/Inventory/InventorySystem.Relay.cs index ed456ed47b..68d067efc9 100644 --- a/Content.Shared/Inventory/InventorySystem.Relay.cs +++ b/Content.Shared/Inventory/InventorySystem.Relay.cs @@ -76,6 +76,7 @@ public partial class InventorySystem SubscribeLocalEvent>(RefRelayInventoryEvent); SubscribeLocalEvent>(RefRelayInventoryEvent); SubscribeLocalEvent>(RefRelayInventoryEvent); + SubscribeLocalEvent>(RefRelayInventoryEvent); SubscribeLocalEvent>(OnGetEquipmentVerbs); SubscribeLocalEvent>(OnGetInnateVerbs); diff --git a/Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs b/Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs new file mode 100644 index 0000000000..47c0723641 --- /dev/null +++ b/Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs @@ -0,0 +1,10 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Overlays; + +/// +/// Makes the entity see everything in black and white by adding an overlay. +/// When added to a clothing item it will also grant the wearer the same overlay. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class BlackAndWhiteOverlayComponent : Component; diff --git a/Resources/Prototypes/Catalog/Fills/Lockers/security.yml b/Resources/Prototypes/Catalog/Fills/Lockers/security.yml index 4d42f2daa4..cfd1aca2b5 100644 --- a/Resources/Prototypes/Catalog/Fills/Lockers/security.yml +++ b/Resources/Prototypes/Catalog/Fills/Lockers/security.yml @@ -120,8 +120,7 @@ components: - type: StorageFill contents: - - id: ClothingEyesGlassesSecurity - prob: 0.3 + - id: ClothingEyesGlassesNoir - id: ClothingHeadHatDetGadget - id: ClothingNeckTieDet - id: ClothingOuterVestDetective diff --git a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml index c44d7c94e6..dd2183ca51 100644 --- a/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml +++ b/Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml @@ -265,3 +265,24 @@ - type: Clothing sprite: Clothing/Eyes/Glasses/ninjavisor.rsi - type: FlashImmunity + +- type: entity + parent: ClothingEyesBase + id: ClothingEyesGlassesNoir + name: noir-tech glasses + description: A pair of glasses that simulate what the world looked like before the invention of color. + components: + - type: Sprite + sprite: Clothing/Eyes/Glasses/noir.rsi + - type: Clothing + sprite: Clothing/Eyes/Glasses/sunglasses.rsi + - type: IdentityBlocker + coverage: EYES + - type: FlashImmunity + - type: EyeProtection + protectionTime: 5 + - type: BlackAndWhiteOverlay + - type: Tag + tags: + - HamsterWearable + - WhitelistChameleon diff --git a/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/equipped-EYES.png b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/equipped-EYES.png new file mode 100644 index 0000000000000000000000000000000000000000..6f15601f03ed3a388dbc0f82cc6bd827636e41ce GIT binary patch literal 321 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0I1|(Ny7TyC=oCO|{#S9F5M?jcysy3fAQ1G*- zi(^Q|oVT|wavm}eaeJt|!#n+j*-Z!cmC`A*&t1q|Q^_$!Xex`+k^leWqy+a=1;kga z?s~MY`g77MhD?WDewV*^T+h9ocf5GlwSA3J_v3b_mW4LhJovhB z`kx;aX%4>jjS`RdmdITU_|Ir-!SG0ip^&e^g56;bv%)z>f#(bmQ_+OOWfk6Yq&$yp zyjR}s%;BA>ulRbOLZMv1EzuWmFUL8(o#t`5>BzE?@)T^q9WJySRkU1&CjvqXzmJQ&9fz2qI_qU8P+rZc=}(Q zS#{@ literal 0 HcmV?d00001 diff --git a/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/meta.json b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/meta.json new file mode 100644 index 0000000000..3f256720a3 --- /dev/null +++ b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/meta.json @@ -0,0 +1,18 @@ +{ + "version": 1, + "license": "CC-BY-NC-SA-3.0", + "copyright": "taken from goonstation at commit https://github.com/goonstation/goonstation/commit/9affe47cd1b192f6d1900a64a5b5a07a54251e37", + "size": { + "x": 32, + "y": 32 + }, + "states": [ + { + "name": "equipped-EYES", + "directions": 4 + }, + { + "name": "icon" + } + ] +} -- 2.51.2