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:
@@ -73,12 +73,17 @@ namespace Content.Shared.SubFloor
|
|||||||
private void OnSubFloorStarted(EntityUid uid, SubFloorHideComponent component, ComponentStartup _)
|
private void OnSubFloorStarted(EntityUid uid, SubFloorHideComponent component, ComponentStartup _)
|
||||||
{
|
{
|
||||||
UpdateEntity(uid);
|
UpdateEntity(uid);
|
||||||
|
EntityManager.EnsureComponent<CollideOnAnchorComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _)
|
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.
|
// Regardless of whether we're on a subfloor or not, unhide.
|
||||||
UpdateEntity(uid, true);
|
UpdateEntity(uid, true);
|
||||||
|
EntityManager.RemoveComponent<CollideOnAnchorComponent>(uid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, ref AnchorStateChangedEvent args)
|
private void HandleAnchorChanged(EntityUid uid, SubFloorHideComponent component, ref AnchorStateChangedEvent args)
|
||||||
@@ -191,12 +196,6 @@ namespace Content.Shared.SubFloor
|
|||||||
{
|
{
|
||||||
appearanceComponent.SetData(SubFloorVisuals.SubFloor, subFloorVisible);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user