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

@@ -11,6 +11,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;
@@ -47,7 +48,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
public override void Initialize()
{
base.Initialize();
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-container", Owner, out var existing);
_ammoContainer = ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-container", out var existing);
if (existing)
{

View File

@@ -9,6 +9,7 @@ using Content.Shared.GameObjects.EntitySystems;
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;
@@ -62,7 +63,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
public override void Initialize()
{
base.Initialize();
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-magazine", Owner, out var existing);
_ammoContainer = ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-magazine", out var existing);
if (existing)
{

View File

@@ -7,6 +7,7 @@ using Content.Shared.GameObjects.Components.Weapons.Ranged.Barrels;
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;
@@ -45,7 +46,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Ammunition
public override void Initialize()
{
base.Initialize();
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-container", Owner, out var existing);
_ammoContainer = ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-container", out var existing);
if (existing)
{

View File

@@ -152,7 +152,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
// TODO: Add existing ammo support on revolvers
base.Initialize();
_spawnedAmmo = new Stack<IEntity>(_capacity - 1);
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-ammo-container", Owner, out var existing);
_ammoContainer = ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-ammo-container", out var existing);
if (existing)
{
@@ -163,7 +163,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
}
}
_chamberContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber-container", Owner);
_chamberContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-chamber-container");
if (Owner.TryGetComponent(out AppearanceComponent appearanceComponent))
{

View File

@@ -8,6 +8,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.Map;
@@ -105,7 +106,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
base.Initialize();
_ammoContainer =
ContainerManagerComponent.Ensure<Container>($"{Name}-ammo-container", Owner, out var existing);
ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-ammo-container", out var existing);
if (existing)
{
@@ -117,7 +118,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
}
_chamberContainer =
ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber-container", Owner, out existing);
ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-chamber-container", out existing);
if (existing)
{
_unspawnedCount--;

View File

@@ -9,6 +9,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;
@@ -92,7 +93,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
base.Initialize();
_unspawnedCount = Capacity;
int idx = 0;
_ammoContainer = ContainerManagerComponent.Ensure<Container>($"{Name}-ammoContainer", Owner, out var existing);
_ammoContainer = ContainerHelpers.EnsureContainer<Container>(Owner, $"{Name}-ammoContainer", out var existing);
if (existing)
{
foreach (var entity in _ammoContainer.ContainedEntities)

View File

@@ -13,6 +13,7 @@ using Content.Shared.GameObjects.Verbs;
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.Map;
@@ -102,7 +103,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
public override void Initialize()
{
base.Initialize();
_powerCellContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-powercell-container", Owner, out var existing);
_powerCellContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-powercell-container", out var existing);
if (!existing && _powerCellPrototype != null)
{
var powerCellEntity = Owner.EntityManager.SpawnEntity(_powerCellPrototype, Owner.Transform.Coordinates);
@@ -111,7 +112,7 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
if (_ammoPrototype != null)
{
_ammoContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-ammo-container", Owner);
_ammoContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-ammo-container");
}
if (Owner.TryGetComponent(out AppearanceComponent appearanceComponent))

View File

@@ -190,8 +190,8 @@ namespace Content.Server.GameObjects.Components.Weapon.Ranged.Barrels
_appearanceComponent = appearanceComponent;
}
_chamberContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-chamber", Owner);
_magazineContainer = ContainerManagerComponent.Ensure<ContainerSlot>($"{Name}-magazine", Owner, out var existing);
_chamberContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-chamber");
_magazineContainer = ContainerHelpers.EnsureContainer<ContainerSlot>(Owner, $"{Name}-magazine", out var existing);
if (!existing && _magFillPrototype != null)
{