Entity is now IEquatable

pull/1/head
cosmonaut 2022-03-31 14:51:43 -07:00
parent 9e6917094d
commit 24455bcaed
2 changed files with 17 additions and 1 deletions

View File

@ -175,6 +175,7 @@ internal class ComponentDepot
return new Filter(this, included, excluded);
}
// FIXME: this dictionary should probably just store entities
public IEnumerable<Entity> FilterEntities(Filter filter)
{
foreach (var id in filterSignatureToEntityIDs[filter.Signature])

View File

@ -1,6 +1,6 @@
namespace MoonTools.ECS;
public struct Entity
public struct Entity : IEquatable<Entity>
{
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;
}
}