Shared Containers (#3331)

* Namespace changes for containers.
Moved ContainerSlot from content to engine.

* Merged client/server ContainerManagerComponents into a single shared version.

* Mapfile and nullability fixes.

* Upgrades map.

* Update engine.
This commit is contained in:
Acruid
2021-03-01 15:24:46 -08:00
committed by GitHub
parent adda1ee404
commit 6c081d9d8d
64 changed files with 796 additions and 1439 deletions

View File

@@ -1,4 +1,4 @@
#nullable enable
#nullable enable
using Content.Server.GameObjects.Components.GUI;
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.GameObjects.Components.Paper;
@@ -17,6 +17,7 @@ using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using System.Threading.Tasks;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Robust.Shared.Containers;
namespace Content.Server.GameObjects.Components.Morgue
{
@@ -37,7 +38,7 @@ namespace Content.Server.GameObjects.Components.Morgue
{
base.Initialize();
_appearance?.SetData(BodyBagVisuals.Label, false);
LabelContainer = ContainerManagerComponent.Ensure<ContainerSlot>("body_bag_label", Owner, out _);
LabelContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, "body_bag_label", out _);
}
protected override bool AddToContents(IEntity entity)
@@ -83,14 +84,18 @@ namespace Content.Server.GameObjects.Components.Morgue
{
if (LabelContainer == null) return;
var ent = LabelContainer.ContainedEntity;
if(ent is null)
return;
if (user.TryGetComponent(out HandsComponent? hands))
{
hands.PutInHandOrDrop(LabelContainer.ContainedEntity.GetComponent<ItemComponent>());
hands.PutInHandOrDrop(ent.GetComponent<ItemComponent>());
_appearance?.SetData(BodyBagVisuals.Label, false);
}
else if (LabelContainer.Remove(LabelContainer.ContainedEntity))
else if (LabelContainer.Remove(ent))
{
LabelContainer.ContainedEntity.Transform.Coordinates = Owner.Transform.Coordinates;
ent.Transform.Coordinates = Owner.Transform.Coordinates;
_appearance?.SetData(BodyBagVisuals.Label, false);
}
}