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 -----------------------------------------