Package org.rspeer.game.coord
Class CoordGrid
- java.lang.Object
-
- org.rspeer.game.coord.CoordGrid
-
public class CoordGrid extends Object
Represents a tile-aligned coordinate in a specific world matrix.A
CoordGridcorresponds to exact RuneScape tile coordinates (also called "scene coordinates" or "grid coordinates"), where each unit ofxandyrepresents 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
CoordGridis 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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)static CoordGridfrom(int matrixId, int x, int y, int floorLevel)Creates a newCoordGridfrom raw tile coordinates.static CoordGridfromCoord(Coord coord)Converts aCoord(tile coordinate with sub tile fraction) into aCoordGrid.static CoordGridfromFine(CoordFine fine)Converts aCoordFine(sub-tile precision) into a tile-levelCoordGrid, discarding sub-tile offset.intgetFloorLevel()intgetMatrixId()SceneContextgetSceneContext()intgetX()intgetY()inthashCode()StringtoString()
-
-
-
Method Detail
-
from
public static CoordGrid from(int matrixId, int x, int y, int floorLevel)
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
public static CoordGrid fromFine(CoordFine fine)
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
public static CoordGrid fromCoord(Coord coord)
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
public SceneContext getSceneContext()
-
-