From 6452850ff8c7ea5983dbd6a79b5a836ed6eb3072 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Tue, 3 Mar 2026 14:46:58 +0800 Subject: [PATCH] improve entities cleanup --- src/EcsWorld.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index b1f1771..b7fcbdf 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -234,14 +234,14 @@ namespace DCFApixels.DragonECS #endif return; } + + for (int i = Entities.Count - 1; i >= 0; i--) + { + DelEntity(Entities[i]); + } + _isDestroyed = true; _listeners.InvokeOnWorldDestroy(); - foreach (var e in Entities) - { - var count = GetComponentTypeIDsFor_Internal(e, ref _componentIDsBuffer); - var span = _componentIDsBuffer.AsSpan(0, count); - RemoveComponents(e, span); - } _entityDispenser = null; _pools = null; _nullPool = null; @@ -259,7 +259,6 @@ namespace DCFApixels.DragonECS //_entities - не обнуляется для работы entlong.IsAlive } } - //public void Clear() { } #endregion #region Getters