Fix EntityStorage entities going through walls when opened (#1181)
This commit is contained in:
@@ -9,6 +9,7 @@ using Content.Shared.GameObjects.Components.Interactable;
|
|||||||
using Content.Shared.GameObjects.Components.Storage;
|
using Content.Shared.GameObjects.Components.Storage;
|
||||||
using Content.Shared.GameObjects.EntitySystems;
|
using Content.Shared.GameObjects.EntitySystems;
|
||||||
using Content.Shared.Interfaces;
|
using Content.Shared.Interfaces;
|
||||||
|
using Content.Shared.Physics;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.GameObjects.Components.Container;
|
using Robust.Server.GameObjects.Components.Container;
|
||||||
using Robust.Server.GameObjects.EntitySystems;
|
using Robust.Server.GameObjects.EntitySystems;
|
||||||
@@ -49,6 +50,8 @@ namespace Content.Server.GameObjects.Components
|
|||||||
private bool _showContents;
|
private bool _showContents;
|
||||||
private bool _open;
|
private bool _open;
|
||||||
private bool _isWeldedShut;
|
private bool _isWeldedShut;
|
||||||
|
private int _collisionMaskStorage;
|
||||||
|
private int _collisionLayerStorage;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the container contents should be drawn when the container is closed.
|
/// 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()
|
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))
|
if (Owner.TryGetComponent<PlaceableSurfaceComponent>(out var placeableSurfaceComponent))
|
||||||
|
|||||||
Reference in New Issue
Block a user