pub struct TradeRoute {Show 13 fields
pub id: TradeRouteId,
pub from_faction: FactionId,
pub to_faction: FactionId,
pub status: TradeRouteStatus,
pub base_volume: f64,
pub current_volume: f64,
pub disruption: f64,
pub export_share_from: f64,
pub import_share_to: f64,
pub age_ticks: u64,
pub volume_history: VecDeque<f64>,
pub escorted: bool,
pub infrastructure: f64,
}Expand description
A trade route connecting two factions, carrying goods in both directions.
Fields§
§id: TradeRouteId§from_faction: FactionId§to_faction: FactionId§status: TradeRouteStatus§base_volume: f64Base gold value transacted per tick.
current_volume: f64Current actual volume (may differ due to disruptions).
disruption: f64Disruption factor (0.0 = fully blocked, 1.0 = full volume).
Fraction of volume that goes to from_faction as export income.
Fraction of volume that goes to to_faction as import income.
age_ticks: u64Ticks this route has been active.
volume_history: VecDeque<f64>History of per-tick volumes.
escorted: boolWhether a military escort is assigned (reduces disruption).
infrastructure: f64Infrastructure investment level (improves volume and reduces disruption risk).
Implementations§
Source§impl TradeRoute
impl TradeRoute
pub fn new( id: TradeRouteId, from: FactionId, to: FactionId, base_volume: f64, export_share: f64, import_share: f64, ) -> Self
Sourcepub fn apply_disruption(&mut self, severity: f64)
pub fn apply_disruption(&mut self, severity: f64)
Apply a disruption event (bandits, war, weather). Value in [0,1].
Sourcepub fn tick(&mut self) -> (f64, f64)
pub fn tick(&mut self) -> (f64, f64)
Tick: compute actual volume and return (export_income, import_income).
Sourcepub fn avg_volume(&self, n: usize) -> f64
pub fn avg_volume(&self, n: usize) -> f64
Average volume over last n ticks.
Trait Implementations§
Source§impl Clone for TradeRoute
impl Clone for TradeRoute
Auto Trait Implementations§
impl Freeze for TradeRoute
impl RefUnwindSafe for TradeRoute
impl Send for TradeRoute
impl Sync for TradeRoute
impl Unpin for TradeRoute
impl UnsafeUnpin for TradeRoute
impl UnwindSafe for TradeRoute
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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.