fix crash in Debug_GetEntities
parent
079765d009
commit
3b460cf326
12
src/World.cs
12
src/World.cs
|
@ -1,8 +1,12 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using MoonTools.ECS.Collections;
|
using MoonTools.ECS.Collections;
|
||||||
|
|
||||||
|
#if DEBUG
|
||||||
|
using System.Reflection;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace MoonTools.ECS;
|
namespace MoonTools.ECS;
|
||||||
|
|
||||||
public class World : IDisposable
|
public class World : IDisposable
|
||||||
|
@ -396,8 +400,10 @@ public class World : IDisposable
|
||||||
|
|
||||||
public IEnumerable<Entity> Debug_GetEntities(Type componentType)
|
public IEnumerable<Entity> Debug_GetEntities(Type componentType)
|
||||||
{
|
{
|
||||||
var storage = ComponentIndex[ComponentTypeToId[componentType]];
|
var baseGetComponentStorageMethod = typeof(World).GetMethod(nameof(World.GetComponentStorage), BindingFlags.NonPublic | BindingFlags.Instance)!;
|
||||||
return storage.Debug_GetEntities();
|
var genericGetComponentStorageMethod = baseGetComponentStorageMethod.MakeGenericMethod(componentType);
|
||||||
|
var storage = genericGetComponentStorageMethod.Invoke(this, null) as ComponentStorage;
|
||||||
|
return storage!.Debug_GetEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Type> Debug_SearchComponentType(string typeString)
|
public IEnumerable<Type> Debug_SearchComponentType(string typeString)
|
||||||
|
|
Loading…
Reference in New Issue