summaryrefslogtreecommitdiffstats
path: root/src/solar_system.rs
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2026-05-07 08:50:05 -0400
committerJon Santmyer <jon@jonsantmyer.com>2026-05-07 08:50:05 -0400
commitc1adf64c1aaecd5a2b9d532d707ef35971f1aa18 (patch)
treefc1050becd0576d75a8d6afb8be09fae80c91541 /src/solar_system.rs
parent9788d9037ad7199701b1710c28559cb96bce5aec (diff)
downloadsystemic4x-c1adf64c1aaecd5a2b9d532d707ef35971f1aa18.tar.gz
systemic4x-c1adf64c1aaecd5a2b9d532d707ef35971f1aa18.tar.bz2
systemic4x-c1adf64c1aaecd5a2b9d532d707ef35971f1aa18.zip
begin work on body info window
Diffstat (limited to 'src/solar_system.rs')
-rw-r--r--src/solar_system.rs28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/solar_system.rs b/src/solar_system.rs
index ad1f304..913ca00 100644
--- a/src/solar_system.rs
+++ b/src/solar_system.rs
@@ -1,9 +1,9 @@
pub mod body;
-pub mod ship;
+pub mod fleet;
pub mod orbit;
use self::body::*;
-use self::ship::*;
+use self::fleet::*;
use self::orbit::*;
use serde::{Deserialize};
@@ -38,13 +38,18 @@ pub struct CSVOrbitalBody
semi_major_axis: Kilometers,
}
+pub trait HasMass
+{
+ fn mass() -> Kilograms;
+}
+
pub struct SolarSystem
{
id: SystemId,
name: String,
bodies: Vec<OrbitalBody>,
- ships: Vec<Ship>
+ fleets: Vec<Fleet>
}
impl SolarSystem
@@ -79,7 +84,7 @@ impl SolarSystem
id: id,
name: bodies[0].name().clone(),
bodies: bodies,
- ships: vec![]
+ fleets: vec![]
})
}
@@ -95,7 +100,6 @@ impl SolarSystem
}
pub fn id(&self) -> SystemId { self.id }
-
pub fn name(&self) -> &String { &self.name }
pub fn bodies(&self)
@@ -104,6 +108,9 @@ impl SolarSystem
self.bodies.as_slice()
}
+ pub fn body(&self, id: BodyId) -> &OrbitalBody
+ { &self.bodies[id] }
+
pub fn body_position(
&self,
body: &OrbitalBody)
@@ -112,12 +119,19 @@ impl SolarSystem
body.absolute_position(self)
}
- pub fn update(
+ pub fn fleets(&self)
+ -> &[Fleet]
+ { self.fleets.as_slice() }
+
+ pub fn tick(
&mut self,
time: Second)
{
self.bodies.iter_mut().for_each(|body| {
- body.update(time);
+ body.tick(time);
+ });
+ self.fleets.iter_mut().for_each(|fleet| {
+ fleet.tick(time);
});
}
}