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,9 +1,6 @@
|
||||
using System.Threading;
|
||||
using Content.Server.DoAfter;
|
||||
using Content.Server.Guardian;
|
||||
using Content.Server.Popups;
|
||||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Hands;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Implants;
|
||||
using Content.Shared.Implants.Components;
|
||||
@@ -18,7 +15,7 @@ namespace Content.Server.Implants;
|
||||
public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
{
|
||||
[Dependency] private readonly PopupSystem _popup = default!;
|
||||
[Dependency] private readonly DoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _container = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -26,12 +23,11 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
base.Initialize();
|
||||
InitializeImplanted();
|
||||
|
||||
SubscribeLocalEvent<ImplanterComponent, HandDeselectedEvent>(OnHandDeselect);
|
||||
SubscribeLocalEvent<ImplanterComponent, AfterInteractEvent>(OnImplanterAfterInteract);
|
||||
SubscribeLocalEvent<ImplanterComponent, ComponentGetState>(OnImplanterGetState);
|
||||
|
||||
SubscribeLocalEvent<ImplanterComponent, DoAfterEvent<ImplantEvent>>(OnImplant);
|
||||
SubscribeLocalEvent<ImplanterComponent, DoAfterEvent<DrawEvent>>(OnDraw);
|
||||
SubscribeLocalEvent<ImplanterComponent, ImplantEvent>(OnImplant);
|
||||
SubscribeLocalEvent<ImplanterComponent, DrawEvent>(OnDraw);
|
||||
}
|
||||
|
||||
private void OnImplanterAfterInteract(EntityUid uid, ImplanterComponent component, AfterInteractEvent args)
|
||||
@@ -62,12 +58,6 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
args.Handled = true;
|
||||
}
|
||||
|
||||
private void OnHandDeselect(EntityUid uid, ImplanterComponent component, HandDeselectedEvent args)
|
||||
{
|
||||
component.CancelToken?.Cancel();
|
||||
component.CancelToken = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempt to implant someone else.
|
||||
/// </summary>
|
||||
@@ -77,27 +67,21 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
/// <param name="implanter">The implanter being used</param>
|
||||
public void TryImplant(ImplanterComponent component, EntityUid user, EntityUid target, EntityUid implanter)
|
||||
{
|
||||
if (component.CancelToken != null)
|
||||
var args = new DoAfterArgs(user, component.ImplantTime, new ImplantEvent(), implanter, target: target, used: implanter)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnDamage = true,
|
||||
NeedHand = true,
|
||||
};
|
||||
|
||||
if (!_doAfter.TryStartDoAfter(args))
|
||||
return;
|
||||
|
||||
_popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user);
|
||||
|
||||
var userName = Identity.Entity(user, EntityManager);
|
||||
_popup.PopupEntity(Loc.GetString("implanter-component-implanting-target", ("user", userName)), user, target, PopupType.LargeCaution);
|
||||
|
||||
component.CancelToken?.Cancel();
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
var implantEvent = new ImplantEvent();
|
||||
|
||||
_doAfter.DoAfter(new DoAfterEventArgs(user, component.ImplantTime, component.CancelToken.Token,target:target, used:implanter)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnStun = true,
|
||||
NeedHand = true
|
||||
}, implantEvent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -110,21 +94,17 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
//TODO: Remove when surgery is in
|
||||
public void TryDraw(ImplanterComponent component, EntityUid user, EntityUid target, EntityUid implanter)
|
||||
{
|
||||
_popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user);
|
||||
|
||||
component.CancelToken?.Cancel();
|
||||
component.CancelToken = new CancellationTokenSource();
|
||||
|
||||
var drawEvent = new DrawEvent();
|
||||
|
||||
_doAfter.DoAfter(new DoAfterEventArgs(user, component.DrawTime, target:target,used:implanter)
|
||||
var args = new DoAfterArgs(user, component.DrawTime, new DrawEvent(), implanter, target: target, used: implanter)
|
||||
{
|
||||
BreakOnUserMove = true,
|
||||
BreakOnTargetMove = true,
|
||||
BreakOnDamage = true,
|
||||
BreakOnStun = true,
|
||||
NeedHand = true
|
||||
}, drawEvent);
|
||||
NeedHand = true,
|
||||
};
|
||||
|
||||
if (_doAfter.TryStartDoAfter(args))
|
||||
_popup.PopupEntity(Loc.GetString("injector-component-injecting-user"), target, user);
|
||||
|
||||
}
|
||||
|
||||
private void OnImplanterGetState(EntityUid uid, ImplanterComponent component, ref ComponentGetState args)
|
||||
@@ -132,47 +112,23 @@ public sealed partial class ImplanterSystem : SharedImplanterSystem
|
||||
args.State = new ImplanterComponentState(component.CurrentMode, component.ImplantOnly);
|
||||
}
|
||||
|
||||
private void OnImplant(EntityUid uid, ImplanterComponent component, DoAfterEvent<ImplantEvent> args)
|
||||
private void OnImplant(EntityUid uid, ImplanterComponent component, ImplantEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.CancelToken = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Handled || args.Args.Target == null || args.Args.Used == null)
|
||||
if (args.Cancelled || args.Handled || args.Target == null || args.Used == null)
|
||||
return;
|
||||
|
||||
Implant(args.Args.Used.Value, args.Args.Target.Value, component);
|
||||
Implant(args.Used.Value, args.Target.Value, component);
|
||||
|
||||
args.Handled = true;
|
||||
component.CancelToken = null;
|
||||
}
|
||||
|
||||
private void OnDraw(EntityUid uid, ImplanterComponent component, DoAfterEvent<DrawEvent> args)
|
||||
private void OnDraw(EntityUid uid, ImplanterComponent component, DrawEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
{
|
||||
component.CancelToken = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Handled || args.Args.Used == null || args.Args.Target == null)
|
||||
if (args.Cancelled || args.Handled || args.Used == null || args.Target == null)
|
||||
return;
|
||||
|
||||
Draw(args.Args.Used.Value, args.Args.User, args.Args.Target.Value, component);
|
||||
Draw(args.Used.Value, args.User, args.Target.Value, component);
|
||||
|
||||
args.Handled = true;
|
||||
component.CancelToken = null;
|
||||
}
|
||||
|
||||
private sealed class ImplantEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private sealed class DrawEvent : EntityEventArgs
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user