Limit hydraulic clamps to one DoAfter at a time (#23982)
Limit Ripleys to one DoAfter at a time (cherry picked from commit f8f5524fd50abb0d5910b0ca0d0badccd6d14854)
This commit is contained in:
parent
16faa3cf64
commit
5467965041
|
|
@ -1,5 +1,6 @@
|
|||
using System.Numerics;
|
||||
using System.Threading;
|
||||
using Content.Shared.DoAfter;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
|
|
@ -47,4 +48,7 @@ public sealed partial class MechGrabberComponent : Component
|
|||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public Container ItemContainer = default!;
|
||||
|
||||
[DataField, ViewVariables(VVAccess.ReadOnly)]
|
||||
public DoAfterId? DoAfter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,6 +128,9 @@ public sealed class MechGrabberSystem : EntitySystem
|
|||
if (args.Handled || args.Target is not {} target)
|
||||
return;
|
||||
|
||||
if (args.Target == args.User || component.DoAfter != null)
|
||||
return;
|
||||
|
||||
if (TryComp<PhysicsComponent>(target, out var physics) && physics.BodyType == BodyType.Static ||
|
||||
HasComp<WallMountComponent>(target) ||
|
||||
HasComp<MobStateComponent>(target))
|
||||
|
|
@ -152,15 +155,19 @@ public sealed class MechGrabberSystem : EntitySystem
|
|||
|
||||
args.Handled = true;
|
||||
component.AudioStream = _audio.PlayPvs(component.GrabSound, uid).Value.Entity;
|
||||
_doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid)
|
||||
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid)
|
||||
{
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnUserMove = true
|
||||
});
|
||||
};
|
||||
|
||||
_doAfter.TryStartDoAfter(doAfterArgs, out component.DoAfter);
|
||||
}
|
||||
|
||||
private void OnMechGrab(EntityUid uid, MechGrabberComponent component, DoAfterEvent args)
|
||||
{
|
||||
component.DoAfter = null;
|
||||
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.AudioStream = _audio.Stop(component.AudioStream);
|
||||
|
|
|
|||
Loading…
Reference in New Issue