JIT Renderer methods
continuous-integration/drone/push Build is passing Details

pull/3/head
Evan Hemsley 2020-03-24 22:19:24 -07:00
parent 0df0916347
commit 20d382f51a
1 changed files with 19 additions and 2 deletions

View File

@ -24,9 +24,9 @@ namespace Encompass
{ {
foreach (var type in _componentTypes) foreach (var type in _componentTypes)
{ {
// CallGenericMethod(type, "ReadEntities", null); CallGenericWrappedMethod(type, "ReadEntitiesWrapper", null);
CallGenericMethod(type, "ReadEntity", null); CallGenericMethod(type, "ReadEntity", null);
// CallGenericMethod(type, "ReadComponents", null); CallGenericWrappedMethod(type, "ReadComponentsWrapper", null);
CallGenericMethod(type, "ReadComponent", null); CallGenericMethod(type, "ReadComponent", null);
CallGenericMethod(type, "GetComponent", new object[] { _entity }); CallGenericMethod(type, "GetComponent", new object[] { _entity });
CallGenericMethod(type, "HasComponent", new object[] { _entity }); CallGenericMethod(type, "HasComponent", new object[] { _entity });
@ -34,11 +34,28 @@ namespace Encompass
} }
} }
protected void ReadEntitiesWrapper<TComponent>() where TComponent : struct, IComponent
{
ReadEntities<TComponent>();
}
protected void ReadComponentsWrapper<TComponent>() where TComponent : struct, IComponent
{
ReadComponents<TComponent>();
}
private void CallGenericMethod(Type type, string methodName, object[] parameters) private void CallGenericMethod(Type type, string methodName, object[] parameters)
{ {
var readComponentMethod = typeof(Renderer).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance); var readComponentMethod = typeof(Renderer).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type); var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type);
genericReadComponentMethod.Invoke(this, parameters); genericReadComponentMethod.Invoke(this, parameters);
} }
private void CallGenericWrappedMethod(Type type, string methodName, object[] parameters)
{
var readComponentMethod = typeof(UberRenderer).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type);
genericReadComponentMethod.Invoke(this, parameters);
}
} }
} }