@@ -16,7 +16,7 @@ namespace Arch.Core;
1616/// stores information about an <see cref="Entity"/> to quickly access its data and location.
1717/// </summary>
1818[ SkipLocalsInit ]
19- public struct EntityData
19+ public struct EntityData : IEquatable < EntityData >
2020{
2121 /// <summary>
2222 /// A reference to its <see cref="Archetype"/>.
@@ -31,7 +31,7 @@ public struct EntityData
3131 /// <summary>
3232 /// Its version.
3333 /// </summary>
34- public int Version ;
34+ public readonly int Version ;
3535
3636 /// <summary>
3737 /// Initializes a new instance of the <see cref="EntityData"/> struct.
@@ -92,6 +92,41 @@ internal void Move(Archetype archetype, Slot slot)
9292 Archetype = archetype ;
9393 Slot = slot ;
9494 }
95+
96+ /// <summary>
97+ /// Returns true if its equal to the passed instance.
98+ /// </summary>
99+ /// <param name="other">The other instance.</param>
100+ /// <returns>True or false.</returns>
101+ public bool Equals ( EntityData other )
102+ {
103+ return Version == other . Version && Archetype . Equals ( other . Archetype ) && Slot . Equals ( other . Slot ) ;
104+ }
105+
106+ /// <summary>
107+ /// Returns true if its equal to the passed instance.
108+ /// </summary>
109+ /// <param name="obj">The other instance.</param>
110+ /// <returns>True or false.</returns>
111+ public override bool Equals ( object ? obj )
112+ {
113+ return obj is EntityData other && Equals ( other ) ;
114+ }
115+
116+ /// <summary>
117+ /// Returns the hashcode of this instance.
118+ /// </summary>
119+ /// <returns>The hashcode.</returns>
120+ public override int GetHashCode ( )
121+ {
122+ unchecked
123+ {
124+ var hashCode = Archetype . GetHashCode ( ) ;
125+ hashCode = ( hashCode * 397 ) ^ Slot . GetHashCode ( ) ;
126+ hashCode = ( hashCode * 397 ) ^ Version ;
127+ return hashCode ;
128+ }
129+ }
95130}
96131
97132/// <summary>
0 commit comments