Skip to content

Commit 4cc171a

Browse files
committed
Replacing HashSet with Dictionary on .NET Standard 2.0
1 parent 84ec162 commit 4cc171a

File tree

3 files changed

+12
-19
lines changed

3 files changed

+12
-19
lines changed

src/ECS/Archetype/EntityStore.Archetype.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
// Hard rule: this file MUST NOT use type: Entity
55

66
using System;
7-
using Friflo.Engine.ECS.Compat;
87

98
// ReSharper disable InlineTemporaryVariable
109
// ReSharper disable ArrangeTrailingCommaInMultilineLists
@@ -187,7 +186,11 @@ internal static void AddArchetype (EntityStoreBase store, Archetype archetype)
187186
}
188187
store.archs[store.archsCount] = archetype;
189188
store.archsCount++;
189+
#if NETSTANDARD && !NETSTANDARD2_1_OR_GREATER
190+
store.archSet.Add(archetype.key, archetype.key);
191+
#else
190192
store.archSet.Add(archetype.key);
193+
#endif
191194
}
192195
#endregion
193196
}

src/ECS/Archetype/EntityStore.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ public abstract partial class EntityStoreBase
7878
// --- archetypes
7979
[Browse(Never)] internal Archetype[] archs; // 8 - array of all archetypes. never null
8080
[Browse(Never)] private int archsCount; // 4 - number of archetypes
81+
#if NETSTANDARD && !NETSTANDARD2_1_OR_GREATER
82+
[Browse(Never)] private readonly Dictionary<ArchetypeKey, ArchetypeKey> archSet; // 8 - Set<> to get archetypes by key
83+
#else
8184
[Browse(Never)] private readonly HashSet<ArchetypeKey> archSet; // 8 - Set<> to get archetypes by key
85+
#endif
8286
/// <summary>The default <see cref="Archetype"/> has no <see cref="Archetype.ComponentTypes"/> and <see cref="Archetype.Tags"/>.<br/>
8387
/// Its <see cref="Archetype"/>.<see cref="Archetype.archIndex"/> is always 0 (<see cref="Static.DefaultArchIndex"/>).</summary>
8488
[Browse(Never)] internal readonly Archetype defaultArchetype; // 8 - default archetype. has no components & tags
@@ -142,7 +146,11 @@ internal static class Static
142146
protected EntityStoreBase()
143147
{
144148
archs = new Archetype[2];
149+
#if NETSTANDARD && !NETSTANDARD2_1_OR_GREATER
150+
archSet = new Dictionary<ArchetypeKey, ArchetypeKey>(ArchetypeKeyEqualityComparer.Instance);
151+
#else
145152
archSet = new HashSet<ArchetypeKey>(ArchetypeKeyEqualityComparer.Instance);
153+
#endif
146154
var config = GetArchetypeConfig(this);
147155
defaultArchetype = new Archetype(config);
148156
searchKey = new ArchetypeKey();

src/ECS/Compat/HashSet.cs

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)