using System; namespace GameCore.TinyECS { public readonly struct Entity : IEquatable> where TEnum : unmanaged { public readonly TEnum type; public readonly int index; public readonly int generation; public Entity(TEnum type, int index, int generation) { this.type = type; this.index = index; this.generation = generation; } public override string ToString() { return $"Entity<{type}>({index},{generation})"; } public bool Equals(Entity other) { return type.Equals(other.type) && index == other.index && generation == other.generation; } public override bool Equals(object obj) { return obj is Entity other && Equals(other); } public override int GetHashCode() { return HashCode.Combine(type, index, generation); } public static bool operator ==(Entity lhs, Entity rhs) { return lhs.Equals(rhs); } public static bool operator !=(Entity lhs, Entity rhs) { return !(lhs == rhs); } } }