pub struct Workbench {
pub id: u64,
pub position: Vec3,
pub bench_type: WorkbenchType,
pub tier: WorkbenchTier,
pub state: WorkbenchState,
pub queue: CraftingQueue,
pub fuel: FuelSystem,
pub efficiency: f32,
pub wear: f32,
pub operator_skill: u32,
/* private fields */
}Expand description
A single crafting station in the world.
Fields§
§id: u64§position: Vec3§bench_type: WorkbenchType§tier: WorkbenchTier§state: WorkbenchState§queue: CraftingQueue§fuel: FuelSystem§efficiency: f32Overall efficiency multiplier (0.0–2.0), affected by repairs and upgrades.
wear: f32Accumulated wear (0.0–1.0). At 1.0 the bench breaks.
operator_skill: u32Skill level assumed for quality calculations (e.g. owner’s skill).
Implementations§
Source§impl Workbench
impl Workbench
pub fn new( id: u64, position: Vec3, bench_type: WorkbenchType, tier: WorkbenchTier, ) -> Self
Sourcepub fn tick(&mut self, dt: f32) -> Vec<WorkbenchEvent>
pub fn tick(&mut self, dt: f32) -> Vec<WorkbenchEvent>
Advance the workbench by dt seconds.
Sourcepub fn compute_results_for_recipe(
&self,
recipe: &Recipe,
quantity: u32,
rng_values: &[f32],
) -> Vec<(String, u32, u8)>
pub fn compute_results_for_recipe( &self, recipe: &Recipe, quantity: u32, rng_values: &[f32], ) -> Vec<(String, u32, u8)>
Compute results for a job using a known recipe.
Sourcepub fn tier_quality_bonus(&self) -> u32
pub fn tier_quality_bonus(&self) -> u32
Effective quality bonus considering tier and bench type.
Sourcepub fn submit_job(
&mut self,
recipe_id: impl Into<String>,
ingredients: Vec<(String, u32)>,
duration: f32,
quantity: u32,
owner_id: impl Into<String>,
) -> Result<u64, WorkbenchEvent>
pub fn submit_job( &mut self, recipe_id: impl Into<String>, ingredients: Vec<(String, u32)>, duration: f32, quantity: u32, owner_id: impl Into<String>, ) -> Result<u64, WorkbenchEvent>
Submit a new crafting job to the queue.
Returns the job_id on success, or an event explaining why it failed.
Sourcepub fn compute_repair_cost(&self) -> u64
pub fn compute_repair_cost(&self) -> u64
Compute repair cost based on tier and wear level.
Sourcepub fn upgrade_cost(&self) -> Option<u64>
pub fn upgrade_cost(&self) -> Option<u64>
Attempt to upgrade the bench to the next tier. Returns the cost or None if already Master.
Sourcepub fn cancel_job(&mut self, job_id: u64) -> Option<CraftingJob>
pub fn cancel_job(&mut self, job_id: u64) -> Option<CraftingJob>
Cancel a queued job by id, returning the job if found.
Sourcepub fn current_progress(&self) -> Option<f32>
pub fn current_progress(&self) -> Option<f32>
Progress of the current job [0.0, 1.0], or None if idle/broken.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Workbench
impl RefUnwindSafe for Workbench
impl Send for Workbench
impl Sync for Workbench
impl Unpin for Workbench
impl UnsafeUnpin for Workbench
impl UnwindSafe for Workbench
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.