MoonTools.ECS/src/Relation.cs

32 lines
539 B
C#
Raw Normal View History

2022-04-08 05:52:03 +00:00
using System;
2022-04-06 19:53:50 +00:00
namespace MoonTools.ECS
{
2022-04-19 19:35:21 +00:00
internal struct Relation : IEquatable<Relation>
2022-04-06 19:53:50 +00:00
{
public Entity A { get; }
public Entity B { get; }
internal Relation(Entity entityA, Entity entityB)
{
A = entityA;
B = entityB;
}
public override bool Equals(object? obj)
{
return obj is Relation relation && Equals(relation);
}
public bool Equals(Relation other)
{
2022-04-19 19:35:21 +00:00
return A.ID == other.A.ID && B.ID == other.B.ID;
2022-04-06 19:53:50 +00:00
}
public override int GetHashCode()
{
2022-04-19 19:35:21 +00:00
return HashCode.Combine(A.ID, B.ID);
2022-04-06 19:53:50 +00:00
}
}
}