2018-04-25 06:42:35 -05:00
|
|
|
|
using SS14.Server.GameObjects.Components.Container;
|
|
|
|
|
|
using SS14.Server.Interfaces.GameObjects;
|
|
|
|
|
|
using SS14.Shared.Interfaces.GameObjects;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2018-11-11 20:04:52 +01:00
|
|
|
|
using SS14.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 />
|
|
|
|
|
|
public override IReadOnlyCollection<IEntity> ContainedEntities => new List<IEntity> { ContainedEntity }.AsReadOnly();
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc />
|
|
|
|
|
|
protected override void InternalRemove(IEntity toremove)
|
|
|
|
|
|
{
|
|
|
|
|
|
ContainedEntity = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|