public class Map
extends java.lang.Object
implements java.lang.Cloneable
Constructor and Description |
---|
Map(java.lang.String name)
Loads a map.
|
Map(java.lang.String name,
Generator generator)
Loads a map.
|
Modifier and Type | Method and Description |
---|---|
Map |
clone()
Clones the map.
|
static void |
createMapFile(java.lang.String mapName)
Should create a new map file.
|
void |
earthquake(int numberofblocks)
a method who gives random blocks offset
|
void |
fill(boolean allowLoading)
Fills the map with blocks.
|
void |
fill(Generator generator,
boolean allowLoading)
Fills the map without overriding the map generator.
|
void |
fillWithAir()
Fill the data array of the map with Cells.
|
<type extends AbstractEntity> |
getAllEntitysOfType(java.lang.Class<? extends AbstractEntity> type)
Find every instance of a special class e.g. find every AbstractCharacter
|
java.util.ArrayList<AbstractEntity> |
getAllEntitysOnCoord(Coordinate coord)
Get every entity on a coord.
|
<type> java.util.ArrayList<type> |
getAllEntitysOnCoord(Coordinate coord,
java.lang.Class<? extends AbstractEntity> type)
Get every entity on a coord of the wanted type
|
Block |
getBlock(Coordinate coord) |
Block |
getBlock(int x,
int y,
int z)
Returns a Block without checking the parameters first.
|
Block |
getBlockClamp(int x,
int y,
int z)
Returns a block of the map.
|
static int |
getBlocksX()
Returns the amount of Blocks inside the map in x-direction.
|
static int |
getBlocksY()
Returns the amount of Blocks inside the map in y-direction.
|
static int |
getBlocksZ()
Returns the amount of Blocks inside the map in z-direction.
|
int[] |
getCellOffset(Coordinate coord) |
static Point |
getCenter()
Returns a coordinate pointing to the absolute center of the map.
|
static Point |
getCenter(float height)
Returns a corodinate pointing to the absolute center of the map.
|
int[] |
getChunkCoords(int pos)
Get the coordinates of a chunk.
|
Cell[][][] |
getData()
Get the data of the map
|
Block |
getDataClamp(Coordinate coords)
Get a block at a coordinate but clamp it first.
|
java.util.ArrayList<AbstractEntity> |
getEntitys()
Returns the entityList
|
java.lang.String |
getFilename()
The name of the map on the file.
|
static int |
getGameDepth()
The depth of the map in game size
|
static int |
getGameHeight()
Game size
|
static int |
getGameWidth()
The width of the map with three chunks in use
|
MapMetaData |
getMeta() |
int |
getWorldSpinDirection()
Returns the degree of the world spin.
|
boolean |
save()
saves every chunk on the map
|
void |
setCelloffset(Coordinate coord,
int field,
int value)
Set the offset in one cell.
|
void |
setCenter(int newmiddle)
Reorganises the map and sets the new middle chunk to param newmiddle.
|
void |
setData(Coordinate coords,
Block block)
Set a block at a specific coordinate.
|
void |
setData(int x,
int y,
int z,
Block block)
Set a block at a specific coordinate.
|
void |
setDataSafe(Coordinate coord,
Block block)
Set a block with safety checks.
|
void |
setDataSafe(int[] coords,
Block block)
Set a block with safety checks.
|
void |
setGenerator(Generator generator)
Set the generator used for generating maps
|
static void |
staticDispose() |
public Map(java.lang.String name) throws java.io.IOException
name
- if available on disk it will be loadjava.io.IOException
#fill(com.BombingGames.WurfelEngine.Core.Map.Generator)
public Map(java.lang.String name, Generator generator) throws java.io.IOException
#fill(com.BombingGames.WurfelEngine.Core.Map.Generator)
name
- if available on disk it will be loadgenerator
- the generator used for generating new chunksjava.io.IOException
- thrown if there is no full read/write access to the map file#fill(com.BombingGames.WurfelEngine.Core.Map.Generator)
public static void createMapFile(java.lang.String mapName) throws java.io.IOException
mapName
- java.io.IOException
public void fill(boolean allowLoading)
allowLoading
- public void fill(Generator generator, boolean allowLoading)
generator
- the custom generatorallowLoading
- public void fillWithAir()
public static int getBlocksX()
public static int getBlocksY()
public static int getBlocksZ()
public Cell[][][] getData()
public void setCenter(int newmiddle)
newmiddle
- newmiddle is 1, 3, 5 or 7public int[] getChunkCoords(int pos)
pos
- public Block getBlock(int x, int y, int z)
x
- positiony
- positionz
- positionpublic Block getBlock(Coordinate coord)
coord
- public Block getBlockClamp(int x, int y, int z)
x
- If too high or too low, it takes the highest/deepest value possibley
- If too high or too low, it takes the highest/deepest value possiblez
- If too high or too low, it takes the highest/deepest value possiblegetDataClamp(com.BombingGames.WurfelEngine.Core.Map.Coordinate)
public Block getDataClamp(Coordinate coords)
coords
- public void setData(int x, int y, int z, Block block)
x
- positiony
- positionz
- positionblock
- public void setData(Coordinate coords, Block block)
coords
- block
- public void setDataSafe(int[] coords, Block block)
coords
- block
- public void setDataSafe(Coordinate coord, Block block)
coord
- block
- public void setGenerator(Generator generator)
generator
- public void earthquake(int numberofblocks)
numberofblocks
- the amount of moved blockspublic java.util.ArrayList<AbstractEntity> getEntitys()
public int getWorldSpinDirection()
public int[] getCellOffset(Coordinate coord)
coord
- public void setCelloffset(Coordinate coord, int field, int value)
coord
- the cellfield
- 0 = X, 1 = y, 2 = zvalue
- the value you want to set the fieldpublic <type extends AbstractEntity> java.util.ArrayList<type> getAllEntitysOfType(java.lang.Class<? extends AbstractEntity> type)
type
- type
- public java.util.ArrayList<AbstractEntity> getAllEntitysOnCoord(Coordinate coord)
coord
- public <type> java.util.ArrayList<type> getAllEntitysOnCoord(Coordinate coord, java.lang.Class<? extends AbstractEntity> type)
type
- the class you want to filter.coord
- the coord where you want to get every entity fromtype
- the class you want to filter.public static Point getCenter()
public static Point getCenter(float height)
height
- You custom height.public static int getGameWidth()
public static int getGameDepth()
public static int getGameHeight()
public java.lang.String getFilename()
public MapMetaData getMeta()
public Map clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException
public static void staticDispose()
public boolean save()