using System.Runtime.Serialization; using MonoGame.Extended.Tiled; namespace MLEM.Extended.Tiled { /// /// A struct that represents a position on a with multiple layers. /// [DataContract] public struct LayerPosition { /// /// The name of the layer that this position is on /// [DataMember] public string Layer; /// /// The x coordinate of this position /// [DataMember] public int X; /// /// The y coordinate of this position /// [DataMember] public int Y; /// /// Creates a new layer position with the given settings /// /// The layer name /// The x coordinate /// The y coordinate public LayerPosition(string layerName, int x, int y) { this.Layer = layerName; this.X = x; this.Y = y; } /// public static bool operator ==(LayerPosition left, LayerPosition right) { return left.Equals(right); } /// public static bool operator !=(LayerPosition left, LayerPosition right) { return !left.Equals(right); } /// public bool Equals(LayerPosition other) { return this.Layer == other.Layer && this.X == other.X && this.Y == other.Y; } /// Indicates whether this instance and a specified object are equal. /// The object to compare with the current instance. /// true if obj and this instance are the same type and represent the same value; otherwise, false. public override bool Equals(object obj) { return obj is LayerPosition other && this.Equals(other); } /// Returns the hash code for this instance. /// A 32-bit signed integer that is the hash code for this instance. public override int GetHashCode() { var hashCode = this.Layer.GetHashCode(); hashCode = (hashCode * 397) ^ this.X; hashCode = (hashCode * 397) ^ this.Y; return hashCode; } /// Returns the fully qualified type name of this instance. /// The fully qualified type name. public override string ToString() { return $"{nameof(this.Layer)}: {this.Layer}, {nameof(this.X)}: {this.X}, {nameof(this.Y)}: {this.Y}"; } } }