pub struct ProcessingBuilding {Show 14 fields
pub id: BuildingId,
pub name: String,
pub recipes: Vec<RecipeId>,
pub recipe_queue: VecDeque<RecipeId>,
pub stockpile: Stockpile,
pub workers: Vec<WorkerId>,
pub worker_slots: u32,
pub modifiers: Vec<EfficiencyModifier>,
pub quota: Option<ProductionQuota>,
pub throughput_history: VecDeque<f64>,
pub lifetime_output: HashMap<CommodityRef, f64>,
pub operational: bool,
pub age_ticks: u64,
pub batches_completed: u64,
/* private fields */
}Expand description
A building that transforms input commodities into output commodities.
Fields§
§id: BuildingId§name: String§recipes: Vec<RecipeId>Available recipes.
recipe_queue: VecDeque<RecipeId>Recipe queue: which recipe to run next.
stockpile: StockpileInput/output stockpile.
workers: Vec<WorkerId>Workers assigned to this building.
worker_slots: u32Max worker slots.
modifiers: Vec<EfficiencyModifier>Efficiency modifiers currently in effect.
quota: Option<ProductionQuota>Production quota.
throughput_history: VecDeque<f64>Throughput per tick (units produced).
lifetime_output: HashMap<CommodityRef, f64>Total lifetime output (per commodity).
operational: boolWhether this building is operational.
age_ticks: u64Ticks this building has been running.
batches_completed: u64Total batches completed.
Implementations§
Source§impl ProcessingBuilding
impl ProcessingBuilding
pub fn new( id: BuildingId, name: &str, worker_slots: u32, stockpile_capacity: f64, ) -> Self
pub fn add_recipe(&mut self, recipe_id: RecipeId)
pub fn assign_worker(&mut self, worker: WorkerId) -> bool
pub fn remove_worker(&mut self, worker: WorkerId) -> bool
pub fn worker_count(&self) -> u32
Sourcepub fn composite_efficiency(&self) -> f64
pub fn composite_efficiency(&self) -> f64
Composite efficiency from all active modifiers.
pub fn add_modifier(&mut self, modifier: EfficiencyModifier)
pub fn remove_modifier(&mut self, kind: ModifierKind)
Sourcepub fn tick(
&mut self,
recipes: &HashMap<RecipeId, Recipe>,
current_tick: u64,
) -> (HashMap<CommodityRef, f64>, Vec<SupplyChainEvent>)
pub fn tick( &mut self, recipes: &HashMap<RecipeId, Recipe>, current_tick: u64, ) -> (HashMap<CommodityRef, f64>, Vec<SupplyChainEvent>)
Full tick: advance modifier timers, check batch completion, start new batch.
pub fn avg_throughput(&self, n: usize) -> f64
Sourcepub fn halt(&mut self, reason: &str, tick: u64) -> SupplyChainEvent
pub fn halt(&mut self, reason: &str, tick: u64) -> SupplyChainEvent
Halt the building (equipment failure, strike, etc.).
Trait Implementations§
Source§impl Clone for ProcessingBuilding
impl Clone for ProcessingBuilding
Source§fn clone(&self) -> ProcessingBuilding
fn clone(&self) -> ProcessingBuilding
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ProcessingBuilding
impl RefUnwindSafe for ProcessingBuilding
impl Send for ProcessingBuilding
impl Sync for ProcessingBuilding
impl Unpin for ProcessingBuilding
impl UnsafeUnpin for ProcessingBuilding
impl UnwindSafe for ProcessingBuilding
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
Mutably borrows from an owned value. Read more
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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.