Entity is now IEquatable
parent
9e6917094d
commit
24455bcaed
|
@ -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])
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue