From 71e5f34d846926b426f0e073c7e7197339c185c7 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 14 Aug 2022 01:59:26 -0400 Subject: [PATCH] prevents revenant harvesting and soul searching from stacking (#10567) Co-authored-by: metalgearsloth --- .../EntitySystems/RevenantSystem.Abilities.cs | 16 ++++++++++++++++ Content.Server/Revenant/RevenantComponent.cs | 2 ++ 2 files changed, 18 insertions(+) diff --git a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs index 46ee071c8b..3e856e644c 100644 --- a/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs +++ b/Content.Server/Revenant/EntitySystems/RevenantSystem.Abilities.cs @@ -43,6 +43,7 @@ public sealed partial class RevenantSystem : EntitySystem { SubscribeLocalEvent(OnInteract); SubscribeLocalEvent(OnSoulSearchComplete); + SubscribeLocalEvent(OnSoulSearchCancelled); SubscribeLocalEvent(OnHarvestComplete); SubscribeLocalEvent(OnHarvestCancelled); @@ -84,6 +85,9 @@ public sealed partial class RevenantSystem : EntitySystem private void BeginSoulSearchDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant) { + if (revenant.SoulSearchCancelToken != null) + return; + _popup.PopupEntity(Loc.GetString("revenant-soul-searching", ("target", target)), uid, Filter.Entities(uid), PopupType.Medium); revenant.SoulSearchCancelToken = new(); var searchDoAfter = new DoAfterEventArgs(uid, revenant.SoulSearchDuration, revenant.SoulSearchCancelToken.Token, target) @@ -91,6 +95,7 @@ public sealed partial class RevenantSystem : EntitySystem BreakOnUserMove = true, DistanceThreshold = 2, UserFinishedEvent = new SoulSearchDoAfterComplete(target), + UserCancelledEvent = new SoulSearchDoAfterCancelled(), }; _doAfter.DoAfter(searchDoAfter); } @@ -99,6 +104,7 @@ public sealed partial class RevenantSystem : EntitySystem { if (!TryComp(args.Target, out var essence)) return; + component.SoulSearchCancelToken = null; essence.SearchComplete = true; string message; @@ -117,8 +123,16 @@ public sealed partial class RevenantSystem : EntitySystem _popup.PopupEntity(Loc.GetString(message, ("target", args.Target)), args.Target, Filter.Entities(uid), PopupType.Medium); } + private void OnSoulSearchCancelled(EntityUid uid, RevenantComponent component, SoulSearchDoAfterCancelled args) + { + component.SoulSearchCancelToken = null; + } + private void BeginHarvestDoAfter(EntityUid uid, EntityUid target, RevenantComponent revenant, EssenceComponent essence) { + if (revenant.HarvestCancelToken != null) + return; + if (essence.Harvested) { _popup.PopupEntity(Loc.GetString("revenant-soul-harvested"), target, Filter.Entities(uid), PopupType.SmallCaution); @@ -152,6 +166,7 @@ public sealed partial class RevenantSystem : EntitySystem private void OnHarvestComplete(EntityUid uid, RevenantComponent component, HarvestDoAfterComplete args) { + component.HarvestCancelToken = null; _appearance.SetData(uid, RevenantVisuals.Harvesting, false); if (!TryComp(args.Target, out var essence)) @@ -184,6 +199,7 @@ public sealed partial class RevenantSystem : EntitySystem private void OnHarvestCancelled(EntityUid uid, RevenantComponent component, HarvestDoAfterCancelled args) { + component.HarvestCancelToken = null; _appearance.SetData(uid, RevenantVisuals.Harvesting, false); } diff --git a/Content.Server/Revenant/RevenantComponent.cs b/Content.Server/Revenant/RevenantComponent.cs index 0ab221ef20..f8fa3c7f9b 100644 --- a/Content.Server/Revenant/RevenantComponent.cs +++ b/Content.Server/Revenant/RevenantComponent.cs @@ -207,6 +207,8 @@ public sealed class SoulSearchDoAfterComplete : EntityEventArgs } } +public sealed class SoulSearchDoAfterCancelled : EntityEventArgs { } + public sealed class HarvestDoAfterComplete : EntityEventArgs { public readonly EntityUid Target;