From 36e60be5f6c121354d66deeac67c799a15914286 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Sun, 12 Jul 2020 15:15:33 -0700 Subject: [PATCH] QueryWith and QueryWithout implicitly Read --- encompass-cs/Attributes/QueryWith.cs | 1 - encompass-cs/Attributes/QueryWithout.cs | 4 +--- encompass-cs/Attributes/Reads.cs | 2 -- encompass-cs/Attributes/Writes.cs | 2 -- encompass-cs/Engine.cs | 10 ++++++++++ encompass-cs/UberEngine.cs | 2 -- test/EngineTest.cs | 4 ---- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/encompass-cs/Attributes/QueryWith.cs b/encompass-cs/Attributes/QueryWith.cs index ac8797d..1f2790f 100644 --- a/encompass-cs/Attributes/QueryWith.cs +++ b/encompass-cs/Attributes/QueryWith.cs @@ -1,7 +1,6 @@ using Encompass.Exceptions; using System; using System.Collections.Generic; -using System.Linq; namespace Encompass { diff --git a/encompass-cs/Attributes/QueryWithout.cs b/encompass-cs/Attributes/QueryWithout.cs index 3332b45..f301674 100644 --- a/encompass-cs/Attributes/QueryWithout.cs +++ b/encompass-cs/Attributes/QueryWithout.cs @@ -1,7 +1,5 @@ -using Encompass.Exceptions; -using System; +using System; using System.Collections.Generic; -using System.Linq; namespace Encompass { diff --git a/encompass-cs/Attributes/Reads.cs b/encompass-cs/Attributes/Reads.cs index e508775..adea1a5 100644 --- a/encompass-cs/Attributes/Reads.cs +++ b/encompass-cs/Attributes/Reads.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using Encompass.Exceptions; namespace Encompass { diff --git a/encompass-cs/Attributes/Writes.cs b/encompass-cs/Attributes/Writes.cs index 0cc1250..2edf24d 100644 --- a/encompass-cs/Attributes/Writes.cs +++ b/encompass-cs/Attributes/Writes.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; -using Encompass.Exceptions; namespace Encompass { diff --git a/encompass-cs/Engine.cs b/encompass-cs/Engine.cs index 36d0ccd..548d7f6 100644 --- a/encompass-cs/Engine.cs +++ b/encompass-cs/Engine.cs @@ -108,11 +108,21 @@ namespace Encompass QueryWithTypes = queryWithAttribute.QueryWithTypes; } + foreach (var queryType in QueryWithTypes) + { + ReadTypes.Add(queryType); + } + var queryWithoutAttribute = GetType().GetCustomAttribute(false); if (queryWithoutAttribute != null) { QueryWithoutTypes = queryWithoutAttribute.QueryWithoutTypes; } + + foreach (var queryType in QueryWithoutTypes) + { + ReadTypes.Add(queryType); + } } public override bool Equals(object obj) diff --git a/encompass-cs/UberEngine.cs b/encompass-cs/UberEngine.cs index 54adce6..bc7c299 100644 --- a/encompass-cs/UberEngine.cs +++ b/encompass-cs/UberEngine.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Reflection; -using System.Runtime.CompilerServices; namespace Encompass { diff --git a/test/EngineTest.cs b/test/EngineTest.cs index c5621fe..a059008 100644 --- a/test/EngineTest.cs +++ b/test/EngineTest.cs @@ -1411,7 +1411,6 @@ namespace Tests struct MockComponentC : IComponent { } struct MockComponentD : IComponent { } - [Reads(typeof(MockComponent), typeof(MockComponentB))] [Writes(typeof(MockComponentB))] [QueryWith(typeof(MockComponent), typeof(MockComponentB))] class EntityQueryWithComponentsEngine : Engine @@ -1465,7 +1464,6 @@ namespace Tests queriedEntities.Should().BeEmpty(); } - [Reads(typeof(MockComponent))] [Writes(typeof(MockComponent))] [QueryWithout(typeof(MockComponent))] class EntityQueryWithoutComponentsEngine : Engine @@ -1519,7 +1517,6 @@ namespace Tests queriedEntities.Should().BeEmpty(); } - [Reads(typeof(MockComponent), typeof(MockComponentB), typeof(MockComponentD))] [QueryWith(typeof(MockComponent), typeof(MockComponentB))] [QueryWithout(typeof(MockComponentD))] class EntityQueryWithandWithoutComponentsEngine : Engine @@ -1745,7 +1742,6 @@ namespace Tests } [ReadsImmediate(typeof(MockComponentB))] - [Reads(typeof(MockComponent))] [QueryWith(typeof(MockComponent), typeof(MockComponentB))] class EntityQueryWithImmediateAndNonImmediateComponents : Engine { -- 2.25.1