From 6d699e4b1753d6587d25decb6a6dc9387c7519a3 Mon Sep 17 00:00:00 2001
From: Evan Hemsley <evan@moonside.games>
Date: Fri, 20 Mar 2020 14:13:26 -0700
Subject: [PATCH] passing draw components by ref

---
 encompass-cs/Engine.cs                    | 2 +-
 encompass-cs/Renderers/OrderedRenderer.cs | 2 +-
 encompass-cs/encompass-cs.csproj          | 3 ++-
 test/OrderedRendererTest.cs               | 6 +++---
 test/WorldTest.cs                         | 2 +-
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/encompass-cs/Engine.cs b/encompass-cs/Engine.cs
index 91b97b7..fab7457 100644
--- a/encompass-cs/Engine.cs
+++ b/encompass-cs/Engine.cs
@@ -105,7 +105,7 @@ namespace Encompass
             var queryWithAttribute = GetType().GetCustomAttribute<QueryWith>(false);
             if (queryWithAttribute != null)
             {
-                QueryWithTypes = queryWithAttribute.QueryWithTypes.ToHashSet();
+                QueryWithTypes = queryWithAttribute.QueryWithTypes;
             }
 
             var queryWithoutAttribute = GetType().GetCustomAttribute<QueryWithout>(false);
diff --git a/encompass-cs/Renderers/OrderedRenderer.cs b/encompass-cs/Renderers/OrderedRenderer.cs
index cfeb73b..162322a 100644
--- a/encompass-cs/Renderers/OrderedRenderer.cs
+++ b/encompass-cs/Renderers/OrderedRenderer.cs
@@ -7,7 +7,7 @@ namespace Encompass
     /// </summary>
     public abstract class OrderedRenderer<TComponent> : Renderer where TComponent : struct, IComponent, IDrawableComponent
     {
-        public abstract void Render(Entity entity, TComponent drawComponent);
+        public abstract void Render(Entity entity, in TComponent drawComponent);
 
         internal void InternalRender(Entity entity)
         {
diff --git a/encompass-cs/encompass-cs.csproj b/encompass-cs/encompass-cs.csproj
index c7be512..67ada2d 100644
--- a/encompass-cs/encompass-cs.csproj
+++ b/encompass-cs/encompass-cs.csproj
@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
-    <TargetFramework>netstandard2.1</TargetFramework>
+    <TargetFramework>netstandard2.0</TargetFramework>
     <LangVersion>8.0</LangVersion>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <RootNamespace>Encompass</RootNamespace>
@@ -28,5 +28,6 @@
     <PackageReference Include="MoonTools.Core.Graph" Version="1.0.0" />
     <PackageReference Include="MoonTools.FastCollections" Version="1.0.0" />
     <PackageReference Include="System.Collections.Immutable" Version="1.7.0" />
+    <PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.0" />
   </ItemGroup>
 </Project>
diff --git a/test/OrderedRendererTest.cs b/test/OrderedRendererTest.cs
index 6f7dc8a..92cb3b8 100644
--- a/test/OrderedRendererTest.cs
+++ b/test/OrderedRendererTest.cs
@@ -20,13 +20,13 @@ namespace Tests
 
         class TestRenderer : OrderedRenderer<TestDrawComponent>
         {
-            public override void Render(Entity entity, TestDrawComponent testDrawComponent) { }
+            public override void Render(Entity entity, in TestDrawComponent testDrawComponent) { }
         }
 
         static bool called = false;
         class DeactivatedRenderer : TestRenderer
         {
-            public override void Render(Entity entity, TestDrawComponent testDrawComponent)
+            public override void Render(Entity entity, in TestDrawComponent testDrawComponent)
             {
                 called = true;
             }
@@ -37,7 +37,7 @@ namespace Tests
 
         class CalledRenderer : OrderedRenderer<TestDrawComponent>
         {
-            public override void Render(Entity entity, TestDrawComponent testDrawComponent)
+            public override void Render(Entity entity, in TestDrawComponent testDrawComponent)
             {
                 resultComponent = (testDrawComponent, entity);
                 calledOnDraw = true;
diff --git a/test/WorldTest.cs b/test/WorldTest.cs
index def4165..6ce089b 100644
--- a/test/WorldTest.cs
+++ b/test/WorldTest.cs
@@ -21,7 +21,7 @@ namespace Tests
 
         class TestEntityRenderer : OrderedRenderer<TestDrawComponent>
         {
-            public override void Render(Entity entity, TestDrawComponent testDrawComponent)
+            public override void Render(Entity entity, in TestDrawComponent testDrawComponent)
             {
                 drawOrder.Add(entity);
             }