~starkingdoms/starkingdoms

811ddecdb23bf83d7d089ce494cc27cafcf773de — TerraMaster85 5 months ago c5e3200
shut off opposing thrusters
1 files changed, 13 insertions(+), 1 deletions(-)

M crates/unified/src/server/player.rs
M crates/unified/src/server/player.rs => crates/unified/src/server/player.rs +13 -1
@@ 118,7 118,14 @@ fn player_thrust(

        let forward = (transform.rotation * Vec3::Y).xy();
        let mut external_force = ExternalForce::default();
        let mut thrusters = [0.0; 4]; // counterclockwise wrt +y axis

        // indices are quadrants:
        // 1 | 0
        // --+--
        // 2 | 3
        //
        let mut thrusters = [0.0; 4]; 

        if thrust.up {
            thrusters[1] = 1.0;
            thrusters[2] = 1.0;


@@ 135,6 142,11 @@ fn player_thrust(
            thrusters[1] = 1.0;
            thrusters[3] = 1.0;
        }

        // prevent fuel wasting when turning while moving forward/reverse
        if thrusters[2] == thrusters[3] && thrusters[3] != 0.0 { (thrusters[2], thrusters[3]) = (0.0, 0.0); }
        if thrusters[0] == thrusters[1] && thrusters[1] != 0.0 { (thrusters[0], thrusters[1]) = (0.0, 0.0); }

        let half_size = Vec2::new(
            world_config.part.default_width / 2.0,
            world_config.part.default_height / 2.0,