Interface Position
-
- All Superinterfaces:
java.io.Serializable
- All Known Implementing Classes:
Coordinate,PfNode,Point
public interface Position extends java.io.SerializableA
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Positioncpy()floatdistanceTo(AbstractGameObject object)floatdistanceTo(Position pos)floatdistanceToHorizontal(AbstractGameObject object)checks only x and y.floatdistanceToHorizontal(Position pos)checks only x and y.floatdistanceToHorizontalSquared(AbstractGameObject object)checks only x and y.floatdistanceToHorizontalSquared(Position pos)checks only x and y.floatdistanceToSquared(AbstractGameObject object)The result is squared for fast comparison.floatdistanceToSquared(Position pos)The result is squared for fast comparison.bytegetBlockId()Get the block at the position.ChunkgetChunk()intgetChunkX()The chunk coordinate.intgetChunkY()The chunk coordinate.CoordinategetCoord()May not be copy safe.<T> java.util.LinkedList<T>getEntitiesNearby(float radius, java.lang.Class<T> type)Get entities in radius.java.util.LinkedList<AbstractEntity>getEntitiesNearbyHorizontal(float radius)get entities in radius (horizontal only)<T> java.util.LinkedList<T>getEntitiesNearbyHorizontal(float radius, java.lang.Class<T> type)get entities in horizontal radius (like a pipe)PointgetPoint()May not be copy safe.intgetProjectionSpaceX(GameView View, Camera camera)equals screen space when zoom=1 with a single, fullscreen camera.intgetProjectionSpaceY(GameView View, Camera camera)equals screen space when zoom=1 with a single camera.intgetViewSpcX()Calculate position in view space.intgetViewSpcY()Calculate position in view space.intgetZGrid()Get the z in block grid coordinates of the coordinate.floatgetZPoint()Get the z in game world coordinates.booleanisInMemoryAreaXY()Checks if the coordiantes are accessable with the currently loaded chunks.booleanisInMemoryAreaXYZ()Checks if the position is on the chunks currently in memory.CoordinatetoCoord()Calculates it and creates new instance if not already in correct format then returns copy of itself.PointtoPoint()Calculates it and creates new instance if not already in correct format then return a copy of itself.
-
-
-
Field Detail
-
SQRT2
static final float SQRT2
square root of two- See Also:
- Constant Field Values
-
SQRT12
static final float SQRT12
half of square root of two- See Also:
- Constant Field Values
-
-
Method Detail
-
toPoint
Point toPoint()
Calculates it and creates new instance if not already in correct format then return a copy of itself.- Returns:
- the point representation. Copy safe.
-
getPoint
Point getPoint()
May not be copy safe.- Returns:
- may not be copy safe
-
getCoord
Coordinate getCoord()
May not be copy safe.- Returns:
- may not be copy safe
-
toCoord
Coordinate toCoord()
Calculates it and creates new instance if not already in correct format then returns copy of itself.- Returns:
- the coordinate representation. Copy safe
-
getViewSpcX
int getViewSpcX()
Calculate position in view space.- Returns:
- Returns the center of the projected (screen) x-position where the object is rendered without regarding the camera. It also adds the cell offset.
-
getViewSpcY
int getViewSpcY()
Calculate position in view space.- Returns:
- Returns the center of the projected (view space) y-position where the object is rendered without regarding the camera.
-
getProjectionSpaceX
int getProjectionSpaceX(GameView View, Camera camera)
equals screen space when zoom=1 with a single, fullscreen camera.- Parameters:
View-camera-- Returns:
-
getProjectionSpaceY
int getProjectionSpaceY(GameView View, Camera camera)
equals screen space when zoom=1 with a single camera.- Parameters:
View-camera-- Returns:
-
getBlockId
byte getBlockId()
Get the block at the position. Clamps positions over the map at topmost layer.- Returns:
- If the coordiante is not in memory will crash.
-
cpy
Position cpy()
- Returns:
- a copy of the object.
-
isInMemoryAreaXY
boolean isInMemoryAreaXY()
Checks if the coordiantes are accessable with the currently loaded chunks. Does not check for z axis (horizontal only). So the position can be udner or over the map.- Returns:
-
isInMemoryAreaXYZ
boolean isInMemoryAreaXYZ()
Checks if the position is on the chunks currently in memory. Checks all axis'.- Returns:
- true if inside a chunk. false if currently not loaded or outside range.
-
distanceTo
float distanceTo(AbstractGameObject object)
- Parameters:
object-- Returns:
- the distance from this point to the other object
-
distanceToSquared
float distanceToSquared(AbstractGameObject object)
The result is squared for fast comparison.- Parameters:
object-- Returns:
- the distance from this point to the other object squared
- See Also:
distanceTo(AbstractGameObject)
-
distanceTo
float distanceTo(Position pos)
- Parameters:
pos-- Returns:
- the distance from this pos to the other pos in game coordinates
-
distanceToSquared
float distanceToSquared(Position pos)
The result is squared for fast comparison.- Parameters:
pos-- Returns:
- the distance from this point to the other object squared
- See Also:
distanceTo(Position)
-
distanceToHorizontal
float distanceToHorizontal(AbstractGameObject object)
checks only x and y.- Parameters:
object-- Returns:
- the distance from this point to the other point only regarding horizontal components.
-
distanceToHorizontal
float distanceToHorizontal(Position pos)
checks only x and y.- Parameters:
pos-- Returns:
- the distance from this pos to the other pos only regarding horizontal components.
-
distanceToHorizontalSquared
float distanceToHorizontalSquared(AbstractGameObject object)
checks only x and y.- Parameters:
object-- Returns:
- the distance from this point to the other point squared only regarding horizontal components.
-
distanceToHorizontalSquared
float distanceToHorizontalSquared(Position pos)
checks only x and y.- Parameters:
pos-- Returns:
- the distance from this pos to the other pos squared only regarding horizontal components.
-
getEntitiesNearby
<T> java.util.LinkedList<T> getEntitiesNearby(float radius, java.lang.Class<T> type)Get entities in radius.- Type Parameters:
T- returns only object if type which is the filter- Parameters:
radius- in game dimension pixelstype- the type you want to filter- Returns:
- every entitie in radius
-
getEntitiesNearbyHorizontal
<T> java.util.LinkedList<T> getEntitiesNearbyHorizontal(float radius, java.lang.Class<T> type)get entities in horizontal radius (like a pipe)- Type Parameters:
T-- Parameters:
radius- in game dimension pixelstype- whitelist- Returns:
- every entitie in radius
-
getEntitiesNearbyHorizontal
java.util.LinkedList<AbstractEntity> getEntitiesNearbyHorizontal(float radius)
get entities in radius (horizontal only)- Parameters:
radius- in game dimension pixels- Returns:
- every entitie in radius
-
getChunk
Chunk getChunk()
- Returns:
-
getChunkX
int getChunkX()
The chunk coordinate.- Returns:
-
getChunkY
int getChunkY()
The chunk coordinate.- Returns:
-
getZGrid
int getZGrid()
Get the z in block grid coordinates of the coordinate. Faster than transforming to coordinate first.- Returns:
- in grid coordinates.
-
getZPoint
float getZPoint()
Get the z in game world coordinates.- Returns:
-
-