AddEntityRenderer and AddGeneralRenderer take initialized renderers

pull/5/head
Evan Hemsley 2019-06-24 16:49:26 -07:00
parent 29179e0ad6
commit 148d629e51
5 changed files with 10 additions and 12 deletions

View File

@ -97,9 +97,8 @@ namespace Encompass
return engine;
}
public TRenderer AddEntityRenderer<TRenderer>() where TRenderer : Renderer, new()
public TRenderer AddEntityRenderer<TRenderer>(TRenderer renderer) where TRenderer : Renderer
{
var renderer = new TRenderer();
renderer.AssignEntityManager(entityManager);
renderer.AssignComponentManager(componentManager);
@ -112,9 +111,8 @@ namespace Encompass
return renderer;
}
public TRenderer AddGeneralRenderer<TRenderer>(int layer) where TRenderer : GeneralRenderer, new()
public TRenderer AddGeneralRenderer<TRenderer>(TRenderer renderer, int layer) where TRenderer : GeneralRenderer
{
var renderer = new TRenderer();
renderer.AssignEntityManager(entityManager);
renderer.AssignComponentManager(componentManager);

View File

@ -1,6 +1,6 @@
using System;
namespace Encompass
namespace Encompass.Exceptions
{
public class ComponentTypeMismatchException : Exception
{

View File

@ -25,7 +25,7 @@ namespace Tests
public void CheckAndTrackEntities()
{
var worldBuilder = new WorldBuilder();
var renderer = worldBuilder.AddEntityRenderer<TestRenderer>();
var renderer = worldBuilder.AddEntityRenderer(new TestRenderer());
AComponent aComponent;
BComponent bComponent;
@ -68,7 +68,7 @@ namespace Tests
public void InactiveDrawComponent()
{
var worldBuilder = new WorldBuilder();
var renderer = worldBuilder.AddEntityRenderer<TestRenderer>();
var renderer = worldBuilder.AddEntityRenderer(new TestRenderer());
AComponent aComponent;
BComponent bComponent;
@ -110,7 +110,7 @@ namespace Tests
public void RenderMethodCalledOnWorldDraw()
{
var worldBuilder = new WorldBuilder();
var renderer = worldBuilder.AddEntityRenderer<CalledRenderer>();
var renderer = worldBuilder.AddEntityRenderer(new CalledRenderer());
AComponent aComponent;
CComponent cComponent;

View File

@ -27,7 +27,7 @@ namespace Tests
public void SingletonComponent()
{
var worldBuilder = new WorldBuilder();
worldBuilder.AddGeneralRenderer<TestRenderer>(1);
worldBuilder.AddGeneralRenderer(new TestRenderer(), 1);
AComponent aComponent;
@ -46,7 +46,7 @@ namespace Tests
public void MultipleComponents()
{
var worldBuilder = new WorldBuilder();
worldBuilder.AddGeneralRenderer<TestRenderer>(1);
worldBuilder.AddGeneralRenderer(new TestRenderer(), 1);
AComponent aComponent;
AComponent aComponentTwo;

View File

@ -37,8 +37,8 @@ namespace Tests
public void DrawOrder()
{
var worldBuilder = new WorldBuilder();
worldBuilder.AddEntityRenderer<TestEntityRenderer>();
var testGeneralRenderer = worldBuilder.AddGeneralRenderer<TestGeneralRenderer>(7);
worldBuilder.AddEntityRenderer(new TestEntityRenderer());
var testGeneralRenderer = worldBuilder.AddGeneralRenderer(new TestGeneralRenderer(), 7);
TestComponent testComponent;
TestDrawComponent testDrawComponent = default(TestDrawComponent);