Class CoordGrid
java.lang.Object
org.rspeer.game.coord.CoordGrid
Represents a tile-aligned coordinate in a specific world matrix.
A CoordGrid corresponds to exact RuneScape tile coordinates
(also called "scene coordinates" or "grid coordinates"), where each unit of
x and y represents a full tile.
This is a lossy representation of CoordFine, which contains sub-tile
precision. Converting from a fine coordinate to a grid coordinate will
discard sub-tile offsets.
Why this type exists
CoordGrid is useful when:
- tile-based collision checks are required
- tile-based LOS (line of sight) traversal is used
- indexing into arrays such as
collisionMaps[floor][x][y] - using tile-level distance and region computations
The coordinate is immutable.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanstatic CoordGridfrom(int matrixId, int x, int y, int floorLevel) Creates a newCoordGridfrom raw tile coordinates.static CoordGridConverts aCoord(tile coordinate with sub tile fraction) into aCoordGrid.static CoordGridConverts aCoordFine(sub-tile precision) into a tile-levelCoordGrid, discarding sub-tile offset.intintintgetX()intgetY()inthashCode()toString()
-
Method Details
-
from
Creates a newCoordGridfrom raw tile coordinates.- Parameters:
matrixId- the matrix IDx- grid X (tile coordinate)y- grid Y (tile coordinate)floorLevel- floor level (0–3)- Returns:
- a new
CoordGrid
-
fromFine
Converts aCoordFine(sub-tile precision) into a tile-levelCoordGrid, discarding sub-tile offset.Grid coordinates are computed as:
gridX = fineX / CoordFine.UNITS_PER_SQUARE gridY = fineY / CoordFine.UNITS_PER_SQUARE
- Parameters:
fine- the fine coordinate to convert- Returns:
- a tile-level
CoordGrid
-
fromCoord
Converts aCoord(tile coordinate with sub tile fraction) into aCoordGrid. This performs aCoord.getCoordFine()and then reduces to tile units.- Parameters:
coord- the world coordinate- Returns:
- a tile-level
CoordGrid
-
getMatrixId
public int getMatrixId() -
getX
public int getX() -
getY
public int getY() -
getFloorLevel
public int getFloorLevel() -
getSceneContext
-
equals
-
hashCode
-
toString
-