pub struct Generator {
pub size: i32,
pub grid: Vec<f32>,
pub paths: Vec<Vec<PathPoint>>,
pub vec28: Vec<[f32; 3]>,
pub points: Vec<[f32; 3]>,
pub lakes: Vec<[f32; 3]>,
pub rng: Random,
pub record: SizeRecord,
}Expand description
The map generator: it makes a terrain from a size record and a seed, in five stages.
use banished_terrain::Generator;
let mut generator = Generator::new(record(), 290);
generator.run(|_stage, _g| {});
let heights = generator.heights(); // as a save stores themOriginal: FUN_1400d4860.
Fields§
§size: i32The terrain’s size in cells, 2n. The grid has (size + 1)² samples.
grid: Vec<f32>The float heights, row by row.
paths: Vec<Vec<PathPoint>>The river paths. The map draws each one with the River material.
vec28: Vec<[f32; 3]>The hill circles of stage 3 (x, y, radius), including the bridges that join them.
points: Vec<[f32; 3]>The lake points: circles (x, y, radius) around each lake, and its centre.
lakes: Vec<[f32; 3]>The lakes (x, y, depth). The map draws them with the Lake material.
rng: RandomThe random number generator, seeded with the map seed. The stages draw from it in order.
record: SizeRecordThe size record.
Implementations§
Source§impl Generator
impl Generator
Sourcepub fn stage1_noise(&mut self)
pub fn stage1_noise(&mut self)
Stage 1: fill the grid from two noise fields, blended by a logistic falloff from the centre.
Original: FUN_1400d3aa0.
Sourcepub fn stage2_records(&mut self)
pub fn stage2_records(&mut self)
Stage 2: make the first river path, the lake points, then the branch paths.
Original: FUN_1400d2560, FUN_1400d2620, FUN_1400d2430.
Sourcepub fn stage3_shape(&mut self)
pub fn stage3_shape(&mut self)
Stage 3: place the hill circles, then draw the paths, lakes and hills into the grid.
Original: FUN_1400d2930, then FUN_1400d3de0.
Sourcepub fn stage4_downhill(&mut self)
pub fn stage4_downhill(&mut self)
Stage 4: walks from random cells inside the map. Each step moves to the lowest of the 3 × 3 neighbours and moves a part of the height difference.
Original: FUN_1400d1550.
Sourcepub fn stage5_smooth(&mut self)
pub fn stage5_smooth(&mut self)
Stage 5: carve the rivers and lakes again (without the hill mask), then smooth the grid twice.
Original: FUN_1400d4120, then FUN_1400d1820 twice.
Source§impl Generator
impl Generator
Sourcepub fn surface_map(&mut self) -> Vec<u32>
pub fn surface_map(&mut self) -> Vec<u32>
Build the packed surface image (dirt | rock << 8 | light << 16). Consumes two random
values, so it must run after run exactly as the game does.
Original: FUN_1400d4910.