Don't allow adminfrozen entities to be pulled (#8205)
This commit is contained in:
@@ -54,7 +54,7 @@ namespace Content.Server.Hands.Systems
|
|||||||
|
|
||||||
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] { typeof(StunSystem) });
|
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] { typeof(StunSystem) });
|
||||||
|
|
||||||
SubscribeLocalEvent<HandsComponent, PullAttemptMessage>(HandlePullAttempt);
|
SubscribeLocalEvent<HandsComponent, PullAttemptEvent>(HandlePullAttempt);
|
||||||
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
|
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
|
||||||
SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
|
SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
|
||||||
|
|
||||||
@@ -148,7 +148,7 @@ namespace Content.Server.Hands.Systems
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region pulling
|
#region pulling
|
||||||
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptMessage args)
|
private static void HandlePullAttempt(EntityUid uid, HandsComponent component, PullAttemptEvent args)
|
||||||
{
|
{
|
||||||
if (args.Puller.Owner != uid)
|
if (args.Puller.Owner != uid)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -2,6 +2,10 @@ using Content.Shared.ActionBlocker;
|
|||||||
using Content.Shared.Interaction.Events;
|
using Content.Shared.Interaction.Events;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Movement;
|
using Content.Shared.Movement;
|
||||||
|
using Content.Shared.Physics.Pull;
|
||||||
|
using Content.Shared.Pulling;
|
||||||
|
using Content.Shared.Pulling.Components;
|
||||||
|
using Content.Shared.Pulling.Events;
|
||||||
using Content.Shared.Throwing;
|
using Content.Shared.Throwing;
|
||||||
|
|
||||||
namespace Content.Shared.Administration;
|
namespace Content.Shared.Administration;
|
||||||
@@ -9,6 +13,7 @@ namespace Content.Shared.Administration;
|
|||||||
public sealed class AdminFrozenSystem : EntitySystem
|
public sealed class AdminFrozenSystem : EntitySystem
|
||||||
{
|
{
|
||||||
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
[Dependency] private readonly ActionBlockerSystem _blocker = default!;
|
||||||
|
[Dependency] private readonly SharedPullingSystem _pulling = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -18,9 +23,25 @@ public sealed class AdminFrozenSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<AdminFrozenComponent, PickupAttemptEvent>((_, _, args) => args.Cancel());
|
SubscribeLocalEvent<AdminFrozenComponent, PickupAttemptEvent>((_, _, args) => args.Cancel());
|
||||||
SubscribeLocalEvent<AdminFrozenComponent, ThrowAttemptEvent>((_, _, args) => args.Cancel());
|
SubscribeLocalEvent<AdminFrozenComponent, ThrowAttemptEvent>((_, _, args) => args.Cancel());
|
||||||
SubscribeLocalEvent<AdminFrozenComponent, InteractionAttemptEvent>((_, _, args) => args.Cancel());
|
SubscribeLocalEvent<AdminFrozenComponent, InteractionAttemptEvent>((_, _, args) => args.Cancel());
|
||||||
SubscribeLocalEvent<AdminFrozenComponent, ComponentStartup>(UpdateCanMove);
|
SubscribeLocalEvent<AdminFrozenComponent, ComponentStartup>(OnStartup);
|
||||||
SubscribeLocalEvent<AdminFrozenComponent, ComponentShutdown>(UpdateCanMove);
|
SubscribeLocalEvent<AdminFrozenComponent, ComponentShutdown>(UpdateCanMove);
|
||||||
SubscribeLocalEvent<AdminFrozenComponent, UpdateCanMoveEvent>(OnUpdateCanMove);
|
SubscribeLocalEvent<AdminFrozenComponent, UpdateCanMoveEvent>(OnUpdateCanMove);
|
||||||
|
SubscribeLocalEvent<AdminFrozenComponent, PullAttemptEvent>(OnPullAttempt);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPullAttempt(EntityUid uid, AdminFrozenComponent component, PullAttemptEvent args)
|
||||||
|
{
|
||||||
|
args.Cancelled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnStartup(EntityUid uid, AdminFrozenComponent component, ComponentStartup args)
|
||||||
|
{
|
||||||
|
if (TryComp<SharedPullableComponent>(uid, out var pullable))
|
||||||
|
{
|
||||||
|
_pulling.TryStopPull(pullable);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateCanMove(uid, component, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnUpdateCanMove(EntityUid uid, AdminFrozenComponent component, UpdateCanMoveEvent args)
|
private void OnUpdateCanMove(EntityUid uid, AdminFrozenComponent component, UpdateCanMoveEvent args)
|
||||||
|
|||||||
11
Content.Shared/Pulling/Events/PullAttemptEvent.cs
Normal file
11
Content.Shared/Pulling/Events/PullAttemptEvent.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using Robust.Shared.Physics;
|
||||||
|
|
||||||
|
namespace Content.Shared.Physics.Pull
|
||||||
|
{
|
||||||
|
public sealed class PullAttemptEvent : PullMessage
|
||||||
|
{
|
||||||
|
public PullAttemptEvent(IPhysBody puller, IPhysBody pulled) : base(puller, pulled) { }
|
||||||
|
|
||||||
|
public bool Cancelled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
using Robust.Shared.Physics;
|
|
||||||
|
|
||||||
namespace Content.Shared.Physics.Pull
|
|
||||||
{
|
|
||||||
public sealed class PullAttemptMessage : PullMessage
|
|
||||||
{
|
|
||||||
public PullAttemptMessage(IPhysBody puller, IPhysBody pulled) : base(puller, pulled) { }
|
|
||||||
|
|
||||||
public bool Cancelled { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -26,12 +26,12 @@ namespace Content.Shared.Pulling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent<IPhysBody?>(pulled, out var _physics))
|
if (!EntityManager.TryGetComponent<IPhysBody>(pulled, out var physics))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_physics.BodyType == BodyType.Static)
|
if (physics.BodyType == BodyType.Static)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -113,12 +113,12 @@ namespace Content.Shared.Pulling
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent<PhysicsComponent?>(puller.Owner, out var pullerPhysics))
|
if (!EntityManager.TryGetComponent<PhysicsComponent>(puller.Owner, out var pullerPhysics))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!EntityManager.TryGetComponent<PhysicsComponent?>(pullable.Owner, out var pullablePhysics))
|
if (!EntityManager.TryGetComponent<PhysicsComponent>(pullable.Owner, out var pullablePhysics))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ namespace Content.Shared.Pulling
|
|||||||
|
|
||||||
// Continue with pulling process.
|
// Continue with pulling process.
|
||||||
|
|
||||||
var pullAttempt = new PullAttemptMessage(pullerPhysics, pullablePhysics);
|
var pullAttempt = new PullAttemptEvent(pullerPhysics, pullablePhysics);
|
||||||
|
|
||||||
RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false);
|
RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user