public class Point extends AbstractPosition
SQRT12, SQRT2
Constructor and Description |
---|
Point(float posX,
float posY,
float height,
boolean relative)
Creates a point refering to a position in the game world.
|
Point(Point point)
Copy-constructor.
|
Modifier and Type | Method and Description |
---|---|
Point |
addVector(float[] vector)
Add a vector to the position
|
Point |
addVector(float x,
float y,
float z)
Add a vector to the position.
|
Point |
addVector(com.badlogic.gdx.math.Vector3 vector)
Add a vector to the position
|
Point |
cpy() |
float |
distanceTo(IsSelfAware object) |
float |
distanceTo(Point point) |
float |
distanceToHorizontal(IsSelfAware object)
checks only x and y.
|
float |
distanceToHorizontal(Point point)
checks only x and y.
|
float[] |
getAbs() |
float |
getAbsX() |
float |
getAbsY() |
Block |
getBlock() |
Block |
getBlockClamp()
Gets the block at the position but clamps coordinate before.
|
Block |
getBlockSafe()
Slower than getBlock().
|
Coordinate |
getCoord()
returns coordinate aquivalent.
|
int |
getDepth(View view)
Returns the depth of the object.
|
java.util.ArrayList<AbstractEntity> |
getEntitiesNearby(float radius)
get entities in radius
|
<type> java.util.ArrayList<type> |
getEntitiesNearby(float radius,
java.lang.Class<? extends AbstractEntity> type)
get entities in radius
|
Point |
getPoint()
Returns itself.
|
int |
getProjectedPosX(View view)
Calculate projected position.
|
int |
getProjectedPosY(View view)
Calculate projected position.
|
float[] |
getRel() |
com.badlogic.gdx.math.Vector3 |
getRelToCoord() |
float |
getRelToCoordX() |
float |
getRelToCoordY() |
float |
getRelToCoordZ() |
float |
getRelX()
Get the game world position from left
|
float |
getRelY()
Get the game world position from top.
|
boolean |
onLoadedMap()
Checks if the position is on the chunks currently in memory.
|
boolean |
onLoadedMapHorizontal()
Checks if the position is on the chunks currently in memory.
|
Intersection |
raycast(com.badlogic.gdx.math.Vector3 direction,
float radius,
Camera camera,
boolean onlySolid)
Trace a ray through the map until ray hits non air block.
|
void |
setPositionRelativeToCoord(float x,
float y,
float z)
Relative to the current coordiante field set the offset.
|
getHeight, getReferenceX, getReferenceY, getZ, setHeight
public Point(float posX, float posY, float height, boolean relative)
posX
- The distance from the left border of the map (game space)posY
- The distance from the top border of the map (game space)height
- The distance from ground (game space)relative
- true if relative to currently loaded map, false if absolute (relative to map with chunk 0,0 in its center)public Point(Point point)
point
- the source of the copypublic Point getPoint()
getPoint
in class AbstractPosition
public Coordinate getCoord()
getCoord
in class AbstractPosition
public float[] getRel()
public float getRelX()
public float getRelY()
public float getRelToCoordX()
public float getRelToCoordY()
public float getRelToCoordZ()
public com.badlogic.gdx.math.Vector3 getRelToCoord()
public float[] getAbs()
public float getAbsX()
public float getAbsY()
public Block getBlock()
getBlock
in class AbstractPosition
AbstractPosition.getBlockSafe()
public Block getBlockSafe()
AbstractPosition
getBlockSafe
in class AbstractPosition
AbstractPosition.getBlock()
public Block getBlockClamp()
public Point cpy()
cpy
in class AbstractPosition
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 boolean onLoadedMapHorizontal()
AbstractPosition
onLoadedMapHorizontal
in class AbstractPosition
public boolean onLoadedMap()
AbstractPosition
onLoadedMap
in class AbstractPosition
public Point addVector(float[] vector)
addVector
in class AbstractPosition
vector
- all values in game world valuespublic Point addVector(com.badlogic.gdx.math.Vector3 vector)
addVector
in class AbstractPosition
vector
- all values in game world valuespublic Point addVector(float x, float y, float z)
AbstractPosition
addVector
in class AbstractPosition
x
- x value to addy
- y value to addz
- height to addpublic void setPositionRelativeToCoord(float x, float y, float z)
x
- offset from originy
- offset from originz
- offset from originpublic Intersection raycast(com.badlogic.gdx.math.Vector3 direction, float radius, Camera camera, boolean onlySolid)
direction
- direction of the rayradius
- the distane after which it should stop.camera
- if set only intersect with blocks which are rendered (not clipped). ignoring clipping if nullonlySolid
- only intersect if true with block which are not transparent =solidpublic float distanceTo(Point point)
point
- public float distanceTo(IsSelfAware object)
object
- public float distanceToHorizontal(Point point)
point
- public float distanceToHorizontal(IsSelfAware object)
object
- public java.util.ArrayList<AbstractEntity> getEntitiesNearby(float radius)
radius
- in game dimension pixelspublic <type> java.util.ArrayList<type> getEntitiesNearby(float radius, java.lang.Class<? extends AbstractEntity> type)
type
- radius
- in game dimension pixelstype
-