From a545d1363a8035d4a733cd4b32d671ebcabd7105 Mon Sep 17 00:00:00 2001 From: core Date: Sun, 23 Nov 2025 20:49:12 -0500 Subject: [PATCH] feat: good luck! --- crates/unified/assets/config/parts/housing.part.toml | 8 ++------ crates/unified/src/client/parts.rs | 12 +++++++++++- crates/unified/src/client/ship/thrusters.rs | 8 ++++---- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/crates/unified/assets/config/parts/housing.part.toml b/crates/unified/assets/config/parts/housing.part.toml index 20b93b52128227d2a7c8cbf097c3110a76eaff1f..ed744a1a09dfdd529a0ff48c8264cb638c80487a 100644 --- a/crates/unified/assets/config/parts/housing.part.toml +++ b/crates/unified/assets/config/parts/housing.part.toml @@ -1,17 +1,13 @@ [part] name = "Housing" -sprite_connected = "textures/thruster_on.png" -sprite_disconnected = "textures/thruster_off.png" +sprite_connected = "textures/housing.png" +sprite_disconnected = "textures/housing.png" [physics] width = 50 height = 50 mass = 50 -[[thruster]] -id = "primary" -thrust_vector = [ 0.0, -50.0 ] - [[joint]] id = "Top" target = { translation = [ 0.0, 55.0, 0.0 ], rotation = 0.0 } diff --git a/crates/unified/src/client/parts.rs b/crates/unified/src/client/parts.rs index ddb771c49410f3941fba336bf584089a9512ca7a..68021cfc6d0c574d56ae00ddca36715dce1b6d5f 100644 --- a/crates/unified/src/client/parts.rs +++ b/crates/unified/src/client/parts.rs @@ -12,12 +12,12 @@ use crate::prelude::*; pub fn parts_plugin(app: &mut App) { app.insert_resource(DragResource(None)); app.insert_resource(SnapResource(None, None)); + app.add_systems(PreUpdate, update_drag_ghosts); app.add_systems( Update, ( handle_incoming_parts, handle_updated_parts, - update_drag_ghosts, update_part_sprites, ), ); @@ -110,6 +110,7 @@ struct Ghost { pub rot: Quat, pub last_target_pos: Vec3, pub vel: Vec3, + pub part: Entity } const ROTATION_SMOOTH: f32 = 0.1; @@ -143,6 +144,7 @@ fn on_part_click( rot: sprite.1.rotation, last_target_pos: sprite.1.translation, vel: Vec3::ZERO, + part: ev.event_target(), }, *sprite.1, s)); drag.0 = Some(ev.event().event_target()); @@ -207,6 +209,8 @@ fn update_drag_ghosts( snaps: Query<(&Transform, &SnapOfJoint, &SnapOf, Entity)>, joints: Query<(&Transform, &JointOf, Entity), Without>, parts: Query<(&GlobalTransform, Option<&Me>, Option<&PartInShip>), With>, + linvel: Query<&LinearVelocity, With>, + dt: Res>, me: Single>, debug: Res, mut rsnap: ResMut, @@ -351,6 +355,7 @@ fn update_drag_ghosts( } ghost_info.rot = best_target.rotation; ghost.rotation = ghost.rotation.slerp(ghost_info.rot, ROTATION_SMOOTH); + let target_vel = (best_target.translation - ghost_info.last_target_pos) /time.delta_secs(); @@ -362,6 +367,11 @@ fn update_drag_ghosts( ghost_info.last_target_pos = best_target.translation; + let partvel = linvel.single().unwrap(); + let t_dt = dt.delta_secs(); + ghost.translation.x += partvel.x * t_dt; + ghost.translation.y += partvel.y * t_dt; + rsnap.0 = snap; rsnap.1 = best_self_snap; } diff --git a/crates/unified/src/client/ship/thrusters.rs b/crates/unified/src/client/ship/thrusters.rs index 425a389dc17b5003da28dfcfc99e8fa7d8b801d4..effa53f3d06b874494dd36bb49e77c751352264c 100644 --- a/crates/unified/src/client/ship/thrusters.rs +++ b/crates/unified/src/client/ship/thrusters.rs @@ -92,16 +92,16 @@ fn solve_thrust( let mut target_unit_vector = Vec3::ZERO; if input.pressed(&ClientAction::ThrustForward) { - target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, -1.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, 1.0, 0.0); } if input.pressed(&ClientAction::ThrustBackward) { - target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, 1.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(0.0, -1.0, 0.0); } if input.pressed(&ClientAction::ThrustRight) { - target_unit_vector += hearty_transform.rotation() * Vec3::new(-1.0, 0.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(1.0, 0.0, 0.0); } if input.pressed(&ClientAction::ThrustLeft) { - target_unit_vector += hearty_transform.rotation() * Vec3::new(1.0, 0.0, 0.0); + target_unit_vector += hearty_transform.rotation() * Vec3::new(-1.0, 0.0, 0.0); } if input.pressed(&ClientAction::TorqueCw) { target_unit_vector += Vec3::new(0.0, 0.0, -1.0);