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)