From c95c0de7db4cf819f1a34f0826a3a581fcace059 Mon Sep 17 00:00:00 2001 From: ghostlyzsh Date: Thu, 4 Jan 2024 16:30:54 -0600 Subject: [PATCH] broken code --- server/src/component.rs | 4 +- server/src/main.rs | 118 ++++++++++++++++++++++++++++++++++++++-- server/src/packet.rs | 7 +++ 3 files changed, 123 insertions(+), 6 deletions(-) diff --git a/server/src/component.rs b/server/src/component.rs index d2626d38bf2fe12c7c2dc4982107c34fbdf4a3c9..9e7568c252f13200cd309651fec7e1915bc94fb8 100644 --- a/server/src/component.rs +++ b/server/src/component.rs @@ -24,14 +24,16 @@ pub enum PlanetType { Moon, } -#[derive(Component, Clone, Copy, Serialize, Deserialize, Debug)] +#[derive(Component, Clone, Copy, PartialEq, Serialize, Deserialize, Debug)] pub enum PartType { Hearty, Cargo, + Hub, } #[derive(Component, Clone, Debug)] pub struct Attach { + pub associated_player: Option, pub parent: Option, pub children: [Option; 4], } diff --git a/server/src/main.rs b/server/src/main.rs index 7ea9531254540fd5e52d7f7cf75b81eac80210cb..59c6043325f651837dbae3636a184e6ed2a8ef1a 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -72,6 +72,7 @@ fn main() { .add_systems(FixedUpdate, on_position_change) .add_systems(FixedUpdate, gravity_update) .add_systems(FixedUpdate, player_input_update) + .add_systems(FixedUpdate, convert_modules) //.insert_resource(Time::::from_seconds(1.0/20.0)) .run(); @@ -95,6 +96,11 @@ fn spawn_planets(mut commands: Commands) { .insert(Collider::ball(EARTH_SIZE / SCALE)) .insert(AdditionalMassProperties::Mass(EARTH_MASS)) .insert(ReadMassProperties::default()) + .with_children(|children| { + children.spawn(Collider::ball((EARTH_SIZE + 3.) / SCALE)) + .insert(ActiveEvents::COLLISION_EVENTS) + .insert(Sensor); + }) .insert(RigidBody::Fixed); let moon_pos = Transform::from_xyz(3000.0 / SCALE, 0.0, 0.0); commands @@ -105,6 +111,11 @@ fn spawn_planets(mut commands: Commands) { .insert(Collider::ball(MOON_SIZE / SCALE)) .insert(AdditionalMassProperties::Mass(MOON_MASS)) .insert(ReadMassProperties::default()) + .with_children(|children| { + children.spawn(Collider::ball((MOON_SIZE + 3.) / SCALE)) + .insert(ActiveEvents::COLLISION_EVENTS) + .insert(Sensor); + }) .insert(RigidBody::Fixed); } fn module_spawn( @@ -112,6 +123,7 @@ fn module_spawn( time: Res