From 19e081d297dd40870a42f3bebcfc485d3b771063 Mon Sep 17 00:00:00 2001 From: TerraMaster85 Date: Mon, 8 Apr 2024 00:07:03 -0400 Subject: [PATCH] better attachment slot qualification math --- Cargo.lock | 2 +- server/src/main.rs | 32 ++++++++++++-------------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1271057ed1417e85f270a941cbd400a62d4de548..ed64d387b7306d646895cc1d85884ec2ae8a9384 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3666,7 +3666,7 @@ dependencies = [ [[package]] name = "starkingdoms-backplane" -version = "0.0.1" +version = "0.1.0-alpha1" dependencies = [ "actix-cors", "actix-web", diff --git a/server/src/main.rs b/server/src/main.rs index df1b548ac440077a906d25ce7421850d86be2bb0..cdee43629e3e903b88ceb1c7d9ce9ac3c0688c3a 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -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.);