M server/src/component.rs => server/src/component.rs +2 -1
@@ 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 {
M server/src/main.rs => server/src/main.rs +19 -1
@@ 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,
},
},
));