refactor(CheatEnabler/UniverseGen): consume centralized constants

This commit is contained in:
2026-06-23 20:41:20 +08:00
parent a133fd9e14
commit 25b33144b8
7 changed files with 92 additions and 94 deletions
@@ -2,6 +2,7 @@ using System;
using HarmonyLib;
using UnityEngine;
using UXAssist.Common;
using UXAssist.Common.GameConstants;
using UXAssist.Common.ModFeatures;
namespace CheatEnabler.Functions.DysonSphere;
@@ -46,7 +47,7 @@ public static class FrameRemovalFunctions
}
dysonSphereLayer.frameCursor = 1;
dysonSphereLayer.frameRecycleCursor = 0;
dysonSphereLayer.SetFrameCapacity(64);
dysonSphereLayer.SetFrameCapacity(DysonSphereConstants.DefaultLayerPoolCapacity);
totalFrameSpInfo?.SetValue(dysonSphereLayer, 0);
}
dysonSphere.CheckAutoNodes();
@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading;
using UnityEngine;
using UXAssist.Common;
using UXAssist.Common.GameConstants;
namespace CheatEnabler.Functions.DysonSphere;
@@ -39,7 +40,7 @@ public static class GeometryHelpers
new PrecalculatedTriangle() { MaxOrbitRadius = 209946, PosA = new Vector3() { x = RawToFloat(0x00000000U), y = RawToFloat(0x00000000U), z = RawToFloat(0x484D0500U)}, PosB = new Vector3() { x = RawToFloat(0x48092F52U), y = RawToFloat(0x00000000U), z = RawToFloat(0x48185BF5U)}, PosC = new Vector3() { x = RawToFloat(0x2F02C70CU), y = RawToFloat(0x00000000U), z = RawToFloat(0xC84D0500U)} },
new PrecalculatedTriangle() { MaxOrbitRadius = 224422, PosA = new Vector3() { x = RawToFloat(0x00000000U), y = RawToFloat(0x00000000U), z = RawToFloat(0x485B2900U)}, PosB = new Vector3() { x = RawToFloat(0x4812A593U), y = RawToFloat(0x00000000U), z = RawToFloat(0x4822DE24U)}, PosC = new Vector3() { x = RawToFloat(0x2F0BCC2BU), y = RawToFloat(0x00000000U), z = RawToFloat(0xC85B2900U)} },
new PrecalculatedTriangle() { MaxOrbitRadius = 239136, PosA = new Vector3() { x = RawToFloat(0x00000000U), y = RawToFloat(0x00000000U), z = RawToFloat(0x48698680U)}, PosB = new Vector3() { x = RawToFloat(0x481C424DU), y = RawToFloat(0x00000000U), z = RawToFloat(0x482D8B0EU)}, PosC = new Vector3() { x = RawToFloat(0x2F14F5F7U), y = RawToFloat(0x00000000U), z = RawToFloat(0xC8698680U)} },
new PrecalculatedTriangle() { MaxOrbitRadius = 250000, PosA = new Vector3() { x = RawToFloat(0x00000000U), y = RawToFloat(0x00000000U), z = RawToFloat(0x48742180U)}, PosB = new Vector3() { x = RawToFloat(0x48235AFEU), y = RawToFloat(0x00000000U), z = RawToFloat(0x48356CB1U)}, PosC = new Vector3() { x = RawToFloat(0x2F1BB9CEU), y = RawToFloat(0x00000000U), z = RawToFloat(0xC8742180U)} },
new PrecalculatedTriangle() { MaxOrbitRadius = DysonSphereConstants.MaxOrbitRadius, PosA = new Vector3() { x = RawToFloat(0x00000000U), y = RawToFloat(0x00000000U), z = RawToFloat(0x48742180U)}, PosB = new Vector3() { x = RawToFloat(0x48235AFEU), y = RawToFloat(0x00000000U), z = RawToFloat(0x48356CB1U)}, PosC = new Vector3() { x = RawToFloat(0x2F1BB9CEU), y = RawToFloat(0x00000000U), z = RawToFloat(0xC8742180U)} },
];
public struct PrecalculatedTriangle
@@ -181,11 +182,11 @@ public static class GeometryHelpers
num3 = num4;
}
}
var gridScale = (int)(Math.Pow(radius / 4000.0, 0.75) + 0.5);
var gridScale = (int)(Math.Pow(radius / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
gridScale = ((gridScale < 1) ? 1 : gridScale);
var gridSize = gridScale * 80f;
var gridSize = gridScale * DysonSphereConstants.GridSizeBase;
var gridSizeDouble = (double)gridSize;
var cpPerVertex = gridScale * gridScale * 2;
var cpPerVertex = gridScale * gridScale * DysonSphereConstants.CpPerVertexFactor;
var num5 = (int)((double)num3 / factor3 / gridSizeDouble + 2.5);
var xaxis = VectorLF3.Cross(center, Vector3.up).normalized;
@@ -317,11 +318,11 @@ public static class GeometryHelpers
num3 = num4;
}
}
shell.gridScale = (int)(Math.Pow(shell.radius / 4000.0, 0.75) + 0.5);
shell.gridScale = (int)(Math.Pow(shell.radius / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
shell.gridScale = ((shell.gridScale < 1) ? 1 : shell.gridScale);
shell.gridSize = shell.gridScale * 80f;
shell.gridSize = shell.gridScale * DysonSphereConstants.GridSizeBase;
var gridSizeDouble = (double)shell.gridSize;
shell.cpPerVertex = shell.gridScale * shell.gridScale * 2;
shell.cpPerVertex = shell.gridScale * shell.gridScale * DysonSphereConstants.CpPerVertexFactor;
int num5 = (int)((double)num3 / factor3 / gridSizeDouble + 2.5);
shell.xaxis = VectorLF3.Cross(normalized, Vector3.up).normalized;
if (shell.xaxis.magnitude < 0.1)
@@ -427,7 +428,7 @@ public static class GeometryHelpers
}
}
int count2 = DysonShell.s_vmap.Count;
if (count2 > 32767)
if (count2 > DysonSphereConstants.MaxShellVertices)
{
return false;
}
@@ -694,7 +695,7 @@ public static class GeometryHelpers
shell.id = shellId;
shell.layerId = layer.id;
shell.protoId = protoId;
shell.randSeed = layer.id * 10000 + shellId;
shell.randSeed = layer.id * DysonSphereConstants.ShellRandSeedMultiplier + shellId;
for (int j = 0; j < nodes.Length; j++)
{
DysonNode dysonNode = nodes[j];
@@ -718,7 +719,7 @@ public static class GeometryHelpers
shell.nodes.Add(dysonNode);
shell.frames.Add(dysonFrame);
}
if (!shell.GenerateCustomShellGeometry() || (limit && DysonShell.s_vmap.Count < 32000))
if (!shell.GenerateCustomShellGeometry() || (limit && DysonShell.s_vmap.Count < DysonSphereConstants.MinShellVertexThreshold))
{
CheatEnabler.Logger.LogDebug($"Stripped VertCount: {DysonShell.s_vmap.Count}");
shell.Free();
@@ -6,6 +6,7 @@ using CheatEnabler.Functions;
using static CheatEnabler.Functions.DysonSphere.GeometryHelpers;
using UnityEngine;
using UXAssist.Common;
using UXAssist.Common.GameConstants;
using UXAssist.Common.ModFeatures;
namespace CheatEnabler.Functions.DysonSphere;
@@ -22,20 +23,20 @@ public static class IllegalShellFunctions
private static void ResetLayerPools(DysonSphereLayer layer)
{
layer.nodePool = new DysonNode[64];
layer.nodeRecycle = new int[64];
layer.nodePool = new DysonNode[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.nodeRecycle = new int[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.nodeRecycleCursor = 0;
layer.nodeCapacity = 64;
layer.nodeCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.nodeCursor = 1;
layer.framePool = new DysonFrame[64];
layer.frameRecycle = new int[64];
layer.framePool = new DysonFrame[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.frameRecycle = new int[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.frameRecycleCursor = 0;
layer.frameCapacity = 64;
layer.frameCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.frameCursor = 1;
layer.shellPool = new DysonShell[64];
layer.shellRecycle = new int[64];
layer.shellPool = new DysonShell[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.shellRecycle = new int[DysonSphereConstants.DefaultLayerPoolCapacity];
layer.shellRecycleCursor = 0;
layer.shellCapacity = 64;
layer.shellCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.shellCursor = 1;
}
@@ -119,7 +120,7 @@ public static class IllegalShellFunctions
for (var j = 0; j < nodeCount; j++)
{
totalCpMax[j] += cpMax[j];
if (totalCpMax[j] > int.MaxValue)
if (totalCpMax[j] > DysonSphereConstants.TotalCpMaxCeiling)
{
totalCpMax[j] = cpMax[j];
dirtyFrames.Add(j > 0 ? j - 1 : nodeCount - 1);
@@ -166,7 +167,7 @@ public static class IllegalShellFunctions
shells[j] = null;
}
var poolCapacity = GeometryHelpers.AlignUpToPowerOfTwo(retainCount + 1);
if (poolCapacity < 64) poolCapacity = 64;
if (poolCapacity < DysonSphereConstants.DefaultLayerPoolCapacity) poolCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.shellPool = new DysonShell[poolCapacity];
layer.shellRecycle = new int[poolCapacity];
layer.shellRecycleCursor = 0;
@@ -192,7 +193,7 @@ public static class IllegalShellFunctions
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();
poolCapacity = GeometryHelpers.AlignUpToPowerOfTwo(frames.Length + 1);
if (poolCapacity < 64) poolCapacity = 64;
if (poolCapacity < DysonSphereConstants.DefaultLayerPoolCapacity) poolCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.framePool = new DysonFrame[poolCapacity];
layer.frameRecycle = new int[poolCapacity];
layer.frameRecycleCursor = 0;
@@ -212,7 +213,7 @@ public static class IllegalShellFunctions
}
}
poolCapacity = GeometryHelpers.AlignUpToPowerOfTwo(nodes.Length + 1);
if (poolCapacity < 64) poolCapacity = 64;
if (poolCapacity < DysonSphereConstants.DefaultLayerPoolCapacity) poolCapacity = DysonSphereConstants.DefaultLayerPoolCapacity;
layer.nodePool = new DysonNode[poolCapacity];
layer.nodeRecycle = new int[poolCapacity];
layer.nodeRecycleCursor = 0;
@@ -262,7 +263,7 @@ public static class IllegalShellFunctions
continue;
}
var radius = dysonSphere.maxOrbitRadius;
for (; radius > 4000; radius -= 10)
for (; radius > DysonSphereConstants.MinOrbitRadiusSearch; radius -= DysonSphereConstants.OrbitRadiusSearchStep)
{
if (dysonSphere.CheckLayerRadius(radius) == 0)
{
@@ -279,7 +280,7 @@ public static class IllegalShellFunctions
UIMessageBox.Show("CheatEnabler".Translate(), string.Format("No precalculated triangle found for radius {0}.".Translate(), radius), "确定".Translate(), UIMessageBox.ERROR, null);
return;
}
layer = dysonSphere.AddLayerOnId(i, radius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / radius) / radius * 57.2957802f);
layer = dysonSphere.AddLayerOnId(i, radius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / radius) / radius * DysonSphereConstants.RadiansToDegrees);
if (layer == null) return;
Vector3[] nodePos = [triangle.PosA.normalized * radius, triangle.PosB.normalized * radius, triangle.PosC.normalized * radius];
DysonNode[] nodes = [layer.QuickAddDysonNode(0, nodePos[0]), layer.QuickAddDysonNode(0, nodePos[1]), layer.QuickAddDysonNode(0, nodePos[2])];
@@ -296,7 +297,7 @@ public static class IllegalShellFunctions
for (var k = 0; k < 3; k++)
{
totalCpMax[k] += cpMax[k];
if (totalCpMax[k] > int.MaxValue)
if (totalCpMax[k] > DysonSphereConstants.TotalCpMaxCeiling)
{
totalCpMax[k] = cpMax[k];
dirtyFrames.Add(k > 0 ? k - 1 : 2);
@@ -325,17 +326,17 @@ public static class IllegalShellFunctions
EnsureDysonShellMaps();
var shellsChanged = false;
var mutex = new object();
var supposedShells = new List<SupposedShell>(60 * 59 * 58);
Vector3[] nodePos = new Vector3[60];
for (var i = 0; i < 60; i++)
var supposedShells = new List<SupposedShell>(DysonSphereConstants.MaxShellSearchCombinations);
Vector3[] nodePos = new Vector3[DysonSphereConstants.MaxShellSearchNodeCount];
for (var i = 0; i < DysonSphereConstants.MaxShellSearchNodeCount; i++)
{
nodePos[i] = new Vector3((float)Math.Sin(Math.PI * 2 * i / 60), 0, (float)Math.Cos(Math.PI * 2 * i / 60)) * layer.orbitRadius;
nodePos[i] = new Vector3((float)Math.Sin(Math.PI * 2 * i / DysonSphereConstants.MaxShellSearchNodeCount), 0, (float)Math.Cos(Math.PI * 2 * i / DysonSphereConstants.MaxShellSearchNodeCount)) * layer.orbitRadius;
}
for (var i = 0; i < 58; i++)
for (var i = 0; i < DysonSphereConstants.MaxShellSearchNodeCount - 2; i++)
{
for (var j = i + 1; j < 59; j++)
for (var j = i + 1; j < DysonSphereConstants.MaxShellSearchNodeCount - 1; j++)
{
for (var k = j + 1; k < 60; k++)
for (var k = j + 1; k < DysonSphereConstants.MaxShellSearchNodeCount; k++)
{
var area = Vector3.Cross(nodePos[j] - nodePos[i], nodePos[k] - nodePos[i]).sqrMagnitude;
supposedShells.Add(new SupposedShell { posA = nodePos[i], posB = nodePos[j], posC = nodePos[k], area = area });
@@ -348,11 +349,11 @@ public static class IllegalShellFunctions
var maxJ = -1;
var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount - 1 };
var gridScale = (int)(Math.Pow(layer.orbitRadius / 4000.0, 0.75) + 0.5);
var gridScale = (int)(Math.Pow(layer.orbitRadius / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
gridScale = (gridScale < 1) ? 1 : gridScale;
var cpPerVertex = gridScale * gridScale * 2;
var barrier = 0x7FFFFFFF / cpPerVertex;
if (barrier > 32767) barrier = 32767;
var cpPerVertex = gridScale * gridScale * DysonSphereConstants.CpPerVertexFactor;
var barrier = DysonSphereConstants.TotalCpMaxCeiling / cpPerVertex;
if (barrier > DysonSphereConstants.MaxShellVertices) barrier = DysonSphereConstants.MaxShellVertices;
var truncValue = barrier / 1000 * 1000;
CheatEnabler.Logger.LogDebug($"cpPerVertex: {cpPerVertex}, Barrier: {barrier}, TruncValue: {truncValue}");
@@ -409,7 +410,7 @@ public static class IllegalShellFunctions
dysonSphere.RemoveLayer(1);
}
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);
layer = dysonSphere.AddLayerOnId(1, maxOrbitRadius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / maxOrbitRadius) / maxOrbitRadius * DysonSphereConstants.RadiansToDegrees);
if (layer == null) return;
var shellsChanged = CreateIllegalDysonShellWithMaxOutputForLayer(layer);
@@ -437,16 +438,16 @@ public static class IllegalShellFunctions
{
var lastGridScale = 0;
var radiusList = new List<int>();
for (var r = 4000; r <= 250000; r++)
for (var r = DysonSphereConstants.MinOrbitRadiusSearch; r <= DysonSphereConstants.MaxOrbitRadius; r++)
{
var gridScale = (int)(Math.Pow(r / 4000.0, 0.75) + 0.5);
var gridScale = (int)(Math.Pow(r / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
gridScale = (gridScale < 1) ? 1 : gridScale;
if (gridScale == lastGridScale) continue;
lastGridScale = gridScale;
radiusList.Add(r);
CheatEnabler.Logger.LogDebug($"Grid Scale: {gridScale} from {r}");
}
radiusList.Add(250000);
radiusList.Add(DysonSphereConstants.MaxOrbitRadius);
var resolved = DysonSphereResolver.ResolveEditorOrLocalSphere(requireLayer: false);
if (resolved == null) return;
var (dysonSphere, star) = resolved.Value;
@@ -466,20 +467,20 @@ public static class IllegalShellFunctions
dysonSphere.RemoveLayer(idx);
}
var orbitRadius = (radiusList[idx] - 1) / 10 * 10f;
layer = dysonSphere.AddLayerOnId(idx, orbitRadius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / orbitRadius) / orbitRadius * 57.2957802f);
layer = dysonSphere.AddLayerOnId(idx, orbitRadius, Quaternion.Euler(0f, 0f, 0f), Mathf.Sqrt(dysonSphere.gravity / orbitRadius) / orbitRadius * DysonSphereConstants.RadiansToDegrees);
if (layer == null) return;
var supposedShells = new List<SupposedShell>(60 * 59 * 58);
Vector3[] nodePos = new Vector3[60];
for (var i = 0; i < 60; i++)
var supposedShells = new List<SupposedShell>(DysonSphereConstants.MaxShellSearchCombinations);
Vector3[] nodePos = new Vector3[DysonSphereConstants.MaxShellSearchNodeCount];
for (var i = 0; i < DysonSphereConstants.MaxShellSearchNodeCount; i++)
{
nodePos[i] = new Vector3((float)Math.Sin(Math.PI * 2 * i / 60), 0, (float)Math.Cos(Math.PI * 2 * i / 60));
nodePos[i] = new Vector3((float)Math.Sin(Math.PI * 2 * i / DysonSphereConstants.MaxShellSearchNodeCount), 0, (float)Math.Cos(Math.PI * 2 * i / DysonSphereConstants.MaxShellSearchNodeCount));
}
for (var i = 0; i < 58; i++)
for (var i = 0; i < DysonSphereConstants.MaxShellSearchNodeCount - 2; i++)
{
for (var j = i + 1; j < 59; j++)
for (var j = i + 1; j < DysonSphereConstants.MaxShellSearchNodeCount - 1; j++)
{
for (var k = j + 1; k < 60; k++)
for (var k = j + 1; k < DysonSphereConstants.MaxShellSearchNodeCount; k++)
{
var area = Vector3.Cross(nodePos[j] - nodePos[i], nodePos[k] - nodePos[i]).sqrMagnitude;
supposedShells.Add(new SupposedShell { posA = nodePos[i], posB = nodePos[j], posC = nodePos[k], area = area });
@@ -490,10 +491,10 @@ public static class IllegalShellFunctions
var options = new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount - 1 };
var gridScale = (int)(Math.Pow(orbitRadius / 4000.0, 0.75) + 0.5);
var gridScale = (int)(Math.Pow(orbitRadius / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
gridScale = (gridScale < 1) ? 1 : gridScale;
var cpPerVertex = gridScale * gridScale * 2;
var barrier = 0x7FFFFFFF / cpPerVertex;
var cpPerVertex = gridScale * gridScale * DysonSphereConstants.CpPerVertexFactor;
var barrier = DysonSphereConstants.TotalCpMaxCeiling / cpPerVertex;
if (barrier > 30000) barrier = 30000;
Parallel.For(0, supposedShells.Count, options, (j, _) =>
@@ -517,10 +518,10 @@ public static class IllegalShellFunctions
var result = Parallel.For((radiusList[idx - 1] + 9) / 10, (radiusList[idx] + 9) / 10, options, (k, loopState) =>
{
var orbitRadius = k * 10f;
var gridScale = (int)(Math.Pow(orbitRadius / 4000.0, 0.75) + 0.5);
var gridScale = (int)(Math.Pow(orbitRadius / DysonSphereConstants.GridScaleBaseRadius, 0.75) + 0.5);
gridScale = (gridScale < 1) ? 1 : gridScale;
var cpPerVertex = gridScale * gridScale * 2;
var barrier = 0x7FFFFFFF / cpPerVertex;
var cpPerVertex = gridScale * gridScale * DysonSphereConstants.CpPerVertexFactor;
var barrier = DysonSphereConstants.TotalCpMaxCeiling / cpPerVertex;
if (barrier > 31000) barrier = 31000;
if (loopState.ShouldExitCurrentIteration) return;
var vertCount = GeometryHelpers.CalculateTriangleVertCount([sshell.posA * orbitRadius, sshell.posB * orbitRadius, sshell.posC * orbitRadius]);
@@ -5,6 +5,7 @@ using HarmonyLib;
using UnityEngine;
using UXAssist.Common;
using GameLogicProc = UXAssist.Common.GameLogic;
using UXAssist.Common.GameConstants;
namespace CheatEnabler.Patches.Factory;
@@ -242,7 +243,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
CalculateAllProductions(result, extra, ref sprayedCount, itemId);
var proliferatorCount = 0f;
if (result.TryGetValue(1143, out var pv))
if (result.TryGetValue(ItemIds.ProliferatorMkIII, out var pv))
{
proliferatorCount = pv;
result.Remove(1143);
@@ -260,7 +261,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
}
if (proliferatorCount > 0f)
{
foreach (var p in ProliferatorSources)
foreach (var p in ItemIds.ProliferatorSources)
{
result[p.Item1] = (result.TryGetValue(p.Item1, out var v) ? v : 0) + p.Item2 * proliferatorCount / ProliferatorDenom;
}
@@ -591,11 +592,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
}
/* BEGIN: Item sources calculation */
private static readonly int[] ExtraOreItemIds = [1000, 1116, 1120, 1121, 1208, 5201, 5202, 5203, 5204, 5205, 5206];
private static readonly HashSet<int> ExtraProliferationItemIds = [1107, 1111, 1125, 1142, 1143, 1202, 1203, 1204, 1205, 1209, 1210, 1301, 1305, 1401, 1402, 1403, 1405, 1406, 1502, 1503, 1802, 6001, 6003, 6004, 6005, 6006];
private static readonly HashSet<int> NoProliferationItemIds = [1126, 6002];
// All source items used to create 25 proliferators mk.III (not self-sprayed)
private static readonly List<(int, float)> ProliferatorSources = [(1015, 60f), (1124, 20f), (1006, 64f), (1012, 16f), (1112, 32f), (1141, 64f), (1142, 40f), (1143, 25f)];
// Item ID constants are provided by UXAssist.Common.GameConstants.ItemIds.
private const float ProliferatorDenom = 21f;
// One sprayed proliferator mk.III can spray 75 items, but one is used for spray itself, so the actual count is 74
private const float ProliferatorSpayCount = 74f;
@@ -626,7 +623,7 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
}
// 水、硫酸、氢、重氢、光子
foreach (var itemId in ExtraOreItemIds)
foreach (var itemId in ItemIds.ExtraOreItemIds)
{
ItemSources[itemId] = new ItemSource { Count = 1 };
}
@@ -725,16 +722,16 @@ internal class BeltSignalGenerator : PatchImpl<BeltSignalGenerator>
}
}
if (itemId == 1143 || itemSource.From == null) return;
if (itemId == ItemIds.ProliferatorMkIII || itemSource.From == null) return;
var useProliferator = FactoryPatch.BeltSignalUseProliferatorEnabled.Value;
if (useProliferator && ExtraProliferationItemIds.Contains(itemId))
if (useProliferator && ItemIds.ExtraProliferationItemIds.Contains(itemId))
{
times *= 0.8f;
}
foreach (var p in itemSource.From)
{
var value = p.Value * times;
if (useProliferator && !NoProliferationItemIds.Contains(p.Key)) sprayedCount += value;
if (useProliferator && !ItemIds.NoProliferationItemIds.Contains(p.Key)) sprayedCount += value;
if (extra.TryGetValue(p.Key, out var rcount))
{
if (value <= rcount)
@@ -3,6 +3,7 @@ using System.Reflection.Emit;
using HarmonyLib;
using UnityEngine;
using UXAssist.Common;
using UXAssist.Common.GameConstants;
namespace CheatEnabler.Patches.Factory;
@@ -157,7 +158,7 @@ internal static class WindTurbinesPowerGlobalCoverage
private static PrefabDesc _prefabdesc;
private static float _oldCoverRadius;
private static float _oldConnectDistance;
private const int WindTurbineId = 2203;
private const int WindTurbineId = ItemIds.WindTurbine;
private const float WindTurbineNewCoverageDistance = 500f;
public static void Enable(bool enable)