add new DebugRenderer which can set component values
continuous-integration/drone/push Build is passing Details

debug
cosmonaut 2021-03-26 12:08:00 -07:00
parent f87cfc4c5a
commit 25bcb2b0f8
3 changed files with 40 additions and 19 deletions

View File

@ -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);

View File

@ -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

View File

@ -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
}
}