diff --git a/src/ComponentDepot.cs b/src/ComponentDepot.cs index beb96de..22d456c 100644 --- a/src/ComponentDepot.cs +++ b/src/ComponentDepot.cs @@ -175,6 +175,7 @@ internal class ComponentDepot return new Filter(this, included, excluded); } + // FIXME: this dictionary should probably just store entities public IEnumerable FilterEntities(Filter filter) { foreach (var id in filterSignatureToEntityIDs[filter.Signature]) diff --git a/src/Entity.cs b/src/Entity.cs index 4036efe..903fb03 100644 --- a/src/Entity.cs +++ b/src/Entity.cs @@ -1,6 +1,6 @@ namespace MoonTools.ECS; -public struct Entity +public struct Entity : IEquatable { public int ID { get; } @@ -8,4 +8,19 @@ public struct Entity { ID = id; } + + public override bool Equals(object? obj) + { + return obj is Entity entity && Equals(entity); + } + + public override int GetHashCode() + { + return HashCode.Combine(ID); + } + + public bool Equals(Entity other) + { + return ID == other.ID; + } }