Expand description
What a renderer reads, sized for a frame budget. Three reads cover it:
structure_view: the floors, lobbies, rooms and shafts, as flat records. Read it when you start, after a load, and whenever the frame header’s tower revision moves (a build, a sale, a fire).ViewReader::frame: everything that moves, every frame: the clock, money and rating, the people, the cars, and only the rooms whose fields changed since this reader’s last frame.meta_since: room names and subtypes that changed, read when the frame header’s meta revision moves.
layout names every slot, and layout_json hands the same tables
and every code over as JSON. None of these reads changes the game.
use verticopolis_engine::clock::GameMode;
use verticopolis_engine::facilities::Kind;
use verticopolis_engine::sim::Simulation;
use verticopolis_engine::view::{layout, structure_view, ViewReader};
let mut sim = Simulation::new_game(1, GameMode::Classic);
let tiles: Vec<i64> = (100..124).collect();
sim.paint_brush(Kind::Lobby, 1, &tiles);
let structure = structure_view(&sim);
assert_eq!(structure[layout::structure::LOWEST_FLOOR], 1.0);
let mut reader = ViewReader::new();
let first = reader.frame(&sim, false);
assert_eq!(first[layout::header::FRAME_SEQ], 1.0);
sim.tick(1.0);
let next = reader.frame(&sim, false);
assert_eq!(next[layout::header::FRAME_SEQ], 2.0);Re-exports§
pub use layout::layout_json;pub use layout::VIEW_LAYOUT_VERSION;
Modules§
- layout
- Every slot and record width of the view’s frame and structural snapshot,
by name. Decode both with these, such as
frame[header::MONEY], never with bare numbers.super::layout_jsonhands the same tables over as JSON, with the state, weather, mode and calendar codes, for a host in another language.
Structs§
- View
Reader - Reads the view’s frame for one game, sending only what changed since its last frame. Keep one per game: a host that loads another game starts a new reader. A reader handed another game sends a full frame.
Functions§
- meta_
since - The metadata a view needs after
since, as{ "revision", "full", "units": [[id, label, subtype], ...] }(layout::META_RECORDnames the record’s fields). - structure_
view - The structural snapshot as one flat number array.