pub struct GenerationService;Expand description
Service for generation calculations (pure functions)
Implementations§
Source§impl GenerationService
impl GenerationService
Sourcepub fn calculate_generation(
base_rate: f32,
generation_type: &GenerationType,
environment: &GenerationEnvironment,
modifiers: &EnvironmentModifiers,
global_multiplier: f32,
delta_time: f32,
) -> f32
pub fn calculate_generation( base_rate: f32, generation_type: &GenerationType, environment: &GenerationEnvironment, modifiers: &EnvironmentModifiers, global_multiplier: f32, delta_time: f32, ) -> f32
Calculate generation amount based on all factors
§Arguments
base_rate- Base generation rate per tickgeneration_type- Type of generationenvironment- Environmental conditionsmodifiers- Environment modifiers for this typeglobal_multiplier- Global generation multiplierdelta_time- Time delta for this tick
§Returns
Amount of progress to add
Sourcepub fn apply_generation(
generation: &mut Generation,
progress_amount: f32,
) -> f32
pub fn apply_generation( generation: &mut Generation, progress_amount: f32, ) -> f32
Sourcepub fn reduce_generation(
generation: &mut Generation,
reduction_amount: f32,
) -> f32
pub fn reduce_generation( generation: &mut Generation, reduction_amount: f32, ) -> f32
Sourcepub fn check_conditions(
conditions: &GenerationConditions,
temperature: f32,
available_resources: &[(String, u32)],
) -> bool
pub fn check_conditions( conditions: &GenerationConditions, temperature: f32, available_resources: &[(String, u32)], ) -> bool
Sourcepub fn completion_percentage(generation: &Generation) -> f32
pub fn completion_percentage(generation: &Generation) -> f32
Calculate completion percentage
Sourcepub fn estimate_completion_time(generation: &Generation) -> Option<f32>
pub fn estimate_completion_time(generation: &Generation) -> Option<f32>
Trait Implementations§
Source§impl Clone for GenerationService
impl Clone for GenerationService
Source§fn clone(&self) -> GenerationService
fn clone(&self) -> GenerationService
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for GenerationService
Source§impl Service for GenerationService
impl Service for GenerationService
Source§fn as_any_mut(&mut self) -> &mut dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
Downcast to Any for type-safe mutable access
Source§fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
_ctx: &'life1 mut Context,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize service (called once at startup)
Auto Trait Implementations§
impl Freeze for GenerationService
impl RefUnwindSafe for GenerationService
impl Send for GenerationService
impl Sync for GenerationService
impl Unpin for GenerationService
impl UnsafeUnpin for GenerationService
impl UnwindSafe for GenerationService
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,
impl<T> Component for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more