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)
await server.WaitAssertion(() =>
{
#pragma warning disable NUnit2045 // Interdependent assertions.
- Assert.That(container.Insert(user));
+ Assert.That(conSystem.Insert(user, container));
Assert.That(sEntities.GetComponent<TransformComponent>(user).ParentUid, Is.EqualTo(containerEntity));
#pragma warning restore NUnit2045
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);
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);
{
if (_containerSystem.CanInsert(itemToSpawn, pocket1Slot))
{
- pocket1Slot.Insert(itemToSpawn);
+ _containerSystem.Insert(itemToSpawn, pocket1Slot);
}
}
else if (_inventory.TryGetSlotContainer(antag, "pocket2", out var pocket2Slot, out _))
{
if (_containerSystem.CanInsert(itemToSpawn, pocket2Slot))
{
- pocket2Slot.Insert(itemToSpawn);
+ _containerSystem.Insert(itemToSpawn, pocket2Slot);
}
}
}
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);
var cloneMindReturn = EntityManager.AddComponent<BeingClonedComponent>(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);
return;
EntityManager.RemoveComponent<BeingClonedComponent>(entity);
- clonePod.BodyContainer.Remove(entity);
+ _containerSystem.Remove(entity, clonePod.BodyContainer);
clonePod.CloningProgress = 0f;
clonePod.UsedBiomass = 0;
UpdateStatus(uid, CloningPodStatus.Idle, clonePod);
return;
}
- container.Remove(cell);
+ containerSystem.Remove(cell, container);
var transform = entityManager.GetComponent<TransformComponent>(uid);
var mech = entityManager.SpawnEntity(MechPrototype, transform.Coordinates);
if (entityManager.TryGetComponent<MechComponent>(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);
foreach (var contained in container.ContainedEntities.ToArray())
{
- if(container.Remove(contained))
+ if(containerSys.Remove(contained, container))
entityManager.QueueDeleteEntity(contained);
}
}
foreach (var contained in from.ContainedEntities.ToArray())
{
- if (from.Remove(contained))
- to.Insert(contained);
+ if (containerSystem.Remove(contained, from))
+ containerSystem.Insert(contained, to);
}
}
}
var coordinates = entityManager.GetComponent<TransformComponent>(uid).Coordinates;
for (var i = 0; i < Amount; i++)
{
- container.Insert(entityManager.SpawnEntity(Prototype, coordinates));
+ containerSystem.Insert(entityManager.SpawnEntity(Prototype, coordinates), container);
}
}
}
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}!");
}
}
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);
}
}
}
{
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);
}
}
void ShutdownContainers()
{
- container.Shutdown();
+ _container.ShutdownContainer(container);
foreach (var c in containers.Values.ToArray())
{
- c.Shutdown();
+ _container.ShutdownContainer(c);
}
}
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;
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;
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);
}
}
construction.Containers.Add(store);
// The container doesn't necessarily need to exist, so we ensure it.
- _container.EnsureContainer<Container>(uid, store).Insert(insert);
+ _container.Insert(insert, _container.EnsureContainer<Container>(uid, store));
}
else
{
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"}!");
}
{
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"}!");
}
}
{
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"}");
}
{
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"}");
}
}
{
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"}");
}
}
return;
args.Handled = true;
- if (!component.PartContainer.Insert(args.Used))
+ if (!_container.Insert(args.Used, component.PartContainer))
return;
}
return;
args.Handled = true;
- if (!component.PartContainer.Insert(args.Used))
+ if (!_container.Insert(args.Used, component.PartContainer))
return;
}
if (!_container.TryRemoveFromContainer(used))
return false;
- if (!component.BoardContainer.Insert(used))
+ if (!_container.Insert(used, component.BoardContainer))
return true;
ResetProgressAndRequirements(component, machineBoard);
if (!_container.TryRemoveFromContainer(used))
return false;
- if (!component.PartContainer.Insert(used))
+ if (!_container.Insert(used, component.PartContainer))
return true;
component.Progress[machinePart.PartType]++;
if (!_container.TryRemoveFromContainer(used))
return false;
- if (!component.PartContainer.Insert(used))
+ if (!_container.Insert(used, component.PartContainer))
return true;
component.MaterialProgress[type] += count;
if (splitStack == null)
return false;
- if (!component.PartContainer.Insert(splitStack.Value))
+ if (!_container.Insert(splitStack.Value, component.PartContainer))
return true;
component.MaterialProgress[type] += needed;
}
foreach (var part in updatedParts)
{
- machine.PartContainer.Insert(part.part, EntityManager);
+ _container.Insert(part.part, machine.PartContainer);
machineParts.Remove(part);
}
if (!machine.Requirements.ContainsKey(part.PartType))
continue;
- machine.PartContainer.Insert(partEnt, EntityManager);
+ _container.Insert(partEnt, machine.PartContainer);
machine.Progress[part.PartType]++;
machineParts.Remove(pair);
}
{
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);
}
}
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);
}
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))
RemComp<BeingDisposedComponent>(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);
}
// Insert into next tube
- if (!to.Contents.Insert(holderUid))
+ if (!_containerSystem.Insert(holderUid, to.Contents))
{
ExitDisposals(holderUid, holder, holderTransform);
return false;
// 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);
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)}");
public void Remove(EntityUid uid, SharedDisposalUnitComponent component, EntityUid toRemove)
{
- component.Container.Remove(toRemove);
+ _containerSystem.Remove(toRemove, component.Container);
if (component.Container.ContainedEntities.Count == 0)
{
{
_audioSystem.PlayPvs(component.InsertSound, uid);
- if (!component.Container.Insert(inserted))
+ if (!_containerSystem.Insert(inserted, component.Container))
return;
if (user != inserted && user != null)
}
component.Ensnared = target;
- ensnareable.Container.Insert(ensnare);
+ _container.Insert(ensnare, ensnareable.Container);
ensnareable.IsEnsnared = true;
Dirty(ensnareable);
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;
if (args.Handled || !TryComp<EnsnaringComponent>(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;
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;
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);
// 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<GuardianComponent>(guardian, out var guardianComp))
}
DebugTools.Assert(hostComponent.GuardianContainer.Contains(guardian));
- hostComponent.GuardianContainer.Remove(guardian);
+ _container.Remove(guardian, hostComponent.GuardianContainer);
DebugTools.Assert(!hostComponent.GuardianContainer.Contains(guardian));
guardianComponent.GuardianLoose = true;
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;
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;
[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<EntityUid> _queuedIdentityUpdates = new();
var ident = Spawn(null, Transform(uid).Coordinates);
QueueIdentityUpdate(uid);
- component.IdentityEntitySlot.Insert(ident);
+ _container.Insert(ident, component.IdentityEntitySlot);
}
/// <summary>
if (metaData.EntityPrototype.ID == recipeSolid.Key)
{
- component.Storage.Remove(item);
+ _sharedContainer.Remove(item, component.Storage);
EntityManager.DeleteEntity(item);
break;
}
foreach (var part in headSlots)
{
- component.Storage.Insert(part.Id);
+ _container.Insert(part.Id, component.Storage);
headCount++;
}
}
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);
}
if (!HasContents(component) || HasComp<ActiveMicrowaveComponent>(uid))
return;
- component.Storage.Remove(EntityManager.GetEntity(args.EntityID));
+ _sharedContainer.Remove(EntityManager.GetEntity(args.EntityID), component.Storage);
UpdateUserInterfaceState(uid, component);
}
if (inputContainer.ContainedEntities.Count >= reagentGrinder.StorageMaxEntities)
return;
- if (!inputContainer.Insert(heldEnt, EntityManager))
+ if (!_containerSystem.Insert(heldEnt, inputContainer))
return;
args.Handled = true;
ClickSound(uid, reagentGrinder);
foreach (var entity in inputContainer.ContainedEntities.ToList())
{
- inputContainer.Remove(entity);
+ _containerSystem.Remove(entity, inputContainer);
_randomHelper.RandomOffset(entity, 0.4f);
}
UpdateUiState(uid);
var inputContainer = _containerSystem.EnsureContainer<Container>(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);
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;
}
}
// 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",
if (light.HasLampOnSpawn != null)
{
var entity = EntityManager.SpawnEntity(light.HasLampOnSpawn, EntityManager.GetComponent<TransformComponent>(uid).Coordinates);
- light.LightBulbContainer.Insert(entity);
+ _containerSystem.Insert(entity, light.LightBulbContainer);
}
// need this to update visualizers
UpdateLight(uid, light);
return false;
// try to insert bulb in container
- if (!light.LightBulbContainer.Insert(bulbUid))
+ if (!_containerSystem.Insert(bulbUid, light.LightBulbContainer))
return false;
UpdateLight(uid, light);
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
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.
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);
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;
if (!val && tagComp.Tags.Contains(tag))
{
component.RequiredParts[tag] = true;
- component.PartsContainer.Insert(args.Used);
+ _container.Insert(args.Used, component.PartsContainer);
break;
}
}
if (!Resolve(toInsert, ref battery, false))
return;
- component.BatterySlot.Insert(toInsert);
+ _container.Insert(toInsert, component.BatterySlot);
component.Energy = battery.CurrentCharge;
component.MaxEnergy = battery.MaxCharge;
if (!HasComp<BodyComponent>(to_insert))
return;
- scannerComponent.BodyContainer.Insert(to_insert);
+ _containerSystem.Insert(to_insert, scannerComponent.BodyContainer);
UpdateAppearance(uid, scannerComponent);
}
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);
}
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;
[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()
{
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);
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 &&
continue;
}
- component.ProvidedContainer.Remove(item, EntityManager, force: true);
+ _container.Remove(item, component.ProvidedContainer, force: true);
}
if (!item.IsValid())
if (LifeStage(item) <= EntityLifeStage.MapInitialized)
{
RemComp<UnremoveableComponent>(item);
- component.ProvidedContainer.Insert(item, EntityManager);
+ _container.Insert(item, component.ProvidedContainer);
}
_hands.RemoveHand(chassis, handId, hands);
}
_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);
}
_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);
[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<JobPrototype>]
public const string BorgJobId = "Borg";
}
}
- 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;
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;
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);
// add container to entity and insert sticker into it
var container = _containerSystem.EnsureContainer<Container>(target, StickerSlotId);
container.ShowContents = true;
- if (!container.Insert(uid))
+ if (!_containerSystem.Insert(uid, container))
return;
// show message to user
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);
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;
{
[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!;
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++;
}
}
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++;
}
}
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!;
foreach (var entity in storage.Contents.ContainedEntities.ToArray())
{
- storage.Contents.Remove(entity);
+ _container.Remove(entity, storage.Contents);
_entityStorage.AddToContents(entity, lockerEnt);
}
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)
DebugTools.AssertOwner(uid, comp);
comp ??= EnsureComp<ActionsContainerComponent>(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;
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)
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);
if (!Containers.TryGetContainer(partId, containerId, out var container))
return false;
- return container.Insert(organId);
+ return Containers.Insert(organId, container);
}
/// <summary>
if (!HasComp<BodyPartComponent>(parent))
return false;
- return container.Remove(organId);
+ return Containers.Remove(organId, container);
}
/// <summary>
return false;
}
- return body.RootContainer.Insert(partId);
+ return Containers.Insert(partId, body.RootContainer);
}
#endregion
return false;
}
- return container.Insert(partId);
+ return Containers.Insert(partId, container);
}
#endregion
{
_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)
if (!_inventorySystem.TryUnequip(Transform(uid).ParentUid, toggleCom.Slot, force: true))
return;
- toggleCom.Container.Insert(uid, EntityManager);
+ _containerSystem.Insert(uid, toggleCom.Container);
args.Handled = true;
}
// 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);
}
/// <summary>
var attachedClothing = EnsureComp<AttachedClothingComponent>(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);
}
return false;
component.CurrentAssembly = assemblyId;
- component.PartsContainer.Insert(part);
+ _container.Insert(part, component.PartsContainer);
var ev = new PartAssemblyPartInsertedEvent();
RaiseLocalEvent(uid, ev);
return true;
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();
continue;
var item = EntityManager.SpawnEntity(slot.StartingItem, EntityManager.GetComponent<TransformComponent>(uid).Coordinates);
- slot.ContainerSlot?.Insert(item);
+ if (slot.ContainerSlot != null)
+ _containers.Insert(item, slot.ContainerSlot);
}
}
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).
/// Useful for predicted interactions</param>
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
/// Useful for predicted interactions</param>
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
var container = cuffable.Container;
var entity = container.ContainedEntities[^1];
- container.Remove(entity);
+ _container.Remove(entity, container);
_transform.SetWorldPosition(entity, _transform.GetWorldPosition(owner));
}
// Success!
_hands.TryDrop(user, handcuff);
- component.Container.Insert(handcuff);
+ _container.Insert(handcuff, component.Container);
UpdateHeldItems(target, handcuff, component);
return true;
}
_audio.PlayPredicted(cuff.EndUncuffSound, target, user);
- cuffable.Container.Remove(cuffsToRemove);
+ _container.Remove(cuffsToRemove, cuffable.Container);
if (_net.IsServer)
{
[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()
{
{
//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<Container>(uid, "stomach");
+ component.Stomach = ContainerSystem.EnsureContainer<Container>(uid, "stomach");
_actionsSystem.AddAction(uid, ref component.DevourActionEntity, component.DevourAction);
}
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;
}
return false;
DoDrop(uid, hand, false, handsComp);
- targetContainer.Insert(entity);
+ ContainerSystem.Insert(entity, targetContainer);
return true;
}
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;
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;
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);
var implantedComp = EnsureComp<ImplantedComponent>(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);
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 };
{
if (_tag.HasTag(implant, "MicroBomb"))
{
- implantContainer.Remove(implant);
+ _container.Remove(implant, implantContainer);
QueueDel(implant);
}
}
var implantContainer = implantedComp.ImplantContainer;
component.ImplantedEntity = target;
- implantContainer.Insert(implant);
+ _container.Insert(implant, implantContainer);
}
/// <summary>
var implantContainer = implanted.ImplantContainer;
- implantContainer.Remove(implant);
+ _container.Remove(implant, implantContainer);
QueueDel(implant);
}
return false;
}
- if (!slotContainer.Insert(itemUid))
+ if (!_containerSystem.Insert(itemUid, slotContainer))
{
if(!silent && _gameTiming.IsFirstTimePredicted)
_popup.PopupCursor(Loc.GetString("inventory-component-can-unequip-cannot"));
}
}
- 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
[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";
private void OnActiveStartup(EntityUid uid, ActiveMaterialReclaimerComponent component, ComponentStartup args)
{
- component.ReclaimingContainer = _container.EnsureContainer<Container>(uid, ActiveReclaimerContainerId);
+ component.ReclaimingContainer = Container.EnsureContainer<Container>(uid, ActiveReclaimerContainerId);
}
private void OnActiveUnpaused(EntityUid uid, ActiveMaterialReclaimerComponent component, ref EntityUnpausedEvent args)
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)
var active = EnsureComp<ActiveMaterialReclaimerComponent>(uid);
active.Duration = duration;
active.EndTime = Timing.CurTime + duration;
- active.ReclaimingContainer.Insert(item);
+ Container.Insert(item, active.ReclaimingContainer);
return true;
}
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);
CycleEquipment(uid, component);
equipmentComponent.EquipmentOwner = null;
- component.EquipmentContainer.Remove(toRemove, EntityManager);
+ _container.Remove(toRemove, component.EquipmentContainer);
UpdateUserInterface(uid, component);
}
return false;
SetupUser(uid, toInsert.Value);
- component.PilotSlot.Insert(toInsert.Value, EntityManager);
+ _container.Insert(toInsert.Value, component.PilotSlot);
UpdateAppearance(uid, component);
return true;
}
return false;
var xform = Transform(target);
- cryoPodComponent.BodyContainer.Insert(target, transform: xform);
+ _containerSystem.Insert((target, xform), cryoPodComponent.BodyContainer);
EnsureComp<InsideCryoPodComponent>(target);
_standingStateSystem.Stand(target, force: true); // Force-stand the mob so that the cryo pod sprite overlays it fully
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<InsideCryoPodComponent>(contained);
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);
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;
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);
}
_joints.RecursiveClearJoints(toInsert);
- if (!component.Contents.Insert(toInsert, EntityManager))
+ if (!_container.Insert(toInsert, component.Contents))
return false;
var inside = EnsureComp<InsideEntityStorageComponent>(toInsert);
return false;
RemComp<InsideEntityStorageComponent>(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;
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;
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)
{
if (entity == null)
return false;
- container.Remove(entity.Value);
+ Containers.Remove(entity.Value, container);
return true;
}
{
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)
var ent = container.ContainedEntities[0];
if (_netManager.IsServer)
- container.Remove(ent);
+ Containers.Remove(ent, container);
args.Ammo.Add((ent, EnsureShootable(ent)));
}
}
component.AmmoSlots[index] = ent.Value;
- component.AmmoContainer.Insert(ent.Value, EntityManager);
+ Containers.Insert(ent.Value, component.AmmoContainer);
if (ev.Ammo.Count == 0)
break;
}
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);
else
{
component.AmmoSlots[i] = null;
- component.AmmoContainer.Remove(slot.Value);
+ Containers.Remove(slot.Value, component.AmmoContainer);
if (!_netManager.IsClient)
EjectCartridge(slot.Value);
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);