Improve unit updates & reloading (#1394)

## Description:

Previously upgrading a unit would have it reload immediately, eg
upgrading missile silo 1=>2 gives it 2 missiles immediately. With this
change it must reload the missile. Same with SAMs. This prevents users
from spamming upgrades as missiles are coming in.

Fix the progress reloading bar. Previously it only showed the SAM/silo
as reloading when it was completely out of missiles. Now it shows
roughly how many missiles are available (eg level 5 fires 3 missiles,
now progress bar is at 40%). It also shows progress of missiles
reloading. If no missiles are available, progress bar is empty

There was a bug where if a silo of SAM was in cooldown it would be
updated each tick, causing the sprite/icon to be rerendered each tick.

## 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
- [x] I understand that submitting code with bugs that could have been
caught through manual testing blocks releases and new features for all
contributors

## Please put your Discord username so you can be contacted if a bug or
regression is found:

evan
This commit is contained in:
evanpelle
2025-07-10 10:06:05 -07:00
committed by GitHub
parent 0feb5d29c5
commit 488ffc5c9e
8 changed files with 89 additions and 62 deletions
+2 -4
View File
@@ -34,16 +34,14 @@ export class MissileSiloExecution implements Execution {
}
}
const frontTime = this.silo.ticksLeftInCooldown();
// frontTime is the time the earliest missile fired.
const frontTime = this.silo.missileTimerQueue()[0];
if (frontTime === undefined) {
return;
}
const cooldown =
this.mg.config().SiloCooldown() - (this.mg.ticks() - frontTime);
if (typeof cooldown === "number" && cooldown >= 0) {
this.silo.touch();
}
if (cooldown <= 0) {
this.silo.reloadMissile();
+1 -4
View File
@@ -190,16 +190,13 @@ export class SAMLauncherExecution implements Execution {
}
}
const frontTime = this.sam.ticksLeftInCooldown();
const frontTime = this.sam.missileTimerQueue()[0];
if (frontTime === undefined) {
return;
}
const cooldown =
this.mg.config().SAMCooldown() - (this.mg.ticks() - frontTime);
if (typeof cooldown === "number" && cooldown >= 0) {
this.sam.touch();
}
if (cooldown <= 0) {
this.sam.reloadMissile();