]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Cleanup: Remove ``TryInsert`` method from the ``DisposableSystem`` and use event...
authorWinkarst-cpu <74284083+Winkarst-cpu@users.noreply.github.com>
Mon, 7 Jul 2025 19:13:35 +0000 (22:13 +0300)
committerGitHub <noreply@github.com>
Mon, 7 Jul 2025 19:13:35 +0000 (12:13 -0700)
Cleanup

Content.Server/Disposal/Tube/DisposalTubeSystem.cs
Content.Server/Disposal/Unit/DisposableSystem.cs

index 24653ce8d4035dbb6a7ae649db8c231b4034b51e..7e63bc4e233c4cc4e8a86356c054ec0290e3e6ff 100644 (file)
@@ -428,7 +428,7 @@ namespace Content.Server.Disposal.Tube
 
             foreach (var entity in from.Container.ContainedEntities.ToArray())
             {
-                _disposableSystem.TryInsert(holder, entity, holderComponent);
+                _containerSystem.Insert(entity, holderComponent.Container);
             }
 
             _atmosSystem.Merge(holderComponent.Air, from.Air);
index 091a91c14e5f20b67e3883862aac6710393ded75..d307488110ebc3a8700cc02f2902ccb113fc9ed8 100644 (file)
@@ -43,6 +43,8 @@ namespace Content.Server.Disposal.Unit
             _xformQuery = GetEntityQuery<TransformComponent>();
 
             SubscribeLocalEvent<DisposalHolderComponent, ComponentStartup>(OnComponentStartup);
+            SubscribeLocalEvent<DisposalHolderComponent, ContainerIsInsertingAttemptEvent>(CanInsert);
+            SubscribeLocalEvent<DisposalHolderComponent, EntInsertedIntoContainerMessage>(OnInsert);
         }
 
         private void OnComponentStartup(EntityUid uid, DisposalHolderComponent holder, ComponentStartup args)
@@ -50,34 +52,16 @@ namespace Content.Server.Disposal.Unit
             holder.Container = _containerSystem.EnsureContainer<Container>(uid, nameof(DisposalHolderComponent));
         }
 
-        public bool TryInsert(EntityUid uid, EntityUid toInsert, DisposalHolderComponent? holder = null)
+        private void CanInsert(Entity<DisposalHolderComponent> ent, ref ContainerIsInsertingAttemptEvent args)
         {
-            if (!Resolve(uid, ref holder))
-                return false;
-            if (!CanInsert(uid, toInsert, holder))
-                return false;
-
-            if (!_containerSystem.Insert(toInsert, holder.Container))
-                return false;
-
-            if (_physicsQuery.TryGetComponent(toInsert, out var physBody))
-                _physicsSystem.SetCanCollide(toInsert, false, body: physBody);
-
-            return true;
+            if (!HasComp<ItemComponent>(args.EntityUid) && !HasComp<BodyComponent>(args.EntityUid))
+                args.Cancel();
         }
 
-        private bool CanInsert(EntityUid uid, EntityUid toInsert, DisposalHolderComponent? holder = null)
+        private void OnInsert(Entity<DisposalHolderComponent> ent, ref EntInsertedIntoContainerMessage args)
         {
-            if (!Resolve(uid, ref holder))
-                return false;
-
-            if (!_containerSystem.CanInsert(toInsert, holder.Container))
-            {
-                return false;
-            }
-
-            return HasComp<ItemComponent>(toInsert) ||
-                   HasComp<BodyComponent>(toInsert);
+            if (_physicsQuery.TryGetComponent(args.Entity, out var physBody))
+                _physicsSystem.SetCanCollide(args.Entity, false, body: physBody);
         }
 
         public void ExitDisposals(EntityUid uid, DisposalHolderComponent? holder = null, TransformComponent? holderTransform = null)