From 0b517cb48bdfd62ff000fca33fd5cf890c392f0e Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Sat, 22 Apr 2023 20:35:19 -0500 Subject: [PATCH] Fix new resource spawning --- 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 a4c4826..c0f9690 100644 --- a/src/data/projEntry.tsx +++ b/src/data/projEntry.tsx @@ -246,13 +246,16 @@ export const main = createLayer("main", function (this: BaseLayer) { function grantResource(type: Resources, amount: DecimalSource) { let node = resourceNodes.value[type]; if (node == null) { - let x = 0; + const mine = board.nodes.value.find(n => n.type === "mine") as BoardNode; + let x = mine.position.x; x = board.nodes.value - .filter(n => n.position.y < 50 && n.position.y > -50) + .filter( + n => n.position.y < mine.position.y + 50 && n.position.y > mine.position.y - 50 + ) .reduce((x, node) => Math.max(x, node.position.x + 100), 0); node = { id: getUniqueNodeID(board), - position: { x, y: 0 }, + position: { x, y: mine.position.y }, type: "resource", state: { type, amount } };