From d7168fedd11287322507e806fa232938e34ade94 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 10 May 2022 19:48:59 +1000 Subject: [PATCH] Allow do_afters to be spammed (#8074) --- .../EntitySystems/ChemistrySystem.Injector.cs | 2 -- Content.Server/Medical/HealingSystem.cs | 5 ++++- .../Nutrition/EntitySystems/DrinkSystem.cs | 2 -- .../Nutrition/EntitySystems/FoodSystem.cs | 2 -- Content.Server/Tools/ToolSystem.TilePrying.cs | 16 +++++++++++++--- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs index 3aab81e2ec..f7e182648d 100644 --- a/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs +++ b/Content.Server/Chemistry/EntitySystems/ChemistrySystem.Injector.cs @@ -108,8 +108,6 @@ public sealed partial class ChemistrySystem if (component.CancelToken != null) { - component.CancelToken.Cancel(); - component.CancelToken = null; args.Handled = true; return; } diff --git a/Content.Server/Medical/HealingSystem.cs b/Content.Server/Medical/HealingSystem.cs index 6da6c1baa4..bc8f39962f 100644 --- a/Content.Server/Medical/HealingSystem.cs +++ b/Content.Server/Medical/HealingSystem.cs @@ -92,7 +92,10 @@ public sealed class HealingSystem : EntitySystem private bool TryHeal(EntityUid uid, EntityUid user, EntityUid target, HealingComponent component) { - if (component.CancelToken != null) return false; + if (component.CancelToken != null) + { + return false; + } if (TryComp(target, out var state) && state.IsDead()) return false; diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 6f8141edc6..7d7a00113a 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -194,8 +194,6 @@ namespace Content.Server.Nutrition.EntitySystems // cannot stack do-afters if (drink.CancelToken != null) { - drink.CancelToken.Cancel(); - drink.CancelToken = null; return true; } diff --git a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs index 8257ed2932..108752ceb1 100644 --- a/Content.Server/Nutrition/EntitySystems/FoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/FoodSystem.cs @@ -79,8 +79,6 @@ namespace Content.Server.Nutrition.EntitySystems // if currently being used to feed, cancel that action. if (food.CancelToken != null) { - food.CancelToken.Cancel(); - food.CancelToken = null; return true; } diff --git a/Content.Server/Tools/ToolSystem.TilePrying.cs b/Content.Server/Tools/ToolSystem.TilePrying.cs index 4d94a47fff..01cfb66e41 100644 --- a/Content.Server/Tools/ToolSystem.TilePrying.cs +++ b/Content.Server/Tools/ToolSystem.TilePrying.cs @@ -18,6 +18,12 @@ public sealed partial class ToolSystem { SubscribeLocalEvent(OnTilePryingAfterInteract); SubscribeLocalEvent(OnTilePryComplete); + SubscribeLocalEvent(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(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 + { + + } }