FieldPos.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SuperTux Editor
  2. // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. namespace DataStructures
  17. {
  18. public struct FieldPos
  19. {
  20. public int X;
  21. public int Y;
  22. public FieldPos(int X, int Y)
  23. {
  24. this.X = X;
  25. this.Y = Y;
  26. }
  27. public static bool operator ==(FieldPos p1, FieldPos p2)
  28. {
  29. return p1.X == p2.X && p1.Y == p2.Y;
  30. }
  31. public static bool operator !=(FieldPos p1, FieldPos p2)
  32. {
  33. return p1.X != p2.X || p1.Y != p2.Y;
  34. }
  35. public override bool Equals(object obj)
  36. {
  37. if (!(obj is FieldPos))
  38. return false;
  39. FieldPos pos = (FieldPos) obj;
  40. return this == pos;
  41. }
  42. public override int GetHashCode()
  43. {
  44. return base.GetHashCode();
  45. }
  46. }
  47. }
  48. /* EOF */