public class Coordinate extends AbstractPosition
map, SQRT12, SQRT2
Constructor and Description |
---|
Coordinate(AbstractMap map,
int x,
int y,
int z)
Creates a coordiante refering to the given position on the map.
|
Coordinate(Coordinate coord)
Creates a new coordinate from an existing coordinate
|
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 |
cpy() |
boolean |
damage(byte amount)
returns true if block got damaged
|
void |
destroy()
destroys the block at the current position, replacing by air.
|
boolean |
equals(java.lang.Object obj) |
CoreData |
getBlock()
Clamps positions over the map at topmost layer.
|
CoreData |
getBlockSafe()
Checks of coordinates are valid before fetching the RenderBlock.
|
Coordinate |
getCoord()
If needed calculates it and creates new instance else return itself.
|
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.
|
com.badlogic.gdx.math.Vector3 |
getVector()
Get as vector
|
int |
getViewSpcX(GameView view)
Calculate position in view space.
|
int |
getViewSpcY(GameView view)
Calculate position in view space.
|
int |
getX()
Gets the X coordinate
|
int |
getY()
Gets the Y coordinate
|
int |
getZ() |
int |
getZClamp()
Checks if the calculated value is inside the map dimensions and if not
clamps it to the map dimensions.
|
Coordinate |
goToNeighbour(int neighbourSide)
Goes to the the neighbour with the specific side.
|
int |
hashCode() |
boolean |
hidingPastBlock(int x,
int y,
int z)
Deprecated.
v1.5
|
boolean |
hidingPastBlocks(int x,
int y,
int z)
Deprecated.
v1.5
|
boolean |
hidingPastLiquid(int x,
int y,
int z)
Deprecated.
v1.5
|
boolean |
isInMemoryArea()
Checks if the coordiantes are accessable with the currently loaded Chunks
(x,y,z).
|
boolean |
isInMemoryAreaHorizontal()
Checks if the coordiantes are accessable with the currently loaded Chunks
(horizontal only).
|
void |
setBlock(CoreData block)
Set a block in the map where the coordinate is pointing to.
|
void |
setBlock(RenderBlock block)
Set a block in the map where the coordinate is pointing to.
|
void |
setX(int x)
Set the coordiantes X component.
|
void |
setY(int y)
Set the coordiantes Y component.
|
void |
setZ(int z)
Set the coordinates Z component.
|
java.lang.String |
toString() |
getDepth, getMap
public Coordinate(AbstractMap map, int x, int y, int z)
x
- The x value as coordinate.y
- The y value as coordinate.z
- The z value as coordinate.map
- public Coordinate(Coordinate coord)
coord
- the Coordinate you want to copypublic int getX()
public int getY()
public int getZ()
public int getZClamp()
getZ()
public com.badlogic.gdx.math.Vector3 getVector()
AbstractPosition
getVector
in class AbstractPosition
public void setX(int x)
x
- public void setY(int y)
y
- public void setZ(int z)
z
- public void setBlock(RenderBlock block)
block
- the block you want to set.public void setBlock(CoreData 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 CoreData getBlock()
AbstractPosition
getBlock
in class AbstractPosition
AbstractPosition.getBlockSafe()
public CoreData getBlockSafe()
getBlockSafe
in class AbstractPosition
AbstractPosition.getBlock()
public boolean hidingPastBlocks(int x, int y, int z)
x
- offset in coordsy
- offset in coordsz
- offset in coordspublic boolean hidingPastLiquid(int x, int y, int z)
x
- offset in coordsy
- offset in coordsz
- offset in coordspublic boolean hidingPastBlock(int x, int y, int z)
x
- offset in coordsy
- offset in coordsz
- offset in coordshidingPastBlocks(int, int, int)
,
hidingPastLiquid(int, int, int)
public Coordinate cpy()
cpy
in class AbstractPosition
public boolean isInMemoryAreaHorizontal()
isInMemoryAreaHorizontal
in class AbstractPosition
public boolean isInMemoryArea()
isInMemoryArea
in class AbstractPosition
public static int getNeighbourSide(float x, float y)
goToNeighbour(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 pixelsgoToNeighbour(int)
public Coordinate goToNeighbour(int neighbourSide)
neighbourSide
- the side number of the given coordinatespublic Point getPoint()
AbstractPosition
getPoint
in class AbstractPosition
refreshCachedPoint()
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 getViewSpcX(GameView view)
AbstractPosition
getViewSpcX
in class AbstractPosition
public int getViewSpcY(GameView view)
AbstractPosition
getViewSpcY
in class AbstractPosition
public void destroy()
public boolean damage(byte amount)
amount
- value between 0 and 100public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object