Fix EntityStorage entities going through walls when opened (#1181)

This commit is contained in:
ShadowCommander
2020-07-02 06:31:55 -07:00
committed by GitHub
parent 8171e40a37
commit bb51fe2cc0

View File

@@ -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;
/// <summary>
/// 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<ICollidableComponent>(out var collidableComponent))
if (!IsCollidableWhenOpen && Owner.TryGetComponent<ICollidableComponent>(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<PlaceableSurfaceComponent>(out var placeableSurfaceComponent))