]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add noir glasses (#36923)
authorslarticodefast <161409025+slarticodefast@users.noreply.github.com>
Thu, 1 May 2025 22:07:47 +0000 (00:07 +0200)
committerGitHub <noreply@github.com>
Thu, 1 May 2025 22:07:47 +0000 (18:07 -0400)
hardboiled

Content.Client/Overlays/BlackAndWhiteOverlay.cs [new file with mode: 0644]
Content.Client/Overlays/BlackAndWhiteOverlaySystem.cs [new file with mode: 0644]
Content.Shared/Inventory/InventorySystem.Relay.cs
Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs [new file with mode: 0644]
Resources/Prototypes/Catalog/Fills/Lockers/security.yml
Resources/Prototypes/Entities/Clothing/Eyes/glasses.yml
Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/equipped-EYES.png [new file with mode: 0644]
Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/icon.png [new file with mode: 0644]
Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/meta.json [new file with mode: 0644]

diff --git a/Content.Client/Overlays/BlackAndWhiteOverlay.cs b/Content.Client/Overlays/BlackAndWhiteOverlay.cs
new file mode 100644 (file)
index 0000000..aae2b63
--- /dev/null
@@ -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<ShaderPrototype>("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 (file)
index 0000000..09c282d
--- /dev/null
@@ -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<BlackAndWhiteOverlayComponent>
+{
+    [Dependency] private readonly IOverlayManager _overlayMan = default!;
+
+    private BlackAndWhiteOverlay _overlay = default!;
+
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        _overlay = new();
+    }
+
+    protected override void UpdateInternal(RefreshEquipmentHudEvent<BlackAndWhiteOverlayComponent> component)
+    {
+        base.UpdateInternal(component);
+
+        _overlayMan.AddOverlay(_overlay);
+    }
+
+    protected override void DeactivateInternal()
+    {
+        base.DeactivateInternal();
+
+        _overlayMan.RemoveOverlay(_overlay);
+    }
+}
index ed456ed47b1960dca8522046b797b0e931e5b372..68d067efc94a3f565bb3db3b77437922de09d1d6 100644 (file)
@@ -76,6 +76,7 @@ public partial class InventorySystem
         SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowMindShieldIconsComponent>>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowSyndicateIconsComponent>>(RefRelayInventoryEvent);
         SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<ShowCriminalRecordIconsComponent>>(RefRelayInventoryEvent);
+        SubscribeLocalEvent<InventoryComponent, RefreshEquipmentHudEvent<BlackAndWhiteOverlayComponent>>(RefRelayInventoryEvent);
 
         SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<EquipmentVerb>>(OnGetEquipmentVerbs);
         SubscribeLocalEvent<InventoryComponent, GetVerbsEvent<InnateVerb>>(OnGetInnateVerbs);
diff --git a/Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs b/Content.Shared/Overlays/BlackAndWhiteOverlayComponent.cs
new file mode 100644 (file)
index 0000000..47c0723
--- /dev/null
@@ -0,0 +1,10 @@
+using Robust.Shared.GameStates;
+
+namespace Content.Shared.Overlays;
+
+/// <summary>
+/// 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.
+/// </summary>
+[RegisterComponent, NetworkedComponent]
+public sealed partial class BlackAndWhiteOverlayComponent : Component;
index 4d42f2daa457c125204f71b666d3099a460f2937..cfd1aca2b551c4748dd0391e90ce663340d78b42 100644 (file)
   components:
   - type: StorageFill
     contents:
-      - id: ClothingEyesGlassesSecurity
-        prob: 0.3
+      - id: ClothingEyesGlassesNoir
       - id: ClothingHeadHatDetGadget
       - id: ClothingNeckTieDet
       - id: ClothingOuterVestDetective
index c44d7c94e6fdeb0711901c054603e1f87b602278..dd2183ca51344d1db13790d666dcec801b3cced5 100644 (file)
   - 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 (file)
index 0000000..6f15601
Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/equipped-EYES.png differ
diff --git a/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/icon.png b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/icon.png
new file mode 100644 (file)
index 0000000..90d9c8b
Binary files /dev/null and b/Resources/Textures/Clothing/Eyes/Glasses/noir.rsi/icon.png differ
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 (file)
index 0000000..3f25672
--- /dev/null
@@ -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"
+    }
+  ]
+}