From c68025286801ceb1f4fd1b97880bbb75477ddec0 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 10 Mar 2024 21:38:43 +0800 Subject: [PATCH] add EcsWorld.Destroy checks --- src/EcsWorld.cs | 5 +++++ src/Utils/Exceptions.cs | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 9bf344a..7923aac 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -162,8 +162,13 @@ namespace DCFApixels.DragonECS { if (_isDestroyed) { + EcsDebug.PrintWarning("The world is already destroyed"); return; } + if(id == NULL_WORLD_ID) + { + Throw.World_WorldCantBeDestroyed(); + } _listeners.InvokeOnWorldDestroy(); _entityDispenser = null; _pools = null; diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index 17fea7a..10bf0c5 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -103,12 +103,15 @@ namespace DCFApixels.DragonECS.Internal { throw new EcsFrameworkException($"An entity with identifier {entityID} is already contained in this world"); } - [MethodImpl(MethodImplOptions.NoInlining)] public static void World_PoolAlreadyCreated() { throw new EcsFrameworkException("The pool has already been created."); } + public static void World_WorldCantBeDestroyed() + { + throw new EcsFrameworkException("This world can't be destroyed"); + } [MethodImpl(MethodImplOptions.NoInlining)] internal static void Ent_ThrowIsNotAlive(entlong entity)