Skip to main content

Agents

Struct Agents 

Source
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,
    /* 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: LifeRules

The 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: f32

The town’s disease level.

§carry: i32

The laborer profession’s carry amount (what home stocking carries at least).

Implementations§

Source§

impl Agents

Source

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).

Source

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

Source

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.

Source

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.

Source

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

Source

pub fn update( &mut self, citizens: &mut Vec<Citizen>, env: &mut Env<'_, '_>, groups: &[Option<&AnimationGroup>], dt: f32, newborn: &mut dyn FnMut(&mut Random, &Citizen, bool) -> Citizen, )

One simulation iteration of every citizen. groups[i] is citizen i’s animation group (None for the dead); newborn makes a child, with its random draws.

Source

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

Source

pub fn new( citizens: &[Citizen], cells: &Cells, desc: CharacterDescription, rules: CitizenRulesAi, carried: Storage, scale: impl Fn(&Citizen) -> f32, ) -> Agents

New agents with no citizens.

Source

pub fn rules(&self) -> CitizenRulesAi

The AI’s rules, from the citizen description.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.