~starkingdoms/starkingdoms

0752435f9022ba035917491b60223b0ac6593cdb — ghostly_zsh 5 months ago 11598ed core/rewrite-it-all-again-lmao
fix: attachment rotation
M crates/unified/assets/config/parts/housing.part.toml => crates/unified/assets/config/parts/housing.part.toml +3 -3
@@ 1,7 1,7 @@
[part]
name = "Housing"
sprite_connected = "textures/housing.png"
sprite_disconnected = "textures/housing.png"
sprite_connected = "textures/thruster_on.png"
sprite_disconnected = "textures/thruster_off.png"

[physics]
width = 50


@@ 27,4 27,4 @@ snap = { translation = [ 0.0, -25.0, 0.0 ], rotation = 0.0 }
[[joints]]
id = "Left"
target = { translation = [ -55.0, 0.0, 0.0 ], rotation = -270.0 }
snap = { translation = [ -25.0, 0.0, 0.0 ], rotation = 0.0 }
\ No newline at end of file
snap = { translation = [ -25.0, 0.0, 0.0 ], rotation = 0.0 }

M crates/unified/src/client/key_input.rs => crates/unified/src/client/key_input.rs +4 -2
@@ 1,8 1,8 @@
use crate::attachment::{JointOf, Peer, SnapOf};
use crate::ecs::{Part, ThrustEvent};
use bevy::color::palettes::css::{FUCHSIA, GREEN, WHITE};
use bevy::color::palettes::css::{FUCHSIA, GREEN, ORANGE, WHITE};
use bevy::dev_tools::picking_debug::DebugPickingMode;
use bevy::math::Vec3Swizzles;
use bevy::math::{Vec3, Vec3Swizzles};
use bevy::prelude::{Gizmos, GlobalTransform, Query, ResMut, Resource, Transform, With};
use bevy::{
    app::{App, Update},


@@ 91,6 91,8 @@ fn draw_attachment_debug(

        if let Some(peer_id) = peer && let Ok(peer) = joints.get(peer_id.0) {
            let Ok(peer_parent_pos) = parts.get(peer.1.0) else { continue };
            gizmos.arrow_2d(peer_parent_pos.translation().xy(), peer_parent_pos.translation().xy() 
                    + ((peer.0.rotation * peer_parent_pos.rotation()).mul_vec3(Vec3::Y).xy()*20.0), ORANGE);
            gizmos.arrow_2d(parent_pos.translation().xy(), peer_parent_pos.translation().xy(), WHITE);
        }
    }

M crates/unified/src/server/player.rs => crates/unified/src/server/player.rs +3 -2
@@ 108,13 108,14 @@ fn dragging(
            // create the joint...
            let joint = FixedJointBuilder::new()
                .local_anchor1(target_joint.2.translation.xy())
                .local_basis2(0.0);
                .local_basis1(target_joint.0.transform.rotation.to_euler(EulerRot::ZYX).0 + PI
                    - source_joint.0.transform.rotation.to_euler(EulerRot::ZYX).0);

            commands.entity(source_part.2)
                .insert(ImpulseJoint::new(target_part.2, joint));

            teleport_to_translation = target_position.translation.xy();
            teleport_to_rotation = event.set_rotation;
            teleport_to_rotation = target_position.rotation * source_joint.0.transform.rotation.inverse() * Quat::from_rotation_z(PI);
            new_vel = Some(*target_part.3);
            // and we're done!
        } else {