add EcsWorld.DestroyAndClearAllWorlds

This commit is contained in:
DCFApixels 2025-03-10 22:28:54 +08:00
parent af3f74bb55
commit cb7e086dcd

View File

@ -66,6 +66,21 @@ namespace DCFApixels.DragonECS
return ref WorldComponentPool<T>.GetForWorldUnchecked(worldID); return ref WorldComponentPool<T>.GetForWorldUnchecked(worldID);
} }
public static void DestroyAndClearAllWorlds()
{
for (int i = 1; i < _worlds.Length; i++)
{
var world = _worlds[i];
if (world == null) { continue; }
if(world.IsDestroyed == false)
{
world.Destroy();
}
world = null;
}
}
#region WorldComponentPool #region WorldComponentPool
public ReadOnlySpan<WorldComponentPoolAbstract> GetWorldComponents() public ReadOnlySpan<WorldComponentPoolAbstract> GetWorldComponents()
{ {
@ -251,11 +266,14 @@ namespace DCFApixels.DragonECS
} }
#endregion #endregion
#region NullWorld
private sealed class NullWorld : EcsWorld private sealed class NullWorld : EcsWorld
{ {
internal NullWorld() : base(new EcsWorldConfig(4, 4, 4, 4, 4), null, 0) { } internal NullWorld() : base(new EcsWorldConfig(4, 4, 4, 4, 4), null, 0) { }
} }
#endregion
#region DebuggerProxy #region DebuggerProxy
protected partial class DebuggerProxy protected partial class DebuggerProxy
{ {