Class WangSet
- All Implemented Interfaces:
ICustomPropertyProvider, ITerrainSet
A Tiled terrain or Wang set containing terrain colors and per-tile edge/corner assignments.
Terrain references in WangTile are one-based indexes into getTerrains(); index zero means
no terrain. The eight positions alternate corners and edges in the order defined by the TMX
format. The returned terrain and Wang-tile lists are live JAXB model collections.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetName()Gets the name of this terrain set.getOrCreateWangTile(int tileId) Finds or creates the assignment for a local tile ID.Returns the live terrain list in Wang-index order.ITerrain[]getTerrains(int tileId) Gets the terrains object associated with the specified tile ID.getType()Gets the type of terrain represented by this instance.int[]getWangId(int tileId) Returns the eight Wang indexes assigned to a local tile.Returns the live list of per-tile assignments.voidremoveWangTileIfEmpty(int tileId) Removes a tile assignment if all eight of its indexes are zero.voidSets the display name; blank values are normalized tonull.voidsetType(TerrainType type) Sets which Wang positions this set uses.toString()Methods inherited from class CustomPropertyProvider
getBoolValue, getBoolValue, getByteValue, getByteValue, getCharValue, getCharValue, getColorValue, getColorValue, getCommaSeparatedStringValues, getDoubleValue, getDoubleValue, getEnumValue, getEnumValue, getFileValue, getFileValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getMapObjectId, getProperties, getProperty, getShortValue, getShortValue, getStringValue, getStringValue, hasCustomProperty, removeProperty, setProperties, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ICustomPropertyProvider
getBoolValue, getBoolValue, getByteValue, getByteValue, getCharValue, getCharValue, getColorValue, getColorValue, getCommaSeparatedStringValues, getDoubleValue, getDoubleValue, getEnumValue, getEnumValue, getFileValue, getFileValue, getFloatValue, getFloatValue, getIntValue, getIntValue, getLongValue, getLongValue, getMapObjectId, getProperties, getProperty, getShortValue, getShortValue, getStringValue, getStringValue, hasCustomProperty, removeProperty, setProperties, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue
-
Constructor Details
-
WangSet
public WangSet()Creates an empty mixed terrain set namedTerrain Set. -
WangSet
Creates an empty terrain set.- Parameters:
name- The set name.type- Whether assignments describe corners, edges, or both.
-
WangSet
Creates a deep copy of a terrain set.- Parameters:
original- The set to copy.
-
-
Method Details
-
getName
Description copied from interface:ITerrainSetGets the name of this terrain set.- Specified by:
getNamein interfaceITerrainSet- Returns:
- THe name of the terrain set.
-
setName
Sets the display name; blank values are normalized tonull.- Parameters:
name- The new name.
-
getType
Description copied from interface:ITerrainSetGets the type of terrain represented by this instance.
This method returns the specific type of terrain as an element of the
TerrainTypeenumeration. TheTerrainTypeenum defines different types of terrain, including "corner," "edge," and "mixed." The return value indicates the classification of the terrain associated with the current instance.- Specified by:
getTypein interfaceITerrainSet- Returns:
- The
TerrainTyperepresenting the type of terrain. - See Also:
-
setType
Sets which Wang positions this set uses.- Parameters:
type- The non-null terrain type.- Throws:
NullPointerException- iftypeisnull.
-
getTerrains
Returns the live terrain list in Wang-index order.- Specified by:
getTerrainsin interfaceITerrainSet- Returns:
- The mutable terrain list.
-
getWangTiles
-
getOrCreateWangTile
Finds or creates the assignment for a local tile ID.- Parameters:
tileId- The non-negative local tile ID.- Returns:
- The existing or newly added assignment.
- Throws:
IllegalArgumentException- iftileIdis negative.
-
getWangId
public int[] getWangId(int tileId) Returns the eight Wang indexes assigned to a local tile.- Parameters:
tileId- The local tile ID.- Returns:
- A defensive copy, or eight zeroes if the tile has no assignment.
-
removeWangTileIfEmpty
public void removeWangTileIfEmpty(int tileId) Removes a tile assignment if all eight of its indexes are zero.- Parameters:
tileId- The local tile ID to inspect.
-
getTerrains
Description copied from interface:ITerrainSetGets the terrains object associated with the specified tile ID.
This method searches through the collection of Wang tiles to find a match for the specified tile ID. If a match is found, it extracts the Wang IDs associated with the tile and maps them to terrains defined by this
ITerrainSet. The resulting array contains references to the corresponding terrain objects based on the Wang IDs. If a Wang ID is 0, the corresponding terrain in the array is set to null.- Specified by:
getTerrainsin interfaceITerrainSet- Parameters:
tileId- The tile ID for which terrains are to be retrieved.- Returns:
- An array of ITerrain objects representing the terrains associated with the given tile ID.
-
toString
-