Allow do_afters to be spammed (#8074)

This commit is contained in:
metalgearsloth
2022-05-10 19:48:59 +10:00
committed by GitHub
parent 1ef2407d02
commit d7168fedd1
5 changed files with 17 additions and 10 deletions

View File

@@ -18,6 +18,12 @@ public sealed partial class ToolSystem
{
SubscribeLocalEvent<TilePryingComponent, AfterInteractEvent>(OnTilePryingAfterInteract);
SubscribeLocalEvent<TilePryingComponent, TilePryingCompleteEvent>(OnTilePryComplete);
SubscribeLocalEvent<TilePryingComponent, TilePryingCancelledEvent>(OnTilePryCancelled);
}
private void OnTilePryCancelled(EntityUid uid, TilePryingComponent component, TilePryingCancelledEvent args)
{
component.CancelToken = null;
}
private void OnTilePryComplete(EntityUid uid, TilePryingComponent component, TilePryingCompleteEvent args)
@@ -38,9 +44,7 @@ public sealed partial class ToolSystem
{
if (component.CancelToken != null)
{
component.CancelToken.Cancel();
component.CancelToken = null;
return false;
return true;
}
if (!TryComp<ToolComponent?>(component.Owner, out var tool) && component.ToolComponentNeeded)
@@ -75,6 +79,7 @@ public sealed partial class ToolSystem
{
Coordinates = clickLocation,
},
new TilePryingCancelledEvent(),
toolComponent: tool,
doAfterEventTarget: component.Owner,
cancelToken: token.Token);
@@ -86,4 +91,9 @@ public sealed partial class ToolSystem
{
public EntityCoordinates Coordinates { get; init; }
}
private sealed class TilePryingCancelledEvent : EntityEventArgs
{
}
}