From 93f9d7ae2300729363319c02b6e1d7795dc9b0d1 Mon Sep 17 00:00:00 2001 From: tobspr Date: Tue, 18 Aug 2020 20:12:18 +0200 Subject: [PATCH] Fix cutter --- src/js/game/systems/logic_gate.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/js/game/systems/logic_gate.js b/src/js/game/systems/logic_gate.js index faf95110..6914410e 100644 --- a/src/js/game/systems/logic_gate.js +++ b/src/js/game/systems/logic_gate.js @@ -226,6 +226,10 @@ export class LogicGateSystem extends GameSystemWithFilter { const definition = /** @type {ShapeItem} */ (item).definition; const lowerLayer = /** @type {import("../shape_definition").ShapeLayer} */ (definition.layers[0]); + if (!lowerLayer) { + return [null, null]; + } + const topRightContent = lowerLayer[0]; if (!topRightContent || topRightContent.subShape === null) { @@ -263,8 +267,12 @@ export class LogicGateSystem extends GameSystemWithFilter { const definition = /** @type {ShapeItem} */ (item).definition; const result = this.root.shapeDefinitionMgr.shapeActionCutHalf(definition); return [ - this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]), - this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]), + result[0].isEntirelyEmpty() + ? null + : this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[0]), + result[1].isEntirelyEmpty() + ? null + : this.root.shapeDefinitionMgr.getShapeItemFromDefinition(result[1]), ]; }