Location.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. namespace OpenSim.Framework
  3. {
  4. [Serializable]
  5. public class Location : ICloneable
  6. {
  7. private readonly int m_x;
  8. private readonly int m_y;
  9. public Location(int x, int y)
  10. {
  11. m_x = x;
  12. m_y = y;
  13. }
  14. public int X
  15. {
  16. get { return m_x; }
  17. }
  18. public int Y
  19. {
  20. get { return m_y; }
  21. }
  22. public override bool Equals(object obj)
  23. {
  24. if (ReferenceEquals(obj, this))
  25. return true;
  26. if (obj is Location)
  27. {
  28. return Equals((Location) obj);
  29. }
  30. return base.Equals(obj);
  31. }
  32. public bool Equals(Location loc)
  33. {
  34. return loc.X == X && loc.Y == Y;
  35. }
  36. public bool Equals(int x, int y)
  37. {
  38. return X == x && y == Y;
  39. }
  40. public UInt64 RegionHandle
  41. {
  42. get { return UInt64.MinValue; }
  43. }
  44. public override int GetHashCode()
  45. {
  46. return X.GetHashCode() * 29 + Y.GetHashCode();
  47. }
  48. public object Clone()
  49. {
  50. return new Location(X, Y);
  51. }
  52. }
  53. }