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

@@ -15,6 +15,7 @@ using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.ViewVariables;
@@ -56,7 +57,7 @@ namespace Content.Server.GameObjects.Components.Power.AME
_injecting = false;
InjectionAmount = 2;
_jarSlot = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-fuelJarContainer", Owner);
_jarSlot = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-fuelJarContainer");
}
public override void HandleMessage(ComponentMessage message, IComponent? component)
@@ -84,7 +85,11 @@ namespace Content.Server.GameObjects.Components.Power.AME
return;
}
_jarSlot.ContainedEntity.TryGetComponent<AMEFuelContainerComponent>(out var fuelJar);
var jar = _jarSlot.ContainedEntity;
if(jar is null)
return;
jar.TryGetComponent<AMEFuelContainerComponent>(out var fuelJar);
if(fuelJar != null && _powerSupplier != null)
{
var availableInject = fuelJar.FuelAmount >= InjectionAmount ? InjectionAmount : fuelJar.FuelAmount;
@@ -222,7 +227,10 @@ namespace Content.Server.GameObjects.Components.Power.AME
return;
var jar = _jarSlot.ContainedEntity;
_jarSlot.Remove(_jarSlot.ContainedEntity);
if(jar is null)
return;
_jarSlot.Remove(jar);
UpdateUserInterface();
if (!user.TryGetComponent<HandsComponent>(out var hands) || !jar.TryGetComponent<ItemComponent>(out var item))

View File

@@ -10,6 +10,7 @@ using Content.Shared.GameObjects.Verbs;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
@@ -48,7 +49,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
base.Initialize();
Owner.EnsureComponent<PowerReceiverComponent>();
_container = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-powerCellContainer", Owner);
_container = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-powerCellContainer");
// Default state in the visualizer is OFF, so when this gets powered on during initialization it will generally show empty
}

View File

@@ -15,6 +15,7 @@ using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Robust.Server.GameObjects;
using Robust.Shared.Audio;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
@@ -219,7 +220,7 @@ namespace Content.Server.GameObjects.Components.Power.ApcNetComponents.PowerRece
{
base.Initialize();
_lightBulbContainer = ContainerManagerComponent.Ensure<ContainerSlot>("light_bulb", Owner);
_lightBulbContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, "light_bulb");
}
public override void HandleMessage(ComponentMessage message, IComponent? component)

View File

@@ -7,6 +7,7 @@ using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
using Content.Shared.GameObjects.Verbs;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization;
@@ -104,7 +105,7 @@ namespace Content.Server.GameObjects.Components.Power
public override void Initialize()
{
base.Initialize();
_cellContainer = ContainerManagerComponent.Ensure<ContainerSlot>("cellslot_cell_container", Owner, out _);
_cellContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, "cellslot_cell_container", out _);
}
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)