Class TerrainChunk

java.lang.Object
com.codename1.gaming.level.TerrainChunk

public class TerrainChunk extends Object
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 Details

  • 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

      public String getMaterial(int localX, int localZ)
    • setMaterial

      public void setMaterial(int localX, int localZ, String materialId)
    • features

      public List<TerrainFeature> features()
      Features anchored in this chunk (mutate directly; mark dirty via #touch()).
    • touch

      public void touch()