Handle running out of energy

This commit is contained in:
thepaperpilot 2023-04-23 14:19:35 -05:00
parent 177f07c6bc
commit 155c4a2986

View file

@ -727,6 +727,18 @@ export const main = createLayer("main", function (this: BaseLayer) {
} }
energy.value = Decimal.add(energy.value, Decimal.times(computedEnergyModifier.value, diff)); 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(() => { const energyChange = computed(() => {