diff --git a/CheatEnabler/Functions/DysonSphereFunctions.cs b/CheatEnabler/Functions/DysonSphereFunctions.cs index 5b40746..d9d0104 100644 --- a/CheatEnabler/Functions/DysonSphereFunctions.cs +++ b/CheatEnabler/Functions/DysonSphereFunctions.cs @@ -284,6 +284,7 @@ public static class DysonSphereFunctions gridScale = ((gridScale < 1) ? 1 : gridScale); var gridSize = (float)gridScale * 80f; var cpPerVertex = gridScale * gridScale * 2; + var num5 = (int)((double)num3 / 0.8660254037844386 / (double)gridSize + 2.5); var xaxis = VectorLF3.Cross(center, Vector3.up).normalized; if (xaxis.magnitude < 0.1) @@ -1147,7 +1148,8 @@ public static class DysonSphereFunctions { dysonSphere.RemoveLayer(1); } - layer = dysonSphere.AddLayerOnId(1, dysonSphere.maxOrbitRadius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / dysonSphere.maxOrbitRadius) / dysonSphere.maxOrbitRadius * 57.2957802f); + var maxOrbitRadius = Patches.DysonSpherePatch.UnlockMaxOrbitRadiusEnabled.Value ? Patches.DysonSpherePatch.UnlockMaxOrbitRadiusValue.Value : dysonSphere.maxOrbitRadius; + layer = dysonSphere.AddLayerOnId(1, maxOrbitRadius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / maxOrbitRadius) / maxOrbitRadius * 57.2957802f); if (layer == null) return; var supposedShells = new List(60 * 59 * 58); @@ -1172,11 +1174,20 @@ public static class DysonSphereFunctions var maxVertCount = -1; var maxJ = -1; var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount - 1 }; + + var gridScale = (int)(Math.Pow(maxOrbitRadius / 4000.0, 0.75) + 0.5); + gridScale = (gridScale < 1) ? 1 : gridScale; + var cpPerVertex = gridScale * gridScale * 2; + var barrier = 0x7FFFFFFF / cpPerVertex; + if (barrier > 32767) barrier = 32767; + var truncValue = barrier / 1000 * 1000; + CheatEnabler.Logger.LogDebug($"cpPerVertex: {cpPerVertex}, Barrier: {barrier}, TruncValue: {truncValue}"); + Parallel.For(0, supposedShells.Count, options, (j, loopState) => { var sshell = supposedShells[j]; var vertCount = CalculateTriangleVertCount([sshell.posA, sshell.posB, sshell.posC]); - if (vertCount < 32768) + if (vertCount <= barrier) { lock (mutex) { @@ -1185,7 +1196,7 @@ public static class DysonSphereFunctions { maxVertCount = vertCount; maxJ = j; - if (maxVertCount >= 32000) + if (maxVertCount >= truncValue) { CheatEnabler.Logger.LogDebug($"!!STOP!! Triangle {j}[{sshell.posA:F2} {sshell.posB:F2} {sshell.posC:F2}] has {vertCount} vertices"); loopState.Stop(); diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index be05216..bb88fe5 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -68,7 +68,7 @@ public static class UIConfigWindow I18N.Add("Overclock Silos", "Overclock Silos (10x)", "高速发射井(10倍射速)"); I18N.Add("Unlock Dyson Sphere max orbit radius", "Unlock Dyson Sphere max orbit radius", "解锁戴森球最大轨道半径"); I18N.Add("Complete Dyson Sphere shells instantly", "Complete Dyson Sphere shells instantly", "立即完成戴森壳建造"); - I18N.Add("Generate illegal dyson shell", "Generate an illegal dyson shell (Put/Paste nodes first)", "生成单层仙术戴森壳(请先设置/粘贴节点)"); + I18N.Add("Generate illegal dyson shell", "Generate an illegal dyson shell (!!All shells will be removed first!!)", "生成单层仙术戴森壳(!!会先删除全部的壳!!)"); I18N.Add("Keep max production shells and remove others", "Keep max production shells and remove others", "保留发电量最高的戴森壳并移除其他戴森壳"); I18N.Add("Duplicate shells from that with highest production", "Duplicate shells from that with highest production", "从发电量最高的壳复制戴森壳"); I18N.Add("WARNING: This operation can be very slow, continue?", "WARNING: This operation can be very slow, continue?", "警告:此操作可能非常慢,继续吗?");