MoonTools.ECS/src/Entity.cs

40 lines
626 B
C#
Raw Normal View History

2022-04-08 05:52:03 +00:00
using System;
2022-03-05 02:01:44 +00:00
2022-04-08 05:52:03 +00:00
namespace MoonTools.ECS
2022-03-05 02:01:44 +00:00
{
2022-04-08 05:52:03 +00:00
public struct Entity : IEquatable<Entity>
2022-03-05 02:01:44 +00:00
{
2022-04-08 05:52:03 +00:00
public int ID { get; }
2022-03-31 21:51:43 +00:00
2022-04-08 05:52:03 +00:00
internal Entity(int id)
{
ID = id;
}
2022-03-31 21:51:43 +00:00
2022-04-08 05:52:03 +00:00
public override bool Equals(object? obj)
{
return obj is Entity entity && Equals(entity);
}
2022-03-31 21:51:43 +00:00
2022-04-08 05:52:03 +00:00
public override int GetHashCode()
{
return HashCode.Combine(ID);
}
public bool Equals(Entity other)
{
return ID == other.ID;
}
2022-08-11 21:04:26 +00:00
public static bool operator ==(Entity a, Entity b)
{
return a.Equals(b);
}
public static bool operator !=(Entity a, Entity b)
{
return !a.Equals(b);
}
2022-03-31 21:51:43 +00:00
}
2022-03-05 02:01:44 +00:00
}