
com.nkasenides.athlos.model.TerrainGenerator Maven / Gradle / Ivy
package com.nkasenides.athlos.model;
import com.nkasenides.athlos.exception.ChunkOutOfBoundsException;
/**
* Abstracts the generation of terrain in a world.
* @param The world class.
* @param The terrain chunk class
* @param The terrain cell class.
*/
public abstract class TerrainGenerator {
/**
* The world of this generator.
*/
protected final TWorld world;
/**
* Constructs a new generator.
* @param world The world of this generator.
*/
public TerrainGenerator(TWorld world) {
this.world = world;
}
/**
* Retrieves the world of this generator.
* @return Returns a world.
*/
public TWorld getWorld() {
return world;
}
/**
* Generates a cell.
* @param cellRow The row of the cell.
* @param cellCol The column of the cell.
* @return Returns a TerrainCell.
*/
protected abstract TTerrainCell generateCell(int cellRow, int cellCol);
/**
* Acquires a cell. If a cell does not exist (i.e. not generated yet), this will generate the cell by calling
* {@link #generateCell(int, int)}, otherwise the cell will be immediately retrieved.
* @param cellRow The row of the cell.
* @param cellCol The column of the cell.
* @return Returns a TerrainCell.
* @throws ChunkOutOfBoundsException thrown when the request
*/
public abstract TTerrainCell acquireCell(int cellRow, int cellCol) throws ChunkOutOfBoundsException;
/**
* Generates an entire chunk.
* @param chunkRow The chunk's row.
* @param chunkCol The chunk's column.
* @return Returns a TerrainChunk.
*/
public abstract TTerrainChunk generateChunk(int chunkRow, int chunkCol);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy