From b1d3f0403a3b96c29b67297b64892e78cc811095 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 22 Jun 2020 00:00:05 +1000 Subject: [PATCH] Fix AI not shutting down their operator (#1176) Was banging my head against the wall for this because I R dumb. It only ever popped up when large numbers of AI were spawned in. Co-authored-by: Metal Gear Sloth --- Content.Server/AI/Operators/AiOperator.cs | 1 + Content.Server/AI/Utility/AiLogic/UtilityAI.cs | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/Content.Server/AI/Operators/AiOperator.cs b/Content.Server/AI/Operators/AiOperator.cs index 1989846ea9..94c809eabd 100644 --- a/Content.Server/AI/Operators/AiOperator.cs +++ b/Content.Server/AI/Operators/AiOperator.cs @@ -5,6 +5,7 @@ namespace Content.Server.AI.Operators { public abstract class AiOperator { + public bool HasStartup => _hasStartup; private bool _hasStartup = false; private bool _hasShutdown = false; diff --git a/Content.Server/AI/Utility/AiLogic/UtilityAI.cs b/Content.Server/AI/Utility/AiLogic/UtilityAI.cs index 0b76293e8f..82d076ba1a 100644 --- a/Content.Server/AI/Utility/AiLogic/UtilityAI.cs +++ b/Content.Server/AI/Utility/AiLogic/UtilityAI.cs @@ -152,6 +152,12 @@ namespace Content.Server.AI.Utility.AiLogic { return; } + + var currentOp = CurrentAction?.ActionOperators.Peek(); + if (currentOp != null && currentOp.HasStartup) + { + currentOp.Shutdown(Outcome.Failed); + } CurrentAction = action; action.SetupOperators(_blackboard);