36 lines
1.4 KiB
C#
36 lines
1.4 KiB
C#
|
using System;
|
||
|
using System.Reflection;
|
||
|
|
||
|
namespace Encompass
|
||
|
{
|
||
|
internal class UberEngine : Engine
|
||
|
{
|
||
|
public override void Update(double dt)
|
||
|
{
|
||
|
foreach (var type in readTypes)
|
||
|
{
|
||
|
var instanceParam = new object[] { Activator.CreateInstance(type) };
|
||
|
|
||
|
CallMethodByName(type, "ReadComponent", null);
|
||
|
CallMethodByName(type, "ReadComponentIncludingEntity", null);
|
||
|
CallMethodByName(type, "ReadComponents", null);
|
||
|
CallMethodByName(type, "ReadComponentsIncludingEntity", null);
|
||
|
CallMethodByName(type, "GetComponent", null);
|
||
|
CallMethodByName(type, "SetComponent", instanceParam);
|
||
|
CallMethodByName(type, "HasComponent", null);
|
||
|
CallMethodByName(type, "SomeComponent", null);
|
||
|
CallMethodByName(type, "RemoveComponent", null);
|
||
|
CallMethodByName(type, "DestroyWith", null);
|
||
|
CallMethodByName(type, "DestroyAllWith", null);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private void CallMethodByName(Type type, string methodName, object[] parameters)
|
||
|
{
|
||
|
var readComponentMethod = typeof(WorldBuilder).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||
|
var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type);
|
||
|
genericReadComponentMethod.Invoke(this, parameters);
|
||
|
}
|
||
|
}
|
||
|
}
|