From 4f23016c72d935d61e1ae9be553728159c37c158 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 25 Mar 2025 02:35:22 +1100 Subject: [PATCH] Fix TrayScannerUser (#35959) * Fix TrayScannerUser * Ignore * Update Content.Shared/SubFloor/TrayScannerUserComponent.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com> --- .../SubFloor/SharedTrayScannerSystem.cs | 23 ++++++++++++++++++- .../SubFloor/TrayScannerUserComponent.cs | 9 +++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs index 79bfddeccd..9a7c829f14 100644 --- a/Content.Shared/SubFloor/SharedTrayScannerSystem.cs +++ b/Content.Shared/SubFloor/SharedTrayScannerSystem.cs @@ -3,12 +3,14 @@ using Content.Shared.Hands; using Content.Shared.Interaction; using Content.Shared.Inventory.Events; using Robust.Shared.GameStates; +using Robust.Shared.Network; using Robust.Shared.Serialization; namespace Content.Shared.SubFloor; public abstract class SharedTrayScannerSystem : EntitySystem { + [Dependency] private readonly INetManager _netMan = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedEyeSystem _eye = default!; @@ -37,12 +39,31 @@ public abstract class SharedTrayScannerSystem : EntitySystem private void OnEquip(EntityUid user) { - EnsureComp(user); + if (_netMan.IsClient) + return; + + var comp = EnsureComp(user); + comp.Count++; + + if (comp.Count > 1) + return; + _eye.RefreshVisibilityMask(user); } private void OnUnequip(EntityUid user) { + if (_netMan.IsClient) + return; + + if (!TryComp(user, out TrayScannerUserComponent? comp)) + return; + + comp.Count--; + + if (comp.Count > 0) + return; + RemComp(user); _eye.RefreshVisibilityMask(user); } diff --git a/Content.Shared/SubFloor/TrayScannerUserComponent.cs b/Content.Shared/SubFloor/TrayScannerUserComponent.cs index f97046c03a..e55b5ea58e 100644 --- a/Content.Shared/SubFloor/TrayScannerUserComponent.cs +++ b/Content.Shared/SubFloor/TrayScannerUserComponent.cs @@ -5,4 +5,11 @@ namespace Content.Shared.SubFloor; /// Added to anyone using to handle the vismask changes. /// [RegisterComponent] -public sealed partial class TrayScannerUserComponent : Component; +public sealed partial class TrayScannerUserComponent : Component +{ + /// + /// How many t-rays the user is currently using. + /// + [DataField] + public int Count; +} -- 2.51.2