diff --git a/src/DebugUtils/TypeMeta.cs b/src/DebugUtils/TypeMeta.cs index 7c3d8c9..1f8ad7b 100644 --- a/src/DebugUtils/TypeMeta.cs +++ b/src/DebugUtils/TypeMeta.cs @@ -623,5 +623,13 @@ namespace DCFApixels.DragonECS #endregion } #endregion + + internal static void Clear() + { + lock (_lock) + { + _metaCache.Clear(); + } + } } } \ No newline at end of file diff --git a/src/EcsAspect.cs b/src/EcsAspect.cs index 75a3be2..15aeb18 100644 --- a/src/EcsAspect.cs +++ b/src/EcsAspect.cs @@ -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 diff --git a/src/EcsStaticCleaner.cs b/src/EcsStaticCleaner.cs new file mode 100644 index 0000000..6007943 --- /dev/null +++ b/src/EcsStaticCleaner.cs @@ -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(); + } + } +} \ No newline at end of file diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index 033321a..c9b94cf 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -346,5 +346,10 @@ namespace DCFApixels.DragonECS return FindPoolInstance(componentType); } #endregion + + internal static void Clear() + { + _allWorldComponentPools.Clear(); + } } } \ No newline at end of file diff --git a/src/Injections/Injector.cs b/src/Injections/Injector.cs index df558b0..c68c965 100644 --- a/src/Injections/Injector.cs +++ b/src/Injections/Injector.cs @@ -357,6 +357,12 @@ namespace DCFApixels.DragonECS instance.Inject(_injectedData); } } + + internal static void Clear() + { + _Empty_Internal._injections.Clear(); + _Empty_Internal._nodes.Clear(); + } } #endregion } diff --git a/src/Internal/EcsTypeCodeManager.cs b/src/Internal/EcsTypeCodeManager.cs index ea902a1..b2c2041 100644 --- a/src/Internal/EcsTypeCodeManager.cs +++ b/src/Internal/EcsTypeCodeManager.cs @@ -53,6 +53,11 @@ namespace DCFApixels.DragonECS.Core.Internal return null; } public static IEnumerable GetDeclaredTypes() { return _codes.Select(o => new TypeCodeInfo(o.Key, o.Value)); } + + internal static void Clear() + { + _codes.Clear(); + } } #if ENABLE_IL2CPP [Il2CppSetOption(Option.NullChecks, false)] diff --git a/src/Utils/IConfigContainer.cs b/src/Utils/IConfigContainer.cs index 98192f0..b5a6103 100644 --- a/src/Utils/IConfigContainer.cs +++ b/src/Utils/IConfigContainer.cs @@ -102,6 +102,11 @@ namespace DCFApixels.DragonECS { return GetAllConfigs().GetEnumerator(); } + + internal static void Clear() + { + Empty._storage.Clear(); + } } public static class ConfigContainerExtensions {