update JIT preload
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
7c8154efdd
commit
0df0916347
|
@ -213,7 +213,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all Entities containing the specified Component type.
|
/// Returns all Entities containing the specified Component type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct
|
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -238,7 +238,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns an Entity containing the specified Component type.
|
/// Returns an Entity containing the specified Component type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
|
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -263,7 +263,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns all of the Components with the specified Component Type.
|
/// Returns all of the Components with the specified Component Type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct
|
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -288,7 +288,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a Component with the specified Component Type. If multiples exist, an arbitrary Component is returned.
|
/// Returns a Component with the specified Component Type. If multiples exist, an arbitrary Component is returned.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected ref readonly TComponent ReadComponent<TComponent>() where TComponent : struct
|
protected ref readonly TComponent ReadComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -313,7 +313,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns true if any Component with the specified Component Type exists.
|
/// Returns true if any Component with the specified Component Type exists.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool SomeComponent<TComponent>() where TComponent : struct
|
protected bool SomeComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -335,7 +335,7 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ref TComponent GetComponentHelper<TComponent>(int entityID) where TComponent : struct
|
private ref TComponent GetComponentHelper<TComponent>(int entityID) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -366,7 +366,7 @@ namespace Encompass
|
||||||
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
||||||
/// Thrown when the Engine does not declare that it reads the given Component Type.
|
/// Thrown when the Engine does not declare that it reads the given Component Type.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected ref readonly TComponent GetComponent<TComponent>(in Entity entity) where TComponent : struct
|
protected ref readonly TComponent GetComponent<TComponent>(in Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return ref GetComponentHelper<TComponent>(entity.ID);
|
return ref GetComponentHelper<TComponent>(entity.ID);
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,7 @@ namespace Encompass
|
||||||
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
||||||
/// Thrown when the Engine does not declare that it reads the given Component Type.
|
/// Thrown when the Engine does not declare that it reads the given Component Type.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected ref TComponent GetComponentMutable<TComponent>(in Entity entity) where TComponent : struct
|
protected ref TComponent GetComponentMutable<TComponent>(in Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return ref GetComponentHelper<TComponent>(entity.ID);
|
return ref GetComponentHelper<TComponent>(entity.ID);
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ namespace Encompass
|
||||||
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
/// <exception cref="Encompass.Exceptions.IllegalReadException">
|
||||||
/// Thrown when the Engine does not declare that is Reads the given Component Type.
|
/// Thrown when the Engine does not declare that is Reads the given Component Type.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected bool HasComponent<TComponent>(in Entity entity) where TComponent : struct
|
protected bool HasComponent<TComponent>(in Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
var immediateRead = ReadImmediateTypes.Contains(typeof(TComponent));
|
||||||
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
var existingRead = ReadTypes.Contains(typeof(TComponent));
|
||||||
|
@ -449,7 +449,7 @@ namespace Encompass
|
||||||
/// <exception cref="Encompass.Exceptions.IllegalWriteException">
|
/// <exception cref="Encompass.Exceptions.IllegalWriteException">
|
||||||
/// Thrown when the Engine does not declare that it Writes the given Component Type.
|
/// Thrown when the Engine does not declare that it Writes the given Component Type.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected void SetComponent<TComponent>(in Entity entity, in TComponent component) where TComponent : struct
|
protected void SetComponent<TComponent>(in Entity entity, in TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var priority = WritePriorities.ContainsKey(typeof(TComponent)) ? WritePriorities[typeof(TComponent)] : DefaultWritePriority;
|
var priority = WritePriorities.ContainsKey(typeof(TComponent)) ? WritePriorities[typeof(TComponent)] : DefaultWritePriority;
|
||||||
|
|
||||||
|
@ -489,7 +489,7 @@ namespace Encompass
|
||||||
/// <exception cref="Encompass.Exceptions.IllegalWriteException">
|
/// <exception cref="Encompass.Exceptions.IllegalWriteException">
|
||||||
/// Thrown when the Engine does not declare that it Writes the given Component Type.
|
/// Thrown when the Engine does not declare that it Writes the given Component Type.
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected void AddComponent<TComponent>(in Entity entity, in TComponent component) where TComponent : struct
|
protected void AddComponent<TComponent>(in Entity entity, in TComponent component) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
if (!EntityCreatedThisFrame(entity.ID))
|
if (!EntityCreatedThisFrame(entity.ID))
|
||||||
{
|
{
|
||||||
|
@ -597,7 +597,7 @@ namespace Encompass
|
||||||
/// Destroys an arbitrary Entity containing a Component of the specified Type.
|
/// Destroys an arbitrary Entity containing a Component of the specified Type.
|
||||||
/// Entity destruction takes place after all the Engines have been processed by World Update.
|
/// Entity destruction takes place after all the Engines have been processed by World Update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void DestroyWith<TComponent>() where TComponent : struct
|
protected void DestroyWith<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
Destroy(ReadEntity<TComponent>());
|
Destroy(ReadEntity<TComponent>());
|
||||||
}
|
}
|
||||||
|
@ -606,7 +606,7 @@ namespace Encompass
|
||||||
/// Destroys all Entities containing a Component of the specified Type.
|
/// Destroys all Entities containing a Component of the specified Type.
|
||||||
/// Entity destruction takes place after all the Engines have been processed by World Update.
|
/// Entity destruction takes place after all the Engines have been processed by World Update.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void DestroyAllWith<TComponent>() where TComponent : struct
|
protected void DestroyAllWith<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
foreach (var entity in ReadEntities<TComponent>())
|
foreach (var entity in ReadEntities<TComponent>())
|
||||||
{
|
{
|
||||||
|
@ -619,7 +619,7 @@ namespace Encompass
|
||||||
/// Note that the Engine must Read the Component type that is being removed.
|
/// Note that the Engine must Read the Component type that is being removed.
|
||||||
/// If a Component with the specified type does not exist on the Entity, returns false and does not mutate the Entity.
|
/// If a Component with the specified type does not exist on the Entity, returns false and does not mutate the Entity.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void RemoveComponent<TComponent>(in Entity entity) where TComponent : struct
|
protected void RemoveComponent<TComponent>(in Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
var priority = WritePriorities.ContainsKey(typeof(TComponent)) ? WritePriorities[typeof(TComponent)] : DefaultWritePriority;
|
var priority = WritePriorities.ContainsKey(typeof(TComponent)) ? WritePriorities[typeof(TComponent)] : DefaultWritePriority;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
namespace Encompass
|
||||||
|
{
|
||||||
|
public interface IComponent { }
|
||||||
|
}
|
|
@ -18,37 +18,37 @@ namespace Encompass
|
||||||
_componentManager = componentManager;
|
_componentManager = componentManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct
|
protected Span<Entity> ReadEntities<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return _componentManager.GetExistingEntities<TComponent>();
|
return _componentManager.GetExistingEntities<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct
|
protected ref readonly Entity ReadEntity<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return ref _componentManager.ExistingSingularEntity<TComponent>();
|
return ref _componentManager.ExistingSingularEntity<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct
|
protected Span<TComponent> ReadComponents<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return _componentManager.GetComponentsByType<TComponent>();
|
return _componentManager.GetComponentsByType<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ref readonly TComponent ReadComponent<TComponent>() where TComponent : struct
|
protected ref readonly TComponent ReadComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return ref _componentManager.ExistingSingular<TComponent>();
|
return ref _componentManager.ExistingSingular<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ref readonly TComponent GetComponent<TComponent>(Entity entity) where TComponent : struct
|
protected ref readonly TComponent GetComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return ref _componentManager.GetComponentByEntityAndType<TComponent>(entity.ID);
|
return ref _componentManager.GetComponentByEntityAndType<TComponent>(entity.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool HasComponent<TComponent>(Entity entity) where TComponent : struct
|
protected bool HasComponent<TComponent>(Entity entity) where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return _componentManager.EntityHasComponentOfType<TComponent>(entity.ID);
|
return _componentManager.EntityHasComponentOfType<TComponent>(entity.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool SomeComponent<TComponent>() where TComponent : struct
|
protected bool SomeComponent<TComponent>() where TComponent : struct, IComponent
|
||||||
{
|
{
|
||||||
return _componentManager.SomeExistingComponent<TComponent>();
|
return _componentManager.SomeExistingComponent<TComponent>();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// OrdereredRenderer provides a structure for the common pattern of wishing to draw a specific DrawComponent at a specific layer.
|
/// OrdereredRenderer provides a structure for the common pattern of wishing to draw a specific DrawComponent at a specific layer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class OrderedRenderer<TComponent> : Renderer where TComponent : struct, IDrawableComponent
|
public abstract class OrderedRenderer<TComponent> : Renderer where TComponent : struct, IComponent, IDrawableComponent
|
||||||
{
|
{
|
||||||
public abstract void Render(Entity entity, in TComponent drawComponent);
|
public abstract void Render(Entity entity, in TComponent drawComponent);
|
||||||
|
|
||||||
|
|
|
@ -35,15 +35,14 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can't reflect invoke on Span returns right now... tragic
|
|
||||||
public override void Update(double dt)
|
public override void Update(double dt)
|
||||||
{
|
{
|
||||||
foreach (var type in _componentTypes)
|
foreach (var type in _componentTypes)
|
||||||
{
|
{
|
||||||
CallGenericMethod(type, "ReadComponent", null);
|
CallGenericMethod(type, "ReadComponent", null);
|
||||||
//CallGenericMethod(type, "ReadComponents", null);
|
CallGenericWrappedMethod(type, "ReadComponentsWrapper", null);
|
||||||
CallGenericMethod(type, "ReadEntity", null);
|
CallGenericMethod(type, "ReadEntity", null);
|
||||||
//CallGenericMethod(type, "ReadEntities", null);
|
CallGenericWrappedMethod(type, "ReadEntitiesWrapper", null);
|
||||||
CallGenericMethod(type, "GetComponent", new object[] { Entity });
|
CallGenericMethod(type, "GetComponent", new object[] { Entity });
|
||||||
CallGenericMethod(type, "HasComponent", 1, new object[] { Entity });
|
CallGenericMethod(type, "HasComponent", 1, new object[] { Entity });
|
||||||
CallGenericMethod(type, "SomeComponent", null);
|
CallGenericMethod(type, "SomeComponent", null);
|
||||||
|
@ -59,7 +58,7 @@ namespace Encompass
|
||||||
CallGenericMethod(type, "SendMessage", 2, new object[] { Activator.CreateInstance(type), 1 });
|
CallGenericMethod(type, "SendMessage", 2, new object[] { Activator.CreateInstance(type), 1 });
|
||||||
CallGenericMethod(type, "ReadMessage", null);
|
CallGenericMethod(type, "ReadMessage", null);
|
||||||
|
|
||||||
//CallGenericMethod(type, "ReadMessages", null);
|
CallGenericWrappedMethod(type, "ReadMessagesWrapper", null);
|
||||||
CallGenericMethod(type, "SomeMessage", null);
|
CallGenericMethod(type, "SomeMessage", null);
|
||||||
if (typeof(IHasEntity).IsAssignableFrom(type))
|
if (typeof(IHasEntity).IsAssignableFrom(type))
|
||||||
{
|
{
|
||||||
|
@ -70,6 +69,23 @@ namespace Encompass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we can't reflect invoke on Span returns right now... so we have non-return wrapper methods
|
||||||
|
|
||||||
|
protected void ReadComponentsWrapper<TComponent>() where TComponent : struct, IComponent
|
||||||
|
{
|
||||||
|
ReadComponents<TComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ReadMessagesWrapper<TMessage>() where TMessage : struct, IMessage
|
||||||
|
{
|
||||||
|
ReadMessages<TMessage>();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void ReadEntitiesWrapper<TComponent>() where TComponent : struct, IComponent
|
||||||
|
{
|
||||||
|
ReadEntities<TComponent>();
|
||||||
|
}
|
||||||
|
|
||||||
// trying to use PrepareMethod because we can't reflect invoke methods that return a span...
|
// trying to use PrepareMethod because we can't reflect invoke methods that return a span...
|
||||||
private void CallGenericMethod(Type type, string methodName, object[] parameters)
|
private void CallGenericMethod(Type type, string methodName, object[] parameters)
|
||||||
{
|
{
|
||||||
|
@ -79,6 +95,13 @@ namespace Encompass
|
||||||
// RuntimeHelpers.PrepareMethod(genericReadComponentMethod.MethodHandle);
|
// RuntimeHelpers.PrepareMethod(genericReadComponentMethod.MethodHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CallGenericWrappedMethod(Type type, string methodName, object[] parameters)
|
||||||
|
{
|
||||||
|
var readComponentMethod = typeof(UberEngine).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
var genericReadComponentMethod = readComponentMethod.MakeGenericMethod(type);
|
||||||
|
genericReadComponentMethod.Invoke(this, parameters);
|
||||||
|
}
|
||||||
|
|
||||||
private void CallGenericMethod(Type type, string methodName, Type[] types, object[] parameters)
|
private void CallGenericMethod(Type type, string methodName, Type[] types, object[] parameters)
|
||||||
{
|
{
|
||||||
var readComponentMethod = typeof(Engine).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance, null, types, null);
|
var readComponentMethod = typeof(Engine).GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Instance, null, types, null);
|
||||||
|
|
|
@ -183,7 +183,7 @@ namespace Encompass
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds the specified OrderedRenderer to the World.
|
/// Adds the specified OrderedRenderer to the World.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public OrderedRenderer<TComponent> AddOrderedRenderer<TComponent>(OrderedRenderer<TComponent> renderer) where TComponent : struct, IDrawableComponent
|
public OrderedRenderer<TComponent> AddOrderedRenderer<TComponent>(OrderedRenderer<TComponent> renderer) where TComponent : struct, IComponent, IDrawableComponent
|
||||||
{
|
{
|
||||||
RegisterComponentType<TComponent>();
|
RegisterComponentType<TComponent>();
|
||||||
renderer.AssignEntityManager(_entityManager);
|
renderer.AssignEntityManager(_entityManager);
|
||||||
|
@ -354,7 +354,7 @@ namespace Encompass
|
||||||
throw new EngineWriteConflictException(errorString);
|
throw new EngineWriteConflictException(errorString);
|
||||||
}
|
}
|
||||||
|
|
||||||
PreloadJIT(_componentTypesToPreload, _messageTypes);
|
PreloadJIT(_messageTypes);
|
||||||
|
|
||||||
var engineOrder = new List<Engine>();
|
var engineOrder = new List<Engine>();
|
||||||
|
|
||||||
|
@ -388,7 +388,7 @@ namespace Encompass
|
||||||
/// It does so by grabbing all component and message types known to the WorldBuilder and
|
/// It does so by grabbing all component and message types known to the WorldBuilder and
|
||||||
/// executing every possible generic method that could be executed with those types.
|
/// executing every possible generic method that could be executed with those types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void PreloadJIT(IEnumerable<Type> componentTypes, IEnumerable<Type> messageTypes)
|
private void PreloadJIT(IEnumerable<Type> messageTypes)
|
||||||
{
|
{
|
||||||
var dummyTimeManager = new TimeManager();
|
var dummyTimeManager = new TimeManager();
|
||||||
var dummyMessageManager = new MessageManager(dummyTimeManager);
|
var dummyMessageManager = new MessageManager(dummyTimeManager);
|
||||||
|
@ -398,9 +398,30 @@ namespace Encompass
|
||||||
var dummyEntityManager = new EntityManager(dummyComponentManager, _entityCapacity);
|
var dummyEntityManager = new EntityManager(dummyComponentManager, _entityCapacity);
|
||||||
var dummyRenderManager = new RenderManager(dummyEntityManager, dummyDrawLayerManager);
|
var dummyRenderManager = new RenderManager(dummyEntityManager, dummyDrawLayerManager);
|
||||||
|
|
||||||
|
// doing reflection to grab all component types, because not all writes need to be declared
|
||||||
|
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
|
||||||
|
{
|
||||||
|
foreach (var componentType in assembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (typeof(IComponent).IsAssignableFrom(componentType) && componentType.IsValueType && !componentType.IsEnum && !componentType.IsPrimitive)
|
||||||
|
{
|
||||||
|
var method = typeof(WorldBuilder).GetMethod("RegisterComponentType", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||||
|
var generic = method.MakeGenericMethod(componentType);
|
||||||
|
generic.Invoke(this, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (componentType.GetInterface("IDrawableComponent") != null)
|
||||||
|
{
|
||||||
|
var drawLayerManagerRegisterMethod = typeof(DrawLayerManager).GetMethod("RegisterOrderedDrawable");
|
||||||
|
var drawLayerManagerRegisterGenericMethod = drawLayerManagerRegisterMethod.MakeGenericMethod(componentType);
|
||||||
|
drawLayerManagerRegisterGenericMethod.Invoke(dummyDrawLayerManager, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var prepEngineOrder = new List<Engine>();
|
var prepEngineOrder = new List<Engine>();
|
||||||
|
|
||||||
var uberEngine = new UberEngine(componentTypes, messageTypes);
|
var uberEngine = new UberEngine(_componentTypesToPreload, messageTypes);
|
||||||
|
|
||||||
uberEngine.AssignEntityManager(dummyEntityManager);
|
uberEngine.AssignEntityManager(dummyEntityManager);
|
||||||
uberEngine.AssignComponentManager(dummyComponentManager);
|
uberEngine.AssignComponentManager(dummyComponentManager);
|
||||||
|
@ -408,24 +429,10 @@ namespace Encompass
|
||||||
uberEngine.AssignTimeManager(dummyTimeManager);
|
uberEngine.AssignTimeManager(dummyTimeManager);
|
||||||
uberEngine.AssignTrackingManager(dummyTrackingManager);
|
uberEngine.AssignTrackingManager(dummyTrackingManager);
|
||||||
|
|
||||||
var uberRenderer = new UberRenderer(componentTypes);
|
var uberRenderer = new UberRenderer(_componentTypesToPreload);
|
||||||
uberRenderer.AssignComponentManager(dummyComponentManager);
|
uberRenderer.AssignComponentManager(dummyComponentManager);
|
||||||
uberRenderer.AssignEntityManager(dummyEntityManager);
|
uberRenderer.AssignEntityManager(dummyEntityManager);
|
||||||
|
|
||||||
foreach (var type in componentTypes)
|
|
||||||
{
|
|
||||||
var componentManagerRegisterMethod = typeof(ComponentManager).GetMethod("RegisterComponentType");
|
|
||||||
var componentManagerRegisterGenericMethod = componentManagerRegisterMethod.MakeGenericMethod(type);
|
|
||||||
componentManagerRegisterGenericMethod.Invoke(dummyComponentManager, null);
|
|
||||||
|
|
||||||
if (type.GetInterface("IDrawableComponent") != null)
|
|
||||||
{
|
|
||||||
var drawLayerManagerRegisterMethod = typeof(DrawLayerManager).GetMethod("RegisterOrderedDrawable");
|
|
||||||
var drawLayerManagerRegisterGenericMethod = drawLayerManagerRegisterMethod.MakeGenericMethod(type);
|
|
||||||
drawLayerManagerRegisterGenericMethod.Invoke(dummyDrawLayerManager, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
prepEngineOrder.Add(uberEngine);
|
prepEngineOrder.Add(uberEngine);
|
||||||
|
|
||||||
var dummyWorld = new World(
|
var dummyWorld = new World(
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public class ComponentTests
|
public class ComponentTests
|
||||||
{
|
{
|
||||||
struct MockComponent
|
struct MockComponent : IComponent
|
||||||
{
|
{
|
||||||
public int myInt;
|
public int myInt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ using Encompass.Exceptions;
|
||||||
|
|
||||||
namespace Tests
|
namespace Tests
|
||||||
{
|
{
|
||||||
struct MockComponent
|
struct MockComponent : IComponent
|
||||||
{
|
{
|
||||||
public int myInt;
|
public int myInt;
|
||||||
}
|
}
|
||||||
|
@ -618,7 +618,7 @@ namespace Tests
|
||||||
world.Update(0.01f);
|
world.Update(0.01f);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct DestroyerComponent { }
|
struct DestroyerComponent : IComponent { }
|
||||||
|
|
||||||
[Reads(typeof(DestroyerComponent))]
|
[Reads(typeof(DestroyerComponent))]
|
||||||
class DestroyerEngine : Engine
|
class DestroyerEngine : Engine
|
||||||
|
@ -964,7 +964,7 @@ namespace Tests
|
||||||
entity.Should().BeEquivalentTo(readEntity);
|
entity.Should().BeEquivalentTo(readEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MockComponentB
|
struct MockComponentB : IComponent
|
||||||
{
|
{
|
||||||
private int value;
|
private int value;
|
||||||
|
|
||||||
|
@ -1407,9 +1407,9 @@ namespace Tests
|
||||||
|
|
||||||
public class QueryTests
|
public class QueryTests
|
||||||
{
|
{
|
||||||
struct MockComponentB { }
|
struct MockComponentB : IComponent { }
|
||||||
struct MockComponentC { }
|
struct MockComponentC : IComponent { }
|
||||||
struct MockComponentD { }
|
struct MockComponentD : IComponent { }
|
||||||
|
|
||||||
[Reads(typeof(MockComponent), typeof(MockComponentB))]
|
[Reads(typeof(MockComponent), typeof(MockComponentB))]
|
||||||
[Writes(typeof(MockComponentB))]
|
[Writes(typeof(MockComponentB))]
|
||||||
|
@ -1863,7 +1863,7 @@ namespace Tests
|
||||||
_components.Should().NotBeEmpty();
|
_components.Should().NotBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MockTimerComponent
|
struct MockTimerComponent : IComponent
|
||||||
{
|
{
|
||||||
public double Timer { get; }
|
public double Timer { get; }
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public static class GeneralRendererTest
|
public static class GeneralRendererTest
|
||||||
{
|
{
|
||||||
struct AComponent { }
|
struct AComponent : IComponent { }
|
||||||
|
|
||||||
public class SingletonRead
|
public class SingletonRead
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,11 +9,11 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public class OrderedRendererTest
|
public class OrderedRendererTest
|
||||||
{
|
{
|
||||||
struct AComponent { }
|
struct AComponent : IComponent { }
|
||||||
struct BComponent { }
|
struct BComponent : IComponent { }
|
||||||
struct CComponent { }
|
struct CComponent : IComponent { }
|
||||||
|
|
||||||
struct TestDrawComponent : IDrawableComponent
|
struct TestDrawComponent : IComponent, IDrawableComponent
|
||||||
{
|
{
|
||||||
public int Layer { get; set; }
|
public int Layer { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public class SpawnerTest
|
public class SpawnerTest
|
||||||
{
|
{
|
||||||
struct TestComponent { }
|
struct TestComponent : IComponent { }
|
||||||
struct SpawnMessageA : IMessage { }
|
struct SpawnMessageA : IMessage { }
|
||||||
|
|
||||||
static Entity resultEntity;
|
static Entity resultEntity;
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace Tests
|
||||||
public Entity entity;
|
public Entity entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AComponent
|
struct AComponent : IComponent
|
||||||
{
|
{
|
||||||
public int myInt;
|
public int myInt;
|
||||||
}
|
}
|
||||||
|
@ -216,7 +216,7 @@ namespace Tests
|
||||||
public Entity entity;
|
public Entity entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AComponent
|
struct AComponent : IComponent
|
||||||
{
|
{
|
||||||
public int myInt;
|
public int myInt;
|
||||||
}
|
}
|
||||||
|
@ -407,8 +407,8 @@ namespace Tests
|
||||||
{
|
{
|
||||||
static List<Engine> order = new List<Engine>();
|
static List<Engine> order = new List<Engine>();
|
||||||
|
|
||||||
struct AComponent { }
|
struct AComponent : IComponent { }
|
||||||
struct BComponent { }
|
struct BComponent : IComponent { }
|
||||||
|
|
||||||
struct AMessage : IMessage { }
|
struct AMessage : IMessage { }
|
||||||
struct BMessage : IMessage { }
|
struct BMessage : IMessage { }
|
||||||
|
|
|
@ -11,8 +11,8 @@ namespace Tests
|
||||||
{
|
{
|
||||||
public class WorldTest
|
public class WorldTest
|
||||||
{
|
{
|
||||||
struct TestComponent { }
|
struct TestComponent : IComponent { }
|
||||||
struct TestDrawComponent : IDrawableComponent
|
struct TestDrawComponent : IComponent, IDrawableComponent
|
||||||
{
|
{
|
||||||
public int Layer { get; set; }
|
public int Layer { get; set; }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue