~starkingdoms/starkingdoms

19e081d297dd40870a42f3bebcfc485d3b771063 — TerraMaster85 1 year, 8 months ago aaff72d
better attachment slot qualification math
2 files changed, 13 insertions(+), 21 deletions(-)

M Cargo.lock
M server/src/main.rs
M Cargo.lock => Cargo.lock +1 -1
@@ 3666,7 3666,7 @@ dependencies = [

[[package]]
name = "starkingdoms-backplane"
version = "0.0.1"
version = "0.1.0-alpha1"
dependencies = [
 "actix-cors",
 "actix-web",

M server/src/main.rs => server/src/main.rs +12 -20
@@ 1215,39 1215,31 @@ fn attach_on_module_tree(
    let mut offset = Vec2::ZERO;
    let mut angle_offset = 0.;

    if attach.children[2].is_none()
    if attach.children[2].is_none() // top
        && attachable & 4 != 0
        && 0.3 < rel_y
        && rel_y < 0.6
        && -0.4 < rel_x
        && rel_x < 0.4
        && -(rel_x.abs()) + rel_y > 0.0
        && rel_x.abs() + rel_y < 1.0
    {
        attachment_slot = 2;
        offset = Vec2::new(0., -1.06);
        angle_offset = 0.;
    } else if attach.children[0].is_none()
        && -0.6 < rel_y
        && rel_y < -0.3
        && -0.4 < rel_x
        && rel_x < 0.4
    } else if attach.children[0].is_none() // bottom
        && rel_x.abs() + rel_y < 0.0
        && -(rel_x.abs()) + rel_y > -1.0
    {
        attachment_slot = 0;
        offset = Vec2::new(0., 1.06);
        angle_offset = PI;
    } else if attach.children[1].is_none()
        && -0.6 < rel_x
        && rel_x < -0.3
        && -0.4 < rel_y
        && rel_y < 0.4
    } else if attach.children[1].is_none() // left
        && rel_x + rel_y.abs() < 0.0
        && rel_x - rel_y.abs() > -1.0
    {
        attachment_slot = 1;
        offset = Vec2::new(1.06, 0.);
        angle_offset = PI / 2.;
    } else if attach.children[3].is_none()
        && 0.3 < rel_x
        && rel_x < 0.6
        && -0.4 < rel_y
        && rel_y < 0.4
    } else if attach.children[3].is_none() // right
        && rel_x - rel_y.abs() > 0.0
        && rel_x + rel_y.abs() < 1.0
    {
        attachment_slot = 3;
        offset = Vec2::new(-1.06, 0.);