Disable build hotkeys after death (#3833)

## Description:

Prevent number-key build shortcuts from opening the unit build ghost
after the player has died.
Keep build hotkeys available only while the player is alive and not in
spawn phase.

## Please complete the following:

- [x] I have added screenshots for all UI updates
- [x] I process any text displayed to the user through translateText()
and I've added it to the en.json file
- [x] I have added relevant tests to the test directory
- [x] I confirm I have thoroughly tested these changes and take full
responsibility for any bugs introduced

## Please put your Discord username so you can be contacted if a bug or
regression is found:
aotumuri
This commit is contained in:
Aotumuri
2026-05-06 13:07:07 +09:00
committed by GitHub
parent 8d1614de72
commit 27e7a56f94
2 changed files with 27 additions and 6 deletions
+11 -4
View File
@@ -519,10 +519,12 @@ export class InputHandler {
}
// Two-phase build keybind matching: exact code match first, then digit/Numpad alias.
const matchedBuild = this.resolveBuildKeybind(e.code, e.shiftKey);
if (matchedBuild !== null) {
e.preventDefault();
this.setGhostStructure(matchedBuild);
if (this.canUseBuildKeybinds()) {
const matchedBuild = this.resolveBuildKeybind(e.code, e.shiftKey);
if (matchedBuild !== null) {
e.preventDefault();
this.setGhostStructure(matchedBuild);
}
}
if (this.keybindMatchesEvent(e, this.keybinds.requestAlliance)) {
@@ -943,6 +945,11 @@ export class InputHandler {
return null;
}
private canUseBuildKeybinds(): boolean {
const myPlayer = this.gameView.myPlayer?.();
return !this.gameView.inSpawnPhase() && myPlayer?.isAlive() === true;
}
private getPinchDistance(): number {
const pointerEvents = Array.from(this.pointers.values());
const dx = pointerEvents[0].clientX - pointerEvents[1].clientX;