From 35fad1f5b55520160bbc8ba58bddc2df52a961df Mon Sep 17 00:00:00 2001 From: circle-gon <97845741+circle-gon@users.noreply.github.com> Date: Tue, 20 Dec 2022 21:26:48 +0000 Subject: [PATCH] checkout --- src/data/layers/factory.tsx | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/data/layers/factory.tsx b/src/data/layers/factory.tsx index 3438452..43d5196 100644 --- a/src/data/layers/factory.tsx +++ b/src/data/layers/factory.tsx @@ -217,21 +217,29 @@ const factory = createLayer(id, () => { }); const graphicContainer = new Graphics(); let spriteContainer = new Container(); - const movingBlocks = new Container(); - - graphicContainer.zIndex = 1; - movingBlocks.zIndex = 2; - app.stage.addChild(graphicContainer, spriteContainer, movingBlocks); + let movingBlocks = new Container(); + resetContainers(); + app.stage.addChild(graphicContainer); app.stage.sortableChildren = true; let loaded = false; + function resetContainers() { + spriteContainer.destroy({ children: true }); + movingBlocks.destroy({ children: true }); + spriteContainer = new Container(); + movingBlocks = new Container(); + graphicContainer.zIndex = 1; + /*graphicContainer.position.x = 0.5 + graphicContainer.position.y = 0.5 + movingBlocks.position.x = 0.5 + movingBlocks.position.y = 0.5*/ + movingBlocks.zIndex = 2; + app.stage.addChild(spriteContainer, movingBlocks); + } + globalBus.on("onLoad", async () => { loaded = false; - spriteContainer.destroy({ - children: true - }); - spriteContainer = new Container(); - app.stage.addChild(spriteContainer); + resetContainers(); for (const y of components.value.keys()) { for (const x of components.value[y].keys()) { const data = components.value[y][x]; @@ -287,6 +295,13 @@ const factory = createLayer(id, () => { if (compBehind.type === "conveyor") { // push it to the next conveyor, kill it from the // curent conveyor + // too many packages + if ( + compBehind.nextPackages.length + + compBehind.packages.length >= + 1 + ) + continue; block.lastX += dirAmt; compBehind.nextPackages.push(block); compData.packages.splice(key, 1);