Adds cursed lockers that teleport anything inside them to other lockers (#1493)
This commit is contained in:
committed by
GitHub
parent
804f287ee3
commit
b9e1f9283d
@@ -2,7 +2,6 @@
|
||||
using System.Linq;
|
||||
using Content.Server.GameObjects.Components.GUI;
|
||||
using Content.Server.GameObjects.Components.Interactable;
|
||||
using Content.Server.GameObjects.Components.Items.Storage;
|
||||
using Content.Server.Interfaces.GameObjects.Components.Interaction;
|
||||
using Content.Shared.GameObjects;
|
||||
using Content.Shared.GameObjects.Components.Interactable;
|
||||
@@ -26,7 +25,7 @@ using Robust.Shared.Maths;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.GameObjects.Components
|
||||
namespace Content.Server.GameObjects.Components.Items.Storage
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(IActivate))]
|
||||
@@ -45,8 +44,6 @@ namespace Content.Server.GameObjects.Components
|
||||
[ViewVariables]
|
||||
private bool _isCollidableWhenOpen;
|
||||
[ViewVariables]
|
||||
private Container _contents;
|
||||
[ViewVariables]
|
||||
private IEntityQuery _entityQuery;
|
||||
private bool _showContents;
|
||||
private bool _occludesLight;
|
||||
@@ -55,6 +52,9 @@ namespace Content.Server.GameObjects.Components
|
||||
private int _collisionMaskStorage;
|
||||
private int _collisionLayerStorage;
|
||||
|
||||
[ViewVariables]
|
||||
protected Container Contents;
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the container contents should be drawn when the container is closed.
|
||||
/// </summary>
|
||||
@@ -65,7 +65,7 @@ namespace Content.Server.GameObjects.Components
|
||||
set
|
||||
{
|
||||
_showContents = value;
|
||||
_contents.ShowContents = _showContents;
|
||||
Contents.ShowContents = _showContents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace Content.Server.GameObjects.Components
|
||||
set
|
||||
{
|
||||
_occludesLight = value;
|
||||
_contents.OccludesLight = _occludesLight;
|
||||
Contents.OccludesLight = _occludesLight;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,11 +109,11 @@ namespace Content.Server.GameObjects.Components
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
_contents = ContainerManagerComponent.Ensure<Container>(nameof(EntityStorageComponent), Owner);
|
||||
Contents = ContainerManagerComponent.Ensure<Container>(nameof(EntityStorageComponent), Owner);
|
||||
_entityQuery = new IntersectingEntityQuery(Owner);
|
||||
|
||||
_contents.ShowContents = _showContents;
|
||||
_contents.OccludesLight = _occludesLight;
|
||||
Contents.ShowContents = _showContents;
|
||||
Contents.OccludesLight = _occludesLight;
|
||||
|
||||
if (Owner.TryGetComponent<PlaceableSurfaceComponent>(out var placeableSurfaceComponent))
|
||||
{
|
||||
@@ -140,7 +140,7 @@ namespace Content.Server.GameObjects.Components
|
||||
ToggleOpen(eventArgs.User);
|
||||
}
|
||||
|
||||
protected virtual void ToggleOpen(IEntity user)
|
||||
private void ToggleOpen(IEntity user)
|
||||
{
|
||||
if (IsWeldedShut)
|
||||
{
|
||||
@@ -158,7 +158,7 @@ namespace Content.Server.GameObjects.Components
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseStorage()
|
||||
public virtual void CloseStorage()
|
||||
{
|
||||
Open = false;
|
||||
var entities = Owner.EntityManager.GetEntities(_entityQuery);
|
||||
@@ -256,7 +256,7 @@ namespace Content.Server.GameObjects.Components
|
||||
entity.Transform.WorldPosition += new Vector2(0, collidableComponent.WorldAABB.Top - entityCollidableComponent.WorldAABB.Top);
|
||||
}
|
||||
}
|
||||
if (_contents.CanInsert(entity))
|
||||
if (Contents.CanInsert(entity))
|
||||
{
|
||||
// Because Insert sets the local position to (0,0), and we want to keep the contents spread out,
|
||||
// we re-apply the world position after inserting.
|
||||
@@ -269,7 +269,7 @@ namespace Content.Server.GameObjects.Components
|
||||
{
|
||||
worldPos = entity.Transform.WorldPosition;
|
||||
}
|
||||
_contents.Insert(entity);
|
||||
Contents.Insert(entity);
|
||||
entity.Transform.WorldPosition = worldPos;
|
||||
if (entityCollidableComponent != null)
|
||||
{
|
||||
@@ -282,9 +282,9 @@ namespace Content.Server.GameObjects.Components
|
||||
|
||||
private void EmptyContents()
|
||||
{
|
||||
foreach (var contained in _contents.ContainedEntities.ToArray())
|
||||
foreach (var contained in Contents.ContainedEntities.ToArray())
|
||||
{
|
||||
if(_contents.Remove(contained))
|
||||
if(Contents.Remove(contained))
|
||||
{
|
||||
if (contained.TryGetComponent<ICollidableComponent>(out var entityCollidableComponent))
|
||||
{
|
||||
@@ -331,7 +331,7 @@ namespace Content.Server.GameObjects.Components
|
||||
/// <inheritdoc />
|
||||
public bool Remove(IEntity entity)
|
||||
{
|
||||
return _contents.CanRemove(entity);
|
||||
return Contents.CanRemove(entity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -344,7 +344,7 @@ namespace Content.Server.GameObjects.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
return _contents.Insert(entity);
|
||||
return Contents.Insert(entity);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -355,12 +355,12 @@ namespace Content.Server.GameObjects.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_contents.ContainedEntities.Count >= _storageCapacityMax)
|
||||
if (Contents.ContainedEntities.Count >= _storageCapacityMax)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return _contents.CanInsert(entity);
|
||||
return Contents.CanInsert(entity);
|
||||
}
|
||||
|
||||
bool IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs)
|
||||
@@ -372,7 +372,7 @@ namespace Content.Server.GameObjects.Components
|
||||
if (!CanWeldShut)
|
||||
return false;
|
||||
|
||||
if (_contents.Contains(eventArgs.User))
|
||||
if (Contents.Contains(eventArgs.User))
|
||||
{
|
||||
Owner.PopupMessage(eventArgs.User, Loc.GetString("It's too Cramped!"));
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user