()
| 279 | const initialOptions = { rechargeTime, units }; |
| 280 | |
| 281 | const updateTime = () => { |
| 282 | const now = state.game.time; |
| 283 | // Reset time remaining if time goes backwards. |
| 284 | if (now < lastTime) { |
| 285 | timeRemaining = 0; |
| 286 | } else { |
| 287 | // update... |
| 288 | timeRemaining -= now-lastTime; |
| 289 | if (timeRemaining < 0) timeRemaining = 0; |
| 290 | } |
| 291 | lastTime = now; |
| 292 | }; |
| 293 | |
| 294 | const canUse = () => { |
| 295 | updateTime(); |