public class Coordinate extends AbstractPosition
SQRT12, SQRT2
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 the given 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) |
Coordinate |
clampToMap()
Clamps x and y coordiantes if outside of map.
|
Coordinate |
clampToMapIncludingZ() |
Coordinate |
cpy() |
boolean |
damage(float amount)
returns true if block got damaged
|
boolean |
destroy()
destroys the block at the current position, replacing by air.
|
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.
|
Coordinate |
getCoord()
If needed calculates it and creates new instance else return itself.
|
int |
getDepth(View view)
Returns the depth of the object.
|
java.util.ArrayList<AbstractEntity> |
getEntitiesInside()
Get every entity on a coord.
|
<type> java.util.ArrayList<type> |
getEntitysInside(java.lang.Class<? extends AbstractEntity> type)
Get every entity on this coord of the wanted type
|
static int |
getNeighbourSide(float x,
float y)
Returns the field-id where the coordiantes are inside in relation to the current field.
|
Point |
getPoint()
If needed calculates it and creates new instance else return itself.
|
int |
getProjectedPosX(View view)
Calculate projected position.
|
int |
getProjectedPosY(View view)
Calculate projected position.
|
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 |
getZClamp()
Checks if the calculated value is inside the map dimensions and if not clamps it to the map dimensions.
|
boolean |
hidingPastBlock(int x,
int y,
int z)
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 (x,y,z).
|
boolean |
onLoadedMapHorizontal()
Checks if the coordiantes are accessable with the currently loaded Chunks (horizontal only).
|
void |
setBlock(Block block)
Set a block in the map where the coordinate is pointing to.
|
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, getZ, 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 getZClamp()
AbstractPosition.getZ()
public int[] getRel()
public int[] getAbs()
public void setRelX(int x)
x
- public void setRelY(int y)
y
- public void setZ(int z)
z
- public void setBlock(Block block)
block
- the block you want to set.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 hidingPastBlock(int x, int y, int z)
x
- offset in coordsy
- offset in coordsz
- offset in coordspublic Coordinate cpy()
cpy
in class AbstractPosition
public boolean onLoadedMapHorizontal()
onLoadedMapHorizontal
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()
AbstractPosition
getPoint
in class AbstractPosition
public Coordinate getCoord()
AbstractPosition
getCoord
in class AbstractPosition
public java.util.ArrayList<AbstractEntity> getEntitiesInside()
public <type> java.util.ArrayList<type> getEntitysInside(java.lang.Class<? extends AbstractEntity> type)
type
- the class you want to filter.type
- the class you want to filter.public int getProjectedPosX(View view)
AbstractPosition
getProjectedPosX
in class AbstractPosition
public int getProjectedPosY(View view)
AbstractPosition
getProjectedPosY
in class AbstractPosition
public int getDepth(View view)
AbstractPosition
getDepth
in class AbstractPosition
public Coordinate clampToMap()
public Coordinate clampToMapIncludingZ()
public boolean destroy()
public boolean damage(float amount)
amount
-