Fix being able to start pulling something while incapacitated. (#4240)
This commit is contained in:
committed by
GitHub
parent
a1088faa35
commit
9bedfe79be
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.MobState;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.State;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.MobState;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.MobState.State;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.MobState.State;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Players;
|
||||
@@ -14,7 +15,7 @@ using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.MobState.State
|
||||
namespace Content.Shared.MobState.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// When attached to an <see cref="IDamageableComponent"/>,
|
||||
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Pulling.Events;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.MobState.EntitySystems
|
||||
{
|
||||
public class SharedMobStateSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SharedMobStateComponent, StartPullAttemptEvent>(OnStartPullAttempt);
|
||||
}
|
||||
|
||||
private void OnStartPullAttempt(EntityUid uid, SharedMobStateComponent component, StartPullAttemptEvent args)
|
||||
{
|
||||
if(component.IsIncapacitated())
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
19
Content.Shared/Pulling/Events/StartPullAttemptEvent.cs
Normal file
19
Content.Shared/Pulling/Events/StartPullAttemptEvent.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user