diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs index b0e3566bdc..d09661b770 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.Ballistic.cs @@ -33,7 +33,7 @@ public sealed partial class GunSystem var existing = component.Entities[^1]; component.Entities.RemoveAt(component.Entities.Count - 1); - component.Container.Remove(existing); + Containers.Remove(existing, component.Container); EnsureShootable(existing); } else if (component.UnspawnedCount > 0) diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index cef74aa386..317aa10400 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -373,7 +373,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click await server.WaitAssertion(() => { #pragma warning disable NUnit2045 // Interdependent assertions. - Assert.That(container.Insert(user)); + Assert.That(conSystem.Insert(user, container)); Assert.That(sEntities.GetComponent(user).ParentUid, Is.EqualTo(containerEntity)); #pragma warning restore NUnit2045 diff --git a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs index 2e46134504..af3e474d08 100644 --- a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs +++ b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs @@ -177,7 +177,7 @@ public sealed class AmeControllerSystem : EntitySystem if (!Exists(jar)) return; - controller.JarSlot.Remove(jar!.Value); + _containerSystem.Remove(jar!.Value, controller.JarSlot); UpdateUi(uid, controller); if (Exists(user)) _handsSystem.PickupOrDrop(user, jar!.Value); @@ -303,7 +303,7 @@ public sealed class AmeControllerSystem : EntitySystem return; } - comp.JarSlot.Insert(args.Used); + _containerSystem.Insert(args.Used, comp.JarSlot); _popupSystem.PopupEntity(Loc.GetString("ame-controller-component-interact-using-success"), uid, args.User, PopupType.Medium); UpdateUi(uid, comp); diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index 6fbbd030d0..a5a7cd89d8 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -285,7 +285,7 @@ public sealed class AntagSelectionSystem : GameRuleSystem { if (_containerSystem.CanInsert(itemToSpawn, pocket1Slot)) { - pocket1Slot.Insert(itemToSpawn); + _containerSystem.Insert(itemToSpawn, pocket1Slot); } } else if (_inventory.TryGetSlotContainer(antag, "pocket2", out var pocket2Slot, out _)) @@ -294,7 +294,7 @@ public sealed class AntagSelectionSystem : GameRuleSystem { if (_containerSystem.CanInsert(itemToSpawn, pocket2Slot)) { - pocket2Slot.Insert(itemToSpawn); + _containerSystem.Insert(itemToSpawn, pocket2Slot); } } } diff --git a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs index 02b2eee771..cb08e19fc2 100644 --- a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs +++ b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs @@ -199,7 +199,7 @@ public sealed class CartridgeLoaderSystem : SharedCartridgeLoaderSystem return false; var installedProgram = Spawn(prototype, new EntityCoordinates(loaderUid, 0, 0)); - container.Insert(installedProgram); + _containerSystem.Insert(installedProgram, container); UpdateCartridgeInstallationStatus(installedProgram, deinstallable ? InstallationStatus.Installed : InstallationStatus.Readonly); diff --git a/Content.Server/Cloning/CloningSystem.cs b/Content.Server/Cloning/CloningSystem.cs index 97575c2d32..6156a88c38 100644 --- a/Content.Server/Cloning/CloningSystem.cs +++ b/Content.Server/Cloning/CloningSystem.cs @@ -255,7 +255,7 @@ namespace Content.Server.Cloning var cloneMindReturn = EntityManager.AddComponent(mob); cloneMindReturn.Mind = mind; cloneMindReturn.Parent = uid; - clonePod.BodyContainer.Insert(mob); + _containerSystem.Insert(mob, clonePod.BodyContainer); ClonesWaitingForMind.Add(mind, mob); UpdateStatus(uid, CloningPodStatus.NoMind, clonePod); _euiManager.OpenEui(new AcceptCloningEui(mindEnt, mind, this), client); @@ -326,7 +326,7 @@ namespace Content.Server.Cloning return; EntityManager.RemoveComponent(entity); - clonePod.BodyContainer.Remove(entity); + _containerSystem.Remove(entity, clonePod.BodyContainer); clonePod.CloningProgress = 0f; clonePod.UsedBiomass = 0; UpdateStatus(uid, CloningPodStatus.Idle, clonePod); diff --git a/Content.Server/Construction/Completions/BuildMech.cs b/Content.Server/Construction/Completions/BuildMech.cs index 46c6caf5cf..e11c79d851 100644 --- a/Content.Server/Construction/Completions/BuildMech.cs +++ b/Content.Server/Construction/Completions/BuildMech.cs @@ -54,7 +54,7 @@ public sealed partial class BuildMech : IGraphAction return; } - container.Remove(cell); + containerSystem.Remove(cell, container); var transform = entityManager.GetComponent(uid); var mech = entityManager.SpawnEntity(MechPrototype, transform.Coordinates); @@ -62,7 +62,7 @@ public sealed partial class BuildMech : IGraphAction if (entityManager.TryGetComponent(mech, out var mechComp) && mechComp.BatterySlot.ContainedEntity == null) { mechSys.InsertBattery(mech, cell, mechComp, batteryComponent); - mechComp.BatterySlot.Insert(cell); + containerSystem.Insert(cell, mechComp.BatterySlot); } var entChangeEv = new ConstructionChangeEntityEvent(mech, uid); diff --git a/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs b/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs index b18bb733d9..b6511883b1 100644 --- a/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs +++ b/Content.Server/Construction/Completions/DeleteEntitiesInContainer.cs @@ -21,7 +21,7 @@ namespace Content.Server.Construction.Completions foreach (var contained in container.ContainedEntities.ToArray()) { - if(container.Remove(contained)) + if(containerSys.Remove(contained, container)) entityManager.QueueDeleteEntity(contained); } } diff --git a/Content.Server/Construction/Completions/MoveContainer.cs b/Content.Server/Construction/Completions/MoveContainer.cs index cba1819ae9..16ab1c57ec 100644 --- a/Content.Server/Construction/Completions/MoveContainer.cs +++ b/Content.Server/Construction/Completions/MoveContainer.cs @@ -26,8 +26,8 @@ namespace Content.Server.Construction.Completions foreach (var contained in from.ContainedEntities.ToArray()) { - if (from.Remove(contained)) - to.Insert(contained); + if (containerSystem.Remove(contained, from)) + containerSystem.Insert(contained, to); } } } diff --git a/Content.Server/Construction/Completions/SpawnPrototypeAtContainer.cs b/Content.Server/Construction/Completions/SpawnPrototypeAtContainer.cs index fc4563c93a..1dd1ee8ddd 100644 --- a/Content.Server/Construction/Completions/SpawnPrototypeAtContainer.cs +++ b/Content.Server/Construction/Completions/SpawnPrototypeAtContainer.cs @@ -24,7 +24,7 @@ namespace Content.Server.Construction.Completions var coordinates = entityManager.GetComponent(uid).Coordinates; for (var i = 0; i < Amount; i++) { - container.Insert(entityManager.SpawnEntity(Prototype, coordinates)); + containerSystem.Insert(entityManager.SpawnEntity(Prototype, coordinates), container); } } } diff --git a/Content.Server/Construction/ConstructionSystem.Computer.cs b/Content.Server/Construction/ConstructionSystem.Computer.cs index edc1d26b6d..0685b08f4f 100644 --- a/Content.Server/Construction/ConstructionSystem.Computer.cs +++ b/Content.Server/Construction/ConstructionSystem.Computer.cs @@ -61,7 +61,7 @@ public sealed partial class ConstructionSystem var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(ent).Coordinates); - if (!container.Insert(board)) + if (!_container.Insert(board, container)) Log.Warning($"Couldn't insert board {board} to computer {ent}!"); } } diff --git a/Content.Server/Construction/ConstructionSystem.Graph.cs b/Content.Server/Construction/ConstructionSystem.Graph.cs index be8b0e688d..570360bf09 100644 --- a/Content.Server/Construction/ConstructionSystem.Graph.cs +++ b/Content.Server/Construction/ConstructionSystem.Graph.cs @@ -388,8 +388,8 @@ namespace Content.Server.Construction for (var i = ourContainer.ContainedEntities.Count - 1; i >= 0; i--) { var entity = ourContainer.ContainedEntities[i]; - ourContainer.ForceRemove(entity); - otherContainer.Insert(entity); + _container.Remove(entity, ourContainer, reparent: false, force: true); + _container.Insert(entity, otherContainer); } } } diff --git a/Content.Server/Construction/ConstructionSystem.Initial.cs b/Content.Server/Construction/ConstructionSystem.Initial.cs index f312308798..52cde02d21 100644 --- a/Content.Server/Construction/ConstructionSystem.Initial.cs +++ b/Content.Server/Construction/ConstructionSystem.Initial.cs @@ -133,14 +133,14 @@ namespace Content.Server.Construction { foreach (var entity in container.ContainedEntities.ToArray()) { - container.Remove(entity); + _container.Remove(entity, container); } foreach (var cont in containers.Values) { foreach (var entity in cont.ContainedEntities.ToArray()) { - cont.Remove(entity); + _container.Remove(entity, cont); } } @@ -150,10 +150,10 @@ namespace Content.Server.Construction void ShutdownContainers() { - container.Shutdown(); + _container.ShutdownContainer(container); foreach (var c in containers.Values.ToArray()) { - c.Shutdown(); + _container.ShutdownContainer(c); } } @@ -188,10 +188,10 @@ namespace Content.Server.Construction if (string.IsNullOrEmpty(materialStep.Store)) { - if (!container.Insert(splitStack.Value)) + if (!_container.Insert(splitStack.Value, container)) continue; } - else if (!GetContainer(materialStep.Store).Insert(splitStack.Value)) + else if (!_container.Insert(splitStack.Value, GetContainer(materialStep.Store))) continue; handled = true; @@ -217,10 +217,10 @@ namespace Content.Server.Construction if (string.IsNullOrEmpty(arbitraryStep.Store)) { - if (!container.Insert(entity)) + if (!_container.Insert(entity, container)) continue; } - else if (!GetContainer(arbitraryStep.Store).Insert(entity)) + else if (!_container.Insert(entity, GetContainer(arbitraryStep.Store))) continue; handled = true; @@ -284,8 +284,8 @@ namespace Content.Server.Construction foreach (var entity in cont.ContainedEntities.ToArray()) { - cont.ForceRemove(entity); - newCont.Insert(entity); + _container.Remove(entity, cont, reparent: false, force: true); + _container.Insert(entity, newCont); } } diff --git a/Content.Server/Construction/ConstructionSystem.Interactions.cs b/Content.Server/Construction/ConstructionSystem.Interactions.cs index 11dd0b2bf0..6112dd13ad 100644 --- a/Content.Server/Construction/ConstructionSystem.Interactions.cs +++ b/Content.Server/Construction/ConstructionSystem.Interactions.cs @@ -329,7 +329,7 @@ namespace Content.Server.Construction construction.Containers.Add(store); // The container doesn't necessarily need to exist, so we ensure it. - _container.EnsureContainer(uid, store).Insert(insert); + _container.Insert(insert, _container.EnsureContainer(uid, store)); } else { diff --git a/Content.Server/Construction/ConstructionSystem.Machine.cs b/Content.Server/Construction/ConstructionSystem.Machine.cs index a6472c38d1..65b0b70476 100644 --- a/Content.Server/Construction/ConstructionSystem.Machine.cs +++ b/Content.Server/Construction/ConstructionSystem.Machine.cs @@ -125,7 +125,7 @@ public sealed partial class ConstructionSystem var board = EntityManager.SpawnEntity(component.BoardPrototype, Transform(uid).Coordinates); - if (!component.BoardContainer.Insert(board)) + if (!_container.Insert(board, component.BoardContainer)) { throw new Exception($"Couldn't insert board with prototype {component.BoardPrototype} to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}!"); } @@ -143,7 +143,7 @@ public sealed partial class ConstructionSystem { var p = EntityManager.SpawnEntity(partProto.StockPartPrototype, xform.Coordinates); - if (!partContainer.Insert(p)) + if (!_container.Insert(p, partContainer)) throw new Exception($"Couldn't insert machine part of type {part} to machine with prototype {partProto.StockPartPrototype ?? "N/A"}!"); } } @@ -152,7 +152,7 @@ public sealed partial class ConstructionSystem { var stack = _stackSystem.Spawn(amount, stackType, Transform(uid).Coordinates); - if (!partContainer.Insert(stack)) + if (!_container.Insert(stack, partContainer)) throw new Exception($"Couldn't insert machine material of type {stackType} to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}"); } @@ -162,7 +162,7 @@ public sealed partial class ConstructionSystem { var c = EntityManager.SpawnEntity(info.DefaultPrototype, Transform(uid).Coordinates); - if(!partContainer.Insert(c)) + if(!_container.Insert(c, partContainer)) throw new Exception($"Couldn't insert machine component part with default prototype '{compName}' to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}"); } } @@ -173,7 +173,7 @@ public sealed partial class ConstructionSystem { var c = EntityManager.SpawnEntity(info.DefaultPrototype, Transform(uid).Coordinates); - if(!partContainer.Insert(c)) + if(!_container.Insert(c, partContainer)) throw new Exception($"Couldn't insert machine component part with default prototype '{tagName}' to machine with prototype {MetaData(uid).EntityPrototype?.ID ?? "N/A"}"); } } diff --git a/Content.Server/Construction/MachineFrameSystem.cs b/Content.Server/Construction/MachineFrameSystem.cs index a033b39d20..09d8d413ec 100644 --- a/Content.Server/Construction/MachineFrameSystem.cs +++ b/Content.Server/Construction/MachineFrameSystem.cs @@ -100,7 +100,7 @@ public sealed class MachineFrameSystem : EntitySystem return; args.Handled = true; - if (!component.PartContainer.Insert(args.Used)) + if (!_container.Insert(args.Used, component.PartContainer)) return; } @@ -132,7 +132,7 @@ public sealed class MachineFrameSystem : EntitySystem return; args.Handled = true; - if (!component.PartContainer.Insert(args.Used)) + if (!_container.Insert(args.Used, component.PartContainer)) return; } @@ -156,7 +156,7 @@ public sealed class MachineFrameSystem : EntitySystem if (!_container.TryRemoveFromContainer(used)) return false; - if (!component.BoardContainer.Insert(used)) + if (!_container.Insert(used, component.BoardContainer)) return true; ResetProgressAndRequirements(component, machineBoard); @@ -181,7 +181,7 @@ public sealed class MachineFrameSystem : EntitySystem if (!_container.TryRemoveFromContainer(used)) return false; - if (!component.PartContainer.Insert(used)) + if (!_container.Insert(used, component.PartContainer)) return true; component.Progress[machinePart.PartType]++; @@ -212,7 +212,7 @@ public sealed class MachineFrameSystem : EntitySystem if (!_container.TryRemoveFromContainer(used)) return false; - if (!component.PartContainer.Insert(used)) + if (!_container.Insert(used, component.PartContainer)) return true; component.MaterialProgress[type] += count; @@ -224,7 +224,7 @@ public sealed class MachineFrameSystem : EntitySystem if (splitStack == null) return false; - if (!component.PartContainer.Insert(splitStack.Value)) + if (!_container.Insert(splitStack.Value, component.PartContainer)) return true; component.MaterialProgress[type] += needed; diff --git a/Content.Server/Construction/PartExchangerSystem.cs b/Content.Server/Construction/PartExchangerSystem.cs index 75629146a4..f364d1b547 100644 --- a/Content.Server/Construction/PartExchangerSystem.cs +++ b/Content.Server/Construction/PartExchangerSystem.cs @@ -91,7 +91,7 @@ public sealed class PartExchangerSystem : EntitySystem } foreach (var part in updatedParts) { - machine.PartContainer.Insert(part.part, EntityManager); + _container.Insert(part.part, machine.PartContainer); machineParts.Remove(part); } @@ -140,7 +140,7 @@ public sealed class PartExchangerSystem : EntitySystem if (!machine.Requirements.ContainsKey(part.PartType)) continue; - machine.PartContainer.Insert(partEnt, EntityManager); + _container.Insert(partEnt, machine.PartContainer); machine.Progress[part.PartType]++; machineParts.Remove(pair); } diff --git a/Content.Server/Containers/EmptyOnMachineDeconstructSystem.cs b/Content.Server/Containers/EmptyOnMachineDeconstructSystem.cs index 77563dd31c..ae3ca47dd7 100644 --- a/Content.Server/Containers/EmptyOnMachineDeconstructSystem.cs +++ b/Content.Server/Containers/EmptyOnMachineDeconstructSystem.cs @@ -26,8 +26,8 @@ namespace Content.Server.Containers { foreach (var slot in component.Slots.Values) { - if (slot.EjectOnDeconstruct && slot.Item != null) - slot.ContainerSlot?.Remove(slot.Item.Value); + if (slot.EjectOnDeconstruct && slot.Item != null && slot.ContainerSlot != null) + _container.Remove(slot.Item.Value, slot.ContainerSlot); } } diff --git a/Content.Server/Devour/DevourSystem.cs b/Content.Server/Devour/DevourSystem.cs index 3b15e725fe..febbd093a6 100644 --- a/Content.Server/Devour/DevourSystem.cs +++ b/Content.Server/Devour/DevourSystem.cs @@ -31,7 +31,7 @@ public sealed class DevourSystem : SharedDevourSystem if (component.ShouldStoreDevoured && args.Args.Target is not null) { - component.Stomach.Insert(args.Args.Target.Value); + ContainerSystem.Insert(args.Args.Target.Value, component.Stomach); } _bloodstreamSystem.TryAddToChemicals(uid, ichorInjection); } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 59aa832f6a..cc9d2f711b 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -63,7 +63,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (!CanInsert(uid, toInsert, holder)) return false; - if (!holder.Container.Insert(toInsert, EntityManager)) + if (!_containerSystem.Insert(toInsert, holder.Container)) return false; if (_physicsQuery.TryGetComponent(toInsert, out var physBody)) @@ -127,14 +127,14 @@ namespace Content.Server.Disposal.Unit.EntitySystems RemComp(entity); var meta = _metaQuery.GetComponent(entity); - holder.Container.Remove(entity, EntityManager, meta: meta, reparent: false, force: true); + _containerSystem.Remove((entity, null, meta), holder.Container, reparent: false, force: true); var xform = _xformQuery.GetComponent(entity); if (xform.ParentUid != uid) continue; if (duc != null) - duc.Container.Insert(entity, EntityManager, xform, meta: meta); + _containerSystem.Insert((entity, xform, meta), duc.Container); else { _xformSystem.AttachToGridOrMap(entity, xform); @@ -185,7 +185,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems } // Insert into next tube - if (!to.Contents.Insert(holderUid)) + if (!_containerSystem.Insert(holderUid, to.Contents)) { ExitDisposals(holderUid, holder, holderTransform); return false; @@ -267,7 +267,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems // Past this point, we are performing inter-tube transfer! // Remove current tube content - _disposalTubeQuery.GetComponent(currentTube).Contents.Remove(uid, reparent: false, force: true); + _containerSystem.Remove(uid, _disposalTubeQuery.GetComponent(currentTube).Contents, reparent: false, force: true); // Find next tube var nextTube = _disposalTubeSystem.NextTubeFor(currentTube, holder.CurrentDirection); diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 659566ca43..0dfc1ffe0d 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -208,7 +208,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem if (!ResolveDisposals(uid, ref disposal)) return; - if (!disposal.Container.Insert(toInsert)) + if (!_containerSystem.Insert(toInsert, disposal.Container)) return; _adminLogger.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(user):player} inserted {ToPrettyString(toInsert)} into {ToPrettyString(uid)}"); @@ -681,7 +681,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem public void Remove(EntityUid uid, SharedDisposalUnitComponent component, EntityUid toRemove) { - component.Container.Remove(toRemove); + _containerSystem.Remove(toRemove, component.Container); if (component.Container.ContainedEntities.Count == 0) { @@ -800,7 +800,7 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem { _audioSystem.PlayPvs(component.InsertSound, uid); - if (!component.Container.Insert(inserted)) + if (!_containerSystem.Insert(inserted, component.Container)) return; if (user != inserted && user != null) diff --git a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs index f355187a0b..169daca07a 100644 --- a/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs +++ b/Content.Server/Ensnaring/EnsnareableSystem.Ensnaring.cs @@ -91,7 +91,7 @@ public sealed partial class EnsnareableSystem } component.Ensnared = target; - ensnareable.Container.Insert(ensnare); + _container.Insert(ensnare, ensnareable.Container); ensnareable.IsEnsnared = true; Dirty(ensnareable); @@ -147,7 +147,7 @@ public sealed partial class EnsnareableSystem var target = component.Ensnared.Value; - ensnareable.Container.Remove(ensnare, force: true); + _container.Remove(ensnare, ensnareable.Container, force: true); ensnareable.IsEnsnared = ensnareable.Container.ContainedEntities.Count > 0; Dirty(ensnareable); component.Ensnared = null; diff --git a/Content.Server/Ensnaring/EnsnareableSystem.cs b/Content.Server/Ensnaring/EnsnareableSystem.cs index 66758eed84..f939e087e0 100644 --- a/Content.Server/Ensnaring/EnsnareableSystem.cs +++ b/Content.Server/Ensnaring/EnsnareableSystem.cs @@ -38,7 +38,7 @@ public sealed partial class EnsnareableSystem : SharedEnsnareableSystem if (args.Handled || !TryComp(args.Args.Used, out var ensnaring)) return; - if (args.Cancelled || !component.Container.Remove(args.Args.Used.Value)) + if (args.Cancelled || !_container.Remove(args.Args.Used.Value, component.Container)) { _popup.PopupEntity(Loc.GetString("ensnare-component-try-free-fail", ("ensnare", args.Args.Used)), uid, uid, PopupType.MediumCaution); return; diff --git a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs index 2674a8d61b..ee3f76d04c 100644 --- a/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ClusterGrenadeSystem.cs @@ -158,7 +158,7 @@ public sealed class ClusterGrenadeSystem : EntitySystem grenade = component.GrenadesContainer.ContainedEntities[0]; // This shouldn't happen but you never know. - if (!component.GrenadesContainer.Remove(grenade)) + if (!_containerSystem.Remove(grenade, component.GrenadesContainer)) return false; return true; diff --git a/Content.Server/Guardian/GuardianSystem.cs b/Content.Server/Guardian/GuardianSystem.cs index 1b3cbd1fc3..02099b2c7b 100644 --- a/Content.Server/Guardian/GuardianSystem.cs +++ b/Content.Server/Guardian/GuardianSystem.cs @@ -67,7 +67,7 @@ namespace Content.Server.Guardian if (!TryComp(host, out GuardianHostComponent? hostComponent)) return; - hostComponent.GuardianContainer.Remove(uid); + _container.Remove(uid, hostComponent.GuardianContainer); hostComponent.HostedGuardian = null; Dirty(host.Value, hostComponent); QueueDel(hostComponent.ActionEntity); @@ -213,7 +213,7 @@ namespace Content.Server.Guardian // Use map position so it's not inadvertantly parented to the host + if it's in a container it spawns outside I guess. var guardian = Spawn(component.GuardianProto, hostXform.MapPosition); - host.GuardianContainer.Insert(guardian); + _container.Insert(guardian, host.GuardianContainer); host.HostedGuardian = guardian; if (TryComp(guardian, out var guardianComp)) @@ -337,7 +337,7 @@ namespace Content.Server.Guardian } DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardian)); - hostComponent.GuardianContainer.Remove(guardian); + _container.Remove(guardian, hostComponent.GuardianContainer); DebugTools.Assert(!hostComponent.GuardianContainer.Contains(guardian)); guardianComponent.GuardianLoose = true; @@ -351,7 +351,7 @@ namespace Content.Server.Guardian return; } - hostComponent.GuardianContainer.Insert(guardian); + _container.Insert(guardian, hostComponent.GuardianContainer); DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardian)); _popupSystem.PopupEntity(Loc.GetString("guardian-entity-recall"), host); guardianComponent.GuardianLoose = false; diff --git a/Content.Server/IdentityManagement/IdentitySystem.cs b/Content.Server/IdentityManagement/IdentitySystem.cs index 5161911254..dbd34d7484 100644 --- a/Content.Server/IdentityManagement/IdentitySystem.cs +++ b/Content.Server/IdentityManagement/IdentitySystem.cs @@ -9,6 +9,7 @@ using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement.Components; using Content.Shared.Inventory; using Content.Shared.Inventory.Events; +using Robust.Shared.Containers; using Robust.Shared.Enums; using Robust.Shared.GameObjects.Components.Localization; @@ -22,6 +23,7 @@ public class IdentitySystem : SharedIdentitySystem [Dependency] private readonly IdCardSystem _idCard = default!; [Dependency] private readonly IAdminLogManager _adminLog = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly HumanoidAppearanceSystem _humanoid = default!; private HashSet _queuedIdentityUpdates = new(); @@ -59,7 +61,7 @@ public class IdentitySystem : SharedIdentitySystem var ident = Spawn(null, Transform(uid).Coordinates); QueueIdentityUpdate(uid); - component.IdentityEntitySlot.Insert(ident); + _container.Insert(ident, component.IdentityEntitySlot); } /// diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 436f040acf..e4159f89ef 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -173,7 +173,7 @@ namespace Content.Server.Kitchen.EntitySystems if (metaData.EntityPrototype.ID == recipeSolid.Key) { - component.Storage.Remove(item); + _sharedContainer.Remove(item, component.Storage); EntityManager.DeleteEntity(item); break; } @@ -208,7 +208,7 @@ namespace Content.Server.Kitchen.EntitySystems foreach (var part in headSlots) { - component.Storage.Insert(part.Id); + _container.Insert(part.Id, component.Storage); headCount++; } } @@ -371,7 +371,7 @@ namespace Content.Server.Kitchen.EntitySystems if (_tag.HasTag(item, "MicrowaveSelfUnsafe") || _tag.HasTag(item, "Plastic")) { var junk = Spawn(component.BadRecipeEntityId, Transform(uid).Coordinates); - component.Storage.Insert(junk); + _container.Insert(junk, component.Storage); QueueDel(item); } @@ -504,7 +504,7 @@ namespace Content.Server.Kitchen.EntitySystems if (!HasContents(component) || HasComp(uid)) return; - component.Storage.Remove(EntityManager.GetEntity(args.EntityID)); + _sharedContainer.Remove(EntityManager.GetEntity(args.EntityID), component.Storage); UpdateUserInterfaceState(uid, component); } diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index 3a6d5e4134..ba6795ad9f 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -159,7 +159,7 @@ namespace Content.Server.Kitchen.EntitySystems if (inputContainer.ContainedEntities.Count >= reagentGrinder.StorageMaxEntities) return; - if (!inputContainer.Insert(heldEnt, EntityManager)) + if (!_containerSystem.Insert(heldEnt, inputContainer)) return; args.Handled = true; @@ -230,7 +230,7 @@ namespace Content.Server.Kitchen.EntitySystems ClickSound(uid, reagentGrinder); foreach (var entity in inputContainer.ContainedEntities.ToList()) { - inputContainer.Remove(entity); + _containerSystem.Remove(entity, inputContainer); _randomHelper.RandomOffset(entity, 0.4f); } UpdateUiState(uid); @@ -244,7 +244,7 @@ namespace Content.Server.Kitchen.EntitySystems var inputContainer = _containerSystem.EnsureContainer(uid, SharedReagentGrinder.InputContainerId); var ent = GetEntity(message.EntityId); - if (inputContainer.Remove(ent)) + if (_containerSystem.Remove(ent, inputContainer)) { _randomHelper.RandomOffset(ent, 0.4f); ClickSound(uid, reagentGrinder); diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index 8347f14ea4..c34fcfe3a2 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -137,7 +137,7 @@ public sealed class LightReplacerSystem : EntitySystem if (bulb.Valid) // FirstOrDefault can return default/invalid uid. { // try to remove it - var hasRemoved = replacer.InsertedBulbs.Remove(bulb); + var hasRemoved = _container.Remove(bulb, replacer.InsertedBulbs); if (!hasRemoved) return false; } @@ -187,7 +187,7 @@ public sealed class LightReplacerSystem : EntitySystem } // try insert light and show message - var hasInsert = replacer.InsertedBulbs.Insert(bulbUid); + var hasInsert = _container.Insert(bulbUid, replacer.InsertedBulbs); if (hasInsert && showTooltip && userUid != null) { var msg = Loc.GetString("comp-light-replacer-insert-light", diff --git a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs index b92fc247d0..6aea340e56 100644 --- a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs +++ b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs @@ -87,7 +87,7 @@ namespace Content.Server.Light.EntitySystems if (light.HasLampOnSpawn != null) { var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent(uid).Coordinates); - light.LightBulbContainer.Insert(entity); + _containerSystem.Insert(entity, light.LightBulbContainer); } // need this to update visualizers UpdateLight(uid, light); @@ -182,7 +182,7 @@ namespace Content.Server.Light.EntitySystems return false; // try to insert bulb in container - if (!light.LightBulbContainer.Insert(bulbUid)) + if (!_containerSystem.Insert(bulbUid, light.LightBulbContainer)) return false; UpdateLight(uid, light); @@ -203,7 +203,7 @@ namespace Content.Server.Light.EntitySystems return null; // try to remove bulb from container - if (!light.LightBulbContainer.Remove(bulb)) + if (!_containerSystem.Remove(bulb, light.LightBulbContainer)) return null; // try to place bulb in hands diff --git a/Content.Server/Materials/MaterialReclaimerSystem.cs b/Content.Server/Materials/MaterialReclaimerSystem.cs index 2f8b43e832..d6a94ec6d2 100644 --- a/Content.Server/Materials/MaterialReclaimerSystem.cs +++ b/Content.Server/Materials/MaterialReclaimerSystem.cs @@ -141,7 +141,7 @@ public sealed class MaterialReclaimerSystem : SharedMaterialReclaimerSystem if (active.ReclaimingContainer.ContainedEntities.FirstOrNull() is not { } item) return false; - active.ReclaimingContainer.Remove(item); + Container.Remove(item, active.ReclaimingContainer); Dirty(component); // scales the output if the process was interrupted. diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index 8b7a4c6204..9f5d564d5a 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -78,7 +78,7 @@ public sealed class MechGrabberSystem : EntitySystem if (!Resolve(uid, ref component)) return; - component.ItemContainer.Remove(toRemove); + _container.Remove(toRemove, component.ItemContainer); var mechxform = Transform(mech); var xform = Transform(toRemove); _transform.AttachToGridOrMap(toRemove, xform); @@ -175,7 +175,7 @@ public sealed class MechGrabberSystem : EntitySystem if (!_mech.TryChangeEnergy(equipmentComponent.EquipmentOwner.Value, component.GrabEnergyDelta)) return; - component.ItemContainer.Insert(args.Args.Target.Value); + _container.Insert(args.Args.Target.Value, component.ItemContainer); _mech.UpdateUserInterface(equipmentComponent.EquipmentOwner.Value); args.Handled = true; diff --git a/Content.Server/Mech/Systems/MechAssemblySystem.cs b/Content.Server/Mech/Systems/MechAssemblySystem.cs index d237324102..e5b7bfaac3 100644 --- a/Content.Server/Mech/Systems/MechAssemblySystem.cs +++ b/Content.Server/Mech/Systems/MechAssemblySystem.cs @@ -47,7 +47,7 @@ public sealed class MechAssemblySystem : EntitySystem if (!val && tagComp.Tags.Contains(tag)) { component.RequiredParts[tag] = true; - component.PartsContainer.Insert(args.Used); + _container.Insert(args.Used, component.PartsContainer); break; } } diff --git a/Content.Server/Mech/Systems/MechSystem.cs b/Content.Server/Mech/Systems/MechSystem.cs index 780dbac82b..fe903655b5 100644 --- a/Content.Server/Mech/Systems/MechSystem.cs +++ b/Content.Server/Mech/Systems/MechSystem.cs @@ -358,7 +358,7 @@ public sealed partial class MechSystem : SharedMechSystem if (!Resolve(toInsert, ref battery, false)) return; - component.BatterySlot.Insert(toInsert); + _container.Insert(toInsert, component.BatterySlot); component.Energy = battery.CurrentCharge; component.MaxEnergy = battery.MaxCharge; diff --git a/Content.Server/Medical/MedicalScannerSystem.cs b/Content.Server/Medical/MedicalScannerSystem.cs index d4694e8fb8..54de0bc3b5 100644 --- a/Content.Server/Medical/MedicalScannerSystem.cs +++ b/Content.Server/Medical/MedicalScannerSystem.cs @@ -233,7 +233,7 @@ namespace Content.Server.Medical if (!HasComp(to_insert)) return; - scannerComponent.BodyContainer.Insert(to_insert); + _containerSystem.Insert(to_insert, scannerComponent.BodyContainer); UpdateAppearance(uid, scannerComponent); } @@ -245,7 +245,7 @@ namespace Content.Server.Medical if (scannerComponent.BodyContainer.ContainedEntity is not { Valid: true } contained) return; - scannerComponent.BodyContainer.Remove(contained); + _containerSystem.Remove(contained, scannerComponent.BodyContainer); _climbSystem.ForciblySetClimbing(contained, uid); UpdateAppearance(uid, scannerComponent); } diff --git a/Content.Server/Morgue/CrematoriumSystem.cs b/Content.Server/Morgue/CrematoriumSystem.cs index 7f3c7aa1e9..1f0682774f 100644 --- a/Content.Server/Morgue/CrematoriumSystem.cs +++ b/Content.Server/Morgue/CrematoriumSystem.cs @@ -16,6 +16,7 @@ using Content.Shared.Verbs; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; +using Robust.Shared.Containers; using Robust.Shared.Player; namespace Content.Server.Morgue; @@ -29,6 +30,7 @@ public sealed class CrematoriumSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly StandingStateSystem _standing = default!; [Dependency] private readonly SharedMindSystem _minds = default!; + [Dependency] private readonly SharedContainerSystem _containers = default!; public override void Initialize() { @@ -126,11 +128,11 @@ public sealed class CrematoriumSystem : EntitySystem for (var i = storage.Contents.ContainedEntities.Count - 1; i >= 0; i--) { var item = storage.Contents.ContainedEntities[i]; - storage.Contents.Remove(item); + _containers.Remove(item, storage.Contents); EntityManager.DeleteEntity(item); } var ash = Spawn("Ash", Transform(uid).Coordinates); - storage.Contents.Insert(ash); + _containers.Insert(ash, storage.Contents); } _entityStorage.OpenStorage(uid, storage); diff --git a/Content.Server/Polymorph/Systems/PolymorphSystem.cs b/Content.Server/Polymorph/Systems/PolymorphSystem.cs index 5531f65409..5b8a7b7165 100644 --- a/Content.Server/Polymorph/Systems/PolymorphSystem.cs +++ b/Content.Server/Polymorph/Systems/PolymorphSystem.cs @@ -181,7 +181,7 @@ namespace Content.Server.Polymorph.Systems childXform.LocalRotation = targetTransformComp.LocalRotation; if (_container.TryGetContainingContainer(uid, out var cont)) - cont.Insert(child); + _container.Insert(child, cont); //Transfers all damage from the original to the new one if (proto.TransferDamage && diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs b/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs index 228f32ad90..a89a101845 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Modules.cs @@ -201,7 +201,7 @@ public sealed partial class BorgSystem continue; } - component.ProvidedContainer.Remove(item, EntityManager, force: true); + _container.Remove(item, component.ProvidedContainer, force: true); } if (!item.IsValid()) @@ -245,7 +245,7 @@ public sealed partial class BorgSystem if (LifeStage(item) <= EntityLifeStage.MapInitialized) { RemComp(item); - component.ProvidedContainer.Insert(item, EntityManager); + _container.Insert(item, component.ProvidedContainer); } _hands.RemoveHand(chassis, handId, hands); } diff --git a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs index ad2622af50..fa551ebc37 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.Ui.cs @@ -33,7 +33,7 @@ public sealed partial class BorgSystem _adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(attachedEntity):player} removed brain {ToPrettyString(brain)} from borg {ToPrettyString(uid)}"); - component.BrainContainer.Remove(brain, EntityManager); + _container.Remove(brain, component.BrainContainer); _hands.TryPickupAnyHand(attachedEntity, brain); UpdateUI(uid, component); } @@ -91,7 +91,7 @@ public sealed partial class BorgSystem _adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(attachedEntity):player} removed module {ToPrettyString(module)} from borg {ToPrettyString(uid)}"); - component.ModuleContainer.Remove(module); + _container.Remove(module, component.ModuleContainer); _hands.TryPickupAnyHand(attachedEntity, module); UpdateUI(uid, component); diff --git a/Content.Server/Silicons/Borgs/BorgSystem.cs b/Content.Server/Silicons/Borgs/BorgSystem.cs index 7de351a70f..4d7892c0b7 100644 --- a/Content.Server/Silicons/Borgs/BorgSystem.cs +++ b/Content.Server/Silicons/Borgs/BorgSystem.cs @@ -46,6 +46,7 @@ public sealed partial class BorgSystem : SharedBorgSystem [Dependency] private readonly PowerCellSystem _powerCell = default!; [Dependency] private readonly ThrowingSystem _throwing = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; [ValidatePrototypeId] public const string BorgJobId = "Borg"; @@ -109,7 +110,7 @@ public sealed partial class BorgSystem : SharedBorgSystem } } - component.BrainContainer.Insert(used); + _container.Insert(used, component.BrainContainer); _adminLog.Add(LogType.Action, LogImpact.Medium, $"{ToPrettyString(args.User):player} installed brain {ToPrettyString(used)} into borg {ToPrettyString(uid)}"); args.Handled = true; @@ -118,7 +119,7 @@ public sealed partial class BorgSystem : SharedBorgSystem if (module != null && CanInsertModule(uid, used, component, module, args.User)) { - component.ModuleContainer.Insert(used); + _container.Insert(used, component.ModuleContainer); _adminLog.Add(LogType.Action, LogImpact.Low, $"{ToPrettyString(args.User):player} installed module {ToPrettyString(used)} into borg {ToPrettyString(uid)}"); args.Handled = true; diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index a15dad8507..5fb0e0756f 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -215,7 +215,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem var target_container = outerContainer; while (target_container != null) { - if (target_container.Insert(entity)) + if (_containerSystem.Insert(entity, target_container)) break; _containerSystem.TryGetContainingContainer(target_container.Owner, out target_container); diff --git a/Content.Server/Sticky/Systems/StickySystem.cs b/Content.Server/Sticky/Systems/StickySystem.cs index bcc1be39a9..2d1104e2ce 100644 --- a/Content.Server/Sticky/Systems/StickySystem.cs +++ b/Content.Server/Sticky/Systems/StickySystem.cs @@ -173,7 +173,7 @@ public sealed class StickySystem : EntitySystem // add container to entity and insert sticker into it var container = _containerSystem.EnsureContainer(target, StickerSlotId); container.ShowContents = true; - if (!container.Insert(uid)) + if (!_containerSystem.Insert(uid, container)) return; // show message to user @@ -207,11 +207,11 @@ public sealed class StickySystem : EntitySystem return; // try to remove sticky item from target container - if (!_containerSystem.TryGetContainer(stuckTo, StickerSlotId, out var container) || !container.Remove(uid)) + if (!_containerSystem.TryGetContainer(stuckTo, StickerSlotId, out var container) || !_containerSystem.Remove(uid, container)) return; // delete container if it's now empty if (container.ContainedEntities.Count == 0) - container.Shutdown(); + _containerSystem.ShutdownContainer(container); // try place dropped entity into user hands _handsSystem.PickupOrDrop(user, uid); diff --git a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs index 4333465f27..9995ed40c1 100644 --- a/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs +++ b/Content.Server/Storage/EntitySystems/BluespaceLockerSystem.cs @@ -11,6 +11,7 @@ using Content.Shared.Mind.Components; using Content.Shared.Storage.Components; using Content.Shared.Storage.EntitySystems; using Content.Shared.Tools.Systems; +using Robust.Shared.Containers; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -20,6 +21,7 @@ public sealed class BluespaceLockerSystem : EntitySystem { [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly WeldableSystem _weldableSystem = default!; [Dependency] private readonly LockSystem _lockSystem = default!; @@ -91,12 +93,12 @@ public sealed class BluespaceLockerSystem : EntitySystem if (!component.BehaviorProperties.TransportSentient) continue; - entityStorageComponent.Contents.Insert(entity, EntityManager); + _containerSystem.Insert(entity, entityStorageComponent.Contents); transportedEntities++; } else if (component.BehaviorProperties.TransportEntities) { - entityStorageComponent.Contents.Insert(entity, EntityManager); + _containerSystem.Insert(entity, entityStorageComponent.Contents); transportedEntities++; } } @@ -308,12 +310,12 @@ public sealed class BluespaceLockerSystem : EntitySystem if (!component.BehaviorProperties.TransportSentient) continue; - target.Value.storageComponent.Contents.Insert(entity, EntityManager); + _containerSystem.Insert(entity, target.Value.storageComponent.Contents); transportedEntities++; } else if (component.BehaviorProperties.TransportEntities) { - target.Value.storageComponent.Contents.Insert(entity, EntityManager); + _containerSystem.Insert(entity, target.Value.storageComponent.Contents); transportedEntities++; } } diff --git a/Content.Server/Storage/EntitySystems/CursedEntityStorageSystem.cs b/Content.Server/Storage/EntitySystems/CursedEntityStorageSystem.cs index a8144311bb..7c58bcccca 100644 --- a/Content.Server/Storage/EntitySystems/CursedEntityStorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/CursedEntityStorageSystem.cs @@ -8,12 +8,14 @@ using Robust.Shared.Random; using System.Linq; using Content.Shared.Storage.Components; using Robust.Shared.Audio.Systems; +using Robust.Shared.Containers; namespace Content.Server.Storage.EntitySystems; public sealed class CursedEntityStorageSystem : EntitySystem { [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly SharedContainerSystem _container = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; @@ -48,7 +50,7 @@ public sealed class CursedEntityStorageSystem : EntitySystem foreach (var entity in storage.Contents.ContainedEntities.ToArray()) { - storage.Contents.Remove(entity); + _container.Remove(entity, storage.Contents); _entityStorage.AddToContents(entity, lockerEnt); } diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs index a2990c2037..798be3fc8e 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.Ballistic.cs @@ -16,7 +16,7 @@ public sealed partial class GunSystem var existing = component.Entities[^1]; component.Entities.RemoveAt(component.Entities.Count - 1); - component.Container.Remove(existing); + Containers.Remove(existing, component.Container); EnsureShootable(existing); } else if (component.UnspawnedCount > 0) diff --git a/Content.Shared/Actions/ActionContainerSystem.cs b/Content.Shared/Actions/ActionContainerSystem.cs index 21e3f79f2b..0fe2b83b11 100644 --- a/Content.Shared/Actions/ActionContainerSystem.cs +++ b/Content.Shared/Actions/ActionContainerSystem.cs @@ -187,7 +187,7 @@ public sealed class ActionContainerSystem : EntitySystem DebugTools.AssertOwner(uid, comp); comp ??= EnsureComp(uid); - if (!comp.Container.Insert(actionId)) + if (!_container.Insert(actionId, comp.Container)) { Log.Error($"Failed to insert action {ToPrettyString(actionId)} into {ToPrettyString(uid)}"); return false; @@ -239,7 +239,7 @@ public sealed class ActionContainerSystem : EntitySystem if (_timing.ApplyingState && component.NetSyncEnabled) return; // The game state should handle the container removal & action deletion. - component.Container.Shutdown(); + _container.ShutdownContainer(component.Container); } private void OnEntityInserted(EntityUid uid, ActionsContainerComponent component, EntInsertedIntoContainerMessage args) diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs index b1b40dccfa..e5e4edddb0 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Body.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Body.cs @@ -161,7 +161,7 @@ public partial class SharedBodySystem var partSlot = CreatePartSlot(parentEntity, connection, childPartComponent.PartType, parentPartComponent); var cont = Containers.GetContainer(parentEntity, GetPartSlotContainerId(connection)); - if (partSlot == null || !cont.Insert(childPart)) + if (partSlot == null || !Containers.Insert(childPart, cont)) { Log.Error($"Could not create slot for connection {connection} in body {prototype.ID}"); QueueDel(childPart); diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs index 6e392b9892..fa11390705 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs @@ -98,7 +98,7 @@ public partial class SharedBodySystem if (!Containers.TryGetContainer(partId, containerId, out var container)) return false; - return container.Insert(organId); + return Containers.Insert(organId, container); } /// @@ -114,7 +114,7 @@ public partial class SharedBodySystem if (!HasComp(parent)) return false; - return container.Remove(organId); + return Containers.Remove(organId, container); } /// diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index cfebaf3094..a1056568ab 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -396,7 +396,7 @@ public partial class SharedBodySystem return false; } - return body.RootContainer.Insert(partId); + return Containers.Insert(partId, body.RootContainer); } #endregion @@ -446,7 +446,7 @@ public partial class SharedBodySystem return false; } - return container.Insert(partId); + return Containers.Insert(partId, container); } #endregion diff --git a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs index 806723de1e..ac12c5e791 100644 --- a/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs +++ b/Content.Shared/CartridgeLoader/SharedCartridgeLoaderSystem.cs @@ -36,7 +36,7 @@ public abstract class SharedCartridgeLoaderSystem : EntitySystem { _itemSlotsSystem.RemoveItemSlot(uid, loader.CartridgeSlot); if (_container.TryGetContainer(uid, InstalledContainerId, out var cont)) - cont.Shutdown(EntityManager, _netMan); + _container.ShutdownContainer(cont); } protected virtual void OnItemInserted(EntityUid uid, CartridgeLoaderComponent loader, EntInsertedIntoContainerMessage args) diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index c9a5c974f9..f03745006f 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -143,7 +143,7 @@ public sealed class ToggleableClothingSystem : EntitySystem if (!_inventorySystem.TryUnequip(Transform(uid).ParentUid, toggleCom.Slot, force: true)) return; - toggleCom.Container.Insert(uid, EntityManager); + _containerSystem.Insert(uid, toggleCom.Container); args.Handled = true; } @@ -229,8 +229,8 @@ public sealed class ToggleableClothingSystem : EntitySystem // As unequipped gets called in the middle of container removal, we cannot call a container-insert without causing issues. // So we delay it and process it during a system update: - if (toggleComp.ClothingUid != null) - toggleComp.Container?.Insert(toggleComp.ClothingUid.Value); + if (toggleComp.ClothingUid != null && toggleComp.Container != null) + _containerSystem.Insert(toggleComp.ClothingUid.Value, toggleComp.Container); } /// @@ -302,7 +302,7 @@ public sealed class ToggleableClothingSystem : EntitySystem var attachedClothing = EnsureComp(component.ClothingUid.Value); attachedClothing.AttachedUid = uid; Dirty(component.ClothingUid.Value, attachedClothing); - component.Container.Insert(component.ClothingUid.Value, EntityManager, ownerTransform: xform); + _containerSystem.Insert(component.ClothingUid.Value, component.Container, containerXform: xform); Dirty(uid, component); } diff --git a/Content.Shared/Construction/PartAssemblySystem.cs b/Content.Shared/Construction/PartAssemblySystem.cs index 91aa25e030..4bc225d370 100644 --- a/Content.Shared/Construction/PartAssemblySystem.cs +++ b/Content.Shared/Construction/PartAssemblySystem.cs @@ -77,7 +77,7 @@ public sealed class PartAssemblySystem : EntitySystem return false; component.CurrentAssembly = assemblyId; - component.PartsContainer.Insert(part); + _container.Insert(part, component.PartsContainer); var ev = new PartAssemblyPartInsertedEvent(); RaiseLocalEvent(uid, ev); return true; diff --git a/Content.Shared/Containers/ContainerFillSystem.cs b/Content.Shared/Containers/ContainerFillSystem.cs index 88aa1def35..e120b6bc88 100644 --- a/Content.Shared/Containers/ContainerFillSystem.cs +++ b/Content.Shared/Containers/ContainerFillSystem.cs @@ -33,7 +33,7 @@ public sealed class ContainerFillSystem : EntitySystem foreach (var proto in prototypes) { var ent = Spawn(proto, coords); - if (!container.Insert(ent, EntityManager, null, xform)) + if (!_containerSystem.Insert(ent, container, containerXform: xform)) { Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}."); Transform(ent).AttachToGridOrMap(); diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index b272cc182e..bc2225a94c 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -68,7 +68,8 @@ namespace Content.Shared.Containers.ItemSlots continue; var item = EntityManager.SpawnEntity(slot.StartingItem, EntityManager.GetComponent(uid).Coordinates); - slot.ContainerSlot?.Insert(item); + if (slot.ContainerSlot != null) + _containers.Insert(item, slot.ContainerSlot); } } @@ -115,7 +116,7 @@ namespace Content.Shared.Containers.ItemSlots if (Terminating(uid) || slot.ContainerSlot == null) return; - slot.ContainerSlot.Shutdown(); + _containers.ShutdownContainer(slot.ContainerSlot); // Don't log missing resolves. when an entity has all of its components removed, the ItemSlotsComponent may // have been removed before some other component that added an item slot (and is now trying to remove it). @@ -228,7 +229,7 @@ namespace Content.Shared.Containers.ItemSlots /// Useful for predicted interactions private void Insert(EntityUid uid, ItemSlot slot, EntityUid item, EntityUid? user, bool excludeUserAudio = false) { - var inserted = slot.ContainerSlot?.Insert(item); + bool? inserted = slot.ContainerSlot != null ? _containers.Insert(item, slot.ContainerSlot) : null; // ContainerSlot automatically raises a directed EntInsertedIntoContainerMessage // Logging @@ -350,7 +351,7 @@ namespace Content.Shared.Containers.ItemSlots /// Useful for predicted interactions private void Eject(EntityUid uid, ItemSlot slot, EntityUid item, EntityUid? user, bool excludeUserAudio = false) { - var ejected = slot.ContainerSlot?.Remove(item); + bool? ejected = slot.ContainerSlot != null ? _containers.Remove(item, slot.ContainerSlot) : null; // ContainerSlot automatically raises a directed EntRemovedFromContainerMessage // Logging diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index 93ef4e4213..9f41ed3b5e 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -384,7 +384,7 @@ namespace Content.Shared.Cuffs var container = cuffable.Container; var entity = container.ContainedEntities[^1]; - container.Remove(entity); + _container.Remove(entity, container); _transform.SetWorldPosition(entity, _transform.GetWorldPosition(owner)); } @@ -448,7 +448,7 @@ namespace Content.Shared.Cuffs // Success! _hands.TryDrop(user, handcuff); - component.Container.Insert(handcuff); + _container.Insert(handcuff, component.Container); UpdateHeldItems(target, handcuff, component); return true; } @@ -634,7 +634,7 @@ namespace Content.Shared.Cuffs _audio.PlayPredicted(cuff.EndUncuffSound, target, user); - cuffable.Container.Remove(cuffsToRemove); + _container.Remove(cuffsToRemove, cuffable.Container); if (_net.IsServer) { diff --git a/Content.Shared/Devour/SharedDevourSystem.cs b/Content.Shared/Devour/SharedDevourSystem.cs index 3d406843f5..a2b788f3f3 100644 --- a/Content.Shared/Devour/SharedDevourSystem.cs +++ b/Content.Shared/Devour/SharedDevourSystem.cs @@ -17,7 +17,7 @@ public abstract class SharedDevourSystem : EntitySystem [Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedActionsSystem _actionsSystem = default!; - [Dependency] private readonly SharedContainerSystem _containerSystem = default!; + [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!; public override void Initialize() { @@ -31,7 +31,7 @@ public abstract class SharedDevourSystem : EntitySystem { //Devourer doesn't actually chew, since he sends targets right into his stomach. //I did it mom, I added ERP content into upstream. Legally! - component.Stomach = _containerSystem.EnsureContainer(uid, "stomach"); + component.Stomach = ContainerSystem.EnsureContainer(uid, "stomach"); _actionsSystem.AddAction(uid, ref component.DevourActionEntity, component.DevourAction); } diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index 4e24013a50..7d2244fbbb 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -120,7 +120,7 @@ public abstract partial class SharedHandsSystem if (!isInContainer || !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true) - || !container.Insert(entity, EntityManager, itemXform)) + || !ContainerSystem.Insert((entity, itemXform), container)) TransformSystem.AttachToGridOrMap(entity, itemXform); return true; } @@ -148,7 +148,7 @@ public abstract partial class SharedHandsSystem return false; DoDrop(uid, hand, false, handsComp); - targetContainer.Insert(entity); + ContainerSystem.Insert(entity, targetContainer); return true; } @@ -189,7 +189,7 @@ public abstract partial class SharedHandsSystem if (TerminatingOrDeleted(uid) || TerminatingOrDeleted(entity)) return; - if (!hand.Container.Remove(entity, EntityManager)) + if (!ContainerSystem.Remove(entity, hand.Container)) { Log.Error($"Failed to remove {ToPrettyString(entity)} from users hand container when dropping. User: {ToPrettyString(uid)}. Hand: {hand.Name}."); return; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs index edba1f98c4..bbae03e45b 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs @@ -217,7 +217,7 @@ public abstract partial class SharedHandsSystem : EntitySystem if (handContainer == null || handContainer.ContainedEntity != null) return; - if (!handContainer.Insert(entity, EntityManager)) + if (!ContainerSystem.Insert(entity, handContainer)) { Log.Error($"Failed to insert {ToPrettyString(entity)} into users hand container when picking up. User: {ToPrettyString(uid)}. Hand: {hand.Name}."); return; diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs index 527ac196b8..f0a1bcb29c 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs @@ -73,7 +73,8 @@ public abstract partial class SharedHandsSystem handsComp.SortedHands.Remove(hand.Name); TryDrop(uid, hand, null, false, true, handsComp); - hand.Container?.Shutdown(); + if (hand.Container != null) + ContainerSystem.ShutdownContainer(hand.Container); if (handsComp.ActiveHand == hand) TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp); diff --git a/Content.Shared/Implants/SharedImplanterSystem.cs b/Content.Shared/Implants/SharedImplanterSystem.cs index 6c8284b9be..36a31bac1d 100644 --- a/Content.Shared/Implants/SharedImplanterSystem.cs +++ b/Content.Shared/Implants/SharedImplanterSystem.cs @@ -63,10 +63,11 @@ public abstract class SharedImplanterSystem : EntitySystem var implantedComp = EnsureComp(target); var implantContainer = implantedComp.ImplantContainer; - component.ImplanterSlot.ContainerSlot?.Remove(implant.Value); + if (component.ImplanterSlot.ContainerSlot != null) + _container.Remove(implant.Value, component.ImplanterSlot.ContainerSlot); implantComp.ImplantedEntity = target; implantContainer.OccludesLight = false; - implantContainer.Insert(implant.Value); + _container.Insert(implant.Value, implantContainer); if (component.CurrentMode == ImplanterToggleMode.Inject && !component.ImplantOnly) DrawMode(implanter, component); @@ -140,9 +141,9 @@ public abstract class SharedImplanterSystem : EntitySystem continue; } - implantContainer.Remove(implant); + _container.Remove(implant, implantContainer); implantComp.ImplantedEntity = null; - implanterContainer.Insert(implant); + _container.Insert(implant, implanterContainer); permanentFound = implantComp.Permanent; var ev = new TransferDnaEvent { Donor = target, Recipient = implanter }; diff --git a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs index 2d68f1cdaa..830d2270aa 100644 --- a/Content.Shared/Implants/SharedSubdermalImplantSystem.cs +++ b/Content.Shared/Implants/SharedSubdermalImplantSystem.cs @@ -48,7 +48,7 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem { if (_tag.HasTag(implant, "MicroBomb")) { - implantContainer.Remove(implant); + _container.Remove(implant, implantContainer); QueueDel(implant); } } @@ -124,7 +124,7 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem var implantContainer = implantedComp.ImplantContainer; component.ImplantedEntity = target; - implantContainer.Insert(implant); + _container.Insert(implant, implantContainer); } /// @@ -140,7 +140,7 @@ public abstract class SharedSubdermalImplantSystem : EntitySystem var implantContainer = implanted.ImplantContainer; - implantContainer.Remove(implant); + _container.Remove(implant, implantContainer); QueueDel(implant); } diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 456c8373df..bad36098c0 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -190,7 +190,7 @@ public abstract partial class InventorySystem return false; } - if (!slotContainer.Insert(itemUid)) + if (!_containerSystem.Insert(itemUid, slotContainer)) { if(!silent && _gameTiming.IsFirstTimePredicted) _popup.PopupCursor(Loc.GetString("inventory-component-can-unequip-cannot")); @@ -374,7 +374,7 @@ public abstract partial class InventorySystem } } - if (!slotContainer.Remove(removedItem.Value, force: force)) + if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force)) return false; // TODO: Inventory needs a hot cleanup hoo boy diff --git a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs index 31df11fa8b..66cb25f530 100644 --- a/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs +++ b/Content.Shared/Materials/SharedMaterialReclaimerSystem.cs @@ -26,7 +26,7 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem [Dependency] protected readonly IGameTiming Timing = default!; [Dependency] protected readonly SharedAmbientSoundSystem AmbientSound = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly SharedContainerSystem _container = default!; + [Dependency] protected readonly SharedContainerSystem Container = default!; public const string ActiveReclaimerContainerId = "active-material-reclaimer-container"; @@ -79,7 +79,7 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem private void OnActiveStartup(EntityUid uid, ActiveMaterialReclaimerComponent component, ComponentStartup args) { - component.ReclaimingContainer = _container.EnsureContainer(uid, ActiveReclaimerContainerId); + component.ReclaimingContainer = Container.EnsureContainer(uid, ActiveReclaimerContainerId); } private void OnActiveUnpaused(EntityUid uid, ActiveMaterialReclaimerComponent component, ref EntityUnpausedEvent args) @@ -107,7 +107,7 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem if (component.Blacklist is {} blacklist && blacklist.IsValid(item)) return false; - if (_container.TryGetContainingContainer(item, out _) && !_container.TryRemoveFromContainer(item)) + if (Container.TryGetContainingContainer(item, out _) && !Container.TryRemoveFromContainer(item)) return false; if (user != null) @@ -133,7 +133,7 @@ public abstract class SharedMaterialReclaimerSystem : EntitySystem var active = EnsureComp(uid); active.Duration = duration; active.EndTime = Timing.CurTime + duration; - active.ReclaimingContainer.Insert(item); + Container.Insert(item, active.ReclaimingContainer); return true; } diff --git a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs index 23f0ce8a7c..b4cd625824 100644 --- a/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs +++ b/Content.Shared/Mech/EntitySystems/SharedMechSystem.cs @@ -220,7 +220,7 @@ public abstract class SharedMechSystem : EntitySystem return; equipmentComponent.EquipmentOwner = uid; - component.EquipmentContainer.Insert(toInsert, EntityManager); + _container.Insert(toInsert, component.EquipmentContainer); var ev = new MechEquipmentInsertedEvent(uid); RaiseLocalEvent(toInsert, ref ev); UpdateUserInterface(uid, component); @@ -258,7 +258,7 @@ public abstract class SharedMechSystem : EntitySystem CycleEquipment(uid, component); equipmentComponent.EquipmentOwner = null; - component.EquipmentContainer.Remove(toRemove, EntityManager); + _container.Remove(toRemove, component.EquipmentContainer); UpdateUserInterface(uid, component); } @@ -364,7 +364,7 @@ public abstract class SharedMechSystem : EntitySystem return false; SetupUser(uid, toInsert.Value); - component.PilotSlot.Insert(toInsert.Value, EntityManager); + _container.Insert(toInsert.Value, component.PilotSlot); UpdateAppearance(uid, component); return true; } diff --git a/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs b/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs index 03577d53ac..f6ce235ff7 100644 --- a/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs +++ b/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs @@ -76,7 +76,7 @@ public abstract partial class SharedCryoPodSystem: EntitySystem return false; var xform = Transform(target); - cryoPodComponent.BodyContainer.Insert(target, transform: xform); + _containerSystem.Insert((target, xform), cryoPodComponent.BodyContainer); EnsureComp(target); _standingStateSystem.Stand(target, force: true); // Force-stand the mob so that the cryo pod sprite overlays it fully @@ -117,7 +117,7 @@ public abstract partial class SharedCryoPodSystem: EntitySystem if (cryoPodComponent.BodyContainer.ContainedEntity is not {Valid: true} contained) return null; - cryoPodComponent.BodyContainer.Remove(contained); + _containerSystem.Remove(contained, cryoPodComponent.BodyContainer); // InsideCryoPodComponent is removed automatically in its EntGotRemovedFromContainerMessage listener // RemComp(contained); diff --git a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs index 31856eefac..746147eb5b 100644 --- a/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs +++ b/Content.Shared/Radio/EntitySystems/EncryptionKeySystem.cs @@ -134,7 +134,7 @@ public sealed partial class EncryptionKeySystem : EntitySystem return; } - if (component.KeyContainer.Insert(args.Used)) + if (_container.Insert(args.Used, component.KeyContainer)) { _popup.PopupClient(Loc.GetString("encryption-key-successfully-installed"), uid, args.User); _audio.PlayPredicted(component.KeyInsertionSound, args.Target, args.User); diff --git a/Content.Shared/Storage/EntitySystems/BinSystem.cs b/Content.Shared/Storage/EntitySystems/BinSystem.cs index 90bca4d933..afb1e52881 100644 --- a/Content.Shared/Storage/EntitySystems/BinSystem.cs +++ b/Content.Shared/Storage/EntitySystems/BinSystem.cs @@ -138,7 +138,7 @@ public sealed class BinSystem : EntitySystem if (component.Whitelist != null && !component.Whitelist.IsValid(toInsert)) return false; - component.ItemContainer.Insert(toInsert); + _container.Insert(toInsert, component.ItemContainer); component.Items.Add(toInsert); Dirty(component); return true; @@ -162,7 +162,7 @@ public sealed class BinSystem : EntitySystem if (toRemove == null || toRemove != component.Items.LastOrDefault()) return false; - if (!component.ItemContainer.Remove(toRemove.Value)) + if (!_container.Remove(toRemove.Value, component.ItemContainer)) return false; component.Items.Remove(toRemove.Value); diff --git a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs index 306f4aeaee..911c6e5380 100644 --- a/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs +++ b/Content.Shared/Storage/EntitySystems/SharedEntityStorageSystem.cs @@ -263,7 +263,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem } _joints.RecursiveClearJoints(toInsert); - if (!component.Contents.Insert(toInsert, EntityManager)) + if (!_container.Insert(toInsert, component.Contents)) return false; var inside = EnsureComp(toInsert); @@ -280,7 +280,7 @@ public abstract class SharedEntityStorageSystem : EntitySystem return false; RemComp(toRemove); - component.Contents.Remove(toRemove, EntityManager); + _container.Remove(toRemove, component.Contents); var pos = TransformSystem.GetWorldPosition(xform) + TransformSystem.GetWorldRotation(xform).RotateVec(component.EnteringOffset); TransformSystem.SetWorldPosition(toRemove, pos); return true; diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs index de664ee537..501d0069a7 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Ballistic.cs @@ -48,7 +48,7 @@ public abstract partial class SharedGunSystem return; component.Entities.Add(args.Used); - component.Container.Insert(args.Used); + Containers.Insert(args.Used, component.Container); // Not predicted so Audio.PlayPredicted(component.SoundInsert, uid, args.User); args.Handled = true; @@ -241,7 +241,7 @@ public abstract partial class SharedGunSystem args.Ammo.Add((entity, EnsureShootable(entity))); component.Entities.RemoveAt(component.Entities.Count - 1); - component.Container.Remove(entity); + Containers.Remove(entity, component.Container); } else if (component.UnspawnedCount > 0) { diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs index bd65ef5cf6..7220faa4d2 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.ChamberMagazine.cs @@ -290,7 +290,7 @@ public abstract partial class SharedGunSystem if (entity == null) return false; - container.Remove(entity.Value); + Containers.Remove(entity.Value, container); return true; } @@ -316,7 +316,7 @@ public abstract partial class SharedGunSystem { return Containers.TryGetContainer(uid, ChamberSlot, out var container) && container is ContainerSlot slot && - slot.Insert(ammo); + Containers.Insert(ammo, slot); } private void OnChamberAmmoCount(EntityUid uid, ChamberMagazineAmmoProviderComponent component, ref GetAmmoCountEvent args) diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Container.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Container.cs index d9a7cb53c1..27104c9d93 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Container.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Container.cs @@ -28,7 +28,7 @@ public partial class SharedGunSystem var ent = container.ContainedEntities[0]; if (_netManager.IsServer) - container.Remove(ent); + Containers.Remove(ent, container); args.Ammo.Add((ent, EnsureShootable(ent))); } diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs index f5eb7e8712..d3d3b7fcde 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.Revolver.cs @@ -132,7 +132,7 @@ public partial class SharedGunSystem } component.AmmoSlots[index] = ent.Value; - component.AmmoContainer.Insert(ent.Value, EntityManager); + Containers.Insert(ent.Value, component.AmmoContainer); if (ev.Ammo.Count == 0) break; @@ -160,7 +160,7 @@ public partial class SharedGunSystem } component.AmmoSlots[index] = uid; - component.AmmoContainer.Insert(uid); + Containers.Insert(uid, component.AmmoContainer); Audio.PlayPredicted(component.SoundInsert, revolverUid, user); Popup(Loc.GetString("gun-revolver-insert"), revolverUid, user); UpdateRevolverAppearance(revolverUid, component); @@ -283,7 +283,7 @@ public partial class SharedGunSystem else { component.AmmoSlots[i] = null; - component.AmmoContainer.Remove(slot.Value); + Containers.Remove(slot.Value, component.AmmoContainer); if (!_netManager.IsClient) EjectCartridge(slot.Value); @@ -366,7 +366,7 @@ public partial class SharedGunSystem continue; } - component.AmmoContainer.Remove(ent.Value); + Containers.Remove(ent.Value, component.AmmoContainer); component.AmmoSlots[index] = null; args.Ammo.Add((ent.Value, EnsureShootable(ent.Value))); TransformSystem.SetCoordinates(ent.Value, args.Coordinates);