diff --git a/encompass-cs/UberEngine.cs b/encompass-cs/UberEngine.cs index 18840c7..7566b82 100644 --- a/encompass-cs/UberEngine.cs +++ b/encompass-cs/UberEngine.cs @@ -41,6 +41,8 @@ namespace Encompass CallGenericMethod(type, "ReadComponentIncludingEntity", null); CallGenericMethod(type, "ReadComponents", null); CallGenericMethod(type, "ReadComponentsIncludingEntity", null); + CallGenericMethod(type, "ReadEntity", null); + CallGenericMethod(type, "ReadEntities", null); CallGenericMethod(type, "GetComponent", new Type[] { typeof(Entity) }, new object[] { _entity }); CallGenericMethod(type, "HasComponent", new Type[] { typeof(Entity) }, new object[] { _entity }); CallGenericMethod(type, "SomeComponent", null); diff --git a/encompass-cs/UberRenderer.cs b/encompass-cs/UberRenderer.cs new file mode 100644 index 0000000..be84634 --- /dev/null +++ b/encompass-cs/UberRenderer.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Reflection; + +namespace Encompass +{ + class UberRenderer : Renderer + { + private Entity _entity; + private IEnumerable _componentTypes; + + public UberRenderer(Entity entity, IEnumerable componentTypes) + { + _entity = entity; + _componentTypes = componentTypes; + } + + public void Render() + { + foreach (var type in _componentTypes) + { + CallGenericMethod(type, "ReadEntities", null); + CallGenericMethod(type, "ReadEntity", null); + CallGenericMethod(type, "ReadComponent", null); + CallGenericMethod(type, "ReadComponentIncludingEntity", null); + CallGenericMethod(type, "ReadComponents", null); + CallGenericMethod(type, "ReadComponentsIncludingEntity", null); + CallGenericMethod(type, "GetComponent", new object[] { _entity }); + CallGenericMethod(type, "HasComponent", new object[] { _entity }); + CallGenericMethod(type, "SomeComponent", null); + } + } + + private void CallGenericMethod(Type type, string methodName, object[] parameters) + { + var readComponentMethod = typeof(Renderer).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance); + var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type); + genericReadComponentMethod.Invoke(this, parameters); + } + } +} diff --git a/encompass-cs/WorldBuilder.cs b/encompass-cs/WorldBuilder.cs index 0a8dce2..0d50a6c 100644 --- a/encompass-cs/WorldBuilder.cs +++ b/encompass-cs/WorldBuilder.cs @@ -399,7 +399,9 @@ namespace Encompass var dummyRenderManager = new RenderManager(dummyDrawLayerManager); var prepEngineOrder = new List(); - var uberEngine = new UberEngine(dummyEntityManager.CreateEntity(), componentTypes, messageTypes); + + var entity = dummyEntityManager.CreateEntity(); + var uberEngine = new UberEngine(entity, componentTypes, messageTypes); uberEngine.AssignEntityManager(dummyEntityManager); uberEngine.AssignComponentManager(dummyComponentManager); @@ -407,6 +409,10 @@ namespace Encompass uberEngine.AssignComponentUpdateManager(dummyComponentUpdateManager); uberEngine.AssignTimeManager(dummyTimeManager); + var uberRenderer = new UberRenderer(entity, componentTypes); + uberRenderer.AssignComponentManager(dummyComponentManager); + uberRenderer.AssignEntityManager(dummyEntityManager); + foreach (var type in componentTypes) { var componentManagerRegisterMethod = typeof(ComponentManager).GetMethod("RegisterComponentType"); @@ -451,6 +457,12 @@ namespace Encompass dummyComponentUpdateManager.Clear(); dummyWorld.Update(1); + + uberEngine.Write(); + dummyComponentManager.WriteComponents(); + dummyComponentUpdateManager.Clear(); + + uberRenderer.Render(); } } }