From bb51fe2cc0352408d632c0b4e1a0ef3169524503 Mon Sep 17 00:00:00 2001 From: ShadowCommander <10494922+ShadowCommander@users.noreply.github.com> Date: Thu, 2 Jul 2020 06:31:55 -0700 Subject: [PATCH] Fix EntityStorage entities going through walls when opened (#1181) --- .../Items/Storage/EntityStorageComponent.cs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs index 9b4eb1f58b..6eae6bf66f 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs @@ -9,6 +9,7 @@ using Content.Shared.GameObjects.Components.Interactable; using Content.Shared.GameObjects.Components.Storage; using Content.Shared.GameObjects.EntitySystems; using Content.Shared.Interfaces; +using Content.Shared.Physics; using Robust.Server.GameObjects; using Robust.Server.GameObjects.Components.Container; using Robust.Server.GameObjects.EntitySystems; @@ -49,6 +50,8 @@ namespace Content.Server.GameObjects.Components private bool _showContents; private bool _open; private bool _isWeldedShut; + private int _collisionMaskStorage; + private int _collisionLayerStorage; /// /// Determines if the container contents should be drawn when the container is closed. @@ -182,9 +185,21 @@ namespace Content.Server.GameObjects.Components private void ModifyComponents() { - if (Owner.TryGetComponent(out var collidableComponent)) + if (!IsCollidableWhenOpen && Owner.TryGetComponent(out var collidableComponent)) { - collidableComponent.CanCollide = IsCollidableWhenOpen || !Open; + var physShape = collidableComponent.PhysicsShapes[0]; + if (Open) + { + _collisionMaskStorage = physShape.CollisionMask; + physShape.CollisionMask = (int)CollisionGroup.Impassable; + _collisionLayerStorage = physShape.CollisionLayer; + physShape.CollisionLayer = (int)CollisionGroup.None; + } + else + { + physShape.CollisionMask = _collisionMaskStorage; + physShape.CollisionLayer = _collisionLayerStorage; + } } if (Owner.TryGetComponent(out var placeableSurfaceComponent))