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 aMapDefinition
record class. -
Method Summary
Modifier and TypeMethodDescriptionlong
depth()
Returns the value of thedepth
record component.final boolean
Indicates whether some other object is "equal to" this one.Returns the value of thefloorColor
record 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.float
getTileHeight
(int x, int y) Returns the height of the tile at the given grid coordinates.float
getTileHeight
(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 int
hashCode()
Returns a hash code value for this object.layers()
Returns the value of thelayers
record component.markers()
Returns the value of themarkers
record component.float[][]
tiles()
Returns the value of thetiles
record component.toString()
Returns a string representation of this record class.long
width()
Returns the value of thewidth
record 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 aMapDefinition
record class.- Parameters:
width
- the value for thewidth
record componentdepth
- the value for thedepth
record componentfloorColor
- the value for thefloorColor
record componenttiles
- the value for thetiles
record componentlayers
- the value for thelayers
record componentmarkers
- the value for themarkers
record 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 thecompare
method from their corresponding wrapper classes. -
width
public long width()Returns the value of thewidth
record component.- Returns:
- the value of the
width
record component
-
depth
public long depth()Returns the value of thedepth
record component.- Returns:
- the value of the
depth
record component
-
floorColor
Returns the value of thefloorColor
record component.- Returns:
- the value of the
floorColor
record component
-
tiles
public float[][] tiles()Returns the value of thetiles
record component.- Returns:
- the value of the
tiles
record component
-
layers
Returns the value of thelayers
record component.- Returns:
- the value of the
layers
record component
-
markers
Returns the value of themarkers
record component.- Returns:
- the value of the
markers
record component
-