123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- using System;
- using OpenMetaverse;
- namespace OpenSim.Framework
- {
- [Serializable]
- public class Location : ICloneable
- {
- private readonly int m_x;
- private readonly int m_y;
- public Location(int x, int y)
- {
- m_x = x;
- m_y = y;
- }
- public Location(ulong regionHandle)
- {
- m_x = (int) regionHandle;
- m_y = (int) (regionHandle >> 32);
- }
- public ulong RegionHandle
- {
- get { return Utils.UIntsToLong((uint)m_x, (uint)m_y); }
- }
- public int X
- {
- get { return m_x; }
- }
- public int Y
- {
- get { return m_y; }
- }
- public override bool Equals(object obj)
- {
- if (ReferenceEquals(obj, this))
- return true;
- if (obj is Location)
- {
- return Equals((Location) obj);
- }
- return base.Equals(obj);
- }
- public bool Equals(Location loc)
- {
- return loc.X == X && loc.Y == Y;
- }
- public bool Equals(int x, int y)
- {
- return X == x && y == Y;
- }
- public static bool operator ==(Location o, object o2)
- {
- return o.Equals(o2);
- }
- public static bool operator !=(Location o, object o2)
- {
- return !o.Equals(o2);
- }
- public override int GetHashCode()
- {
- return X.GetHashCode() ^ Y.GetHashCode();
- }
- public object Clone()
- {
- return new Location(X, Y);
- }
- }
- }
|