Skip to main content

WorkHost

Trait WorkHost 

Source
pub trait WorkHost {
Show 20 methods // Required methods fn profession(&self, citizen: usize) -> usize; fn workplace(&self, citizen: usize) -> Option<usize>; fn cell(&self, citizen: usize) -> i32; fn has_emergency(&self, citizen: usize) -> bool; fn works_anywhere(&self, profession: usize) -> bool; fn rank(&mut self, a: i32, b: i32) -> i32; fn stock(&self, slot: usize) -> (i32, i32); fn laborer(&self) -> usize; fn builder(&self) -> usize; fn rng(&mut self) -> &mut Random; fn refresh(&mut self, work: &mut Work); fn try_assign(&mut self, work: &mut Work, citizen: usize, time: i64) -> u8; fn complete(&mut self, work: &mut Work, citizen: usize, param: i32) -> bool; fn fail(&mut self, work: &mut Work, citizen: usize, param: i32); fn cancel(&mut self, work: &mut Work); // Provided methods fn try_assign_again( &mut self, _work: &mut Work, _citizen: usize, _time: i64, ) -> bool { ... } fn take_events(&mut self) -> Vec<JobEvent> { ... } fn take_offers(&mut self) -> Vec<i32> { ... } fn offers_again(&mut self) -> bool { ... } fn resume(&mut self, _work: &mut Work, _citizen: usize) -> u8 { ... }
}
Expand description

The citizen and world queries and the work slots the manager calls.

Required Methods§

Source

fn profession(&self, citizen: usize) -> usize

Citizen +0x1f0, +0x248, the character’s cell, and FUN_14011b0b0.

Source

fn workplace(&self, citizen: usize) -> Option<usize>

The citizen’s workplace.

Source

fn cell(&self, citizen: usize) -> i32

The citizen’s map cell.

Source

fn has_emergency(&self, citizen: usize) -> bool

Whether there is an emergency near the citizen.

Source

fn works_anywhere(&self, profession: usize) -> bool

Profession +0x4c.

Source

fn rank(&mut self, a: i32, b: i32) -> i32

FUN_1400a4ce0(map, a, b, 1), with the callers’ fallback n + (int)sqrtf(d²).

Source

fn stock(&self, slot: usize) -> (i32, i32)

The stock manager’s (count, limit) per slot (Game +0xf0 → +0x170).

Source

fn laborer(&self) -> usize

The laborer and builder professions (Game +0xb0 → +0x30/+0x38).

Source

fn builder(&self) -> usize

The builder profession.

Source

fn rng(&mut self) -> &mut Random

The game’s random numbers.

Source

fn refresh(&mut self, work: &mut Work)

Slot +0x48: refresh (drop workers that no longer hold this work’s task).

Source

fn try_assign(&mut self, work: &mut Work, citizen: usize, time: i64) -> u8

Slot +0x20: 0 cannot, 1 not now, 2 assigned. time is the manager’s clock +0x130.

Source

fn complete(&mut self, work: &mut Work, citizen: usize, param: i32) -> bool

Slot +0x30: a CompleteTask finished; true removes the work.

Source

fn fail(&mut self, work: &mut Work, citizen: usize, param: i32)

Slot +0x38: a CompleteTask was aborted.

Source

fn cancel(&mut self, work: &mut Work)

Slot +0x40: clear every worker’s action stack (their CompleteTask aborts call WorkHost::fail on this work, which the host handles directly).

Provided Methods§

Source

fn try_assign_again( &mut self, _work: &mut Work, _citizen: usize, _time: i64, ) -> bool

Slot +0x28 (the base returns false).

Source

fn take_events(&mut self) -> Vec<JobEvent>

Job messages raised while the host ran a slot (aborted CompleteTasks of other works), for the manager to deliver: (work, citizen, param, completed).

Source

fn take_offers(&mut self) -> Vec<i32>

Works a slot +0x20 asked the manager to offer in its place (FUN_1400fdaf0 called from inside a try, as ClearArea does with the piles in its footprint), in order. A try answering NESTED has queued them.

Source

fn offers_again(&mut self) -> bool

The queued offers get a second try (FUN_1400fdaf0(.., 1)).

Source

fn resume(&mut self, _work: &mut Work, _citizen: usize) -> u8

After a NESTED answer none of whose offers was taken: the rest of the try (ConsumeProduce goes on to work a cycle).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl WorkHost for Sim<'_, '_>