From 6ec56cc3a1031c675caa6646ff9e97c14262d7a5 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Wed, 3 Jan 2024 00:42:46 -0600 Subject: [PATCH] cheese --- server/src/component.rs | 3 ++- server/src/main.rs | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/server/src/component.rs b/server/src/component.rs index 95cf9b2203e30387f8b0a0758993f20fc5e53ccd..d2626d38bf2fe12c7c2dc4982107c34fbdf4a3c9 100644 --- a/server/src/component.rs +++ b/server/src/component.rs @@ -21,6 +21,7 @@ use serde::{Deserialize, Serialize}; #[derive(Component, Clone, Copy, Serialize, Deserialize, Debug)] pub enum PlanetType { Earth, + Moon, } #[derive(Component, Clone, Copy, Serialize, Deserialize, Debug)] @@ -74,7 +75,7 @@ pub struct PlayerBundle { pub struct ModuleTimer(pub Timer); impl ModuleTimer { pub fn new() -> Self { - Self(Timer::from_seconds(1.0, TimerMode::Repeating)) + Self(Timer::from_seconds(3.0, TimerMode::Repeating)) } } impl Default for ModuleTimer { diff --git a/server/src/main.rs b/server/src/main.rs index 38a21812fcc01dd6afde9af031069d83df3374b6..93609aac41ce95d738c562bf2b95b32641c4146f 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -32,7 +32,13 @@ pub mod mathutil; pub mod packet; const SCALE: f32 = 10.0; + const EARTH_SIZE: f32 = 1000.0; +const MOON_SIZE: f32 = EARTH_SIZE / 4.; + +const EARTH_MASS: f32 = 10000.0; +const MOON_MASS: f32 = EARTH_MASS / 30.; + const GRAVITY: f32 = 0.02; const PART_HALF_SIZE: f32 = 25.0; const THRUSTER_FORCE: f32 = 0.08; @@ -84,7 +90,17 @@ fn spawn_planets(mut commands: Commands) { transform: TransformBundle::from(earth_pos), }) .insert(Collider::ball(EARTH_SIZE / SCALE)) - .insert(AdditionalMassProperties::Mass(10000.0)) + .insert(AdditionalMassProperties::Mass(EARTH_MASS)) + .insert(ReadMassProperties::default()) + .insert(RigidBody::Fixed); + let moon_pos = Transform::from_xyz(3000.0 / SCALE, 0.0, 0.0); + commands + .spawn(PlanetBundle { + planet_type: PlanetType::Moon, + transform: TransformBundle::from(moon_pos), + }) + .insert(Collider::ball(MOON_SIZE / SCALE)) + .insert(AdditionalMassProperties::Mass(MOON_MASS)) .insert(ReadMassProperties::default()) .insert(RigidBody::Fixed); } @@ -208,6 +224,7 @@ fn on_message( )), radius: match *planet_type { PlanetType::Earth => EARTH_SIZE, + PlanetType::Moon => MOON_SIZE, }, }, )); @@ -734,6 +751,7 @@ fn on_position_change( )), radius: match *planet_type { PlanetType::Earth => EARTH_SIZE, + PlanetType::Moon => MOON_SIZE, }, }, ));