diff --git a/Content.Server/Movement/Components/PullMoverComponent.cs b/Content.Server/Movement/Components/PullMoverComponent.cs
deleted file mode 100644
index 19a01c6b17..0000000000
--- a/Content.Server/Movement/Components/PullMoverComponent.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Content.Server.Movement.Components;
-
-///
-/// Added to an entity that is ctrl-click moving their pulled object.
-///
-///
-/// This just exists so we don't have MoveEvent subs going off for every single mob constantly.
-///
-[RegisterComponent]
-public sealed partial class PullMoverComponent : Component
-{
-
-}
diff --git a/Content.Server/Movement/Systems/PullController.cs b/Content.Server/Movement/Systems/PullController.cs
index 72110ff67d..f227d9c55c 100644
--- a/Content.Server/Movement/Systems/PullController.cs
+++ b/Content.Server/Movement/Systems/PullController.cs
@@ -18,6 +18,7 @@ using Robust.Shared.Physics.Controllers;
using Robust.Shared.Physics.Dynamics.Joints;
using Robust.Shared.Player;
using Robust.Shared.Timing;
+using Robust.Shared.Utility;
namespace Content.Server.Movement.Systems;
@@ -91,7 +92,7 @@ public sealed class PullController : VirtualController
UpdatesAfter.Add(typeof(MoverController));
SubscribeLocalEvent(OnPullStop);
- SubscribeLocalEvent(OnPullerMove);
+ SubscribeLocalEvent(OnPullerMove);
base.Initialize();
}
@@ -155,19 +156,22 @@ public sealed class PullController : VirtualController
coords = fromUserCoords.WithEntityId(coords.EntityId);
}
- EnsureComp(player);
var moving = EnsureComp(pulled!.Value);
moving.MovingTo = coords;
return false;
}
- private void OnPullerMove(EntityUid uid, PullMoverComponent component, ref MoveEvent args)
+ private void OnPullerMove(EntityUid uid, ActivePullerComponent component, ref MoveEvent args)
{
if (!_pullerQuery.TryComp(uid, out var puller))
return;
if (puller.Pulling is not { } pullable)
+ {
+ DebugTools.Assert($"Failed to clean up puller: {ToPrettyString(uid)}");
+ RemCompDeferred(uid, component);
return;
+ }
UpdatePulledRotation(uid, pullable);
@@ -182,13 +186,7 @@ public sealed class PullController : VirtualController
if (_physicsQuery.TryComp(uid, out var physics))
PhysicsSystem.WakeBody(uid, body: physics);
- StopMove(uid, pullable);
- }
-
- private void StopMove(Entity mover, Entity moving)
- {
- RemCompDeferred(mover.Owner);
- RemCompDeferred(moving.Owner);
+ RemCompDeferred(pullable);
}
private void UpdatePulledRotation(EntityUid puller, EntityUid pulled)
@@ -302,17 +300,5 @@ public sealed class PullController : VirtualController
PhysicsSystem.ApplyLinearImpulse(puller, -impulse);
}
}
-
- // Cleanup PullMover
- var moverQuery = EntityQueryEnumerator();
-
- while (moverQuery.MoveNext(out var uid, out _, out var puller))
- {
- if (!HasComp(puller.Pulling))
- {
- RemCompDeferred(uid);
- continue;
- }
- }
}
}
diff --git a/Content.Shared/Movement/Pulling/Components/ActivePullerComponent.cs b/Content.Shared/Movement/Pulling/Components/ActivePullerComponent.cs
new file mode 100644
index 0000000000..83bfd9f795
--- /dev/null
+++ b/Content.Shared/Movement/Pulling/Components/ActivePullerComponent.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared.Movement.Pulling.Components;
+
+///
+/// Component that indicates that an entity is currently pulling some other entity.
+///
+[RegisterComponent]
+public sealed partial class ActivePullerComponent : Component;
diff --git a/Content.Shared/Movement/Pulling/Components/PullerComponent.cs b/Content.Shared/Movement/Pulling/Components/PullerComponent.cs
index f47ae32f90..32e4d9b1f3 100644
--- a/Content.Shared/Movement/Pulling/Components/PullerComponent.cs
+++ b/Content.Shared/Movement/Pulling/Components/PullerComponent.cs
@@ -9,7 +9,7 @@ namespace Content.Shared.Movement.Pulling.Components;
///
/// Specifies an entity as being able to pull another entity with
///
-[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
+[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(PullingSystem))]
public sealed partial class PullerComponent : Component
{
diff --git a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs
index 161868370e..72b87476bb 100644
--- a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs
+++ b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs
@@ -61,6 +61,7 @@ public sealed class PullingSystem : EntitySystem
SubscribeLocalEvent(OnPullableContainerInsert);
SubscribeLocalEvent(OnModifyUncuffDuration);
+ SubscribeLocalEvent(OnAfterState);
SubscribeLocalEvent(OnPullerContainerInsert);
SubscribeLocalEvent(OnPullerUnpaused);
SubscribeLocalEvent(OnVirtualItemDeleted);
@@ -72,6 +73,14 @@ public sealed class PullingSystem : EntitySystem
.Register();
}
+ private void OnAfterState(Entity ent, ref AfterAutoHandleStateEvent args)
+ {
+ if (ent.Comp.Pulling == null)
+ RemComp(ent.Owner);
+ else
+ EnsureComp(ent.Owner);
+ }
+
private void OnDropHandItems(EntityUid uid, PullerComponent pullerComp, DropHandItemsEvent args)
{
if (pullerComp.Pulling == null || pullerComp.NeedsHands)
@@ -228,6 +237,9 @@ public sealed class PullingSystem : EntitySystem
}
var oldPuller = pullableComp.Puller;
+ if (oldPuller != null)
+ RemComp(oldPuller.Value);
+
pullableComp.PullJointId = null;
pullableComp.Puller = null;
Dirty(pullableUid, pullableComp);
@@ -410,6 +422,7 @@ public sealed class PullingSystem : EntitySystem
// Use net entity so it's consistent across client and server.
pullableComp.PullJointId = $"pull-joint-{GetNetEntity(pullableUid)}";
+ EnsureComp(pullerUid);
pullerComp.Pulling = pullableUid;
pullableComp.Puller = pullerUid;