Fix error when running out of power

This commit is contained in:
thepaperpilot 2023-05-17 20:05:13 -05:00
parent ef5b38d67b
commit 5dc4b4eaae

View file

@ -870,9 +870,12 @@ export const main = createLayer("main", function (this: BaseLayer) {
if (Decimal.lt(energy.value, 0)) {
// Uh oh, time to de-power machines!
energy.value = 0;
poweredMachines.forEach(machine => {
(machine.value?.state as { powered: boolean }).powered = false;
});
poweredMachines
.map(m => m.value)
.filter(machine => machine != null)
.forEach(machine => {
(machine?.state as { powered: boolean }).powered = false;
});
Object.values(portalNodes.value).forEach(portal => {
(portal.state as { powered: boolean }).powered = false;
});