pub struct Jobs {
pub pass: i32,
pub works: BTreeMap<i32, Work>,
pub time: i64,
/* private fields */
}Expand description
The manager.
Fields§
§pass: i32Pass counter (one per simulation iteration).
Original: FUN_14009b850.
works: BTreeMap<i32, Work>Id → work.
time: i64Manager clock (ticks), advanced with the pass.
Implementations§
Source§impl Jobs
impl Jobs
Sourcepub fn step(&mut self, dt: i64)
pub fn step(&mut self, dt: i64)
One simulation iteration of the job manager.
Original: FUN_1400fe650, and the step in FUN_14009b850.
Sourcepub fn add(&mut self, work: Work, mask: u32, keep: Option<i32>) -> i32
pub fn add(&mut self, work: Work, mask: u32, keep: Option<i32>) -> i32
Register a work. With keep, the work gets that priority (moved down past any value already
taken), else the next one in sequence. Returns the work’s id.
Original: FUN_1400fdd70(work, mask, keep, priority).
Sourcepub fn restore(
&mut self,
next_id: i32,
next_priority: i32,
pass: i32,
works: impl IntoIterator<Item = (Work, Vec<u32>)>,
professions: &[usize],
)
pub fn restore( &mut self, next_id: i32, next_priority: i32, pass: i32, works: impl IntoIterator<Item = (Work, Vec<u32>)>, professions: &[usize], )
A saved manager: its counters, then each work with the categories it was filed under (1..14), and the professions its profession map holds. The priority index is rebuilt from the works’ own priorities, as the load pass does; the clock is not saved and restarts at 0.
Original: FUN_1400fe710.
Sourcepub fn category(&self, c: u32) -> Vec<i32>
pub fn category(&self, c: u32) -> Vec<i32>
The works filed under category c (1..14), in id order.
Sourcepub fn by_profession(&self) -> Vec<(usize, Vec<i32>)>
pub fn by_profession(&self) -> Vec<(usize, Vec<i32>)>
The works by profession, in profession then id order.
Sourcepub fn remove(&mut self, id: i32, host: &mut impl WorkHost)
pub fn remove(&mut self, id: i32, host: &mut impl WorkHost)
Unregister, refresh, cancel every worker, delete.
Original: FUN_1400fe300.
Sourcepub fn drain(&mut self, host: &mut impl WorkHost)
pub fn drain(&mut self, host: &mut impl WorkHost)
Deliver the host’s pending job events in order.
Sourcepub fn prioritize(&mut self, id: i32)
pub fn prioritize(&mut self, id: i32)
Move a work to the front (lowest priority − 1).
Original: FUN_1400fefa0.
Sourcepub fn change_profession(&mut self, id: i32, from: usize, to: usize)
pub fn change_profession(&mut self, id: i32, from: usize, to: usize)
Move a work from one profession’s list to another’s.
Original: FUN_1400fd8d0.
Sourcepub fn complete(
&mut self,
id: i32,
citizen: usize,
param: i32,
host: &mut impl WorkHost,
)
pub fn complete( &mut self, id: i32, citizen: usize, param: i32, host: &mut impl WorkHost, )
A task finished (the start of CompleteTask): remove the work when its slot says it is
done.
Original: FUN_1400fdc30.
Sourcepub fn fail(
&mut self,
id: i32,
citizen: usize,
param: i32,
host: &mut impl WorkHost,
)
pub fn fail( &mut self, id: i32, citizen: usize, param: i32, host: &mut impl WorkHost, )
A task failed (CompleteTask cancelled).
Original: FUN_1400fdcd0.
Sourcepub fn offer_one(
&mut self,
id: i32,
citizen: usize,
again: bool,
host: &mut impl WorkHost,
) -> bool
pub fn offer_one( &mut self, id: i32, citizen: usize, again: bool, host: &mut impl WorkHost, ) -> bool
Offer one work by id, with a second try when the first answers “not now” and again is set.
Original: FUN_1400fdaf0.
Sourcepub fn assign_work(&mut self, citizen: usize, host: &mut impl WorkHost)
pub fn assign_work(&mut self, citizen: usize, host: &mut impl WorkHost)
Give a citizen work: activity 9.
Original: FUN_1400fcd00.
Sourcepub fn assign_emergency(
&mut self,
citizen: usize,
host: &mut impl WorkHost,
) -> bool
pub fn assign_emergency( &mut self, citizen: usize, host: &mut impl WorkHost, ) -> bool
Give a citizen emergency work (activity 2), for example fighting a fire. Returns whether there was some.
Original: FUN_1400fca20.