Minor cuff changes (#4164)
This commit is contained in:
25
Content.Shared/Cuffs/SharedCuffableSystem.cs
Normal file
25
Content.Shared/Cuffs/SharedCuffableSystem.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Content.Shared.Cuffs.Components;
|
||||
using Content.Shared.Pulling.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Shared.Cuffs
|
||||
{
|
||||
public abstract class SharedCuffableSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SharedCuffableComponent, StopPullingEvent>(HandleStopPull);
|
||||
}
|
||||
|
||||
private void HandleStopPull(EntityUid uid, SharedCuffableComponent component, StopPullingEvent args)
|
||||
{
|
||||
if (args.User == null || !EntityManager.TryGetEntity(args.User.Value, out var user)) return;
|
||||
|
||||
if (user == component.Owner && !component.CanStillInteract)
|
||||
{
|
||||
args.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,13 +245,18 @@ namespace Content.Shared.Pulling.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TryStopPull()
|
||||
public bool TryStopPull(IEntity? user = null)
|
||||
{
|
||||
if (!BeingPulled)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var msg = new StopPullingEvent(user?.Uid);
|
||||
Owner.EntityManager.EventBus.RaiseLocalEvent(Owner.Uid, msg);
|
||||
|
||||
if (msg.Cancelled) return false;
|
||||
|
||||
if (_physics != null && _pullJoint != null)
|
||||
{
|
||||
_physics.RemoveJoint(_pullJoint);
|
||||
@@ -375,4 +380,17 @@ namespace Content.Shared.Pulling.Components
|
||||
Puller = puller;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised when a request is made to stop pulling an entity.
|
||||
/// </summary>
|
||||
public sealed class StopPullingEvent : CancellableEntityEventArgs
|
||||
{
|
||||
public EntityUid? User { get; }
|
||||
|
||||
public StopPullingEvent(EntityUid? uid = null)
|
||||
{
|
||||
User = uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user