Kill ContainerHelpers (#20908)

This commit is contained in:
Kara
2023-10-11 02:18:49 -07:00
committed by GitHub
parent 14dac914ce
commit dbb7c7065a
14 changed files with 54 additions and 46 deletions

View File

@@ -11,6 +11,8 @@ namespace Content.Server.Containers
[UsedImplicitly]
public sealed class EmptyOnMachineDeconstructSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _container = default!;
public override void Initialize()
{
base.Initialize();
@@ -33,12 +35,12 @@ namespace Content.Server.Containers
{
if (!EntityManager.TryGetComponent<ContainerManagerComponent>(uid, out var mComp))
return;
var baseCoords = EntityManager.GetComponent<TransformComponent>(component.Owner).Coordinates;
var baseCoords = EntityManager.GetComponent<TransformComponent>(uid).Coordinates;
foreach (var v in component.Containers)
{
if (mComp.TryGetContainer(v, out var container))
{
container.EmptyContainer(true, baseCoords);
_container.EmptyContainer(container, true, baseCoords);
}
}
}

View File

@@ -16,6 +16,7 @@ using Content.Shared.Destructible;
using Content.Shared.FixedPoint;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -36,6 +37,7 @@ namespace Content.Server.Destructible
[Dependency] public readonly TriggerSystem TriggerSystem = default!;
[Dependency] public readonly SolutionContainerSystem SolutionContainerSystem = default!;
[Dependency] public readonly PuddleSystem PuddleSystem = default!;
[Dependency] public readonly SharedContainerSystem ContainerSystem = default!;
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
[Dependency] public readonly IAdminLogManager _adminLogger = default!;

View File

@@ -15,7 +15,7 @@ namespace Content.Server.Destructible.Thresholds.Behaviors
foreach (var container in containerManager.GetAllContainers())
{
container.EmptyContainer(true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
system.ContainerSystem.EmptyContainer(container, true, system.EntityManager.GetComponent<TransformComponent>(owner).Coordinates);
}
}
}

View File

@@ -31,6 +31,7 @@ namespace Content.Server.Guardian
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
public override void Initialize()
{
@@ -88,7 +89,7 @@ namespace Content.Server.Guardian
private void OnHostInit(EntityUid uid, GuardianHostComponent component, ComponentInit args)
{
component.GuardianContainer = uid.EnsureContainer<ContainerSlot>("GuardianContainer");
component.GuardianContainer = _container.EnsureContainer<ContainerSlot>(uid, "GuardianContainer");
_actionSystem.AddAction(uid, ref component.ActionEntity, component.Action);
}

View File

@@ -169,9 +169,9 @@ namespace Content.Server.Hands.Systems
if (playerSession.AttachedEntity is not {Valid: true} player ||
!Exists(player) ||
player.IsInContainer() ||
ContainerSystem.IsEntityInContainer(player) ||
!TryComp(player, out HandsComponent? hands) ||
hands.ActiveHandEntity is not EntityUid throwEnt ||
hands.ActiveHandEntity is not { } throwEnt ||
!_actionBlockerSystem.CanThrow(player, throwEnt))
return false;

View File

@@ -2,7 +2,6 @@ using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Server.Chemistry.EntitySystems;
using Content.Server.Nutrition.Components;
using Content.Shared.Nutrition.Components;
using Content.Shared.Chemistry;
using Content.Shared.Chemistry.Reagent;
@@ -29,11 +28,12 @@ namespace Content.Server.Nutrition.EntitySystems
[Dependency] private readonly InventorySystem _inventorySystem = default!;
[Dependency] private readonly ClothingSystem _clothing = default!;
[Dependency] private readonly SharedItemSystem _items = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
private const float UpdateTimer = 3f;
private float _timer = 0f;
private float _timer;
/// <summary>
/// We keep a list of active smokables, because iterating all existing smokables would be dumb.
@@ -130,8 +130,8 @@ namespace Content.Server.Nutrition.EntitySystems
// This is awful. I hate this so much.
// TODO: Please, someone refactor containers and free me from this bullshit.
if (!smokable.Owner.TryGetContainerMan(out var containerManager) ||
!(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == smokable.Owner) ||
if (!_container.TryGetContainingContainer(uid, out var containerManager) ||
!(_inventorySystem.TryGetSlotEntity(containerManager.Owner, "mask", out var inMaskSlotUid) && inMaskSlotUid == uid) ||
!TryComp(containerManager.Owner, out BloodstreamComponent? bloodstream))
{
continue;

View File

@@ -80,7 +80,7 @@ public sealed class EscapeInventorySystem : EntitySystem
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
return;
Dirty(component);
Dirty(user, component);
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
}
@@ -88,12 +88,12 @@ public sealed class EscapeInventorySystem : EntitySystem
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
{
component.DoAfter = null;
Dirty(component);
Dirty(uid, component);
if (args.Handled || args.Cancelled)
return;
Transform(uid).AttachParentToContainerOrGrid(EntityManager);
_containerSystem.AttachParentToContainerOrGrid(Transform(uid));
args.Handled = true;
}