builder doesn't de-select after building a tower
This commit is contained in:
parent
7f60ce2613
commit
e33898c671
1 changed files with 15 additions and 2 deletions
|
|
@ -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 -----------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue