using System;

namespace Decal.Adapter.Wrappers;

public class CoordsObject
{
	private double myNorthSouth;

	private double myEastWest;

	public double NorthSouth => myNorthSouth;

	public double EastWest => myEastWest;

	public CoordsObject(double northSouth, double eastWest)
	{
		myNorthSouth = northSouth;
		myEastWest = eastWest;
	}

	public double DistanceToCoords(CoordsObject destination)
	{
		if (destination == null)
		{
			throw new ArgumentNullException("destination");
		}
		double num = myNorthSouth - destination.myNorthSouth;
		double num2 = myEastWest - destination.myEastWest;
		return Math.Sqrt(num * num + num2 * num2);
	}

	public double AngleToCoords(CoordsObject destination)
	{
		return 180.0 / Math.PI * AngleToCoordsRadians(destination);
	}

	public double AngleToCoordsRadians(CoordsObject destination)
	{
		if (destination == null)
		{
			throw new ArgumentNullException("destination");
		}
		double num = Math.Atan2(destination.myEastWest - myEastWest, destination.myNorthSouth - myNorthSouth);
		if (num < 0.0)
		{
			num += Math.PI * 2.0;
		}
		return num;
	}

	public override string ToString()
	{
		return ToString("0.0");
	}

	public string ToString(string numberFormat)
	{
		return Math.Abs(myNorthSouth).ToString(numberFormat) + ((myNorthSouth >= 0.0) ? "N" : "S") + ", " + Math.Abs(myEastWest).ToString(numberFormat) + ((myEastWest >= 0.0) ? "E" : "W");
	}

	public override bool Equals(object obj)
	{
		if (obj is CoordsObject)
		{
			CoordsObject coordsObject = (CoordsObject)obj;
			if (coordsObject.myNorthSouth == myNorthSouth)
			{
				return coordsObject.myEastWest == myEastWest;
			}
			return false;
		}
		return false;
	}

	public bool Equals(CoordsObject obj)
	{
		if (obj == null)
		{
			return false;
		}
		if (obj.myNorthSouth == myNorthSouth)
		{
			return obj.myEastWest == myEastWest;
		}
		return false;
	}

	public override int GetHashCode()
	{
		return myNorthSouth.GetHashCode() ^ myEastWest.GetHashCode();
	}

	public static bool operator ==(CoordsObject a, CoordsObject b)
	{
		if (object.Equals(a, null))
		{
			return object.Equals(b, null);
		}
		return a.Equals(b);
	}

	public static bool operator !=(CoordsObject a, CoordsObject b)
	{
		return !(a == b);
	}
}
