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

@@ -100,6 +100,17 @@ namespace Content.Server.Ghost
SubscribeLocalEvent<RoundEndTextAppendEvent>(_ => MakeVisible(true));
SubscribeLocalEvent<ToggleGhostVisibilityToAllEvent>(OnToggleGhostVisibilityToAll);
SubscribeLocalEvent<GhostComponent, GetVisMaskEvent>(OnGhostVis);
}
private void OnGhostVis(Entity<GhostComponent> ent, ref GetVisMaskEvent args)
{
// If component not deleting they can see ghosts.
if (ent.Comp.LifeStage <= ComponentLifeStage.Running)
{
args.VisibilityMask |= (int)VisibilityFlags.Ghost;
}
}
private void OnGhostHearingAction(EntityUid uid, GhostComponent component, ToggleGhostHearingActionEvent args)
@@ -186,8 +197,7 @@ namespace Content.Server.Ghost
_visibilitySystem.RefreshVisibility(uid, visibilityComponent: visibility);
}
SetCanSeeGhosts(uid, true);
_eye.RefreshVisibilityMask(uid);
var time = _gameTiming.CurTime;
component.TimeOfDeath = time;
}
@@ -207,21 +217,10 @@ namespace Content.Server.Ghost
}
// Entity can't see ghosts anymore.
SetCanSeeGhosts(uid, false);
_eye.RefreshVisibilityMask(uid);
_actions.RemoveAction(uid, component.BooActionEntity);
}
private void SetCanSeeGhosts(EntityUid uid, bool canSee, EyeComponent? eyeComponent = null)
{
if (!Resolve(uid, ref eyeComponent, false))
return;
if (canSee)
_eye.SetVisibilityMask(uid, eyeComponent.VisibilityMask | (int) VisibilityFlags.Ghost, eyeComponent);
else
_eye.SetVisibilityMask(uid, eyeComponent.VisibilityMask & ~(int) VisibilityFlags.Ghost, eyeComponent);
}
private void OnMapInit(EntityUid uid, GhostComponent component, MapInitEvent args)
{
_actions.AddAction(uid, ref component.BooActionEntity, component.BooAction);