Class WangTile
public class WangTile
Associates one local tile ID with the terrains at its four corners and four edges.
Wang IDs always contain eight entries in Tiled order. Zero means no terrain; positive values are
one-based indexes into WangSet.getTerrains(). Arrays supplied to or returned from this class are
defensively copied.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the local tileset tile ID.int[]Returns the eight terrain indexes.voidsetTerrain(int position, int terrain) Assigns one corner or edge position.voidsetWangId(int[] wangId) Replaces all terrain indexes.
-
Constructor Details
-
WangTile
public WangTile()Creates tile zero with no assigned terrains. -
WangTile
public WangTile(int tileId, int[] wangId) Creates a tile assignment.- Parameters:
tileId- The local tileset tile ID.wangId- Up to eight terrain indexes; missing entries become zero.
-
WangTile
Creates an independent copy.- Parameters:
original- The assignment to copy.
-
-
Method Details
-
getTileId
public int getTileId()Returns the local tileset tile ID.- Returns:
- The tile ID.
-
getWangId
public int[] getWangId()Returns the eight terrain indexes.- Returns:
- A defensive copy of the Wang ID.
-
setWangId
public void setWangId(int[] wangId) Replaces all terrain indexes.- Parameters:
wangId- Up to eight indexes; negative values become zero.
-
setTerrain
public void setTerrain(int position, int terrain) Assigns one corner or edge position.- Parameters:
position- The Tiled Wang position from zero through seven.terrain- The non-negative, one-based terrain index, or zero for none.- Throws:
IndexOutOfBoundsException- ifpositionis outside zero through seven.IllegalArgumentException- ifterrainis negative.
-