pub enum Impact {
Step {
at: Tick,
delta: Level,
},
Claim {
start: Tick,
end: Tick,
amount: Level,
},
Rate {
start: Tick,
end: Tick,
per_tick: Level,
},
}Expand description
One effect of an activity on the level of a resource.
The level at tick t is the timeline’s initial level plus the contribution of every
impact at t:
Step { at, delta } contributes delta if at <= t
Claim { start, end, amount } contributes -amount if start <= t < end
Rate { start, end, per_tick } contributes per_tick * (min(t, end) - start) if start <= tSteps and rates are permanent (consumption and production persist), claims are returned at their end.
Variants§
Step
A permanent change of the level, as for a consumable resource.
Consumption (energy drawn, storage filled) is a negative delta, production (charging,
downlinked data freed) a positive one.
Fields
Claim
A temporary hold on a resource during the half-open interval [start, end).
The level is the amount available, so a claim lowers it by amount while it holds and
returns it at end. A claim ending at t and another starting at t do not overlap.
Fields
Rate
A linear change of the level by per_tick for every tick elapsed in [start, end).
Models a battery discharging under a power draw (negative), solar charging or thermal
drift (either sign). The level at start is unchanged, at start + k it has changed by
k * per_tick, and from end onward the total (end - start) * per_tick persists.
Fractional rates are expressed by choosing a finer level unit. The level is never
clamped (a full battery does not stop charging): exceeding the capacity is reported as a
violation instead.
Implementations§
Source§impl Impact
impl Impact
Sourcepub const fn first_tick(&self) -> Tick
pub const fn first_tick(&self) -> Tick
The earliest tick at which this impact changes the level.
Sourcepub const fn last_tick(&self) -> Tick
pub const fn last_tick(&self) -> Tick
The last tick at which this impact changes the level or its slope.
From this tick onward the contribution of the impact is constant.