Sloth's subfloor vismask adventure (#35347)

* Add a subfloor vismask

Significantly cuts down on sent entity count.

* More optimisations

* Fix command

* Fixes

* namespace cleanup

* Review

* Vismasks

* Content update

* Bandaid

* awewa

* Revert these

* reh

* Update Content.Shared/SubFloor/TrayScannerComponent.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2025-03-21 00:57:04 +11:00
committed by GitHub
parent 2e7f01b99e
commit 9292e3a43c
22 changed files with 277 additions and 47 deletions

View File

@@ -1,17 +1,16 @@
using Content.Shared.Eye;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Robust.Shared.Containers;
using Content.Shared.Inventory.Events;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Serialization;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using System.Linq;
namespace Content.Shared.SubFloor;
public abstract class SharedTrayScannerSystem : EntitySystem
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedEyeSystem _eye = default!;
public const float SubfloorRevealAlpha = 0.8f;
@@ -22,6 +21,50 @@ public abstract class SharedTrayScannerSystem : EntitySystem
SubscribeLocalEvent<TrayScannerComponent, ComponentGetState>(OnTrayScannerGetState);
SubscribeLocalEvent<TrayScannerComponent, ComponentHandleState>(OnTrayScannerHandleState);
SubscribeLocalEvent<TrayScannerComponent, ActivateInWorldEvent>(OnTrayScannerActivate);
SubscribeLocalEvent<TrayScannerComponent, GotEquippedHandEvent>(OnTrayHandEquipped);
SubscribeLocalEvent<TrayScannerComponent, GotUnequippedHandEvent>(OnTrayHandUnequipped);
SubscribeLocalEvent<TrayScannerComponent, GotEquippedEvent>(OnTrayEquipped);
SubscribeLocalEvent<TrayScannerComponent, GotUnequippedEvent>(OnTrayUnequipped);
SubscribeLocalEvent<TrayScannerUserComponent, GetVisMaskEvent>(OnUserGetVis);
}
private void OnUserGetVis(Entity<TrayScannerUserComponent> ent, ref GetVisMaskEvent args)
{
args.VisibilityMask |= (int)VisibilityFlags.Subfloor;
}
private void OnEquip(EntityUid user)
{
EnsureComp<TrayScannerUserComponent>(user);
_eye.RefreshVisibilityMask(user);
}
private void OnUnequip(EntityUid user)
{
RemComp<TrayScannerUserComponent>(user);
_eye.RefreshVisibilityMask(user);
}
private void OnTrayHandUnequipped(Entity<TrayScannerComponent> ent, ref GotUnequippedHandEvent args)
{
OnUnequip(args.User);
}
private void OnTrayHandEquipped(Entity<TrayScannerComponent> ent, ref GotEquippedHandEvent args)
{
OnEquip(args.User);
}
private void OnTrayUnequipped(Entity<TrayScannerComponent> ent, ref GotUnequippedEvent args)
{
OnUnequip(args.Equipee);
}
private void OnTrayEquipped(Entity<TrayScannerComponent> ent, ref GotEquippedEvent args)
{
OnEquip(args.Equipee);
}
private void OnTrayScannerActivate(EntityUid uid, TrayScannerComponent scanner, ActivateInWorldEvent args)