Skip to main content

World

Struct World 

Source
pub struct World<'a> {
Show 24 fields pub size: usize, pub types: &'a [CellType], pub objects: &'a [Option<usize>], pub occupants: &'a [Option<usize>], pub flags: &'a [u8], pub roads: &'a [u8], pub floors: &'a Floors, pub regions: &'a [u16], pub terrain: &'a HeightGrid<'a>, pub pathfinder: &'a mut Pathfinder, pub rng: &'a mut Random, pub messages: &'a mut Vec<Message>, pub used: &'a mut Vec<(usize, i32)>, pub storages: &'a mut [Storage], pub materials: &'a [RawMaterial], pub carried: &'a mut Storage, pub storage_search: Option<&'a mut StorageSearch<'a>>, pub pushes: Vec<Action>, pub tool_uses: &'a mut i32, pub shown_tool: &'a mut i32, pub animating: &'a mut [bool], pub accident: &'a mut Option<usize>, pub accident_timer: &'a mut i64, pub accident_odds: Option<(usize, f32, f32)>,
}
Expand description

What a character needs from the world to move: the map, the ground and the path finder.

Fields§

§size: usize

The map’s size in cells.

§types: &'a [CellType]

The type of each map cell.

§objects: &'a [Option<usize>]

The object stamped into each map cell.

§occupants: &'a [Option<usize>]

The occupant of each map cell.

§flags: &'a [u8]

The flags of each map cell.

§roads: &'a [u8]

The road kind planned or built (0xff none).

§floors: &'a Floors

The floors (bridge decks) that characters walk on.

§regions: &'a [u16]

The walkable region of each cell.

§terrain: &'a HeightGrid<'a>

The ground’s heights.

§pathfinder: &'a mut Pathfinder

The pathfinder.

§rng: &'a mut Random

The game’s random numbers.

§messages: &'a mut Vec<Message>

The messages that actions send, delivered after the update.

§used: &'a mut Vec<(usize, i32)>

What ConsumeRawMaterial used up (material, amount), for the stock manager’s count.

§storages: &'a mut [Storage]

The town’s storages.

§materials: &'a [RawMaterial]

The raw materials.

§carried: &'a mut Storage

What the character carries.

§storage_search: Option<&'a mut StorageSearch<'a>>

The drop-off redirect’s storage search (citizens only).

§pushes: Vec<Action>

Actions an action pushed from its start (ActionStack::Push), pushed once it returns.

§tool_uses: &'a mut i32

Citizen: tool uses left (PerformWork with a tool spends one).

§shown_tool: &'a mut i32

The tool ShowTool attached (-1 none, -2 carried goods).

§animating: &'a mut [bool]

Per placed entity: its model is playing an animation (MeshInstance::IsAnimating).

§accident: &'a mut Option<usize>

A citizen’s accident: the profession whose work it had the accident at.

§accident_timer: &'a mut i64

The time since the last check for an injury at work.

§accident_odds: Option<(usize, f32, f32)>

The current job’s profession (→ the work’s slot) and its accident odds.

Implementations§

Source§

impl World<'_>

Source

pub fn injury_check(&mut self) -> bool

Already hurt, or, at a job whose profession has accidents, RandFloat < time since the last check / (× 12 × 300 s ×) (the time restarts at every check). Not ported: the debug flag that stops it (Game bit 8).

Original: Citizen::InjuryCheck, FUN_14011bb20, FUN_1400ae760.

Source

pub fn cell(&self, p: [f32; 3]) -> i32

Cell under a map position (clamped, as every caller in the original does).

Source

pub fn cell_centre(&self, cell: i32) -> [f32; 3]

Centre of a cell on the ground (on a bridge’s floor).

Original: FUN_1400a48b0.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for World<'a>

§

impl<'a> !Send for World<'a>

§

impl<'a> !Sync for World<'a>

§

impl<'a> !UnwindSafe for World<'a>

§

impl<'a> Freeze for World<'a>

§

impl<'a> Unpin for World<'a>

§

impl<'a> UnsafeUnpin for World<'a>

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.