WorldGenerator
namespace Griff.Modules.BlockWorlds;
public sealed class WorldGenerator : ComponentFills its Tilemap with a world made from a Seed: rolling hills of grass over dirt, stone below with caves and veins of ore, sand, trees, and a floor that can’t be dug through. The same seed always makes the same world; 0 makes a new one every time.
With GenerateOnPlay the map’s tiles are replaced by a fresh world each time the game starts (unless a saved world comes back, see SaveAs); untick it to keep the world as painted. Tile numbers are the map’s tileset’s: -1 leaves a feature out.
This is a component: its saved properties are on its component page.
Properties
Section titled “Properties”BottomTile
Section titled “BottomTile”public int BottomTile { get; set; }A tile for the bottom row, usually one that’s unbreakable (see Unbreakable).
public float Caves { get; set; }How much of the underground is caves, from 0 (solid) to 1 (mostly hollow). 0.3 is plenty.
DirtDepth
Section titled “DirtDepth”public int DirtDepth { get; set; }How many cells of dirt lie under the grass before the stone starts.
DirtTile
Section titled “DirtTile”public int DirtTile { get; set; }The tile under the grass, DirtDepth cells deep.
GenerateOnPlay
Section titled “GenerateOnPlay”public bool GenerateOnPlay { get; set; }Make the world when the game starts. Untick it to keep (and paint on) the map as it is.
GrassTile
Section titled “GrassTile”public int GrassTile { get; set; }The tile on top of the ground.
Height
Section titled “Height”public int Height { get; set; }Cells down, sky included.
HillWidth
Section titled “HillWidth”public float HillWidth { get; set; }About how many cells from one hilltop to the next.
public float Hills { get; set; }How many cells the ground rises and falls.
LeavesTile
Section titled “LeavesTile”public int LeavesTile { get; set; }The tile for treetops; -1 for none.
public string? Ores { get; set; }Ores in the stone: a tile and how much of the stone it makes up, separated by commas, e.g. “3 6%, 4 3%”. Each comes in little veins; the second and later ores lie deeper.
public float Sand { get; set; }Patches of sand along the surface, from 0 (none) to 1 (everywhere).
SandTile
Section titled “SandTile”public int SandTile { get; set; }The tile for patches of sand; -1 for none.
public int Seed { get; set; }Picks the world: the same number always makes the same one. 0 makes a new world each time.
public string? Spawn { get; set; }Entities to stand on the ground in the middle of the world once it’s made, by name, separated by commas, e.g. “Player”.
StoneTile
Section titled “StoneTile”public int StoneTile { get; set; }The tile under the dirt, all the way down.
Surface
Section titled “Surface”public int Surface { get; set; }Rows of sky above the ground, on average.
public float Trees { get; set; }How often a tree grows on the grass, from 0 (never) to 1 (wherever there’s room).
TrunkTile
Section titled “TrunkTile”public int TrunkTile { get; set; }The tile for tree trunks; -1 for no trees.
UsedSeed
Section titled “UsedSeed”public int UsedSeed { get; }The seed the world was last made from: the one picked when Seed is 0.
public string? Walls { get; set; }The name of another tilemap to fill with the walls of the underground, drawn behind the world: what caves and tunnels show instead of the sky. Give it the same position and tileset, no collisions (untick Solid), a darker tint, and a lower Order.
public int Width { get; set; }Cells across.