Fix TrayScannerUser (#35959)
* Fix TrayScannerUser * Ignore * Update Content.Shared/SubFloor/TrayScannerUserComponent.cs --------- Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
@@ -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<TrayScannerUserComponent>(user);
|
||||
if (_netMan.IsClient)
|
||||
return;
|
||||
|
||||
var comp = EnsureComp<TrayScannerUserComponent>(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<TrayScannerUserComponent>(user);
|
||||
_eye.RefreshVisibilityMask(user);
|
||||
}
|
||||
|
||||
@@ -5,4 +5,11 @@ namespace Content.Shared.SubFloor;
|
||||
/// Added to anyone using <see cref="TrayScannerComponent"/> to handle the vismask changes.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class TrayScannerUserComponent : Component;
|
||||
public sealed partial class TrayScannerUserComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// How many t-rays the user is currently using.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public int Count;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user