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() => $"Entity<{type}>({index},{generation})"; public bool Equals(Entity other) => type.Equals(other.type) && index == other.index && generation == other.generation; public override bool Equals(object obj) => obj is Entity other && Equals(other); public override int GetHashCode() => HashCode.Combine(type, index, generation); public static bool operator ==(Entity lhs, Entity rhs) => lhs.Equals(rhs); public static bool operator !=(Entity lhs, Entity rhs) => !(lhs == rhs); } }