Class TerrainChunk
java.lang.Object
com.codename1.gaming.level.TerrainChunk
A
#SIZEx#SIZE square block of terrain -- the unit of streaming. Identified by its chunk
coordinates (#getChunkX(), #getChunkZ()), it is self-describing: a height per cell, a
material per cell (stored compactly as an index into the chunk's own material palette), and
the TerrainFeatures anchored within it. StreamingTerrain loads/saves chunks on demand so
a world can be arbitrarily large without holding it all in memory.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidfeatures()Features anchored in this chunk (mutate directly; mark dirty via#touch()).intintfloatgetHeight(int localX, int localZ) getMaterial(int localX, int localZ) booleanhasGround(int localX, int localZ) booleanisDirty()Whether the chunk has unsaved edits (used by providers to decide what to persist).voidsetHeight(int localX, int localZ, float h) voidsetMaterial(int localX, int localZ, String materialId) voidtouch()
-
Field Details
-
SIZE
public static final int SIZECells per side of a chunk.- See Also:
-
-
Constructor Details
-
TerrainChunk
public TerrainChunk(int cx, int cz)
-
-
Method Details
-
getChunkX
public int getChunkX() -
getChunkZ
public int getChunkZ() -
isDirty
public boolean isDirty()Whether the chunk has unsaved edits (used by providers to decide what to persist). -
clearDirty
public void clearDirty() -
getHeight
public float getHeight(int localX, int localZ) -
setHeight
public void setHeight(int localX, int localZ, float h) -
hasGround
public boolean hasGround(int localX, int localZ) -
getMaterial
-
setMaterial
-
features
Features anchored in this chunk (mutate directly; mark dirty via#touch()). -
touch
public void touch()
-