From 168699d23a8f60d9efd77e40c1a35ab43010ae1e Mon Sep 17 00:00:00 2001 From: Bakke Date: Wed, 25 Oct 2023 06:40:06 +0200 Subject: [PATCH] Fix prescription glasses working from pockets (#286) Fixes #241. --- .../Overlays/Systems/NearsightedSystems.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Client/SimpleStation14/Overlays/Systems/NearsightedSystems.cs b/Content.Client/SimpleStation14/Overlays/Systems/NearsightedSystems.cs index ef413ec65d3..dedb067429c 100644 --- a/Content.Client/SimpleStation14/Overlays/Systems/NearsightedSystems.cs +++ b/Content.Client/SimpleStation14/Overlays/Systems/NearsightedSystems.cs @@ -32,15 +32,21 @@ public sealed class NearsightedSystem : EntitySystem private void OnEquip(GotEquippedEvent args) { + // Note: it would be cleaner to check if the glasses are being equipped + // to the eyes rather than the pockets using `args.SlotFlags.HasFlag(SlotFlags.EYES)`, + // but this field is not present on GotUnequippedEvent. This method is + // used for both equip and unequip to make it consistent between checks. if (TryComp(args.Equipee, out var nearsighted) && - EnsureComp(args.Equipment).Tags.Contains("GlassesNearsight")) + EnsureComp(args.Equipment).Tags.Contains("GlassesNearsight") && + args.Slot == "eyes") UpdateShader(nearsighted, true); } private void OnUnEquip(GotUnequippedEvent args) { if (TryComp(args.Equipee, out var nearsighted) && - EnsureComp(args.Equipment).Tags.Contains("GlassesNearsight")) + EnsureComp(args.Equipment).Tags.Contains("GlassesNearsight") && + args.Slot == "eyes") UpdateShader(nearsighted, false); }