// Copyright (c) 2014-2015 Robert Rouhani and other contributors (see CONTRIBUTORS file). // Licensed under the MIT License - https://raw.github.com/Robmaister/SharpNav/master/LICENSE using System; namespace SharpNav.Geometry { /// /// A 2d vector represented by integers. /// [Serializable] public struct Vector2i : IEquatable { /// /// A vector where both X and Y are . /// public static readonly Vector2i Min = new Vector2i(int.MinValue, int.MinValue); /// /// A vector where both X and Y are . /// public static readonly Vector2i Max = new Vector2i(int.MaxValue, int.MaxValue); /// /// A vector where both X and Y are 0. /// public static readonly Vector2i Zero = new Vector2i(0, 0); /// /// The X coordinate. /// public int X; /// /// The Y coordinate. /// public int Y; /// /// Initializes a new instance of the struct with a specified coordinate. /// /// The X coordinate. /// The Y coordinate. public Vector2i(int x, int y) { X = x; Y = y; } /// /// Compares two instances of for equality. /// /// An instance of . /// Another instance of . /// A value indicating whether the two instances are equal. public static bool operator ==(Vector2i left, Vector2i right) { return left.Equals(right); } /// /// Compares two instances of for inequality. /// /// An instance of . /// Another instance of . /// A value indicating whether the two instances are unequal. public static bool operator !=(Vector2i left, Vector2i right) { return !(left == right); } /// /// Gets a unique hash code for this instance. /// /// A hash code. public override int GetHashCode() { //TODO generate a good hashcode. return base.GetHashCode(); } /// /// Turns the instance into a human-readable string. /// /// A string representing the instance. public override string ToString() { return "{ X: " + X.ToString() + ", Y: " + Y.ToString() + " }"; } /// /// Checks for equality between this instance and a specified object. /// /// An object. /// A value indicating whether this instance and the object are equal. public override bool Equals(object obj) { Vector2i? objV = obj as Vector2i?; if (objV != null) return this.Equals(objV); return false; } /// /// Checks for equality between this instance and a specified instance of . /// /// An instance of . /// A value indicating whether this instance and the other instance are equal. public bool Equals(Vector2i other) { return X == other.X && Y == other.Y; } } }