From 2e6661e8856c9bf21451ace398f7a286cafdbfbc Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 11 Jul 2020 01:27:36 +1000 Subject: [PATCH] Fix AI shutting storage crash (#1344) Co-authored-by: Metal Gear Sloth --- .../Considerations/State/StoredStateEntityIsNullCon.cs | 4 +++- Content.Server/AI/WorldState/Blackboard.cs | 4 ++-- Content.Server/AI/WorldState/StateData.cs | 5 +---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs b/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs index a2750b6ed1..76fd3fd176 100644 --- a/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs +++ b/Content.Server/AI/Utility/Considerations/State/StoredStateEntityIsNullCon.cs @@ -1,6 +1,7 @@ using System; using Content.Server.AI.WorldState; using Content.Server.AI.WorldState.States.Utility; +using Robust.Shared.Interfaces.GameObjects; namespace Content.Server.AI.Utility.Considerations.State { @@ -20,7 +21,8 @@ namespace Content.Server.AI.Utility.Considerations.State protected override float GetScore(Blackboard context) { var stateData = context.GetState().GetValue(); - return stateData == null ? 1.0f : 0.0f; + context.GetStoredState(stateData, out StoredStateData state); + return state.GetValue() == null ? 1.0f : 0.0f; } } } \ No newline at end of file diff --git a/Content.Server/AI/WorldState/Blackboard.cs b/Content.Server/AI/WorldState/Blackboard.cs index 160a65875d..3b1d5176e8 100644 --- a/Content.Server/AI/WorldState/Blackboard.cs +++ b/Content.Server/AI/WorldState/Blackboard.cs @@ -56,9 +56,9 @@ namespace Content.Server.AI.WorldState } } - public void GetState(Type type, out IAiState state) + public void GetStoredState(Type type, out StoredStateData state) { - state = _states[type]; + state = (StoredStateData) _states[type]; } /// diff --git a/Content.Server/AI/WorldState/StateData.cs b/Content.Server/AI/WorldState/StateData.cs index 4acf5c00eb..ba4dfad8fe 100644 --- a/Content.Server/AI/WorldState/StateData.cs +++ b/Content.Server/AI/WorldState/StateData.cs @@ -25,10 +25,7 @@ namespace Content.Server.AI.WorldState void CheckCache(); } - public interface IStoredState - { - - } + public interface IStoredState {} /// /// The default class for state values. Also see CachedStateData and PlanningStateData