pub struct ResourceNode {Show 18 fields
pub id: NodeId,
pub name: String,
pub kind: NodeKind,
pub output_commodity: CommodityRef,
pub base_yield_per_worker: f64,
pub reserves: Option<f64>,
pub max_reserves: Option<f64>,
pub workers_assigned: u32,
pub worker_capacity: u32,
pub stockpile: f64,
pub stockpile_capacity: f64,
pub efficiency: f64,
pub degradation_rate: f64,
pub maintenance_due_in: u64,
pub disruption: f64,
pub season_modifier: f64,
pub output_history: VecDeque<f64>,
pub active: bool,
}Expand description
A resource extraction node in the world.
Fields§
§id: NodeId§name: String§kind: NodeKind§output_commodity: CommodityRefThe commodity this node produces.
base_yield_per_worker: f64Base output per worker per tick.
reserves: Option<f64>Remaining reserves (None = infinite for renewable).
max_reserves: Option<f64>Maximum reserves (for computing depletion fraction).
workers_assigned: u32Workers currently assigned.
worker_capacity: u32Maximum worker capacity.
stockpile: f64Accumulated stockpile (output not yet transferred).
stockpile_capacity: f64Maximum stockpile before output is lost.
efficiency: f64Current efficiency (0.0 – 1.0 plus bonuses).
degradation_rate: f64Degradation: amount efficiency decays per tick without maintenance.
maintenance_due_in: u64Ticks until scheduled maintenance (0 = needs maintenance).
disruption: f64Disruption severity (0 = none, 1 = fully halted).
season_modifier: f64Season modifier (1.0 = normal, farm might be 0.0 in winter).
output_history: VecDeque<f64>Output history ring buffer (last 64 ticks).
active: boolWhether this node is active.
Implementations§
Source§impl ResourceNode
impl ResourceNode
pub fn new( id: NodeId, name: &str, kind: NodeKind, output_commodity: CommodityRef, base_yield_per_worker: f64, reserves: Option<f64>, worker_capacity: u32, stockpile_capacity: f64, ) -> Self
Sourcepub fn assign_workers(&mut self, count: u32) -> u32
pub fn assign_workers(&mut self, count: u32) -> u32
Assign up to count additional workers. Returns how many were actually assigned.
Sourcepub fn remove_workers(&mut self, count: u32)
pub fn remove_workers(&mut self, count: u32)
Remove workers.
Sourcepub fn compute_output(&self, rng_variance: f64) -> f64
pub fn compute_output(&self, rng_variance: f64) -> f64
Compute gross output for this tick before stockpile and reserve limits.
Sourcepub fn tick_output(&mut self, rng_variance: f64) -> f64
pub fn tick_output(&mut self, rng_variance: f64) -> f64
Apply output to the stockpile and consume reserves. Returns actual output.
Sourcepub fn perform_maintenance(&mut self)
pub fn perform_maintenance(&mut self)
Perform maintenance: restore efficiency.
Sourcepub fn apply_disruption(&mut self, severity: f64)
pub fn apply_disruption(&mut self, severity: f64)
Apply a disruption event.
Sourcepub fn recover_disruption(&mut self, rate: f64)
pub fn recover_disruption(&mut self, rate: f64)
Recover from disruption over time.
Sourcepub fn avg_output(&self, n: usize) -> f64
pub fn avg_output(&self, n: usize) -> f64
Average output over last n ticks.
Sourcepub fn depletion_fraction(&self) -> Option<f64>
pub fn depletion_fraction(&self) -> Option<f64>
Reserve depletion fraction (0 = full, 1 = empty). None if unlimited.
Trait Implementations§
Source§impl Clone for ResourceNode
impl Clone for ResourceNode
Source§fn clone(&self) -> ResourceNode
fn clone(&self) -> ResourceNode
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ResourceNode
impl RefUnwindSafe for ResourceNode
impl Send for ResourceNode
impl Sync for ResourceNode
impl Unpin for ResourceNode
impl UnsafeUnpin for ResourceNode
impl UnwindSafe for ResourceNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.