Fix being able to start pulling something while incapacitated. (#4240)

This commit is contained in:
Vera Aguilera Puerto
2021-06-28 14:17:37 +02:00
committed by GitHub
parent a1088faa35
commit 9bedfe79be
7 changed files with 58 additions and 1 deletions

View File

@@ -204,6 +204,11 @@ namespace Content.Shared.Pulling.Components
return false;
}
if (!EntitySystem.Get<SharedPullingSystem>().CanPull(puller, Owner))
{
return false;
}
if (_physics == null)
{
return false;

View File

@@ -0,0 +1,19 @@
using Robust.Shared.GameObjects;
namespace Content.Shared.Pulling.Events
{
/// <summary>
/// Directed event raised on the puller to see if it can start pulling something.
/// </summary>
public class StartPullAttemptEvent : CancellableEntityEventArgs
{
public StartPullAttemptEvent(IEntity puller, IEntity pulled)
{
Puller = puller;
Pulled = pulled;
}
public IEntity Puller { get; }
public IEntity Pulled { get; }
}
}

View File

@@ -6,6 +6,7 @@ using Content.Shared.GameTicking;
using Content.Shared.Input;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Pulling.Events;
using Content.Shared.Rotatable;
using JetBrains.Annotations;
using Robust.Shared.Containers;
@@ -237,5 +238,12 @@ namespace Content.Shared.Pulling
pulled.Transform.WorldRotation = newAngle;
}
}
public bool CanPull(IEntity puller, IEntity pulled)
{
var startPull = new StartPullAttemptEvent(puller, pulled);
RaiseLocalEvent(puller.Uid, startPull);
return !startPull.Cancelled;
}
}
}