From 148d629e5128929cd2a063e49cd35bd925dd24fd Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Mon, 24 Jun 2019 16:49:26 -0700 Subject: [PATCH] AddEntityRenderer and AddGeneralRenderer take initialized renderers --- encompass-cs/WorldBuilder.cs | 6 ++---- encompass-cs/exceptions/ComponentTypeMismatchException.cs | 2 +- test/EntityRendererTest.cs | 6 +++--- test/GeneralRendererTest.cs | 4 ++-- test/WorldTest.cs | 4 ++-- 5 files changed, 10 insertions(+), 12 deletions(-) diff --git a/encompass-cs/WorldBuilder.cs b/encompass-cs/WorldBuilder.cs index f1331fc..da38ed6 100644 --- a/encompass-cs/WorldBuilder.cs +++ b/encompass-cs/WorldBuilder.cs @@ -97,9 +97,8 @@ namespace Encompass return engine; } - public TRenderer AddEntityRenderer() where TRenderer : Renderer, new() + public TRenderer AddEntityRenderer(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(int layer) where TRenderer : GeneralRenderer, new() + public TRenderer AddGeneralRenderer(TRenderer renderer, int layer) where TRenderer : GeneralRenderer { - var renderer = new TRenderer(); renderer.AssignEntityManager(entityManager); renderer.AssignComponentManager(componentManager); diff --git a/encompass-cs/exceptions/ComponentTypeMismatchException.cs b/encompass-cs/exceptions/ComponentTypeMismatchException.cs index d28e7c4..17caf96 100644 --- a/encompass-cs/exceptions/ComponentTypeMismatchException.cs +++ b/encompass-cs/exceptions/ComponentTypeMismatchException.cs @@ -1,6 +1,6 @@ using System; -namespace Encompass +namespace Encompass.Exceptions { public class ComponentTypeMismatchException : Exception { diff --git a/test/EntityRendererTest.cs b/test/EntityRendererTest.cs index ceaf243..009528f 100644 --- a/test/EntityRendererTest.cs +++ b/test/EntityRendererTest.cs @@ -25,7 +25,7 @@ namespace Tests public void CheckAndTrackEntities() { var worldBuilder = new WorldBuilder(); - var renderer = worldBuilder.AddEntityRenderer(); + 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(); + 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(); + var renderer = worldBuilder.AddEntityRenderer(new CalledRenderer()); AComponent aComponent; CComponent cComponent; diff --git a/test/GeneralRendererTest.cs b/test/GeneralRendererTest.cs index 3ada80c..3319043 100644 --- a/test/GeneralRendererTest.cs +++ b/test/GeneralRendererTest.cs @@ -27,7 +27,7 @@ namespace Tests public void SingletonComponent() { var worldBuilder = new WorldBuilder(); - worldBuilder.AddGeneralRenderer(1); + worldBuilder.AddGeneralRenderer(new TestRenderer(), 1); AComponent aComponent; @@ -46,7 +46,7 @@ namespace Tests public void MultipleComponents() { var worldBuilder = new WorldBuilder(); - worldBuilder.AddGeneralRenderer(1); + worldBuilder.AddGeneralRenderer(new TestRenderer(), 1); AComponent aComponent; AComponent aComponentTwo; diff --git a/test/WorldTest.cs b/test/WorldTest.cs index f403608..675a75e 100644 --- a/test/WorldTest.cs +++ b/test/WorldTest.cs @@ -37,8 +37,8 @@ namespace Tests public void DrawOrder() { var worldBuilder = new WorldBuilder(); - worldBuilder.AddEntityRenderer(); - var testGeneralRenderer = worldBuilder.AddGeneralRenderer(7); + worldBuilder.AddEntityRenderer(new TestEntityRenderer()); + var testGeneralRenderer = worldBuilder.AddGeneralRenderer(new TestGeneralRenderer(), 7); TestComponent testComponent; TestDrawComponent testDrawComponent = default(TestDrawComponent);