2019-07-08 13:35:05 +02:00
|
|
|
|
using System;
|
2019-11-13 17:37:46 -05:00
|
|
|
|
using System.Collections.Generic;
|
2019-07-08 13:35:05 +02:00
|
|
|
|
using Robust.Server.GameObjects.Components.Container;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
2019-12-22 13:41:04 +01:00
|
|
|
|
using Robust.Shared.Interfaces.GameObjects.Components;
|
2019-04-15 21:11:38 -06:00
|
|
|
|
using Robust.Shared.ViewVariables;
|
2018-04-25 06:42:35 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects
|
|
|
|
|
|
{
|
|
|
|
|
|
public class ContainerSlot : BaseContainer
|
|
|
|
|
|
{
|
2018-11-11 20:04:52 +01:00
|
|
|
|
[ViewVariables]
|
2018-04-25 06:42:35 -05:00
|
|
|
|
public IEntity ContainedEntity { get; private set; } = null;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
2019-07-08 13:35:05 +02:00
|
|
|
|
public override IReadOnlyCollection<IEntity> ContainedEntities
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ContainedEntity == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Array.Empty<IEntity>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return new List<IEntity> {ContainedEntity}.AsReadOnly();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-04-25 06:42:35 -05:00
|
|
|
|
|
|
|
|
|
|
public ContainerSlot(string id, IContainerManager manager) : base(id, manager)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public override bool CanInsert(IEntity toinsert)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ContainedEntity != null)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
return base.CanInsert(toinsert);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
public override bool Contains(IEntity contained)
|
|
|
|
|
|
{
|
2018-05-07 05:05:27 -04:00
|
|
|
|
if (contained != null && contained == ContainedEntity)
|
2018-04-25 06:42:35 -05:00
|
|
|
|
return true;
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
protected override void InternalInsert(IEntity toinsert)
|
|
|
|
|
|
{
|
|
|
|
|
|
ContainedEntity = toinsert;
|
2019-05-05 13:08:56 +02:00
|
|
|
|
base.InternalInsert(toinsert);
|
2018-04-25 06:42:35 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
protected override void InternalRemove(IEntity toremove)
|
|
|
|
|
|
{
|
|
|
|
|
|
ContainedEntity = null;
|
2019-05-05 13:08:56 +02:00
|
|
|
|
base.InternalRemove(toremove);
|
2018-04-25 06:42:35 -05:00
|
|
|
|
}
|
2019-03-26 09:35:51 +01:00
|
|
|
|
|
|
|
|
|
|
public override void Shutdown()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Shutdown();
|
|
|
|
|
|
|
|
|
|
|
|
ContainedEntity?.Delete();
|
|
|
|
|
|
}
|
2018-04-25 06:42:35 -05:00
|
|
|
|
}
|
|
|
|
|
|
}
|