From 0490d8559fd9e2a458b6172415ba5649d3d4a45a Mon Sep 17 00:00:00 2001 From: Architector #4 Date: Sun, 7 Dec 2025 08:31:40 +0300 Subject: [PATCH] Prevent Constructor from building out of bounds. Without this patch, the user can aim and click out of scene bounds with the order construction cursor. This is suboptimal because building there just wastes material, and it can get annoying and disorienting if the cursor ends up out of bounds. --- .../Devices/Tools/Constructor/Constructor.lua | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/Data/Base.rte/Devices/Tools/Constructor/Constructor.lua b/Data/Base.rte/Devices/Tools/Constructor/Constructor.lua index d2fd0a3b64..306cf1720f 100644 --- a/Data/Base.rte/Devices/Tools/Constructor/Constructor.lua +++ b/Data/Base.rte/Devices/Tools/Constructor/Constructor.lua @@ -471,6 +471,8 @@ function Update(self) if cursorMovement:MagnitudeIsGreaterThan(0) then self.cursor = self.cursor + (mouseControlled and cursorMovement or cursorMovement:SetMagnitude(self.cursorMoveSpeed * (aiming and 0.5 or 1))); + + SceneMan:ForceBounds(self.cursor); end local precise = not mouseControlled and aiming; @@ -562,21 +564,23 @@ function Update(self) for x = 1, cellSize do for y = 1, cellSize do local pos = Vector(startPos.X + x, startPos.Y + y); - local strengthRatio = SceneMan:GetMaterialFromID(SceneMan:GetTerrMatter(pos.X, pos.Y)).StructuralIntegrity/self.digStrength; - if strengthRatio < 1 and SceneMan:GetMOIDPixel(pos.X, pos.Y) == rte.NoMOID then - local name = ""; - if bx + x == 0 or bx + x == self.buildList[1][4] - 1 or by + y == 0 or by + y == self.buildList[1][4] - 1 then - name = "Base.rte/Constructor Border Tile " .. math.random(4); - else - name = "Base.rte/Constructor Tile " .. math.random(16); - end - - local terrainObject = CreateTerrainObject(name); - terrainObject.Pos = pos; - SceneMan:AddSceneObject(terrainObject); + if SceneMan:IsWithinBounds(pos.X, pos.Y, 0) then + local strengthRatio = SceneMan:GetMaterialFromID(SceneMan:GetTerrMatter(pos.X, pos.Y)).StructuralIntegrity/self.digStrength; + if strengthRatio < 1 and SceneMan:GetMOIDPixel(pos.X, pos.Y) == rte.NoMOID then + local name = ""; + if bx + x == 0 or bx + x == self.buildList[1][4] - 1 or by + y == 0 or by + y == self.buildList[1][4] - 1 then + name = "Base.rte/Constructor Border Tile " .. math.random(4); + else + name = "Base.rte/Constructor Tile " .. math.random(16); + end - didBuild = true; - totalCost = 1 - strengthRatio; + local terrainObject = CreateTerrainObject(name); + terrainObject.Pos = pos; + SceneMan:AddSceneObject(terrainObject); + + didBuild = true; + totalCost = 1 - strengthRatio; + end end end end