From 9298ec75400833770319848b429aa3d9225a6d2a Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 25 Feb 2024 02:33:18 +0800 Subject: [PATCH 1/2] fix Destroy --- src/EcsWorld.static.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EcsWorld.static.cs b/src/EcsWorld.static.cs index 9a1a9f6..bdcbef1 100644 --- a/src/EcsWorld.static.cs +++ b/src/EcsWorld.static.cs @@ -117,6 +117,7 @@ namespace DCFApixels.DragonECS { _interface.OnDestroy(ref _items[itemIndex], _worlds[worldID]); _recycledItems[_recycledItemsCount++] = itemIndex; + itemIndex = 0; } } private sealed class Releaser : DataReleaser From 95fc264c6f12dc4f45b21c159c2653701b080802 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 25 Feb 2024 02:33:24 +0800 Subject: [PATCH 2/2] Update Injector.cs --- src/Injections/Injector.cs | 45 ++++++++++---------------------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/src/Injections/Injector.cs b/src/Injections/Injector.cs index 9a17f34..3d849cd 100644 --- a/src/Injections/Injector.cs +++ b/src/Injections/Injector.cs @@ -26,44 +26,23 @@ namespace DCFApixels.DragonECS public void Inject(T obj) { - Type type = typeof(T); -#if DEBUG - if (obj.GetType() != type) - { - throw new ArgumentException(); - } - if (IsCanInstantiated(type) == false) - { - throw new Exception(); - } -#endif + Type type = obj.GetType(); if (_branches.TryGetValue(type, out InjectionBranch branch) == false) { - InitNode(new InjectionNode(type)); - branch = new InjectionBranch(this, type, true); - InitBranch(branch); + if (typeof(T) == type) + { + InitNode(new InjectionNode(type)); + branch = new InjectionBranch(this, type, true); + InitBranch(branch); + } + else + { + branch = new InjectionBranch(this, type, false); + InitBranch(branch); + } } branch.Inject(obj); } - // public void InjectNoBoxing(T data) where T : struct - // { - // foreach (var system in _pipeline.GetProcess>()) - // { - // system.Inject(data); - // } - // } - //#if !REFLECTION_DISABLED - // public void InjectRaw(object obj) - // { - // Type type = obj.GetType(); - // if (_branches.TryGetValue(type, out InjectionBranch branch) == false) - // { - // branch = new InjectionBranch(this, type, false); - // InitBranch(branch); - // } - // branch.Inject(obj); - // } - //#endif #region Internal private void InitBranch(InjectionBranch branch)