Add static method to clear static fields

This commit is contained in:
Karpik 2026-03-02 20:11:19 +04:00
parent 4512245e57
commit 7b75720999
7 changed files with 52 additions and 0 deletions

View File

@ -623,5 +623,13 @@ namespace DCFApixels.DragonECS
#endregion
}
#endregion
internal static void Clear()
{
lock (_lock)
{
_metaCache.Clear();
}
}
}
}

View File

@ -467,6 +467,11 @@ namespace DCFApixels.DragonECS
public delegate void OnBuildApectHandler(object aspect, EcsMask mask);
public static event OnBuildApectHandler OnAfterInit = delegate { };
#endregion
internal static void Clear()
{
_staticMaskCache.Clear();
}
}
#region EcsAspect.Builder.Extensions

18
src/EcsStaticCleaner.cs Normal file
View File

@ -0,0 +1,18 @@
using DCFApixels.DragonECS.Core.Internal;
namespace DCFApixels.DragonECS
{
public static class EcsStaticCleaner
{
public static void ResetAll()
{
TypeMeta.Clear();
Injector.InjectionList.Clear();
// MemoryAllocator.Clear();
EcsTypeCodeManager.Clear();
ConfigContainer.Clear();
EcsAspect.Clear();
EcsWorld.Clear();
}
}
}

View File

@ -346,5 +346,10 @@ namespace DCFApixels.DragonECS
return FindPoolInstance(componentType);
}
#endregion
internal static void Clear()
{
_allWorldComponentPools.Clear();
}
}
}

View File

@ -357,6 +357,12 @@ namespace DCFApixels.DragonECS
instance.Inject(_injectedData);
}
}
internal static void Clear()
{
_Empty_Internal._injections.Clear();
_Empty_Internal._nodes.Clear();
}
}
#endregion
}

View File

@ -53,6 +53,11 @@ namespace DCFApixels.DragonECS.Core.Internal
return null;
}
public static IEnumerable<TypeCodeInfo> GetDeclaredTypes() { return _codes.Select(o => new TypeCodeInfo(o.Key, o.Value)); }
internal static void Clear()
{
_codes.Clear();
}
}
#if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)]

View File

@ -102,6 +102,11 @@ namespace DCFApixels.DragonECS
{
return GetAllConfigs().GetEnumerator();
}
internal static void Clear()
{
Empty._storage.Clear();
}
}
public static class ConfigContainerExtensions
{