public class Coordinate extends AbstractPosition
Constructor and Description |
---|
Coordinate(Coordinate coord)
Creates a new coordinate from an existing coordinate
|
Coordinate(int x,
int y,
float height,
boolean relative)
Creates a coordiante.
|
Coordinate(int x,
int y,
int z,
boolean relative)
Creates a coordiante refering to a position on the map.
|
Modifier and Type | Method and Description |
---|---|
Coordinate |
addVector(float[] vector)
Add a vector to the coordinates.
|
Coordinate |
addVector(float x,
float y,
float z)
Add a vector to the coordinates.
|
Coordinate |
addVector(com.badlogic.gdx.math.Vector3 vector) |
void |
clampToMap()
Clamps x and y coordiantes if outside of map.
|
Coordinate |
cpy() |
int[] |
getAbs() |
int |
getAbsX()
Absolute coordinates are independent of the currently loaded chunks.
|
int |
getAbsY()
Absolute coordinates are independent of the currently loaded chunks.
|
Block |
getBlock() |
Block |
getBlockClamp() |
Block |
getBlockSafe()
Checks of coordinates are valid before fetching the Block.
|
int[] |
getCellOffset() |
Coordinate |
getCoord() |
static int |
getNeighbourSide(float x,
float y)
Returns the field-id where the coordiantes are inside in relation to the current field.
|
Point |
getPoint() |
int |
getProjectedPosX() |
int |
getProjectedPosY() |
int[] |
getRel() |
int |
getRelX()
Gets the X coordinate relative to the map.
|
int |
getRelY()
Gets the Y coordinate relative to the map.
|
protected int |
getX() |
protected int |
getY() |
int |
getZ()
The z value is absolute even when used as relative coordinate because there are no chunks in Z direction.
|
int |
getZClamp()
Checks if the calculated value is valid and clamps it to the map dimensions.
|
boolean |
hasOffset()
Has the object an offset (pos vector)?
|
boolean |
hidingPastBlock()
The block hides the past block when it has sides and is not transparent (like normal block)
|
Coordinate |
neighbourSidetoCoords(int neighbourSide)
Get the neighbour coordinates of the neighbour of the coords you give.
|
boolean |
onLoadedMap()
Checks if the coordiantes are accessable with the currently loaded Chunks.
|
void |
setBlock(Block block) |
void |
setCellOffsetZ(int height)
Set the vertical offset in the cell, where the coordiante is pointing at.
|
void |
setRelX(int x)
Set the coordiantes X component.
|
void |
setRelY(int y)
Set the coordiantes Y component.
|
void |
setZ(int z)
Set the coordinates Z component.
|
getHeight, getReferenceX, getReferenceY, setHeight
public Coordinate(int x, int y, int z, boolean relative)
x
- The x value as coordinate.y
- The y value as coordinate.z
- The z value as coordinate.relative
- True when the coordiantes are relative to the currently loaded map. False when they are absolute.public Coordinate(int x, int y, float height, boolean relative)
x
- The x value as coordinate.y
- The y value as coordinate.height
- The z value as height.relative
- True when the coordiantes are relative to the currently loaded map. False when they are absolute.public Coordinate(Coordinate coord)
coord
- the Coordinate you want to copypublic int getRelX()
public int getRelY()
public int getAbsX()
public int getAbsY()
public int getZ()
public int getZClamp()
getZ()
public int[] getCellOffset()
public void setRelX(int x)
x
- public void setRelY(int y)
y
- public void setZ(int z)
z
- public void setCellOffsetZ(int height)
height
- public void setBlock(Block block)
block
- public int[] getRel()
public int[] getAbs()
public Coordinate addVector(float[] vector)
addVector
in class AbstractPosition
vector
- public Coordinate addVector(com.badlogic.gdx.math.Vector3 vector)
addVector
in class AbstractPosition
vector
- public Coordinate addVector(float x, float y, float z)
addVector
in class AbstractPosition
x
- y
- z
- public Block getBlock()
getBlock
in class AbstractPosition
AbstractPosition.getBlockSafe()
public Block getBlockSafe()
getBlockSafe
in class AbstractPosition
AbstractPosition.getBlock()
public Block getBlockClamp()
public boolean hasOffset()
public boolean hidingPastBlock()
public Coordinate cpy()
cpy
in class AbstractPosition
public boolean onLoadedMap()
onLoadedMap
in class AbstractPosition
public static int getNeighbourSide(float x, float y)
neighbourSidetoCoords(int)
with the parameter found by this function.
The numbering of the sides:x
- game-space-coordinates, value in pixelsy
- game-space-coordinates, value in pixelsneighbourSidetoCoords(int)
public Coordinate neighbourSidetoCoords(int neighbourSide)
neighbourSide
- the side number of the given coordinatesprotected int getX()
protected int getY()
public Point getPoint()
getPoint
in class AbstractPosition
public Coordinate getCoord()
getCoord
in class AbstractPosition
public int getProjectedPosX()
getProjectedPosX
in class AbstractPosition
public int getProjectedPosY()
getProjectedPosY
in class AbstractPosition
public void clampToMap()