diff options
| author | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-10 13:29:56 -0400 |
|---|---|---|
| committer | Jon Santmyer <jon@jonsantmyer.com> | 2026-05-10 13:29:56 -0400 |
| commit | 7f63ec5c10eb7e8dd4edaabd1a6a437328911d39 (patch) | |
| tree | 36bd3d75ebc0c25256413c21a7cb28c9296953f5 /src/solar_system/fleet.rs | |
| parent | c9041e2e6fe59d6127bb1085b874e8e3cda8000e (diff) | |
| download | systemic4x-7f63ec5c10eb7e8dd4edaabd1a6a437328911d39.tar.gz systemic4x-7f63ec5c10eb7e8dd4edaabd1a6a437328911d39.tar.bz2 systemic4x-7f63ec5c10eb7e8dd4edaabd1a6a437328911d39.zip | |
fleets
Diffstat (limited to 'src/solar_system/fleet.rs')
| -rw-r--r-- | src/solar_system/fleet.rs | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/solar_system/fleet.rs b/src/solar_system/fleet.rs deleted file mode 100644 index c331cd7..0000000 --- a/src/solar_system/fleet.rs +++ /dev/null @@ -1,60 +0,0 @@ -use crate::solar_system::{GRAVITATIONAL_CONSTANT, Kilometers, SolarSystem, body::OrbitalBody, orbit::StaticOrbit}; -use crate::timeman::Second; - -pub type FleetId = usize; - -pub struct Fleet -{ - id: FleetId, - name: String, - - position: cgmath::Vector3<Kilometers>, - velocity: cgmath::Vector3<f32>, - acceleration: cgmath::Vector3<f32>, - - baked_orbit: Option<(f64, StaticOrbit)>, -} - -impl Fleet -{ - pub fn new( - id: FleetId, - name: String) - -> Self - { - Self { - id, - name, - position: cgmath::vec3(0.0, 0.0, 0.0), - velocity: cgmath::vec3(0.0, 0.0, 0.0), - acceleration: cgmath::vec3(0.0, 0.0, 0.0), - baked_orbit: None, - } - } - - pub fn id(&self) -> FleetId { self.id } - pub fn name(&self) -> &String { &self.name } - - pub fn make_orbit( - &mut self, - body: &OrbitalBody, - radius: Kilometers) - { - let sgp = body.mass() * GRAVITATIONAL_CONSTANT; - self.baked_orbit = Some((sgp, StaticOrbit::new_circular(body, radius))); - } - - pub fn tick( - &mut self, - time: Second) - { - match &self.baked_orbit { - Some(orbit_info) => { - let sgp = orbit_info.0; - let orbit = &orbit_info.1; - self.position = orbit.calculate_position_at(sgp, time); - }, - None => {} - } - } -} |
