package org.apollo.game.model.area;

import org.apollo.game.model.Position;

/**
 * An immutable class representing the coordinates of a sector, where the coordinates ({@code x, y}) are the top-left of
 * the sector.
 * 
 * @author Graham
 */
public final class SectorCoordinates {

	/**
	 * Gets a pair of sector coordinates from a {@link Position}.
	 * 
	 * @param position The position.
	 * @return The sector coordinates.
	 */
	public static SectorCoordinates fromPosition(Position position) {
		return new SectorCoordinates(position.getTopLeftSectorX(), position.getTopLeftSectorY());
	}

	/**
	 * The x coordinate of this sector.
	 */
	private final int x;

	/**
	 * The y coordinate of this sector.
	 */
	private final int y;

	/**
	 * Creates the sector coordinates.
	 * 
	 * @param x The x coordinate.
	 * @param y The y coordinate.
	 */
	public SectorCoordinates(int x, int y) {
		this.x = x;
		this.y = y;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null || getClass() != obj.getClass()) {
			return false;
		}
		final SectorCoordinates other = (SectorCoordinates) obj;
		if (x != other.x || y != other.y) {
			return false;
		}
		return true;
	}

	/**
	 * Gets the x coordinate (equivalent to the {@link Position#getTopLeftSectorX()} of a position within this sector).
	 * 
	 * @return The x coordinate.
	 */
	public int getX() {
		return x;
	}

	/**
	 * Gets the y coordinate (equivalent to the {@link Position#getTopLeftSectorY()} of a position within this sector).
	 * 
	 * @return The y coordinate.
	 */
	public int getY() {
		return y;
	}

	@Override
	public int hashCode() {
		return 61 * (427 + x) + y;
	}

}
@@ -1036,16 +1036,17 @@
 se;%0A%09%09%7D%0A
+%0A
 %09%09final 
@@ -1102,15 +1102,18 @@
 ;%0A%09%09
-if (x !
+return x =
 = ot
@@ -1122,14 +1122,14 @@
 r.x 
-%7C%7C y !
+&& y =
 = ot
@@ -1137,46 +1137,8 @@
 er.y
-) %7B%0A%09%09%09return false;%0A%09%09%7D%0A%09%09return true
 ;%0A%09%7D
@@ -1586,24 +1586,17 @@
 urn 
-61 * (427 + x) +
+x %3C%3C 16 %7C
  y;%0A

Improve hashcode in Sectorcoordinates.