diff --git a/Robust.Client/GameObjects/ClientEntityManager.cs b/Robust.Client/GameObjects/ClientEntityManager.cs
index 652514235..00df4cb9b 100644
--- a/Robust.Client/GameObjects/ClientEntityManager.cs
+++ b/Robust.Client/GameObjects/ClientEntityManager.cs
@@ -72,8 +72,12 @@ namespace Robust.Client.GameObjects
return;
}
+ if (ShuttingDown)
+ return;
+
// Client-side entity deletion is not supported and will cause errors.
- Logger.Error($"Predicting the queued deletion of a networked entity: {ToPrettyString(uid)}. Trace: {Environment.StackTrace}");
+ if (_client.RunLevel == ClientRunLevel.Connected || _client.RunLevel == ClientRunLevel.InGame)
+ Logger.Error($"Predicting the queued deletion of a networked entity: {ToPrettyString(uid)}. Trace: {Environment.StackTrace}");
}
///
diff --git a/Robust.Shared/GameObjects/EntityManager.cs b/Robust.Shared/GameObjects/EntityManager.cs
index 5ff64054f..a29b14ed8 100644
--- a/Robust.Shared/GameObjects/EntityManager.cs
+++ b/Robust.Shared/GameObjects/EntityManager.cs
@@ -70,6 +70,9 @@ namespace Robust.Shared.GameObjects
public event Action? EntityDirtied; // only raised after initialization
public bool Started { get; protected set; }
+
+ public bool ShuttingDown { get; protected set; }
+
public bool Initialized { get; protected set; }
///
@@ -107,10 +110,12 @@ namespace Robust.Shared.GameObjects
public virtual void Shutdown()
{
+ ShuttingDown = true;
FlushEntities();
_eventBus.ClearEventTables();
_entitySystemManager.Shutdown();
ClearComponents();
+ ShuttingDown = false;
Started = false;
}
@@ -118,12 +123,14 @@ namespace Robust.Shared.GameObjects
{
_componentFactory.ComponentAdded -= OnComponentAdded;
_componentFactory.ComponentReferenceAdded -= OnComponentReferenceAdded;
+ ShuttingDown = true;
FlushEntities();
_entitySystemManager.Clear();
_eventBus.Dispose();
_eventBus = null!;
ClearComponents();
+ ShuttingDown = false;
Initialized = false;
Started = false;
}