This commit is contained in:
Aviu00
2023-08-09 20:20:29 +03:00
committed by Aviu00
parent c0c1f52890
commit 1115d62db6

View File

@@ -1,3 +1,4 @@
using System.Linq;
using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Logs;
using Content.Shared.Buckle.Components;
@@ -26,6 +27,7 @@ namespace Content.Shared.Pulling
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly SharedJointSystem _jointSystem = default!; // WD
public bool CanPull(EntityUid puller, EntityUid pulled)
{
@@ -98,6 +100,7 @@ namespace Content.Shared.Pulling
if (!pullable.BeingPulled)
{
ClearPullJoints(pullable); // WD
return false;
}
@@ -117,6 +120,31 @@ namespace Content.Shared.Pulling
return true;
}
// WD START
private void ClearPullJoints(SharedPullableComponent pullable)
{
var uid = pullable.Owner;
if (_timing.ApplyingState || !TryComp(uid, out JointComponent? jointComp))
return;
TryComp(uid, out SharedPullerComponent? puller);
foreach (var joint in jointComp.GetJoints.Where(j => j.Key.StartsWith("pull-joint")))
{
if (pullable.PullJointId == joint.Key)
continue;
if (puller is {Pulling: not null} &&
EntityManager.GetComponent<SharedPullableComponent>(puller.Pulling.Value).PullJointId == joint.Key)
continue;
_jointSystem.RemoveJoint(joint.Value);
}
}
// WD END
public bool TryStartPull(EntityUid puller, EntityUid pullable)
{
if (!EntityManager.TryGetComponent(puller, out SharedPullerComponent? pullerComp))