More DoAfter Changes (#14609)
* DoAfters * Compact Clone() * Fix mice and cuffables * Try generalize attempt events * moves climbabledoafter event to shared, fixes issue with climbable target * Fix merge (cuffing) * Make all events netserializable * handful of doafter events moved * moves the rest of the events to their respective shared folders * Changes all mentions of server doafter to shared * stop stripping cancellation * fix merge errors * draw paused doafters * handle unpausing * missing netserializable ref * removes break on stun reference * removes cuffing state reference * Fix tools * Fix door prying. * Fix construction * Fix dumping * Fix wielding assert * fix rev * Fix test * more test fixes --------- Co-authored-by: keronshb <keronshb@live.com>
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Contests;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Server.Popups;
|
||||
@@ -10,12 +8,13 @@ using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Interaction.Events;
|
||||
using Content.Shared.Resist;
|
||||
|
||||
namespace Content.Server.Resist;
|
||||
|
||||
public sealed class EscapeInventorySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||
@@ -32,7 +31,7 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, MoveInputEvent>(OnRelayMovement);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, DoAfterEvent<EscapeInventoryEvent>>(OnEscape);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, EscapeInventoryEvent>(OnEscape);
|
||||
SubscribeLocalEvent<CanEscapeInventoryComponent, DroppedEvent>(OnDropped);
|
||||
}
|
||||
|
||||
@@ -69,50 +68,37 @@ public sealed class EscapeInventorySystem : EntitySystem
|
||||
if (component.IsEscaping)
|
||||
return;
|
||||
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
component.IsEscaping = true;
|
||||
var escapeEvent = new EscapeInventoryEvent();
|
||||
var doAfterEventArgs = new DoAfterEventArgs(user, component.BaseResistTime * multiplier, cancelToken: component.CancelToken.Token, target:container)
|
||||
var doAfterEventArgs = new DoAfterArgs(user, component.BaseResistTime * multiplier, new EscapeInventoryEvent(), user, target: container)
|
||||
{
|
||||
BreakOnTargetMove = false,
|
||||
BreakOnUserMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnStun = true,
|
||||
NeedHand = false
|
||||
};
|
||||
|
||||
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
|
||||
return;
|
||||
|
||||
Dirty(component);
|
||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
|
||||
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
|
||||
_doAfterSystem.DoAfter(doAfterEventArgs, escapeEvent);
|
||||
}
|
||||
|
||||
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, DoAfterEvent<EscapeInventoryEvent> args)
|
||||
private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.CancelToken = null;
|
||||
component.IsEscaping = false;
|
||||
return;
|
||||
}
|
||||
component.DoAfter = null;
|
||||
Dirty(component);
|
||||
|
||||
if (args.Handled)
|
||||
if (args.Handled || args.Cancelled)
|
||||
return;
|
||||
|
||||
Transform(uid).AttachParentToContainerOrGrid(EntityManager);
|
||||
|
||||
component.CancelToken = null;
|
||||
component.IsEscaping = false;
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnDropped(EntityUid uid, CanEscapeInventoryComponent component, DroppedEvent args)
|
||||
{
|
||||
component.CancelToken?.Cancel();
|
||||
component.CancelToken = null;
|
||||
}
|
||||
|
||||
private sealed class EscapeInventoryEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
if (component.DoAfter != null)
|
||||
_doAfterSystem.Cancel(component.DoAfter);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user