]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Kill `ContainerHelpers` (#20908)
authorKara <lunarautomaton6@gmail.com>
Wed, 11 Oct 2023 09:18:49 +0000 (02:18 -0700)
committerGitHub <noreply@github.com>
Wed, 11 Oct 2023 09:18:49 +0000 (20:18 +1100)
14 files changed:
Content.Client/Commands/HideMechanismsCommand.cs
Content.Client/Instruments/UI/InstrumentMenu.xaml.cs
Content.Client/Interactable/InteractionSystem.cs
Content.Server/Containers/EmptyOnMachineDeconstructSystem.cs
Content.Server/Destructible/DestructibleSystem.cs
Content.Server/Destructible/Thresholds/Behaviors/EmptyAllContainersBehaviour.cs
Content.Server/Guardian/GuardianSystem.cs
Content.Server/Hands/Systems/HandsSystem.cs
Content.Server/Nutrition/EntitySystems/SmokingSystem.cs
Content.Server/Resist/EscapeInventorySystem.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.Virtual.cs
Content.Shared/Hands/EntitySystems/SharedHandsSystem.cs

index 88100a0f8c1a7c3f075c1ef730deeaf5da208364..e9c2073b20af96792863a5be1e41f216b5f0aea7 100644 (file)
@@ -15,6 +15,7 @@ namespace Content.Client.Commands
         public void Execute(IConsoleShell shell, string argStr, string[] args)
         {
             var entityManager = IoCManager.Resolve<IEntityManager>();
+            var containerSys = entityManager.System<SharedContainerSystem>();
             var organs = entityManager.EntityQuery<OrganComponent>(true);
 
             foreach (var part in organs)
@@ -27,7 +28,7 @@ namespace Content.Client.Commands
                 sprite.ContainerOccluded = false;
 
                 var tempParent = part.Owner;
-                while (tempParent.TryGetContainer(out var container))
+                while (containerSys.TryGetContainingContainer(tempParent, out var container))
                 {
                     if (!container.ShowContents)
                     {
index b50ab96251e9d346934cb167e2ba7c2e6fab4ea8..201b7b630418e77b6753b351fb6ddcdadb3116cf 100644 (file)
@@ -174,8 +174,9 @@ namespace Content.Client.Instruments.UI
             if (localPlayer.ControlledEntity == instrumentEnt)
                 return true;
 
+            var container = _owner.Entities.System<SharedContainerSystem>();
             // If we're a handheld instrument, we might be in a container. Get it just in case.
-            instrumentEnt.TryGetContainerMan(out var conMan);
+            container.TryGetContainingContainer(instrumentEnt, out var conMan);
 
             // If the instrument is handheld and we're not holding it, we return.
             if ((instrument.Handheld && (conMan == null || conMan.Owner != localPlayer.ControlledEntity)))
index cdfd3aa54fa83c17b887457ed13efccf6e88e6fb..0af8830e9acd45457248e826ea3eb1236356b9f9 100644 (file)
@@ -6,15 +6,17 @@ namespace Content.Client.Interactable
 {
     public sealed class InteractionSystem : SharedInteractionSystem
     {
+        [Dependency] private readonly SharedContainerSystem _container = default!;
+
         public override bool CanAccessViaStorage(EntityUid user, EntityUid target)
         {
             if (!EntityManager.EntityExists(target))
                 return false;
 
-            if (!target.TryGetContainer(out var container))
+            if (!_container.TryGetContainingContainer(target, out var container))
                 return false;
 
-            if (!TryComp(container.Owner, out StorageComponent? storage))
+            if (!HasComp<StorageComponent>(container.Owner))
                 return false;
 
             // we don't check if the user can access the storage entity itself. This should be handed by the UI system.
index 234408c3bab300802395c6cb7531619a2b4d15ce..c0cae8fdf7cc8cbc19c2a281e6383ac37e368888 100644 (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);
                 }
             }
         }
index b9c260a7d9b8f5c5d493fd9086f306c79c99cb5d..0ef0d621f315add9859e51f5baabb77a111ab4ea 100644 (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!;
index 406e7bf7e2801aaa4117242ce1b1caaeb0e4ab74..e696ad92580d28383af6782320197a7c6f47bcbe 100644 (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);
             }
         }
     }
index f34b765ac77ef8c72281fe1fe928ea4ef4eecbc6..118574db3f75bcc80d1d80632d5d256ede1b3168 100644 (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);
         }
 
index 1cae95c78eb7d2739baa655ec558410b1c9a72e6..298aa57ccf212cdc2d146016bd26fd27d5a2099a 100644 (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;
 
index 772e87211053226763fe8d5117274e0bbc57abd8..96c7f8a64c4bd0f30dbc26fd0ebf1ac8d8bdff9b 100644 (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;
index eb7c4c847866eeebe2ce83e0cfebc0620318b58d..ea603084b55c7457bea3821f5d92f613cb74c2b1 100644 (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;
     }
 
index e43f2561a16142dab4d95e4006414f36187a08c6..06d6526566bfebd684ca4fa2948131a846959831 100644 (file)
@@ -6,10 +6,8 @@ using Robust.Shared.Map;
 
 namespace Content.Shared.Hands.EntitySystems;
 
-public abstract partial class SharedHandsSystem : EntitySystem
+public abstract partial class SharedHandsSystem
 {
-    [Dependency] private readonly SharedContainerSystem _container = default!;
-
     private void InitializeDrop()
     {
         SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
@@ -23,10 +21,10 @@ public abstract partial class SharedHandsSystem : EntitySystem
         }
 
         var gotUnequipped = new GotUnequippedHandEvent(uid, args.Entity, hand);
-        RaiseLocalEvent(args.Entity, gotUnequipped, false);
+        RaiseLocalEvent(args.Entity, gotUnequipped);
 
         var didUnequip = new DidUnequipHandEvent(uid, args.Entity, hand);
-        RaiseLocalEvent(uid, didUnequip, false);
+        RaiseLocalEvent(uid, didUnequip);
     }
 
     /// <summary>
@@ -37,7 +35,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (hand.Container?.ContainedEntity is not {} held)
             return false;
 
-        if (!_container.CanRemove(held, hand.Container))
+        if (!ContainerSystem.CanRemove(held, hand.Container))
             return false;
 
         if (checkActionBlocker && !_actionBlocker.CanDrop(uid))
@@ -90,7 +88,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
 
         var userXform = Transform(uid);
         var itemXform = Transform(entity);
-        var isInContainer = _containerSystem.IsEntityInContainer(uid);
+        var isInContainer = ContainerSystem.IsEntityInContainer(uid);
 
         if (targetDropLocation == null || isInContainer)
         {
@@ -98,14 +96,14 @@ public abstract partial class SharedHandsSystem : EntitySystem
             // TODO recursively check upwards for containers
 
             if (!isInContainer
-                || !_containerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true)
+                || !ContainerSystem.TryGetContainingContainer(userXform.ParentUid, uid, out var container, skipExistCheck: true)
                 || !container.Insert(entity, EntityManager, itemXform))
-                itemXform.AttachToGridOrMap();
+                TransformSystem.AttachToGridOrMap(entity, itemXform);
             return true;
         }
 
-        var target = targetDropLocation.Value.ToMap(EntityManager);
-        itemXform.WorldPosition = GetFinalDropCoordinates(uid, userXform.MapPosition, target);
+        var target = targetDropLocation.Value.ToMap(EntityManager, TransformSystem);
+        TransformSystem.SetWorldPosition(userXform, GetFinalDropCoordinates(uid, userXform.MapPosition, target));
         return true;
     }
 
@@ -123,7 +121,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (!CanDropHeld(uid, hand, checkActionBlocker))
             return false;
 
-        if (!_container.CanInsert(entity, targetContainer))
+        if (!ContainerSystem.CanInsert(entity, targetContainer))
             return false;
 
         DoDrop(uid, hand, false, handsComp);
@@ -171,12 +169,12 @@ public abstract partial class SharedHandsSystem : EntitySystem
             return;
         }
 
-        Dirty(handsComp);
+        Dirty(uid, handsComp);
 
         if (doDropInteraction)
             _interactionSystem.DroppedInteraction(uid, entity);
 
         if (hand == handsComp.ActiveHand)
-            RaiseLocalEvent(entity, new HandDeselectedEvent(uid), false);
+            RaiseLocalEvent(entity, new HandDeselectedEvent(uid));
     }
 }
index 278470c4a2c2f97df83a8512b37e28a6bd1b4482..0171b9f70c9dac6bf1d7ef854070b15715560583 100644 (file)
@@ -180,7 +180,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
             return false;
 
         // check can insert (including raising attempt events).
-        return _containerSystem.CanInsert(entity, handContainer);
+        return ContainerSystem.CanInsert(entity, handContainer);
     }
 
     /// <summary>
@@ -202,7 +202,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
         {
             // TODO make this check upwards for any container, and parent to that.
             // Currently this just checks the direct parent, so items can still teleport through containers.
-            Transform(entity).AttachParentToContainerOrGrid(EntityManager);
+            ContainerSystem.AttachParentToContainerOrGrid(Transform(entity));
         }
     }
 
index 36498d929b1a81ba5b876b884f105591bcb54ae3..b83ec8c128ca7c8473f9bcd60498236851ef16ab 100644 (file)
@@ -12,7 +12,7 @@ public abstract partial class SharedHandsSystem
     private void OnVirtualAfter(EntityUid uid, HandVirtualItemComponent component, ref AfterAutoHandleStateEvent args)
     {
         // update hands GUI with new entity.
-        if (_containerSystem.IsEntityInContainer(uid))
+        if (ContainerSystem.IsEntityInContainer(uid))
             _items.VisualsChanged(uid);
     }
 }
index af53b2625c005b3c113f58dc89bdca8d648acab8..9f7623329e4082beeff1fc585382dda15605b917 100644 (file)
@@ -11,11 +11,11 @@ using Robust.Shared.Input.Binding;
 
 namespace Content.Shared.Hands.EntitySystems;
 
-public abstract partial class SharedHandsSystem : EntitySystem
+public abstract partial class SharedHandsSystem
 {
     [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
     [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!;
-    [Dependency] private readonly SharedContainerSystem _containerSystem = default!;
+    [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!;
     [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
     [Dependency] private readonly SharedItemSystem _items = default!;
     [Dependency] private readonly SharedStorageSystem _storage = default!;
@@ -47,7 +47,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (handsComp.Hands.ContainsKey(handName))
             return;
 
-        var container = _containerSystem.EnsureContainer<ContainerSlot>(uid, handName);
+        var container = ContainerSystem.EnsureContainer<ContainerSlot>(uid, handName);
         container.OccludesLight = false;
 
         var newHand = new Hand(handName, handLocation, container);
@@ -57,8 +57,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (handsComp.ActiveHand == null)
             SetActiveHand(uid, newHand, handsComp);
 
-        RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
-        Dirty(handsComp);
+        RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
+        Dirty(uid, handsComp);
     }
 
     public virtual void RemoveHand(EntityUid uid, string handName, HandsComponent? handsComp = null)
@@ -76,8 +76,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (handsComp.ActiveHand == hand)
             TrySetActiveHand(uid, handsComp.SortedHands.FirstOrDefault(), handsComp);
 
-        RaiseLocalEvent(uid, new HandCountChangedEvent(uid), false);
-        Dirty(handsComp);
+        RaiseLocalEvent(uid, new HandCountChangedEvent(uid));
+        Dirty(uid, handsComp);
     }
 
     /// <summary>
@@ -169,7 +169,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
             if (name == handsComp.ActiveHand?.Name)
                 continue;
 
-            if (handsComp.Hands[name].HeldEntity is EntityUid held)
+            if (handsComp.Hands[name].HeldEntity is { } held)
                 yield return held;
         }
     }
@@ -206,8 +206,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
         if (hand == handComp.ActiveHand)
             return false;
 
-        if (handComp.ActiveHand?.HeldEntity is EntityUid held)
-            RaiseLocalEvent(held, new HandDeselectedEvent(uid), false);
+        if (handComp.ActiveHand?.HeldEntity is { } held)
+            RaiseLocalEvent(held, new HandDeselectedEvent(uid));
 
         if (hand == null)
         {
@@ -219,8 +219,9 @@ public abstract partial class SharedHandsSystem : EntitySystem
         OnHandSetActive?.Invoke(handComp);
 
         if (hand.HeldEntity != null)
-            RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid), false);
-        Dirty(handComp);
+            RaiseLocalEvent(hand.HeldEntity.Value, new HandSelectedEvent(uid));
+
+        Dirty(uid, handComp);
         return true;
     }