From 5dc4b4eaae5532112afcb9c51b15055f264aa20b Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 17 May 2023 20:05:13 -0500 Subject: [PATCH] Fix error when running out of power --- src/data/projEntry.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/data/projEntry.tsx b/src/data/projEntry.tsx index 0ce7ca9..fc02dbc 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -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; });