using Robust.Shared.Physics.Dynamics.Joints;
using Robust.Shared.Player;
using Robust.Shared.Timing;
+using Robust.Shared.Utility;
namespace Content.Server.Movement.Systems;
UpdatesAfter.Add(typeof(MoverController));
SubscribeLocalEvent<PullMovingComponent, PullStoppedMessage>(OnPullStop);
- SubscribeLocalEvent<PullMoverComponent, MoveEvent>(OnPullerMove);
+ SubscribeLocalEvent<ActivePullerComponent, MoveEvent>(OnPullerMove);
base.Initialize();
}
coords = fromUserCoords.WithEntityId(coords.EntityId);
}
- EnsureComp<PullMoverComponent>(player);
var moving = EnsureComp<PullMovingComponent>(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);
if (_physicsQuery.TryComp(uid, out var physics))
PhysicsSystem.WakeBody(uid, body: physics);
- StopMove(uid, pullable);
- }
-
- private void StopMove(Entity<PullMoverComponent?> mover, Entity<PullMovingComponent?> moving)
- {
- RemCompDeferred<PullMoverComponent>(mover.Owner);
- RemCompDeferred<PullMovingComponent>(moving.Owner);
+ RemCompDeferred<PullMovingComponent>(pullable);
}
private void UpdatePulledRotation(EntityUid puller, EntityUid pulled)
PhysicsSystem.ApplyLinearImpulse(puller, -impulse);
}
}
-
- // Cleanup PullMover
- var moverQuery = EntityQueryEnumerator<PullMoverComponent, PullerComponent>();
-
- while (moverQuery.MoveNext(out var uid, out _, out var puller))
- {
- if (!HasComp<PullMovingComponent>(puller.Pulling))
- {
- RemCompDeferred<PullMoverComponent>(uid);
- continue;
- }
- }
}
}
SubscribeLocalEvent<PullableComponent, EntGotInsertedIntoContainerMessage>(OnPullableContainerInsert);
SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
+ SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
SubscribeLocalEvent<PullerComponent, EntityUnpausedEvent>(OnPullerUnpaused);
SubscribeLocalEvent<PullerComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
.Register<PullingSystem>();
}
+ private void OnAfterState(Entity<PullerComponent> ent, ref AfterAutoHandleStateEvent args)
+ {
+ if (ent.Comp.Pulling == null)
+ RemComp<ActivePullerComponent>(ent.Owner);
+ else
+ EnsureComp<ActivePullerComponent>(ent.Owner);
+ }
+
private void OnDropHandItems(EntityUid uid, PullerComponent pullerComp, DropHandItemsEvent args)
{
if (pullerComp.Pulling == null || pullerComp.NeedsHands)
}
var oldPuller = pullableComp.Puller;
+ if (oldPuller != null)
+ RemComp<ActivePullerComponent>(oldPuller.Value);
+
pullableComp.PullJointId = null;
pullableComp.Puller = null;
Dirty(pullableUid, pullableComp);
// Use net entity so it's consistent across client and server.
pullableComp.PullJointId = $"pull-joint-{GetNetEntity(pullableUid)}";
+ EnsureComp<ActivePullerComponent>(pullerUid);
pullerComp.Pulling = pullableUid;
pullableComp.Puller = pullerUid;