pub struct CitizenAi {
pub current: u32,
pub queued: Option<u32>,
pub eating: bool,
pub warming: bool,
pub cooldowns: [i64; 16],
pub since_loiter: i64,
pub carrying_time: i64,
}Expand description
A citizen’s AI: the cooldown of each activity, the current and queued activity, and the urgent flags.
Fields§
§current: u32The current activity.
queued: Option<u32>The queued activity, if any.
eating: boolEating urgently.
warming: boolWarming up urgently.
cooldowns: [i64; 16]Per-activity cooldowns (ticks).
since_loiter: i64The time since the citizen last loitered.
carrying_time: i64How long the citizen has carried goods (reset while it carries nothing).
Implementations§
Source§impl CitizenAi
impl CitizenAi
Sourcepub fn tick(&mut self, dt: i64, carrying: i32)
pub fn tick(&mut self, dt: i64, carrying: i32)
Count cooldowns down, advance the loiter and carry clocks.
Original: FUN_1401148b0 (timers).
Sourcepub fn update(
&mut self,
dt: i64,
view: &CitizenView,
d: &Thresholds,
rng: &mut Random,
busy: impl Fn() -> bool,
run: impl FnMut(&mut CitizenAi, u32, &mut Random) -> bool,
)
pub fn update( &mut self, dt: i64, view: &CitizenView, d: &Thresholds, rng: &mut Random, busy: impl Fn() -> bool, run: impl FnMut(&mut CitizenAi, u32, &mut Random) -> bool, )
The scheduled update. busy is the character’s “has actions” test; run dispatches an
activity (see CitizenAi::choose). Eating from a stocked home before an urgent choice and
the per-profession inventory size and model refresh are the caller’s.
Original: FUN_14011a7b0, FUN_140114c70, FUN_140114d60, FUN_1401148b0.
Sourcepub fn choose(
&mut self,
view: &CitizenView,
d: &Thresholds,
urgent_only: bool,
rng: &mut Random,
run: impl FnMut(&mut CitizenAi, u32, &mut Random) -> bool,
)
pub fn choose( &mut self, view: &CitizenView, d: &Thresholds, urgent_only: bool, rng: &mut Random, run: impl FnMut(&mut CitizenAi, u32, &mut Random) -> bool, )
Run the queued activity, or try candidates in order until run leaves the character busy.
run(activity) is the dispatcher and returns whether the character now has actions queued.
Original: FUN_1401146c0, FUN_140113060.