Skip to main content

Module terraform

Module terraform 

Source
Expand description

Terraforming: a tunnel reshapes the terrain when it is built. See docs/TUNNELS.md.

When the build is done (entity event 4; a multi-object passes it to its parts), the vertices of the ceiling mesh raise the terrain where it is below them, keeping what was there, and the vertices of the floor mesh lower it where it is above them. Then the rough cells (10) under the building become high ground (6). When the tunnel is removed, the raised heights are put back and those cells become rough again; the dug floor stays.

Original: TerraformComponent (vtable 0x1401609a0): FUN_140057c70 (built, slot +0x60), FUN_1400574b0 (ceiling and floor), FUN_140057a80 (cell types), FUN_140057cb0 (removed, slot +0x38).

Deviation: the heights belong to the terrain outside the simulation, so the town queues the dig and the game applies it after the iteration (StartingTown::apply_terraforms), not during it.

Structs§

TerraformState
The component’s raised points (where the ground was) and cells turned high.
TerraformTemplate
The description’s meshes as the first submesh’s vertices (PickingMesh::Vertices(0)).

Enums§

Terraform
A request for the terrain owner: dig (event 4) or undo (removal) an entity’s terraform.

Functions§

flatten
Each cell of the inclusive rectangle x0, y0, x1, y1 sets its low corner’s height to 0 (the ground point of the cell’s middle, in the height grid). cells is the map’s cells per side; the height grid is width − 1 cells, the map in its middle.
harden
Rough cells (10) of the rectangle become high ground (6), kept.
reshape
Move the ground to a mesh: each vertex goes through the model’s transform (yaw, position) and a quarter cell further. Where the cells at it, one to the west, one to the south-west and (again) one to the west are all of the mask’s types, and the vertex is above (ceiling) or below (floor) the ground, the height sample under it takes the vertex’s height. A ceiling keeps the ground it raised.
undo
The raised samples get their ground back and the kept cells become rough.