diff --git a/encompass-cs/ComponentManager.cs b/encompass-cs/ComponentManager.cs index 961fb5a..ecb6c3c 100644 --- a/encompass-cs/ComponentManager.cs +++ b/encompass-cs/ComponentManager.cs @@ -84,6 +84,13 @@ namespace Encompass return result; } + #if DEBUG + internal void Debug_UpdateComponent(int entityID, in TComponent component) where TComponent : struct + { + _existingComponentStore.Set(entityID, component); + } + #endif + internal void AddComponent(int entityID, in TComponent component) where TComponent : struct { _upToDateComponentStore.Set(entityID, component); diff --git a/encompass-cs/DebugRenderer.cs b/encompass-cs/DebugRenderer.cs new file mode 100644 index 0000000..113819a --- /dev/null +++ b/encompass-cs/DebugRenderer.cs @@ -0,0 +1,33 @@ +#if DEBUG + +using System; +using System.Collections.Generic; + +namespace Encompass +{ + public abstract class DebugRenderer : Renderer + { + protected IEnumerable Debug_GetAllComponents(Entity entity) + { + return _componentManager.Debug_Components(entity.ID); + } + + protected IEnumerable 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)generic.Invoke(this, null); + } + + protected IEnumerable Debug_SearchComponentType(string typeString) + { + return _componentManager.Debug_SearchComponentType(typeString); + } + + protected void Debug_SetComponent(in Entity entity, in TComponent component) where TComponent : struct + { + _componentManager.Debug_UpdateComponent(entity.ID, component); + } + } +} +#endif diff --git a/encompass-cs/Renderer.cs b/encompass-cs/Renderer.cs index 658ab36..2ebf732 100644 --- a/encompass-cs/Renderer.cs +++ b/encompass-cs/Renderer.cs @@ -64,24 +64,5 @@ namespace Encompass { return _componentManager.SomeExistingComponent(); } - - #if DEBUG - protected IEnumerable Debug_GetAllComponents(Entity entity) - { - return _componentManager.Debug_Components(entity.ID); - } - - protected IEnumerable 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)generic.Invoke(this, null); - } - - protected IEnumerable Debug_SearchComponentType(string typeString) - { - return _componentManager.Debug_SearchComponentType(typeString); - } - #endif } }