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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user