mirror of
https://github.com/thepaperpilot/Planar-Pioneers.git
synced 2024-11-21 16:13:54 +00:00
Handle running out of energy
This commit is contained in:
parent
177f07c6bc
commit
155c4a2986
1 changed files with 12 additions and 0 deletions
|
@ -727,6 +727,18 @@ export const main = createLayer("main", function (this: BaseLayer) {
|
|||
}
|
||||
|
||||
energy.value = Decimal.add(energy.value, Decimal.times(computedEnergyModifier.value, diff));
|
||||
|
||||
if (Decimal.lt(energy.value, 0)) {
|
||||
// Uh oh, time to de-power machines!
|
||||
energy.value = 0;
|
||||
mine.value.state = { ...(mine.value.state as object), powered: false };
|
||||
toast.warning(
|
||||
<div>
|
||||
<h3>Ran out of energy!</h3>
|
||||
<div>All machines have been turned off.</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const energyChange = computed(() => {
|
||||
|
|
Loading…
Reference in a new issue