1
0
mirror of https://github.com/soarqin/DSP_Mods.git synced 2025-12-15 05:53:42 +08:00

work in progress

This commit is contained in:
2025-05-22 20:56:21 +08:00
parent e1c1d9d8bd
commit 2a8e5f7514

View File

@@ -988,6 +988,7 @@ public static class DysonSphereFunctions
shells[j] = null; shells[j] = null;
} }
var count = UpToPowerOfTwo(retainCount + 1); var count = UpToPowerOfTwo(retainCount + 1);
if (count < 64) count = 64;
layer.shellPool = new DysonShell[count]; layer.shellPool = new DysonShell[count];
layer.shellRecycle = new int[count]; layer.shellRecycle = new int[count];
layer.shellRecycleCursor = 0; 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 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(); var frames = layer.framePool.Where(frame => frame != null && retainFrames.Contains((frame.nodeA.id, frame.nodeB.id))).ToArray();
count = UpToPowerOfTwo(frames.Length + 1); count = UpToPowerOfTwo(frames.Length + 1);
if (count < 64) count = 64;
layer.framePool = new DysonFrame[count]; layer.framePool = new DysonFrame[count];
layer.frameRecycle = new int[count]; layer.frameRecycle = new int[count];
layer.frameRecycleCursor = 0; layer.frameRecycleCursor = 0;
@@ -1025,6 +1027,7 @@ public static class DysonSphereFunctions
frames[j].id = id; frames[j].id = id;
} }
count = UpToPowerOfTwo(nodes.Length + 1); count = UpToPowerOfTwo(nodes.Length + 1);
if (count < 64) count = 64;
layer.nodePool = new DysonNode[count]; layer.nodePool = new DysonNode[count];
layer.nodeRecycle = new int[count]; layer.nodeRecycle = new int[count];
layer.nodeRecycleCursor = 0; layer.nodeRecycleCursor = 0;
@@ -1035,8 +1038,21 @@ public static class DysonSphereFunctions
int id = j + 1; int id = j + 1;
layer.nodePool[id] = nodes[j]; layer.nodePool[id] = nodes[j];
nodes[j].id = id; 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(); dysonSphere.CheckAutoNodes();