From 48c83fedd5a9062c103d8e4f7e3e0ebb6afdc358 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 22 May 2025 20:56:21 +0800 Subject: [PATCH] work in progress --- .../Functions/DysonSphereFunctions.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/CheatEnabler/Functions/DysonSphereFunctions.cs b/CheatEnabler/Functions/DysonSphereFunctions.cs index 89bb227..60de08f 100644 --- a/CheatEnabler/Functions/DysonSphereFunctions.cs +++ b/CheatEnabler/Functions/DysonSphereFunctions.cs @@ -988,6 +988,7 @@ public static class DysonSphereFunctions shells[j] = null; } var count = UpToPowerOfTwo(retainCount + 1); + if (count < 64) count = 64; layer.shellPool = new DysonShell[count]; layer.shellRecycle = new int[count]; layer.shellRecycleCursor = 0; @@ -1013,6 +1014,7 @@ public static class DysonSphereFunctions var nodes = layer.nodePool.Where(node => node != null && retainNodes.Contains(node.id)).ToArray(); var frames = layer.framePool.Where(frame => frame != null && retainFrames.Contains((frame.nodeA.id, frame.nodeB.id))).ToArray(); count = UpToPowerOfTwo(frames.Length + 1); + if (count < 64) count = 64; layer.framePool = new DysonFrame[count]; layer.frameRecycle = new int[count]; layer.frameRecycleCursor = 0; @@ -1025,6 +1027,7 @@ public static class DysonSphereFunctions frames[j].id = id; } count = UpToPowerOfTwo(nodes.Length + 1); + if (count < 64) count = 64; layer.nodePool = new DysonNode[count]; layer.nodeRecycle = new int[count]; layer.nodeRecycleCursor = 0; @@ -1035,8 +1038,21 @@ public static class DysonSphereFunctions int id = j + 1; layer.nodePool[id] = nodes[j]; nodes[j].id = id; - nodes[j].RecalcSpReq(); - nodes[j].RecalcCpReq(); + } + for (var j = 1; j < layer.shellCursor; j++) + { + var shell = layer.shellPool[j]; + shell.nodeIndexMap.Clear(); + for (var k = 0; k < shell.nodes.Count; k++) + { + shell.nodeIndexMap[shell.nodes[k].id] = k; + } + } + for (var j = 1; j < layer.nodeCursor; j++) + { + var node = layer.nodePool[j]; + node.RecalcSpReq(); + node.RecalcCpReq(); } } dysonSphere.CheckAutoNodes();