Expand description
The flat frame: everything a renderer reads each frame, as one
Vec<f64> (frame_view), and the new log messages (log_since).
Read the frame by slot name, never by bare index: header names the
header slots, person, unit, transport and car the slots
of each record, and FRAME_HEADER, PERSON_FIXED, UNIT_RECORD,
TRANSPORT_FIXED and CAR_RECORD the widths. frame_view says
what each value means. The JavaScript binding hands over the same frame as
one Float64Array.
crate::view is the newer read path: it sends only the rooms that
changed since the last frame, plus a structural snapshot for the floors
and shafts. Both read the same simulation.
use verticopolis_engine::clock::GameMode;
use verticopolis_engine::frame::{frame_view, header, FRAME_LAYOUT_VERSION};
use verticopolis_engine::sim::{Simulation, STARTING_MONEY};
let sim = Simulation::new_game(1, GameMode::Classic);
let frame = frame_view(&sim);
assert_eq!(frame[header::MONEY], STARTING_MONEY);
assert_eq!(frame[header::PEOPLE], 0.0);Modules§
- car
- The slots of one car in a transport record, counted from the car’s start.
- header
- The header slots of the frame view by name, so a native decoder reads
v[header::MONEY]instead of a bare index. A group of values starts at its named slot:EXPLOSION_FXis seq, floor, x;THIEF_FXis seq, caught, floor;TREASURE_FXis seq, floor, x;EVENT_COUNTSis fires, firesGutRooms, bombs.frame_viewdescribes each value. - person
- The fixed slots of a person record by name, counted from the record’s
start. The route follows them:
FLOOR_COUNTfloors, thenSHAFT_COUNTshafts. - transport
- The slots of a transport record by name:
IDandCARS, thenCARScar records ofCAR_RECORDslots, each laid out ascar. - unit
- The slots of a unit record by name.
Constants§
- CAR_
RECORD - Slots of each car in a transport record.
- FRAME_
HEADER - Fixed header slots of the frame view, before the three variable sections.
- FRAME_
LAYOUT_ VERSION - The version of the frame’s layout, also in
crate::identity::identity. It goes up when a slot moves, a record’s width changes, or a slot or code changes meaning, so a decoder can refuse a layout it was not written for. - PERSON_
FIXED - Fixed slots of a person record, before its route (
floorsthenshafts). - TRANSPORT_
FIXED - Slots of a transport record before its cars.
- UNIT_
RECORD - Slots of a unit record.
- UNKNOWN_
ROUTINE - The routine code for a routine this layout has no code for yet. A decoder should refuse a frame that carries it: the engine has gained a routine the decoder does not know.
Functions§
- frame_
view - The frame: every value a renderer reads between two structural reads, flat, so it crosses to another language as one array of numbers.
- log_
since - The log messages numbered after
seq, oldest first, as JSON. The newest message’s number is the frame’sheader::LOG_SEQ, so a host passes the last number it showed and gets only the new ones.