Record Class MapDefinition
java.lang.Object
java.lang.Record
dev.zwazel.internal.game.map.MapDefinition
public record MapDefinition(long width, long depth, SimplifiedRGB floorColor, float[][] tiles, LayerDefinition[] layers, MarkerDefinition[] markers)
extends Record
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionMapDefinition(long width, long depth, SimplifiedRGB floorColor, float[][] tiles, LayerDefinition[] layers, MarkerDefinition[] markers) Creates an instance of aMapDefinitionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionlongdepth()Returns the value of thedepthrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of thefloorColorrecord component.getClosestTileFromWorld(Vec3 worldPos) Returns the Coordinates of the closest tile to the given world position in the map grid.getTile(int x, int y) Returns the tile at the given grid coordinates as a Vec3.Returns the tile at the given grid coordinates as a Vec3.floatgetTileHeight(int x, int y) Returns the height of the tile at the given grid coordinates.floatgetTileHeight(Vec3 pos) Returns the height of the tile at the given grid coordinates.getWorldTileCenter(int x, int y) Returns the center of the tile in world coordinates.Returns the world coordinates of the tile centers in the map grid as a list.final inthashCode()Returns a hash code value for this object.layers()Returns the value of thelayersrecord component.markers()Returns the value of themarkersrecord component.float[][]tiles()Returns the value of thetilesrecord component.toString()Returns a string representation of this record class.longwidth()Returns the value of thewidthrecord component.
-
Field Details
-
TILE_SIZE
public static final float TILE_SIZE- See Also:
-
-
Constructor Details
-
MapDefinition
public MapDefinition(long width, long depth, SimplifiedRGB floorColor, float[][] tiles, LayerDefinition[] layers, MarkerDefinition[] markers) Creates an instance of aMapDefinitionrecord class.- Parameters:
width- the value for thewidthrecord componentdepth- the value for thedepthrecord componentfloorColor- the value for thefloorColorrecord componenttiles- the value for thetilesrecord componentlayers- the value for thelayersrecord componentmarkers- the value for themarkersrecord component
-
-
Method Details
-
getClosestTileFromWorld
Returns the Coordinates of the closest tile to the given world position in the map grid. The closest tile is the tile whose center is closest to the given world position. The y coordinate of the world position must be positive. If the y coordinate of the world position is negative, an IllegalArgumentException is thrown. The y coordinate of the returned Vec3 is the height of the tile. The returned Vec3 is in grid coordinates, not world coordinates. The given Vec3 must be in world coordinates, not grid coordinates.- Parameters:
worldPos- the world position- Returns:
- the closest tile to the world position, as a Vec3.
-
gridToWorld
-
getWorldTileCenter
Returns the center of the tile in world coordinates.- Parameters:
x- the x coordinate of the tile in the map grid (0-indexed)y- the y coordinate of the tile in the map grid (0-indexed)- Returns:
- the world coordinate of the center of the tile
-
getTileHeight
public float getTileHeight(int x, int y) Returns the height of the tile at the given grid coordinates.- Parameters:
x- the x coordinate of the tile in the map grid (0-indexed)y- the y coordinate of the tile in the map grid (0-indexed)- Returns:
- the height of the tile
-
getTileHeight
Returns the height of the tile at the given grid coordinates.- Parameters:
pos- the grid coordinates of the tile, not world coordinates! The y coordinate is the height of the tile. The y coordinate is ignored in this method. The z coordinate of the given Vec3 is the y coordinate of the tile in the 2D map grid. The x coordinate of the given Vec3 is the x coordinate of the tile in the 2D map grid.- Returns:
- the height of the tile
-
getTile
Returns the tile at the given grid coordinates as a Vec3.- Parameters:
x- the x coordinate of the tile in the map grid (0-indexed)y- the y coordinate of the tile in the map grid (0-indexed)- Returns:
- the tile as a Vec3 in grid coordinates. the y is the height of the tile.
-
getTile
Returns the tile at the given grid coordinates as a Vec3.- Parameters:
pos- the grid coordinates of the tile, not world coordinates! The y coordinate is the height of the tile. The y coordinate is ignored in this method. The z coordinate of the given Vec3 is the y coordinate of the tile in the 2D map grid. The x coordinate of the given Vec3 is the x coordinate of the tile in the 2D map grid.- Returns:
- the tile as a Vec3 in grid coordinates. the y is always 0, as this is a 2D map.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
width
public long width()Returns the value of thewidthrecord component.- Returns:
- the value of the
widthrecord component
-
depth
public long depth()Returns the value of thedepthrecord component.- Returns:
- the value of the
depthrecord component
-
floorColor
Returns the value of thefloorColorrecord component.- Returns:
- the value of the
floorColorrecord component
-
tiles
public float[][] tiles()Returns the value of thetilesrecord component.- Returns:
- the value of the
tilesrecord component
-
layers
Returns the value of thelayersrecord component.- Returns:
- the value of the
layersrecord component
-
markers
Returns the value of themarkersrecord component.- Returns:
- the value of the
markersrecord component
-