MoonTools.ECS/src/Entity.cs

30 lines
445 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-03-31 21:51:43 +00:00
}
2022-03-05 02:01:44 +00:00
}