Fix RotateWhilePulling not working (#29032)
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
namespace Content.Server.Movement.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Added to an entity that is ctrl-click moving their pulled object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This just exists so we don't have MoveEvent subs going off for every single mob constantly.
|
||||
/// </remarks>
|
||||
[RegisterComponent]
|
||||
public sealed partial class PullMoverComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Content.Shared.Movement.Pulling.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Component that indicates that an entity is currently pulling some other entity.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed partial class ActivePullerComponent : Component;
|
||||
@@ -9,7 +9,7 @@ namespace Content.Shared.Movement.Pulling.Components;
|
||||
/// <summary>
|
||||
/// Specifies an entity as being able to pull another entity with <see cref="PullableComponent"/>
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||
[Access(typeof(PullingSystem))]
|
||||
public sealed partial class PullerComponent : Component
|
||||
{
|
||||
|
||||
@@ -61,6 +61,7 @@ public sealed class PullingSystem : EntitySystem
|
||||
SubscribeLocalEvent<PullableComponent, EntGotInsertedIntoContainerMessage>(OnPullableContainerInsert);
|
||||
SubscribeLocalEvent<PullableComponent, ModifyUncuffDurationEvent>(OnModifyUncuffDuration);
|
||||
|
||||
SubscribeLocalEvent<PullerComponent, AfterAutoHandleStateEvent>(OnAfterState);
|
||||
SubscribeLocalEvent<PullerComponent, EntGotInsertedIntoContainerMessage>(OnPullerContainerInsert);
|
||||
SubscribeLocalEvent<PullerComponent, EntityUnpausedEvent>(OnPullerUnpaused);
|
||||
SubscribeLocalEvent<PullerComponent, VirtualItemDeletedEvent>(OnVirtualItemDeleted);
|
||||
@@ -72,6 +73,14 @@ public sealed class PullingSystem : EntitySystem
|
||||
.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)
|
||||
@@ -228,6 +237,9 @@ public sealed class PullingSystem : EntitySystem
|
||||
}
|
||||
|
||||
var oldPuller = pullableComp.Puller;
|
||||
if (oldPuller != null)
|
||||
RemComp<ActivePullerComponent>(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<ActivePullerComponent>(pullerUid);
|
||||
pullerComp.Pulling = pullableUid;
|
||||
pullableComp.Puller = pullerUid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user