signals library

Signals and rails on package:voxel_engine/core.dart: levers, buttons, plates, wires with decaying strength, lamps, doors, pistons and powered rails as declared block roles; and rails that orient themselves.

Classes

RailGraph
Rails that lay themselves: which ends a rail joins, which rail a cell should hold from what is around it, and how a cart walks the line.
RailVariant
One rail block: its kind (rails of a kind turn into one another), its shape (ns, ew, ne, nw, se, sw, slope_n, slope_e, slope_s, slope_w) and, for a kind that has two states, whether this is the on one (a powered rail).
SignalNetwork
Redstone-lite over a VoxelEditor. Sources power their six neighbours; power runs along wires with a strength of SignalRules.maxStrength beside a source, one less per link. Wires link on the same plane (four neighbours) and one step up or down along a block edge — the staircase rule: the climb needs no opaque block over the lower cell, the drop none in the far cell. A block beside a source or a live wire is powered, and its reaction runs.
SignalReactions
Stock SignalReactions.
SignalRules
What each block is to a SignalNetwork, by id. Every state is a block id (a lever on and off, a lit and an unlit lamp), so a flip is a plain setBlock and meshing, saving and networking come free.

Typedefs

ButtonRule = ({int pressed, double seconds})
A button: pressed it becomes pressed for seconds, then goes back.
SignalReaction = void Function(SignalNetwork net, IVec3 cell, int id)
What a block does when the network around it changes: read SignalNetwork.isPowered at cell and write the world.