add EcsWorld.Destroy checks

This commit is contained in:
Mikhail 2024-03-10 21:38:43 +08:00
parent 7f3c2d05c6
commit c680252868
2 changed files with 9 additions and 1 deletions

View File

@ -162,8 +162,13 @@ namespace DCFApixels.DragonECS
{ {
if (_isDestroyed) if (_isDestroyed)
{ {
EcsDebug.PrintWarning("The world is already destroyed");
return; return;
} }
if(id == NULL_WORLD_ID)
{
Throw.World_WorldCantBeDestroyed();
}
_listeners.InvokeOnWorldDestroy(); _listeners.InvokeOnWorldDestroy();
_entityDispenser = null; _entityDispenser = null;
_pools = null; _pools = null;

View File

@ -103,12 +103,15 @@ namespace DCFApixels.DragonECS.Internal
{ {
throw new EcsFrameworkException($"An entity with identifier {entityID} is already contained in this world"); throw new EcsFrameworkException($"An entity with identifier {entityID} is already contained in this world");
} }
[MethodImpl(MethodImplOptions.NoInlining)] [MethodImpl(MethodImplOptions.NoInlining)]
public static void World_PoolAlreadyCreated() public static void World_PoolAlreadyCreated()
{ {
throw new EcsFrameworkException("The pool has already been created."); 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)] [MethodImpl(MethodImplOptions.NoInlining)]
internal static void Ent_ThrowIsNotAlive(entlong entity) internal static void Ent_ThrowIsNotAlive(entlong entity)