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
This commit is contained in:
metalgearsloth 2021-10-10 13:17:07 +11:00 committed by GitHub
parent fbea5744e2
commit 04b374f32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 6 deletions

View File

@ -73,12 +73,17 @@ namespace Content.Shared.SubFloor
private void OnSubFloorStarted(EntityUid uid, SubFloorHideComponent component, ComponentStartup _)
{
UpdateEntity(uid);
EntityManager.EnsureComponent<CollideOnAnchorComponent>(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<CollideOnAnchorComponent>(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;
}
}
}