From cd5b46cc3b98e11ae153b3f9666d1cea750638ac Mon Sep 17 00:00:00 2001
From: Redo <A509DCFC@cock.li>
Date: Mon, 22 Jan 2024 02:16:07 -0600
Subject: [PATCH] add select zone by ctrl-selectingt zone brick

---
 classes/server/duplimode/boxselect.cs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/classes/server/duplimode/boxselect.cs b/classes/server/duplimode/boxselect.cs
index bdcf7d0..bbefad8 100644
--- a/classes/server/duplimode/boxselect.cs
+++ b/classes/server/duplimode/boxselect.cs
@@ -161,6 +161,7 @@ function NDM_BoxSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
 		}
 		else
 		{
+			%client.ndSelectionBox.ez_zoneBrick = "";
 			%box = %obj.getWorldBox();
 			%p1 = getWords(%box, 0, 2);
 			%p2 = getWords(%box, 3, 5);
@@ -180,6 +181,9 @@ function NDM_BoxSelect::onSelectObject(%this, %client, %obj, %pos, %normal)
 		if(%client.ndMultiSelect) {
 			if(%obj.getDatablock().isLogicRom) {
 				%box = ndGetBoxFromRom(%obj);
+			} else if (isObject(%obj.physicalZone)) {
+				%box = ndGetBoxFromZone(%obj);
+				%client.ndSelectionBox.ez_zoneBrick = %obj;
 			} else {
 				%box = ndGetPlateBoxFromRayCast(%pos, %normal);
 			}
@@ -206,6 +210,15 @@ function ndGetBoxFromRom(%b) {
 	return %bl SPC %bh;
 }
 
+function ndGetBoxFromZone(%b) {
+	%z = %b.physicalZone;
+	%pos = %z.position;
+	%scale = %z.getScale(); %sx = getWord(%scale, 0); %sy = getWord(%scale, 1); %sz = getWord(%scale, 2);
+	%bl = %pos;
+	%bh = vectorAdd(%pos, %sx SPC (-%sy) SPC %sz);
+	return %bl SPC %bh;
+}
+
 
 
 //Generic inputs