diff --git a/src/gas.rs b/src/gas.rs index 9656ea8..ba4dc21 100644 --- a/src/gas.rs +++ b/src/gas.rs @@ -465,10 +465,16 @@ where ) } +/// Gets the amount of gases that are active in byond. +/// # Panics +/// if `GAS_MIXTURES` hasn't been initialized, somehow. pub fn amt_gases() -> usize { GAS_MIXTURES.read().as_ref().unwrap().len() - NEXT_GAS_IDS.read().as_ref().unwrap().len() } +/// Gets the amount of gases that are allocated, but not necessarily active in byond. +/// # Panics +/// if `GAS_MIXTURES` hasn't been initialized, somehow. pub fn tot_gases() -> usize { GAS_MIXTURES.read().as_ref().unwrap().len() } diff --git a/src/parser.rs b/src/parser.rs index 80417de..0c5a795 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -17,7 +17,8 @@ fn parse_moles(input: &str) -> IResult<&str, f32> { float(input) } -//parses the gas string, invalid patterns will be ignored +/// Parses gas strings, invalid patterns will be ignored +/// E.g: "o2=2500;plasma=5000;TEMP=370" will return vec![("o2", 2500_f32), ("plasma", 5000_f32), ("TEMP", 370_f32)] pub fn parse_gas_string(input: &str) -> IResult<&str, Vec<(&str, f32)>> { separated_list0( tag(";"), diff --git a/src/reaction.rs b/src/reaction.rs index 6e21ac5..f6b8860 100644 --- a/src/reaction.rs +++ b/src/reaction.rs @@ -138,6 +138,7 @@ impl Reaction { })?; Ok(our_reaction) } + /// Gets the reaction's identifier. #[must_use] pub fn get_id(&self) -> ReactionIdentifier { self.id diff --git a/src/turfs.rs b/src/turfs.rs index f05fb2b..1af87a7 100644 --- a/src/turfs.rs +++ b/src/turfs.rs @@ -106,10 +106,12 @@ struct TurfMixture { #[allow(dead_code)] impl TurfMixture { + /// Whether the turf is processed at all or not pub fn enabled(&self) -> bool { self.flags.intersects(SimulationFlags::SIMULATION_ANY) } + /// Whether the turf's gas is immutable or not, see [`super::gas::Mixture`] pub fn is_immutable(&self) -> bool { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -119,6 +121,7 @@ impl TurfMixture { .is_immutable() }) } + /// Returns the pressure of the turf's gas, see [`super::gas::Mixture`] pub fn return_pressure(&self) -> f32 { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -128,6 +131,7 @@ impl TurfMixture { .return_pressure() }) } + /// Returns the temperature of the turf's gas, see [`super::gas::Mixture`] pub fn return_temperature(&self) -> f32 { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -137,6 +141,7 @@ impl TurfMixture { .get_temperature() }) } + /// Returns the total moles of the turf's gas, see [`super::gas::Mixture`] pub fn total_moles(&self) -> f32 { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -146,6 +151,7 @@ impl TurfMixture { .total_moles() }) } + /// Clears the turf's airs, see [`super::gas::Mixture`] pub fn clear_air(&self) { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -155,6 +161,7 @@ impl TurfMixture { .clear(); }); } + /// Copies from a given gas mixture to the turf's airs, see [`super::gas::Mixture`] pub fn copy_from_mutable(&self, sample: &Mixture) { GasArena::with_all_mixtures(|all_mixtures| { all_mixtures @@ -164,7 +171,9 @@ impl TurfMixture { .copy_from_mutable(sample); }); } - pub fn clear_vol(&self, amt: f32) { + /// Clears a number of moles from the turf's air + /// If the number of moles is greater than the turf's total moles, just clears the turf + pub fn clear_moles(&self, amt: f32) { GasArena::with_all_mixtures(|all_mixtures| { let moles = all_mixtures .get(self.mix) @@ -188,6 +197,7 @@ impl TurfMixture { } }); } + /// Gets a copy of the turf's airs, see [`super::gas::Mixture`] pub fn get_gas_copy(&self) -> Mixture { let mut ret: Mixture = Mixture::new(); GasArena::with_all_mixtures(|all_mixtures| { @@ -200,6 +210,9 @@ impl TurfMixture { }); ret } + /// Invalidates the turf's visibility cache + /// This turf will most likely be visually updated the next processing cycle + /// If that is even running pub fn invalidate_vis_cache(&self) { self.vis_hash.store(0, std::sync::atomic::Ordering::Relaxed); } @@ -227,24 +240,6 @@ impl TurfGases { self.graph.remove_node(index); } } - /* - pub fn invalidate(&mut self) { - *self.map.lock() = None; - } - */ - /* - pub fn turf_id_map(&self) -> TurfGraphMap { - self.map - .lock() - .get_or_insert_with(|| { - self.graph. - .enumerate() - .map(|(i, n)| (n.weight.id, NodeIndex::from(i))) - .collect() - }) - .clone() - } - */ pub fn update_adjacencies(&mut self, idx: TurfID, adjacent_list: List) -> Result<(), Runtime> { if let Some(&this_index) = self.map.get(&idx) { self.remove_adjacencies(this_index);