Skip to main content

Module construction

Module construction 

Source
Expand description

Construction sites: the building state machine (StateMachineComponent with the ClearArea, WorkPlace, Build and Residence controllers) and the construction works (GatherRawMaterials, BuildStructure). See docs/JOBS.md.

A placed building’s controllers are linked in component order; a state is handled by the last controller that defines it, and a callback returning false passes it to the previous one. The callbacks themselves live on crate::town::Sim.

Original: FUN_1400aeb30.

Structs§

Attendance
AttendanceComponent: who attends a school, chapel or doctor.
BuildWork
BuildStructure state (destroy flag, point cursor, occupied build points, workers).
ClearWork
ClearArea state: claimed resources (entity → citizen), claimed cells, template filter, resources / cells / piles.
Construction
The job manager, professions, workforce and every construction site.
Decal
DecalComponent (0x38 bytes, serialized alpha, material): setup takes the description’s alpha; entity event 1 (the ClearArea’s state 2) and the build’s state 8 make it opaque; a collapse switches to the DestroyDescription’s material. Each change re-adds the map decal. See docs/DECALS.md.
Gather
GatherRawMaterials state (delivered per requirement, in transit, workers).
Machine
The runner’s fields (StateMachineComponent): the current interface, state, its index, pending state, pending transition.
PickupWork
Pickup work: its state lives on the Pile it belongs to.
Pile
RawMaterialComponent: a loose pile.
ProduceState
ConsumeProduceComponent state (switched off, selector, weights, productions so far).
ProduceTemplate
A resolved [banished_formats::game::ConsumeProduceDescription].
ProduceWork
ConsumeProduce work state: the worker at each use point, each output point’s state (0 free, 1 a production is under way, 2 holds output), every output point was taken, work cycles towards the next production.
Recipe
A production alternative: inputs (raw material, count), the output pile template and its raw material, and the stock group the limit check reads.
Site
One building under construction (and, once built, its WorkComponent).
SiteTemplate
The parts of a building’s descriptions construction reads.
StateDef
One state of a building’s state machine: its callbacks and its transitions.

Enums§

Callback
A state callback (records: enter, scheduled update, transition functions).
Controller
The ControllerComponents the port has state tables for.

Traits§

Callbacks
What a callback needs to run, borrowed from the town (see crate::town::Sim).

Functions§

run
Run a building’s state machine for one visit: handle the pending state change, then the scheduled or per-iteration update of the current state.