Skip to main content

Environment

Struct Environment 

Source
pub struct Environment {
    pub climate: Climate,
    pub state: i32,
    pub level: i32,
    pub temperature: f32,
    pub season: SeasonValues,
    pub effects: [Option<WeatherEffect>; 2],
    pub fade_times: [Option<f32>; 2],
    pub tornado_timer: i64,
    pub game_flags: u32,
    /* private fields */
}
Expand description

The environment: temperature, weather and the renderer’s seasonal values. See the module documentation.

Fields§

§climate: Climate

The climate.

§state: i32

0 precipitation, 1 cloudy, 2 partly sunny, 3 sunny.

§level: i32

Precipitation level 0..5 (starts at 4).

§temperature: f32

°F.

§season: SeasonValues

The renderer’s seasonal values.

§effects: [Option<WeatherEffect>; 2]

The Rain and Snow effects while they exist.

§fade_times: [Option<f32>; 2]

Weather of each slot’s description: seconds to fade in or out. A slot without a loaded description never starts.

§tornado_timer: i64

The time since the last tornado check.

§game_flags: u32

Game: bit 7 stops tornadoes (set with disasters off).

Implementations§

Source§

impl Environment

Source

pub fn restore( &mut self, state: i32, level: i32, temperature: f32, season: SeasonValues, baseline: (f32, f32), bias: (f32, f32), slice: i32, effects: [Option<WeatherEffect>; 2], )

The environment as a save stores it: the state, the level, the temperature, the renderer’s values, the baseline, the bias, the last slice, and each weather effect that exists (made again on load with its direction and intensity).

Original: FUN_140099160.

Deviation: the temperature noise (+0x34) is not saved; after a load the original keeps its constructor’s clock-seeded field until the next reseed (slice 0 or 24). The port keeps its constructor’s fixed seed.

Source

pub fn saved(&self) -> ((f32, f32), (f32, f32), i32)

What Environment::restore takes, for saving: baseline and bias with their targets, and the last slice.

Source

pub fn new(climate: Climate) -> Environment

A new environment for a climate: state 0, level 4, and the climate’s baseline.

Original: FUN_140099430, then FUN_140099300.

Deviation: the constructor seeds its first Perlin field from two clock-seeded Random()s; the first update always reseeds it (slice 0), so a fixed seed is used here.

Source

pub fn update(&mut self, elapsed: f32, dt: f32, rng: &mut Random) -> bool

One simulation iteration. elapsed is the calendar’s time into the current year in seconds, already advanced for this iteration; dt is the iteration’s step; rng is the game’s shared random stream (Game/Game).

Returns whether a tornado forms (step 6): this can happen while it rains above 34 °F with tornadoes on. The caller then creates the environment template’s entity.

Original: FUN_1400999b0, FUN_1400c8bf0, FUN_1400c9d70.

Source

pub fn active_effect(&self, weather_enabled: bool) -> Option<usize>

Which weather effect slot is active: only in state 0 with weather enabled; slot 0 Rain above 34°, slot 1 Snow at or below.

Original: FUN_1400999b0, FUN_140099790.

Trait Implementations§

Source§

impl Clone for Environment

Source§

fn clone(&self) -> Environment

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Environment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.