context: /***************************************************************************
   *                                Geometry.cs
   *                            -------------------
   *   begin                : May 1, 2002
   *   copyright            : (C) The RunUO Software Team
   *   email                : info@runuo.com
   *
   *   $Id: Geometry.cs,v 1.3 2005/01/22 04:25:04 krrios Exp $
   *   $Author: krrios $
   *   $Date: 2005/01/22 04:25:04 $
   *
   *
   ***************************************************************************/
  
  /***************************************************************************
   *
   *   This program is free software; you can redistribute it and/or modify
   *   it under the terms of the GNU General Public License as published by
   *   the Free Software Foundation; either version 2 of the License, or
   *   (at your option) any later version.
   *
   ***************************************************************************/
  
  using System;
  
  namespace Server
  {
  	[Parsable]
  	public struct Point2D : IPoint2D
  	{
  		internal int m_X;
  		internal int m_Y;
  
  		public static readonly Point2D Zero = new Point2D( 0, 0 );
  
  		public Point2D( int x, int y )
  		{
  			m_X = x;
  			m_Y = y;
  		}
  
  		public Point2D( IPoint2D p ) : this( p.X, p.Y )
  		{
  		}
  
  		[CommandProperty( AccessLevel.Counselor )]
  		public int X
  		{
  			get
  			{
  				return m_X;
  			}
  			set
  			{
  				m_X = value;
  			}
  		}
  
  		[CommandProperty( AccessLevel.Counselor )]
  		public int Y
  		{
  			get
  			{
  				return m_Y;
  			}
  			set
  			{
  				m_Y = value;
  			}
  		}
  
  		public override string ToString()
  		{
  			return String.Format( "({0}, {1})", m_X, m_Y );
  		}
  
  		public static Point2D Parse( string value )
  		{
  			int start = value.IndexOf( '(' );
  			int end = value.IndexOf( ',', start + 1 );
  
  			string param1 = value.Substring( start + 1, end - (start + 1) ).Trim();
  
  			start = end;
  			end = value.IndexOf( ')', start + 1 );
  
  			string param2 = value.Substring( start + 1, end - (start + 1) ).Trim();
  
  			return new Point2D( Convert.ToInt32( param1 ), Convert.ToInt32( param2 ) );
  		}
  
  		public override bool Equals( object o )
  		{
  			if ( o == null || !(o is IPoint2D) ) return false;
  
  			IPoint2D p = (IPoint2D)o;
  
  			return m_X == p.X && m_Y == p.Y;
  		}
  
  		public override int GetHashCode()
  		{
  			return m_X ^ m_Y;
  		}
  
  		public static bool operator == ( Point2D l, Point2D r )
  		{
  			return l.m_X == r.m_X && l.m_Y == r.m_Y;
  		}
  
  		public static bool operator != ( Point2D l, Point2D r )
  		{
  			return l.m_X != r.m_X || l.m_Y != r.m_Y;
  		}
  
  		public static bool operator == ( Point2D l, IPoint2D r )
  		{
  			return l.m_X == r.X && l.m_Y == r.Y;
  		}
  
  		public static bool operator != ( Point2D l, IPoint2D r )
  		{
  			return l.m_X !=r.X || l.m_Y != r.Y;
  		}
  
  		public static bool operator > ( Point2D l, Point2D r )
  		{
  			return l.m_X > r.m_X && l.m_Y > r.m_Y;
  		}
  
  		public static bool operator > ( Point2D l, Point3D r )
  		{
  			return l.m_X > r.m_X && l.m_Y > r.m_Y;
  		}
  
  		public static bool operator > ( Point2D l, IPoint2D r )
  		{
  			return l.m_X > r.X && l.m_Y > r.Y;
  		}
  
  		public static bool operator < ( Point2D l, Point2D r )
  		{
  			return l.m_X < r.m_X && l.m_Y < r.m_Y;
  		}
  
  		public static bool operator < ( Point2D l, Point3D r )
  		{
  			return l.m_X < r.m_X && l.m_Y < r.m_Y;
  		}
  
  		public static bool operator < ( Point2D l, IPoint2D r )
  		{
  			return l.m_X < r.X && l.m_Y < r.Y;
  		}
  
  		public static bool operator >= ( Point2D l, Point2D r )
  		{
  			return l.m_X >= r.m_X && l.m_Y >= r.m_Y;
  		}
  
  		public static bool operator >= ( Point2D l, Point3D r )
  		{
  			return l.m_X >= r.m_X && l.m_Y >= r.m_Y;
  		}
  
  		public static bool operator >= ( Point2D l, IPoint2D r )
  		{
  			return l.m_X >= r.X && l.m_Y >= r.Y;
  		}
  
  		public static bool operator <= ( Point2D l, Point2D r )
  		{
  			return l.m_X <= r.m_X && l.m_Y <= r.m_Y;
  		}
  
  		public static bool operator <= ( Point2D l, Point3D r )
  		{
  			return l.m_X <= r.m_X && l.m_Y <= r.m_Y;
  		}
  
  		public static bool operator <= ( Point2D l, IPoint2D r )
  		{
  			return l.m_X <= r.X && l.m_Y <= r.Y;
  		}
  	}
  
  	[Parsable]
  	public struct Point3D : IPoint3D
  	{
  		internal int m_X;
  		internal int m_Y;
  		internal int m_Z;
  
  		public static readonly Point3D Zero = new Point3D( 0, 0, 0 );
  
  		public Point3D( int x, int y, int z )
  		{
  			m_X = x;
  			m_Y = y;
  			m_Z = z;
  		}
  
  		public Point3D( IPoint3D p ) : this( p.X, p.Y, p.Z )
  		{
  		}
  
  		public Point3D( IPoint2D p, int z ) : this( p.X, p.Y, z )
  		{
  		}
  
  
gt: 		[CommandProperty( AccessLevel.Counselor )]