mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-05 17:40:24 +08:00
fix(CheatEnabler): retry invalid Dyson shell candidates
This commit is contained in:
@@ -162,17 +162,18 @@ public static class GeometryHelpers
|
||||
double num = 0.0;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
double num2 = Vector3.Distance(pos[i], pos[(i + 1) % 3]);
|
||||
float num2 = Vector3.Distance(pos[i], pos[(i + 1) % 3]);
|
||||
VectorLF3 vectorLF2 = ((VectorLF3)pos[i] + (VectorLF3)pos[(i + 1) % 3]) * 0.5;
|
||||
sum += vectorLF2 * num2;
|
||||
num += num2;
|
||||
num += (double)num2;
|
||||
}
|
||||
var radius = Math.Round(polygon[0].magnitude * 10.0) / 10.0;
|
||||
for (int j = 0; j < polygon.Length; j++)
|
||||
{
|
||||
polygon[j] = polygon[j].normalized * radius;
|
||||
}
|
||||
var center = (sum / num).normalized * radius;
|
||||
var normalized = (sum / num).normalized;
|
||||
var center = normalized * radius;
|
||||
float num3 = 0f;
|
||||
for (int k = 0; k < 3; k++)
|
||||
{
|
||||
@@ -189,12 +190,12 @@ public static class GeometryHelpers
|
||||
var cpPerVertex = gridScale * gridScale * DysonSphereConstants.CpPerVertexFactor;
|
||||
|
||||
var num5 = (int)((double)num3 / factor3 / gridSizeDouble + 2.5);
|
||||
var xaxis = VectorLF3.Cross(center, Vector3.up).normalized;
|
||||
var xaxis = VectorLF3.Cross(normalized, Vector3.up).normalized;
|
||||
if (xaxis.magnitude < 0.1)
|
||||
{
|
||||
xaxis = new VectorLF3(0f, 0f, 1f);
|
||||
}
|
||||
var yaxis = VectorLF3.Cross(xaxis, center).normalized;
|
||||
var yaxis = VectorLF3.Cross(xaxis, normalized).normalized;
|
||||
var raydir = xaxis * factor0 + yaxis * factor1;
|
||||
var w1axis = xaxis * (0.5 * gridSizeDouble) - yaxis * (factor3 * gridSizeDouble);
|
||||
var w2axis = xaxis * (0.5 * gridSizeDouble) + yaxis * (factor3 * gridSizeDouble);
|
||||
@@ -206,7 +207,9 @@ public static class GeometryHelpers
|
||||
var polynu = new double[3];
|
||||
for (int l = 0; l < 3; l++)
|
||||
{
|
||||
polyn[l] = VectorLF3.Cross(polygon[l], polygon[(l + 1) % 3]).normalized;
|
||||
Vector3 vector = polygon[l];
|
||||
Vector3 vector2 = polygon[(l + 1) % 3];
|
||||
polyn[l] = VectorLF3.Cross(vector, vector2).normalized;
|
||||
polynu[l] = polyn[l].x * raydir.x + polyn[l].y * raydir.y + polyn[l].z * raydir.z;
|
||||
}
|
||||
var vmap = _vmap.Value;
|
||||
|
||||
@@ -362,6 +362,7 @@ public static class IllegalShellFunctions
|
||||
{
|
||||
var sshell = supposedShells[j];
|
||||
var vertCount = GeometryHelpers.CalculateTriangleVertCount([sshell.posA, sshell.posB, sshell.posC]);
|
||||
sshell.vertCount = vertCount <= barrier ? vertCount : -1;
|
||||
if (vertCount <= barrier)
|
||||
{
|
||||
lock (mutex)
|
||||
@@ -385,16 +386,32 @@ public static class IllegalShellFunctions
|
||||
if (maxJ >= 0)
|
||||
{
|
||||
ResetLayerPools(layer);
|
||||
var sshell = supposedShells[maxJ];
|
||||
DysonNode[] newNodes = [layer.QuickAddDysonNode(0, sshell.posA), layer.QuickAddDysonNode(0, sshell.posB), layer.QuickAddDysonNode(0, sshell.posC)];
|
||||
DysonFrame[] newFrames = [layer.QuickAddDysonFrame(0, newNodes[0], newNodes[1], false), layer.QuickAddDysonFrame(0, newNodes[1], newNodes[2], false), layer.QuickAddDysonFrame(0, newNodes[2], newNodes[0], false)];
|
||||
layer.QuickAddDysonShell(0, newNodes, newFrames, false);
|
||||
foreach (var node in newNodes)
|
||||
foreach (var sshell in supposedShells.OrderByDescending(shell => shell.vertCount))
|
||||
{
|
||||
node.RecalcSpReq();
|
||||
node.RecalcCpReq();
|
||||
if (sshell.vertCount <= 0) break;
|
||||
|
||||
DysonNode[] newNodes = [layer.QuickAddDysonNode(0, sshell.posA), layer.QuickAddDysonNode(0, sshell.posB), layer.QuickAddDysonNode(0, sshell.posC)];
|
||||
DysonFrame[] newFrames = [layer.QuickAddDysonFrame(0, newNodes[0], newNodes[1], false), layer.QuickAddDysonFrame(0, newNodes[1], newNodes[2], false), layer.QuickAddDysonFrame(0, newNodes[2], newNodes[0], false)];
|
||||
if (layer.QuickAddDysonShell(0, newNodes, newFrames, false) == 0)
|
||||
{
|
||||
foreach (var frame in newFrames)
|
||||
{
|
||||
layer.QuickRemoveDysonFrame(frame.id);
|
||||
}
|
||||
foreach (var node in newNodes)
|
||||
{
|
||||
layer.QuickRemoveDysonNode(node.id);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
foreach (var node in newNodes)
|
||||
{
|
||||
node.RecalcSpReq();
|
||||
node.RecalcCpReq();
|
||||
}
|
||||
shellsChanged = true;
|
||||
break;
|
||||
}
|
||||
shellsChanged = true;
|
||||
}
|
||||
return shellsChanged;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user