From 3b460cf326db986242d9a6020789bbe858bb1e88 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Tue, 27 Feb 2024 15:47:26 -0800 Subject: [PATCH] fix crash in Debug_GetEntities --- src/World.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/World.cs b/src/World.cs index 753d0b7..bcaedf6 100644 --- a/src/World.cs +++ b/src/World.cs @@ -1,8 +1,12 @@ -using System; +using System; using System.Collections.Generic; using System.Runtime.CompilerServices; using MoonTools.ECS.Collections; +#if DEBUG +using System.Reflection; +#endif + namespace MoonTools.ECS; public class World : IDisposable @@ -396,8 +400,10 @@ public class World : IDisposable public IEnumerable Debug_GetEntities(Type componentType) { - var storage = ComponentIndex[ComponentTypeToId[componentType]]; - return storage.Debug_GetEntities(); + var baseGetComponentStorageMethod = typeof(World).GetMethod(nameof(World.GetComponentStorage), BindingFlags.NonPublic | BindingFlags.Instance)!; + var genericGetComponentStorageMethod = baseGetComponentStorageMethod.MakeGenericMethod(componentType); + var storage = genericGetComponentStorageMethod.Invoke(this, null) as ComponentStorage; + return storage!.Debug_GetEntities(); } public IEnumerable Debug_SearchComponentType(string typeString)