Fix RotateWhilePulling not working (#29032)
This commit is contained in:
@@ -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<PullMovingComponent, PullStoppedMessage>(OnPullStop);
|
||||
SubscribeLocalEvent<PullMoverComponent, MoveEvent>(OnPullerMove);
|
||||
SubscribeLocalEvent<ActivePullerComponent, MoveEvent>(OnPullerMove);
|
||||
|
||||
base.Initialize();
|
||||
}
|
||||
@@ -155,19 +156,22 @@ public sealed class PullController : VirtualController
|
||||
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);
|
||||
|
||||
@@ -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<PullMoverComponent?> mover, Entity<PullMovingComponent?> moving)
|
||||
{
|
||||
RemCompDeferred<PullMoverComponent>(mover.Owner);
|
||||
RemCompDeferred<PullMovingComponent>(moving.Owner);
|
||||
RemCompDeferred<PullMovingComponent>(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<PullMoverComponent, PullerComponent>();
|
||||
|
||||
while (moverQuery.MoveNext(out var uid, out _, out var puller))
|
||||
{
|
||||
if (!HasComp<PullMovingComponent>(puller.Pulling))
|
||||
{
|
||||
RemCompDeferred<PullMoverComponent>(uid);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user