filter determinism

pull/5/head
cosmonaut 2023-10-09 16:48:58 -07:00
parent 3cb3c64459
commit 7b519ed4b2
4 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MoonTools.ECS.Collections;
namespace MoonTools.ECS namespace MoonTools.ECS
{ {
@ -8,7 +9,7 @@ namespace MoonTools.ECS
internal FilterSignature Signature; internal FilterSignature Signature;
private FilterStorage FilterStorage; private FilterStorage FilterStorage;
internal Filter(FilterStorage filterStorage, HashSet<int> included, HashSet<int> excluded) internal Filter(FilterStorage filterStorage, IndexableSet<int> included, IndexableSet<int> excluded)
{ {
FilterStorage = filterStorage; FilterStorage = filterStorage;
Signature = new FilterSignature(included, excluded); Signature = new FilterSignature(included, excluded);

View File

@ -1,5 +1,4 @@
using System; using MoonTools.ECS.Collections;
using System.Collections.Generic;
namespace MoonTools.ECS namespace MoonTools.ECS
{ {
@ -7,18 +6,18 @@ namespace MoonTools.ECS
{ {
private TypeIndices ComponentTypeIndices; private TypeIndices ComponentTypeIndices;
private FilterStorage FilterStorage; private FilterStorage FilterStorage;
private HashSet<int> Included; private IndexableSet<int> Included;
private HashSet<int> Excluded; private IndexableSet<int> Excluded;
internal FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices) internal FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices)
{ {
FilterStorage = filterStorage; FilterStorage = filterStorage;
ComponentTypeIndices = componentTypeIndices; ComponentTypeIndices = componentTypeIndices;
Included = new HashSet<int>(); Included = new IndexableSet<int>();
Excluded = new HashSet<int>(); Excluded = new IndexableSet<int>();
} }
private FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices, HashSet<int> included, HashSet<int> excluded) private FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices, IndexableSet<int> included, IndexableSet<int> excluded)
{ {
FilterStorage = filterStorage; FilterStorage = filterStorage;
ComponentTypeIndices = componentTypeIndices; ComponentTypeIndices = componentTypeIndices;

View File

@ -1,14 +1,15 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MoonTools.ECS.Collections;
namespace MoonTools.ECS namespace MoonTools.ECS
{ {
public struct FilterSignature : IEquatable<FilterSignature> public struct FilterSignature : IEquatable<FilterSignature>
{ {
public readonly HashSet<int> Included; public readonly IndexableSet<int> Included;
public readonly HashSet<int> Excluded; public readonly IndexableSet<int> Excluded;
public FilterSignature(HashSet<int> included, HashSet<int> excluded) public FilterSignature(IndexableSet<int> included, IndexableSet<int> excluded)
{ {
Included = included; Included = included;
Excluded = excluded; Excluded = excluded;

View File

@ -20,7 +20,7 @@ namespace MoonTools.ECS
ComponentTypeIndices = componentTypeIndices; ComponentTypeIndices = componentTypeIndices;
} }
public Filter CreateFilter(HashSet<int> included, HashSet<int> excluded) public Filter CreateFilter(IndexableSet<int> included, IndexableSet<int> excluded)
{ {
var filterSignature = new FilterSignature(included, excluded); var filterSignature = new FilterSignature(included, excluded);
if (!filterSignatureToEntityIDs.ContainsKey(filterSignature)) if (!filterSignatureToEntityIDs.ContainsKey(filterSignature))