Module scheduler
Expand description
The bit-exact foundations, from their own crate (banished-core).
Game time, and the entity manager’s update buckets.
Time. The engine counts time in integer microseconds (System::Time). ticks and
seconds convert as the original does: through f64, truncating to time and rounding to
f32 seconds.
Buckets. A town has tens of thousands of entities, so the game does not update all of them
in every simulation iteration. EntityScheduler keeps them in five buckets, and each
iteration visits at most QUOTAS entities of each bucket, starting where the last visit
stopped. Each entity receives the time since its own last visit, so no time is lost.
use banished_core::scheduler::{seconds, ticks};
assert_eq!(ticks(1.5), 1_500_000);
assert_eq!(seconds(ticks(1.5)), 1.5);The port’s handles are stable indices; the engine uses object pointers. Removing an entity still swaps it with the last one of its bucket, as in the engine.
Original: FUN_1400c9460, FUN_1400c9560, FUN_1400c9d70.
Structs§
- Entity
Scheduler - The entity manager’s buckets: which entities are visited in each simulation iteration, and
the time each one has had since its last visit.
Tis the caller’s value for an entity.
Constants§
- EXTRA
- Handles of entities registered with
EntityScheduler::register_extrastart here, so that a placed entity’s handle stays its index. The game gives such entities values from here too: citizensEXTRA + citizen, and entities the town does not model (the map ambience, a saved game’s entities of templates it skips) fromFOREIGN. - FOREIGN
- Values of scheduled entities with no behaviour in the port (visited for the cursors’ sake).
- QUOTAS
- How many entities of each bucket one iteration visits, for buckets 0 to 4.
- SECONDS_
PER_ TICK - The length of one tick of game time, in seconds: the engine’s timer counts 1,000,000 ticks per second.