~starkingdoms/starkingdoms

a545d1363a8035d4a733cd4b32d671ebcabd7105 — core 22 days ago cb50998
feat: good luck!
M crates/unified/assets/config/parts/housing.part.toml => crates/unified/assets/config/parts/housing.part.toml +2 -6
@@ 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 }

M crates/unified/src/client/parts.rs => crates/unified/src/client/parts.rs +11 -1
@@ 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<Peer>>,
    parts: Query<(&GlobalTransform, Option<&Me>, Option<&PartInShip>), With<Part>>,
    linvel: Query<&LinearVelocity, With<Me>>,
    dt: Res<Time<Fixed>>,
    me: Single<Entity, With<Me>>,
    debug: Res<AttachmentDebugRes>,
    mut rsnap: ResMut<SnapResource>,


@@ 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;
}

M crates/unified/src/client/ship/thrusters.rs => crates/unified/src/client/ship/thrusters.rs +4 -4
@@ 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);