add new DebugRenderer which can set component values
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
f87cfc4c5a
commit
25bcb2b0f8
|
@ -84,6 +84,13 @@ namespace Encompass
|
|||
return result;
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
internal void Debug_UpdateComponent<TComponent>(int entityID, in TComponent component) where TComponent : struct
|
||||
{
|
||||
_existingComponentStore.Set(entityID, component);
|
||||
}
|
||||
#endif
|
||||
|
||||
internal void AddComponent<TComponent>(int entityID, in TComponent component) where TComponent : struct
|
||||
{
|
||||
_upToDateComponentStore.Set(entityID, component);
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
#if DEBUG
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Encompass
|
||||
{
|
||||
public abstract class DebugRenderer : Renderer
|
||||
{
|
||||
protected IEnumerable<object> Debug_GetAllComponents(Entity entity)
|
||||
{
|
||||
return _componentManager.Debug_Components(entity.ID);
|
||||
}
|
||||
|
||||
protected IEnumerable<Entity> Debug_Entities(Type componentType)
|
||||
{
|
||||
var method = typeof(Renderer).GetMethod(nameof(ReadEntitiesAsEnumerable), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
var generic = method.MakeGenericMethod(componentType);
|
||||
return (IEnumerable<Entity>)generic.Invoke(this, null);
|
||||
}
|
||||
|
||||
protected IEnumerable<Type> Debug_SearchComponentType(string typeString)
|
||||
{
|
||||
return _componentManager.Debug_SearchComponentType(typeString);
|
||||
}
|
||||
|
||||
protected void Debug_SetComponent<TComponent>(in Entity entity, in TComponent component) where TComponent : struct
|
||||
{
|
||||
_componentManager.Debug_UpdateComponent(entity.ID, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -64,24 +64,5 @@ namespace Encompass
|
|||
{
|
||||
return _componentManager.SomeExistingComponent<TComponent>();
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
protected IEnumerable<object> Debug_GetAllComponents(Entity entity)
|
||||
{
|
||||
return _componentManager.Debug_Components(entity.ID);
|
||||
}
|
||||
|
||||
protected IEnumerable<Entity> Debug_Entities(Type componentType)
|
||||
{
|
||||
var method = typeof(Renderer).GetMethod(nameof(ReadEntitiesAsEnumerable), System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
|
||||
var generic = method.MakeGenericMethod(componentType);
|
||||
return (IEnumerable<Entity>)generic.Invoke(this, null);
|
||||
}
|
||||
|
||||
protected IEnumerable<Type> Debug_SearchComponentType(string typeString)
|
||||
{
|
||||
return _componentManager.Debug_SearchComponentType(typeString);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue