pub struct Agents {
pub characters: Vec<Character>,
pub ais: Vec<CitizenAi>,
pub states: Vec<CitizenState>,
pub life: LifeRules,
pub registry: Vec<usize>,
pub events: Vec<LifeEvent>,
pub diseases: Vec<Disease>,
pub town_disease: f32,
pub carry: i32,
pub sounds: AnimationSounds,
/* private fields */
}Expand description
The citizens’ agents: each citizen’s AI and character, and the state the iteration needs.
Fields§
§characters: Vec<Character>The citizens’ characters.
ais: Vec<CitizenAi>The citizens’ AI.
states: Vec<CitizenState>The citizens’ states.
life: LifeRulesThe CitizenDescription for the CitizenComponent’s update.
registry: Vec<usize>The living citizens, in activation order.
events: Vec<LifeEvent>Log entries the citizens asked for since the caller last took them.
diseases: Vec<Disease>Game/Disease/Diseases.rsc (GameGlobal).
town_disease: f32The town’s disease level.
carry: i32The laborer profession’s carry amount (what home stocking carries at least).
sounds: AnimationSoundsThe sound events the citizens’ and animals’ clips fire.
Implementations§
Source§impl Agents
impl Agents
Sourcepub fn apply_commands(
&mut self,
citizens: &mut Vec<Citizen>,
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen,
)
pub fn apply_commands( &mut self, citizens: &mut Vec<Citizen>, env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen, )
Player commands and newly placed sites, applied before an iteration (where the original’s UI events and placement land between iterations).
Sourcepub fn set_tree_slot(&mut self, i: usize, slot: i32)
pub fn set_tree_slot(&mut self, i: usize, slot: i32)
Citizen i‘s place in the characters’ tree, put in by whoever made it.
Source§impl Agents
impl Agents
Sourcepub fn road_path(
&mut self,
cells: &Cells,
a: i32,
b: i32,
mask: u32,
manhattan: bool,
) -> Option<Vec<i32>>
pub fn road_path( &mut self, cells: &Cells, a: i32, b: i32, mask: u32, manhattan: bool, ) -> Option<Vec<i32>>
The cells of a road from a to b, over mask, avoiding the cells of zones. The road
tool uses it.
Original: FUN_1400a22d0.
Sourcepub fn walk_path(&mut self, cells: &Cells, a: i32, b: i32) -> Option<Vec<i32>>
pub fn walk_path(&mut self, cells: &Cells, a: i32, b: i32) -> Option<Vec<i32>>
A citizen’s walk from a to b as the path manager finds it (mask 0xe1f, mode 0), for
the Path tool; the finder’s state is kept.
Original: FUN_1400a2480, FUN_1400e2c40.
Sourcepub fn update_commute(
&mut self,
citizens: &[Citizen],
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
dt: i64,
)
pub fn update_commute( &mut self, citizens: &[Citizen], env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], dt: i64, )
StockManager::Update’s commute optimisation (see crate::behaviour::commute) by dt
ticks.
Original: FUN_140091780.
Source§impl Agents
impl Agents
Sourcepub fn move_animals(
&mut self,
wildlife: &mut Wildlife,
cells: &Cells,
terrain: &HeightGrid<'_>,
rng: &mut Random,
materials: &[RawMaterial],
dt: f32,
)
pub fn move_animals( &mut self, wildlife: &mut Wildlife, cells: &Cells, terrain: &HeightGrid<'_>, rng: &mut Random, materials: &[RawMaterial], dt: f32, )
The wild animals’ character update: animate, run the actions, turn and move.
Deviation: the entity manager runs these updates in the order of a tree keyed by the entity’s address; the port takes them in the order they were made, which a growing heap usually gives too.
Original: FUN_14010e990; the order comes from FUN_1400c9560, FUN_1400c82b0 and the
tree at manager +0x68 (FUN_1400c90a0).
Source§impl Agents
impl Agents
Sourcepub fn split_visits(
visits: &[(usize, i64)],
) -> (Vec<(usize, i64)>, Vec<(usize, i64)>)
pub fn split_visits( visits: &[(usize, i64)], ) -> (Vec<(usize, i64)>, Vec<(usize, i64)>)
The bucket visits in visits split into the placed entities’ (sites, piles) and the
citizens’ (from EXTRA, as citizen indices), each in visiting order.
Sourcepub fn every_iteration(
&mut self,
citizens: &mut Vec<Citizen>,
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
dt: f32,
newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen,
)
pub fn every_iteration( &mut self, citizens: &mut Vec<Citizen>, env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], dt: f32, newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen, )
The citizens’ part of an iteration’s every-iteration phase (bit 0x04): the town step,
the job icons, every citizen’s character (animation, actions, movement), then the sites’
state machines, nomads, boats and tornadoes. groups[i] is citizen i’s animation group
(None for the dead); newborn makes a child, with its random draws.
Original: FUN_1400c9560 (the bit-0x04 set).
Sourcepub fn visit_sites(
&mut self,
citizens: &mut [Citizen],
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
dt: f32,
site_visits: &[(usize, i64)],
)
pub fn visit_sites( &mut self, citizens: &mut [Citizen], env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], dt: f32, site_visits: &[(usize, i64)], )
Bucket 3’s visits (sites and piles), in visiting order, each with the time since its last
visit, entity by entity: blight, fire, the state machine’s scheduled update (with a
residence’s storage and hearth), hunt, attendance, and a pile’s age. dt is the
iteration’s time.
Original: FUN_1400c9560 (bucket 3).
Sourcepub fn visit_citizens(
&mut self,
citizens: &mut Vec<Citizen>,
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
visits: &[(usize, i64)],
newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen,
)
pub fn visit_citizens( &mut self, citizens: &mut Vec<Citizen>, env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], visits: &[(usize, i64)], newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen, )
Bucket 1’s visits (the scheduler’s values: citizens from EXTRA, nomads by entity), in
visiting order, each with the time since its last visit: a citizen’s character notify,
CitizenComponent, then CitizenAIComponent; a nomad’s character notify.
Original: FUN_1400c9560 (bucket 1).
Sourcepub fn finish(
&mut self,
citizens: &mut Vec<Citizen>,
env: &mut Env<'_, '_>,
groups: &[Option<&AnimationGroup>],
)
pub fn finish( &mut self, citizens: &mut Vec<Citizen>, env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], )
The end of an iteration, after every bucket: destroyed sites leave, the burials’ tombstones are placed, and the queued citizens are deleted (each component’s remove slot).
Original: FUN_1400c9560 (its deletions).
Source§impl Agents
impl Agents
Sourcepub fn new(
citizens: &[Citizen],
cells: &Cells,
desc: CharacterDescription,
rules: CitizenRulesAi,
carried: Storage,
scale: impl Fn(&Citizen) -> f32,
) -> Agents
pub fn new( citizens: &[Citizen], cells: &Cells, desc: CharacterDescription, rules: CitizenRulesAi, carried: Storage, scale: impl Fn(&Citizen) -> f32, ) -> Agents
New agents with no citizens.
Sourcepub fn rules(&self) -> CitizenRulesAi
pub fn rules(&self) -> CitizenRulesAi
The AI’s rules, from the citizen description.