From 04b374f32f34bf18b997a04905f56e6099f43257 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 10 Oct 2021 13:17:07 +1100 Subject: [PATCH] Turn off collision for all subfloor objects (#4813) * Turn off collision for all subfloor objects And not just ones that are hidden. * Only update collision on terminating * Move termination --- Content.Shared/SubFloor/SubFloorHideSystem.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Content.Shared/SubFloor/SubFloorHideSystem.cs b/Content.Shared/SubFloor/SubFloorHideSystem.cs index 21b01cc898..61455966c6 100644 --- a/Content.Shared/SubFloor/SubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SubFloorHideSystem.cs @@ -73,12 +73,17 @@ namespace Content.Shared.SubFloor private void OnSubFloorStarted(EntityUid uid, SubFloorHideComponent component, ComponentStartup _) { UpdateEntity(uid); + EntityManager.EnsureComponent(uid); } private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _) { + // If component is being deleted don't need to worry about updating any component stuff because it won't matter very shortly. + if (EntityManager.GetEntity(uid).LifeStage >= EntityLifeStage.Terminating) return; + // Regardless of whether we're on a subfloor or not, unhide. UpdateEntity(uid, true); + EntityManager.RemoveComponent(uid); } private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, ref AnchorStateChangedEvent args) @@ -191,12 +196,6 @@ namespace Content.Shared.SubFloor { appearanceComponent.SetData(SubFloorVisuals.SubFloor, subFloorVisible); } - - // So for collision all we care about is that the component is running. - if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent)) - { - physicsComponent.CanCollide = subFloor; - } } }