From e33898c671fdefab8dec69123a5635680d5c8cb0 Mon Sep 17 00:00:00 2001 From: Ian Woods Date: Tue, 2 Jun 2026 21:44:23 -0700 Subject: [PATCH] builder doesn't de-select after building a tower --- .../Gameplay/TowerPlacementController.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Assets/_Project/Scripts/Gameplay/TowerPlacementController.cs b/Assets/_Project/Scripts/Gameplay/TowerPlacementController.cs index 4e29d24..cc47d58 100644 --- a/Assets/_Project/Scripts/Gameplay/TowerPlacementController.cs +++ b/Assets/_Project/Scripts/Gameplay/TowerPlacementController.cs @@ -58,6 +58,11 @@ namespace TD.Gameplay private TowerDefinition activeDef; private int activeTowerTypeId; + // Set true by a single-shot placement submit; processed at the top of the next + // Update so that BuilderInputController still sees IsPlacing=true on the same + // frame as the click and doesn't deselect the builder via its empty-space check. + private bool pendingCancel; + // The cursor ghost GameObject: the tower prefab instantiated with transparent materials. // Null when placement mode is inactive. private GameObject ghostGO; @@ -100,6 +105,13 @@ namespace TD.Gameplay private void Update() { + if (pendingCancel) + { + pendingCancel = false; + CancelPlacement(); + return; + } + if (activeDef == null) return; // idle — nothing to do var mouse = Mouse.current; @@ -375,8 +387,9 @@ namespace TD.Gameplay return; } - // Single-shot: exit placement mode immediately. - CancelPlacement(); + // Single-shot: defer the cancel to the next frame so BuilderInputController + // still sees IsPlacing=true this frame and doesn't deselect the builder. + pendingCancel = true; } // ----- Rejection feedback -----------------------------------------