diff --git a/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs b/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs index 596dbd5..fa98448 100644 --- a/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs +++ b/CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs @@ -1,12 +1,10 @@ using System; using UnityEngine; using UXAssist.Common; -using UXAssist.Common.ModFeatures; using CheatEnabler; namespace CheatEnabler.Functions.DysonSphere; -[ModFeature("DysonSphereResolver")] public static class DysonSphereResolver { public static (global::DysonSphere sphere, StarData star)? ResolveCurrent() diff --git a/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs b/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs index 18ce27b..c3da420 100644 --- a/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs +++ b/CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs @@ -3,13 +3,11 @@ using HarmonyLib; using UnityEngine; using UXAssist.Common; using UXAssist.Common.GameConstants; -using UXAssist.Common.ModFeatures; using UXAssist.Common.Utils; using CheatEnabler; namespace CheatEnabler.Functions.DysonSphere; -[ModFeature("FrameRemovalFunctions")] public static class FrameRemovalFunctions { public static void RemoveAllFrames() diff --git a/CheatEnabler/Functions/DysonSphere/IllegalShellFunctions.cs b/CheatEnabler/Functions/DysonSphere/IllegalShellFunctions.cs index 698d6f9..2bf4cb8 100644 --- a/CheatEnabler/Functions/DysonSphere/IllegalShellFunctions.cs +++ b/CheatEnabler/Functions/DysonSphere/IllegalShellFunctions.cs @@ -7,12 +7,10 @@ using static CheatEnabler.Functions.DysonSphere.GeometryHelpers; using UnityEngine; using UXAssist.Common; using UXAssist.Common.GameConstants; -using UXAssist.Common.ModFeatures; using CheatEnabler; namespace CheatEnabler.Functions.DysonSphere; -[ModFeature("IllegalShellFunctions")] public static class IllegalShellFunctions { private static void EnsureDysonShellMaps() @@ -41,7 +39,7 @@ public static class IllegalShellFunctions layer.shellCursor = 1; } - private static void FinalizeDysonSphereChanges(global::DysonSphere sphere, DysonSphereLayer layer, bool notify = false, bool resetRenderMasks = false) + private static void FinalizeDysonSphereChanges(global::DysonSphere sphere, bool notify = false, bool resetRenderMasks = false) { if (sphere == null) return; sphere.CheckAutoNodes(); @@ -140,7 +138,7 @@ public static class IllegalShellFunctions node.RecalcSpReq(); node.RecalcCpReq(); } - FinalizeDysonSphereChanges(dysonSphere, layer, true, true); + FinalizeDysonSphereChanges(dysonSphere, true, true); } public static void KeepMaxProductionShells() @@ -245,7 +243,7 @@ public static class IllegalShellFunctions node.RecalcCpReq(); } } - FinalizeDysonSphereChanges(dysonSphere, null); + FinalizeDysonSphereChanges(dysonSphere); } public static void CreateIllegalDysonShellQuickly(int triangleCount) @@ -317,7 +315,7 @@ public static class IllegalShellFunctions node.RecalcSpReq(); node.RecalcCpReq(); } - FinalizeDysonSphereChanges(dysonSphere, layer, true); + FinalizeDysonSphereChanges(dysonSphere, true); return; } } @@ -433,7 +431,7 @@ public static class IllegalShellFunctions var shellsChanged = CreateIllegalDysonShellWithMaxOutputForLayer(layer); - FinalizeDysonSphereChanges(dysonSphere, layer, shellsChanged, true); + FinalizeDysonSphereChanges(dysonSphere, shellsChanged, true); } public static void CreateIllegalDysonShellWithMaxOutputForAllLayers() @@ -449,7 +447,7 @@ public static class IllegalShellFunctions shellsChanged = CreateIllegalDysonShellWithMaxOutputForLayer(layer) || shellsChanged; } - FinalizeDysonSphereChanges(dysonSphere, dysonSphere.layersSorted.FirstOrDefault(l => l != null), shellsChanged, true); + FinalizeDysonSphereChanges(dysonSphere, shellsChanged, true); } public static void CreateIllegalDysonShellsSpecially() @@ -477,8 +475,6 @@ public static class IllegalShellFunctions for (var idx = 1; idx <= 2; idx++) { - Dictionary<(int, int), int> availableFrames = []; - HashSet unusedFrameIds = []; var layer = dysonSphere.layersIdBased[idx]; if (layer != null) { @@ -571,6 +567,6 @@ public static class IllegalShellFunctions } } - FinalizeDysonSphereChanges(dysonSphere, dysonSphere.layersIdBased[2], shellsChanged, true); + FinalizeDysonSphereChanges(dysonSphere, shellsChanged, true); } } diff --git a/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs b/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs index 32c60f6..a89f943 100644 --- a/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs +++ b/CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs @@ -3,13 +3,11 @@ using System.Linq; using HarmonyLib; using UnityEngine; using UXAssist.Common; -using UXAssist.Common.ModFeatures; using UXAssist.Common.Utils; using CheatEnabler; namespace CheatEnabler.Functions.DysonSphere; -[ModFeature("ShellCompletionFunctions")] public static class ShellCompletionFunctions { public static void CompleteShellsInstantly() diff --git a/CheatEnabler/Functions/DysonSphereFunctions.cs b/CheatEnabler/Functions/DysonSphereFunctions.cs index 467a24a..552d910 100644 --- a/CheatEnabler/Functions/DysonSphereFunctions.cs +++ b/CheatEnabler/Functions/DysonSphereFunctions.cs @@ -1,11 +1,9 @@ using BepInEx.Configuration; using CheatEnabler.Functions.DysonSphere; using UXAssist.Common; -using UXAssist.Common.ModFeatures; namespace CheatEnabler.Functions; -[ModFeature("CheatDysonSphere", Order = 20)] public static class DysonSphereFunctions { public const int MinShellsCountForFunctions = 1; diff --git a/CheatEnabler/Functions/PlanetFunctions.cs b/CheatEnabler/Functions/PlanetFunctions.cs index 371232d..cfc0e1c 100644 --- a/CheatEnabler/Functions/PlanetFunctions.cs +++ b/CheatEnabler/Functions/PlanetFunctions.cs @@ -1,9 +1,7 @@ using Random = UnityEngine.Random; -using UXAssist.Common.ModFeatures; namespace CheatEnabler.Functions; -[ModFeature("PlanetFunctions")] public static class PlanetFunctions { public static void BuryAllVeins(bool bury) @@ -35,4 +33,4 @@ public static class PlanetFunctions } GameMain.gpuiManager.SyncAllGPUBuffer(); } -} \ No newline at end of file +} diff --git a/CheatEnabler/Functions/PlayerFunctions.cs b/CheatEnabler/Functions/PlayerFunctions.cs index d3e38a2..8e3f88d 100644 --- a/CheatEnabler/Functions/PlayerFunctions.cs +++ b/CheatEnabler/Functions/PlayerFunctions.cs @@ -2,11 +2,9 @@ using System.Linq; using UXAssist.Common; using UXAssist.Common.GameConstants; -using UXAssist.Common.ModFeatures; namespace CheatEnabler.Functions; -[ModFeature("PlayerFunctions")] public static class PlayerFunctions { public static void Init() diff --git a/CheatEnabler/Patches/Factory/BeltSignalPatch.cs b/CheatEnabler/Patches/Factory/BeltSignalPatch.cs index fc053da..7c22769 100644 --- a/CheatEnabler/Patches/Factory/BeltSignalPatch.cs +++ b/CheatEnabler/Patches/Factory/BeltSignalPatch.cs @@ -16,7 +16,6 @@ internal class BeltSignalGenerator : PatchImpl private static Dictionary[] _signalBelts; private static Dictionary _portalFrom; private static Dictionary> _portalTo; - private static int _signalBeltsCapacity; private static bool _initialized; private static ProductionCatalog _sourceCatalog; private static ProductionItem _preferredProliferator; @@ -50,7 +49,6 @@ internal class BeltSignalGenerator : PatchImpl _signalBelts = null; _portalFrom = null; _portalTo = null; - _signalBeltsCapacity = 0; PendingSources.Clear(); ClearSourceCache(); } @@ -84,7 +82,6 @@ internal class BeltSignalGenerator : PatchImpl GameLogicProc.OnGameBegin -= OnGameBegin; _initialized = false; _signalBelts = null; - _signalBeltsCapacity = 0; PendingSources.Clear(); ClearSourceCache(); } @@ -181,7 +178,6 @@ internal class BeltSignalGenerator : PatchImpl { if (DSPGame.IsMenuDemo) return; _signalBelts = new Dictionary[64]; - _signalBeltsCapacity = 64; _portalFrom = []; _portalTo = []; @@ -225,13 +221,12 @@ internal class BeltSignalGenerator : PatchImpl { Dictionary obj; if (index < 0) return null; - if (index >= _signalBeltsCapacity) + if (index >= _signalBelts.Length) { - var newCapacity = _signalBeltsCapacity * 2; + var newCapacity = _signalBelts.Length * 2; var newSignalBelts = new Dictionary[newCapacity]; - Array.Copy(_signalBelts, newSignalBelts, _signalBeltsCapacity); + Array.Copy(_signalBelts, newSignalBelts, _signalBelts.Length); _signalBelts = newSignalBelts; - _signalBeltsCapacity = newCapacity; } else { @@ -246,7 +241,7 @@ internal class BeltSignalGenerator : PatchImpl private static Dictionary GetSignalBelts(int index) { - return index >= 0 && index < _signalBeltsCapacity ? _signalBelts[index] : null; + return index >= 0 && _signalBelts != null && index < _signalBelts.Length ? _signalBelts[index] : null; } private static void SetSignalBelt(int factory, int beltId, int signalId, int number) diff --git a/CheatEnabler/Patches/Tech/TechClickHandler.cs b/CheatEnabler/Patches/Tech/TechClickHandler.cs index 8b12d14..cf89a44 100644 --- a/CheatEnabler/Patches/Tech/TechClickHandler.cs +++ b/CheatEnabler/Patches/Tech/TechClickHandler.cs @@ -17,7 +17,7 @@ internal static class TechClickHandler } catch (Exception e) { - TechLog.Warn($"click handling failed: {e}"); + CheatEnabler.Logger.LogWarning($"[TechTweaks] click handling failed: {e}"); } } @@ -40,7 +40,7 @@ internal static class TechClickHandler return; } - if (!TechKeyCombo.TryDecode(out int steps)) + if (!TryDecodeModifiers(out int steps)) { return; } @@ -54,4 +54,32 @@ internal static class TechClickHandler TechUnlock.Run(history, techProto, steps); } } + + private static bool TryDecodeModifiers(out int steps) + { + steps = 0; + + if (VFInput.shift) + { + if (VFInput.alt) return false; + steps = VFInput.control ? 100 : 1; + return true; + } + + if (VFInput.control) + { + if (VFInput.alt) return false; + steps = 10; + return true; + } + + if (VFInput.alt) + { + // Alt applies or reverts every level available to this click. + steps = int.MaxValue; + return true; + } + + return false; + } } diff --git a/CheatEnabler/Patches/Tech/TechDowngrade.cs b/CheatEnabler/Patches/Tech/TechDowngrade.cs index 7391d7c..66d015f 100644 --- a/CheatEnabler/Patches/Tech/TechDowngrade.cs +++ b/CheatEnabler/Patches/Tech/TechDowngrade.cs @@ -20,7 +20,7 @@ internal static class TechDowngrade { if (!TryGetLastAppliedLevel(history, techProto, out int lastApplied) || steps <= 0) return; - int target = steps == TechKeyCombo.LevelToMax + int target = steps == int.MaxValue ? techProto.Level - 1 : System.Math.Max(techProto.Level - 1, lastApplied - steps); Targets.Clear(); diff --git a/CheatEnabler/Patches/Tech/TechFuncRevert.cs b/CheatEnabler/Patches/Tech/TechFuncRevert.cs index ade610d..a823111 100644 --- a/CheatEnabler/Patches/Tech/TechFuncRevert.cs +++ b/CheatEnabler/Patches/Tech/TechFuncRevert.cs @@ -410,7 +410,7 @@ namespace CheatEnabler.Patches.Tech // a downgrade can walk thousands of levels and must not flood the log. if (UnknownFuncsWarned.Add(func)) { - TechLog.Warn($"revert: no inverse known for tech function {func} (value={value}, level={level}); " + + CheatEnabler.Logger.LogWarning($"[TechTweaks] revert: no inverse known for tech function {func} (value={value}, level={level}); " + "the field was left untouched. A game update may have added a new function."); } @@ -429,7 +429,7 @@ namespace CheatEnabler.Patches.Tech ModeConfig freeMode = Configs.freeMode; if (freeMode == null) { - TechLog.Warn($"recompute of tech function {func} skipped: Configs.freeMode is not available"); + CheatEnabler.Logger.LogWarning($"[TechTweaks] recompute of tech function {func} skipped: Configs.freeMode is not available"); return; } @@ -819,7 +819,7 @@ namespace CheatEnabler.Patches.Tech if (Configs.freeMode == null || history.gameData == null || player?.mecha == null || player.package?.grids == null || player.deliveryPackage?.grids == null) { - TechLog.Warn("downgrade skipped: game data is not ready"); + CheatEnabler.Logger.LogWarning("[TechTweaks] downgrade skipped: game data is not ready"); return false; } @@ -836,7 +836,7 @@ namespace CheatEnabler.Patches.Tech int func = proto.UnlockFunctions[j]; if (!(func is >= 1 and <= 45 or >= 61 and <= 86 or 99)) { - TechLog.Warn($"downgrade skipped: unsupported tech function {func} in tech {proto.ID}"); + CheatEnabler.Logger.LogWarning($"[TechTweaks] downgrade skipped: unsupported tech function {func} in tech {proto.ID}"); UIRealtimeTip.Popup(Localization.TechDowngradeUnsupportedFunction.Translate()); return false; } diff --git a/CheatEnabler/Patches/Tech/TechKeyCombo.cs b/CheatEnabler/Patches/Tech/TechKeyCombo.cs deleted file mode 100644 index 677bf10..0000000 --- a/CheatEnabler/Patches/Tech/TechKeyCombo.cs +++ /dev/null @@ -1,59 +0,0 @@ -namespace CheatEnabler.Patches.Tech; - -/// -/// The key-modifier semantics shared by the upgrade and the downgrade side. -/// -/// Both directions use the same modifier mapping: -/// -/// -/// Shift+1 / -1 -/// Ctrl+10 / -10 -/// Ctrl + Shift+100 / -100 -/// Altto MAX / back to locked -/// Shift + Alt, Ctrl + Altignored -/// -/// -internal static class TechKeyCombo -{ - /// Sentinel for the "Alt" combination: apply or revert everything this click can. - public const int LevelToMax = int.MaxValue; - - /// - /// Decodes the currently held modifiers. - /// Returns false when the combination carries no meaning and the click must be left alone. - /// - public static bool TryDecode(out int steps) - { - steps = 0; - - if (VFInput.shift) - { - if (VFInput.alt) - { - return false; - } - - steps = VFInput.control ? 100 : 1; - return true; - } - - if (VFInput.control) - { - if (VFInput.alt) - { - return false; - } - - steps = 10; - return true; - } - - if (VFInput.alt) - { - steps = LevelToMax; - return true; - } - - return false; - } -} diff --git a/CheatEnabler/Patches/Tech/TechLog.cs b/CheatEnabler/Patches/Tech/TechLog.cs deleted file mode 100644 index e8eb463..0000000 --- a/CheatEnabler/Patches/Tech/TechLog.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CheatEnabler.Patches.Tech; - -/// -/// Single funnel for the tech unlock / downgrade feature's log output. -/// -/// Only real problems are reported: a Harmony target that no longer resolves, a tech function without -/// a known inverse, or a refused package resize. Those are conditions the player or the maintainer -/// needs to know about after a game update. -/// -internal static class TechLog -{ - public static void Warn(string message) - { - CheatEnabler.Logger.LogWarning("[TechTweaks] " + message); - } -} diff --git a/CheatEnabler/Patches/Tech/TechUnlock.cs b/CheatEnabler/Patches/Tech/TechUnlock.cs index 15118d8..f681f15 100644 --- a/CheatEnabler/Patches/Tech/TechUnlock.cs +++ b/CheatEnabler/Patches/Tech/TechUnlock.cs @@ -17,7 +17,7 @@ internal static class TechUnlock { // Mirrors the built-in maxLevel argument: "to MAX" passes the default, the other combinations // pass -(steps) so the loop advances exactly `steps` levels. - int maxLevel = steps == TechKeyCombo.LevelToMax ? 10000 : -steps; + int maxLevel = steps == int.MaxValue ? 10000 : -steps; UnlockTechRecursive(history, techProto, maxLevel); diff --git a/CheatEnabler/UIConfigWindow.cs b/CheatEnabler/UIConfigWindow.cs index 58f0e49..58aef83 100644 --- a/CheatEnabler/UIConfigWindow.cs +++ b/CheatEnabler/UIConfigWindow.cs @@ -12,8 +12,6 @@ namespace CheatEnabler; public static class UIConfigWindow { - private static RectTransform _windowTrans; - private static UIButton _resignGameBtn; private static UIButton _clearBanBtn; @@ -76,13 +74,12 @@ public static class UIConfigWindow private static void CreateUI(MyConfigWindow wnd, RectTransform trans) { - _windowTrans = trans; // General tab var x = 0f; var y = 10f; wnd.AddSplitter(trans, 10f); wnd.AddTabGroup(trans, "Cheat Enabler", "tab-group-cheatenabler"); - var tab1 = wnd.AddTab(_windowTrans, "General"); + var tab1 = wnd.AddTab(trans, "General"); var cb = wnd.AddCheckBox(x, y, tab1, GamePatch.DevShortcutsEnabled, "Enable Dev Shortcuts"); x += cb.Width + 5f; y += 6f; @@ -107,7 +104,7 @@ public static class UIConfigWindow y = 10f; _resignGameBtn = wnd.AddButton(x, y, 300f, tab1, "Assign gamesave to current account", 16, "resign-game-btn", () => { GameMain.data.account = AccountData.me; }); - var tab2 = wnd.AddTab(_windowTrans, "Factory"); + var tab2 = wnd.AddTab(trans, "Factory"); x = 0f; y = 10f; wnd.AddCheckBox(x, y, tab2, FactoryPatch.ImmediateEnabled, "Finish build immediately"); @@ -170,7 +167,7 @@ public static class UIConfigWindow wnd.AddText2(x + 32f, y, tab2, "Boost fuel power 2", 13); // Planet Tab - var tab3 = wnd.AddTab(_windowTrans, "Planet"); + var tab3 = wnd.AddTab(trans, "Planet"); x = 0f; y = 10f; wnd.AddCheckBox(x, y, tab3, ResourcePatch.InfiniteResourceEnabled, "Infinite Natural Resources"); @@ -207,7 +204,7 @@ public static class UIConfigWindow GameMain.localPlanet.factory.PlanetReformRevert(); }); - var tab4 = wnd.AddTab(_windowTrans, "Dyson Sphere"); + var tab4 = wnd.AddTab(trans, "Dyson Sphere"); x = 0f; y = 10f; wnd.AddCheckBox(x, y, tab4, DysonSpherePatch.SkipBulletEnabled, "Skip bullet period"); @@ -299,7 +296,7 @@ public static class UIConfigWindow } } - var tab5 = wnd.AddTab(_windowTrans, "Mecha/Combat"); + var tab5 = wnd.AddTab(trans, "Mecha/Combat"); x = 0f; y = 10f; wnd.AddCheckBox(x, y, tab5, CombatPatch.MechaInvincibleEnabled, "Mecha and Drones/Fleets invicible"); @@ -315,11 +312,6 @@ public static class UIConfigWindow } private static void UpdateUI() - { - UpdateButtons(); - } - - private static void UpdateButtons() { if (_resignGameBtn == null || _clearBanBtn == null) return; var data = GameMain.data; diff --git a/Dustbin/BeltSignal.cs b/Dustbin/BeltSignal.cs index 954a48f..fcedeeb 100644 --- a/Dustbin/BeltSignal.cs +++ b/Dustbin/BeltSignal.cs @@ -28,31 +28,14 @@ public static class BeltSignal } } - private static byte[] LoadEmbeddedResource(string path, Assembly assembly = null) + private static Sprite LoadDustbinSprite() { - if (assembly == null) - { - assembly = Assembly.GetCallingAssembly(); - } - var info = assembly.GetName(); - var name = info.Name; - using var stream = assembly.GetManifestResourceStream($"{name}.{path.Replace('/', '.')}")!; + using var stream = Assembly.GetExecutingAssembly() + .GetManifestResourceStream("Dustbin.assets.icon.signal-410.png")!; var buffer = new byte[stream.Length]; _ = stream.Read(buffer, 0, buffer.Length); - return buffer; - } - - private static Texture2D LoadEmbeddedTexture(string path, Assembly assembly = null) - { - var fileData = LoadEmbeddedResource(path, assembly); var tex = new Texture2D(2, 2); - tex.LoadImage(fileData); - return tex; - } - - private static Sprite LoadEmbeddedSprite(string path, Assembly assembly = null) - { - var tex = LoadEmbeddedTexture(path, assembly); + tex.LoadImage(buffer); return Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f)); } @@ -61,7 +44,6 @@ public static class BeltSignal private static void VFPreload_InvokeOnLoadWorkEnded_Postfix() { if (_initialized) return; - var assembly = Assembly.GetExecutingAssembly(); var signals = LDB._signals; var index = signals.dataArray.Length; var p = new SignalProto @@ -70,7 +52,7 @@ public static class BeltSignal Name = "DUSTBIN", GridIndex = 3110, IconPath = "Assets/signal-410.png", - _iconSprite = LoadEmbeddedSprite("assets/icon/signal-410.png", assembly), + _iconSprite = LoadDustbinSprite(), SID = "" }; p.name = p.Name.Translate(); diff --git a/HideTips/HideTips.cs b/HideTips/HideTips.cs index ac18995..f6b41a4 100644 --- a/HideTips/HideTips.cs +++ b/HideTips/HideTips.cs @@ -20,9 +20,6 @@ public class HideTips : BaseUnityPlugin private static bool _noResearchCompletionPopups = true; private static bool _noResearchCompletionTips; private static bool _skipPrologue = true; - // private static bool _hideMenuDemo; - - private static Harmony _patch; private void Awake() { @@ -34,21 +31,8 @@ public class HideTips : BaseUnityPlugin _noResearchCompletionPopups = Config.Bind("General", "NoResearchCompletionPopups", _noResearchCompletionPopups, "Disable Research Completion Popup Windows").Value; _noResearchCompletionTips = Config.Bind("General", "NoResearchCompletionTips", _noResearchCompletionTips, "Disable Research Completion Tips").Value; _skipPrologue = Config.Bind("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").Value; - // _hideMenuDemo = Config.Bind("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value; if (!_cfgEnabled) return; Harmony.CreateAndPatchAll(typeof(HideTips)); - /* - if (_hideMenuDemo) - { - _patch = Harmony.CreateAndPatchAll(typeof(HideMenuDemo)); - } - */ - } - - private void OnDestroy() - { - _patch?.UnpatchSelf(); - _patch = null; } [HarmonyPrefix] @@ -146,74 +130,3 @@ public class HideTips : BaseUnityPlugin return false; } } - -/* -[HarmonyPatch] -class HideMenuDemo -{ - [HarmonyPriority(Priority.First), HarmonyPrefix] - [HarmonyPatch(typeof(DSPGame), nameof(DSPGame.StartDemoGame), typeof(int))] - private static bool DSPGame_StartDemoGame_Prefix() - { - if (DSPGame.Game != null) - { - DSPGame.EndGame(); - } - - DSPGame.IsMenuDemo = true; - DSPGame.CreateGameMainObject(); - DSPGame.Game.isMenuDemo = true; - DSPGame.Game.CreateIconSet(); - GameMain.data = new GameData(); - GameMain.data.mainPlayer = Player.Create(GameMain.data, 1); - GameMain.data.galaxy = new GalaxyData - { - starCount = 0 - }; - - if (GameMain.universeSimulator != null) - { - UnityEngine.Object.Destroy(GameMain.universeSimulator.gameObject); - } - GameMain.universeSimulator = UnityEngine.Object.Instantiate(Configs.builtin.universeSimulatorPrefab); - GameMain.universeSimulator.spaceAudio = new GameObject("Space Audio") - { - transform = - { - parent = GameMain.universeSimulator.transform - } - }.AddComponent(); - GameMain.Begin(); - return false; - } - - [HarmonyPriority(Priority.First), HarmonyPrefix] - [HarmonyPatch(typeof(VFPreload), nameof(VFPreload.IsMenuDemoLoaded))] - private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result) - { - __result = true; - return false; - } - - [HarmonyPriority(Priority.First), HarmonyPrefix] - [HarmonyPatch(typeof(DSPGame), nameof(DSPGame.LateUpdate))] - [HarmonyPatch(typeof(GameMain), nameof(GameMain.LateUpdate))] - [HarmonyPatch(typeof(GameMain), nameof(GameMain.FixedUpdate))] - [HarmonyPatch(typeof(GameMain), nameof(GameMain.Update))] - [HarmonyPatch(typeof(GameCamera), nameof(GameCamera.LateUpdate))] - private static bool DSPGame_LateUpdate_Prefix() - { - return !DSPGame.IsMenuDemo; - } - - [HarmonyPriority(Priority.First), HarmonyPrefix] - [HarmonyPatch(typeof(GameMain), nameof(GameMain.Begin))] - private static bool GameMain_Begin_Prefix() - { - if (!DSPGame.IsMenuDemo) return true; - DSPGame.Game._loading = false; - DSPGame.Game._running = true; - return false; - } -} -*/ \ No newline at end of file diff --git a/LiveStreamAssist/tools/Test-WebSocketApi.ps1 b/LiveStreamAssist/tools/Test-WebSocketApi.ps1 index 0a6130a..0025bfe 100644 --- a/LiveStreamAssist/tools/Test-WebSocketApi.ps1 +++ b/LiveStreamAssist/tools/Test-WebSocketApi.ps1 @@ -21,17 +21,6 @@ function New-OpCts { [Threading.CancellationTokenSource]::new([TimeSpan]::FromSeconds($TimeoutSec)) } -function Get-ConnSocket { - param($Conn) - if ($null -eq $Conn) { return $null } - if ($Conn -is [hashtable]) { - if ($Conn.ContainsKey('Ws')) { return $Conn['Ws'] } - return $null - } - if ($Conn.PSObject.Properties.Name -contains 'Ws') { return $Conn.Ws } - return $null -} - function Connect-Api { param([string] $Uri) $ws = [Net.WebSockets.ClientWebSocket]::new() @@ -49,7 +38,8 @@ function Connect-Api { function Close-Api { param($Conn) - $ws = Get-ConnSocket $Conn + if ($null -eq $Conn) { return } + $ws = $Conn.Ws if ($null -eq $ws) { return } $cts = New-OpCts try { @@ -64,7 +54,7 @@ function Close-Api { function Send-Text { param($Conn, [string] $Text, [bool] $End = $true) - $ws = Get-ConnSocket $Conn + $ws = $Conn.Ws $bytes = $utf8.GetBytes($Text) $seg = [ArraySegment[byte]]::new($bytes) $cts = New-OpCts @@ -75,7 +65,7 @@ function Send-Text { function Receive-Message { param($Conn) - $ws = Get-ConnSocket $Conn + $ws = $Conn.Ws $buffer = [byte[]]::new(65536) $ms = [IO.MemoryStream]::new() $cts = New-OpCts @@ -183,7 +173,7 @@ try { $cts = New-OpCts try { - $null = (Get-ConnSocket $conn).SendAsync( + $null = $conn.Ws.SendAsync( [ArraySegment[byte]]::new([byte[]](1, 2, 3)), [Net.WebSockets.WebSocketMessageType]::Binary, $true, diff --git a/MechaDronesTweaks/FastDronesRemover.cs b/MechaDronesTweaks/FastDronesRemover.cs deleted file mode 100644 index 822bee7..0000000 --- a/MechaDronesTweaks/FastDronesRemover.cs +++ /dev/null @@ -1,25 +0,0 @@ -using HarmonyLib; - -namespace MechaDronesTweaks; - -class FastDronesRemover -{ - public const string FastDronesGuid = "com.dkoppstein.plugin.DSP.FastDrones"; - private const string FastDronesVersion = "0.0.5"; - - public static bool Run(Harmony harmony) - { - if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(FastDronesGuid, out var pluginInfo) || - pluginInfo.Metadata.Version.ToString() != FastDronesVersion) return false; - var assembly = pluginInfo.Instance.GetType().Assembly; - var classType = assembly.GetType("com.dkoppstein.plugin.DSP.FastDrones.FastDronesPlugin"); - harmony.Patch(AccessTools.Method(classType, "Start"), - new HarmonyMethod(typeof(FastDronesRemover).GetMethod("PatchFastDronesStart"))); - return true; - } - - public static bool PatchFastDronesStart() - { - return false; - } -} \ No newline at end of file diff --git a/MechaDronesTweaks/MechaDronesTweaks.cs b/MechaDronesTweaks/MechaDronesTweaks.cs index 203db9d..1f15f3a 100644 --- a/MechaDronesTweaks/MechaDronesTweaks.cs +++ b/MechaDronesTweaks/MechaDronesTweaks.cs @@ -9,9 +9,11 @@ using UnityEngine; namespace MechaDronesTweaks; [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] -[BepInDependency(FastDronesRemover.FastDronesGuid, BepInDependency.DependencyFlags.SoftDependency)] +[BepInDependency(FastDronesGuid, BepInDependency.DependencyFlags.SoftDependency)] public class MechaDronesTweaksPlugin : BaseUnityPlugin { + private const string FastDronesGuid = "com.dkoppstein.plugin.DSP.FastDrones"; + public new static readonly BepInEx.Logging.ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource(PluginInfo.PLUGIN_NAME); @@ -22,8 +24,13 @@ public class MechaDronesTweaksPlugin : BaseUnityPlugin /* Remove FastDrones MOD if loaded */ try { - if (FastDronesRemover.Run(_harmony)) + if (BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(FastDronesGuid, out var pluginInfo) && + pluginInfo.Metadata.Version.ToString() == "0.0.5") { + var assembly = pluginInfo.Instance.GetType().Assembly; + var classType = assembly.GetType("com.dkoppstein.plugin.DSP.FastDrones.FastDronesPlugin"); + _harmony.Patch(AccessTools.Method(classType, "Start"), + new HarmonyMethod(AccessTools.Method(typeof(MechaDronesTweaksPlugin), nameof(PatchFastDronesStart)))); Logger.LogInfo("Unpatch FastDrones - OK"); } } @@ -33,6 +40,8 @@ public class MechaDronesTweaksPlugin : BaseUnityPlugin } } + private static bool PatchFastDronesStart() => false; + public void Awake() { MechaDronesTweaks.UseFixedSpeed = Config.Bind("MechaDrones", "UseFixedSpeed", MechaDronesTweaks.UseFixedSpeed, @@ -54,10 +63,6 @@ public class MechaDronesTweaksPlugin : BaseUnityPlugin MechaDronesTweaks.EnergyMultiplier, new ConfigDescription("Energy consumption multiplier for mecha drones", new AcceptableValueRange(0f, 1f))).Value; - MechaDronesTweaks.EnergyMultiplier = Config.Bind("MechaDrones", "EnergyMultiplier", - MechaDronesTweaks.EnergyMultiplier, - new ConfigDescription("Energy consumption multiplier for mecha drones", - new AcceptableValueRange(0f, 1f))).Value; _harmony.PatchAll(typeof(MechaDronesTweaks)); } diff --git a/OverclockEverything/OverclockEverything.cs b/OverclockEverything/OverclockEverything.cs index 71c1980..0cc48b8 100644 --- a/OverclockEverything/OverclockEverything.cs +++ b/OverclockEverything/OverclockEverything.cs @@ -104,21 +104,6 @@ public class Patch : BaseUnityPlugin, IModCanSave { } - /* Belt fix for GalacticScale old versions, should be of no use now. - [HarmonyTranspiler, HarmonyPatch(typeof(BuildTool_Path), "CheckBuildConditions")] - private static IEnumerable BuildTool_Path_CheckBuildConditions_Transpiler( - IEnumerable instructions) - { - foreach (var instr in instructions) - { - if (instr.opcode == OpCodes.Ldc_R4 && instr.OperandIs(0.28f)) - { - instr.operand = 0.21f; - } - yield return instr; - } - } - */ [HarmonyPostfix, HarmonyPatch(typeof(LabComponent), "SetFunction")] private static void LabComponent_SetFunction_Postfix(ref LabComponent __instance) @@ -380,20 +365,6 @@ public class Patch : BaseUnityPlugin, IModCanSave foreach (var proto in LDB.items.dataArray) { var prefabDesc = proto.prefabDesc; - /* Fix collision sizes, for GalacticScale old versions, should be of no use now. - FixExtValue(ref prefabDesc.buildCollider.ext.x); - FixExtValue(ref prefabDesc.buildCollider.ext.y); - FixExtValue(ref prefabDesc.buildCollider.ext.z); - if (prefabDesc.buildColliders != null) - { - for (var i = 0; i < prefabDesc.buildColliders.Length; i++) - { - FixExtValue(ref prefabDesc.buildColliders[i].ext.x); - FixExtValue(ref prefabDesc.buildColliders[i].ext.y); - FixExtValue(ref prefabDesc.buildColliders[i].ext.z); - } - } - */ if (prefabDesc.isInserter) { @@ -472,16 +443,4 @@ public class Patch : BaseUnityPlugin, IModCanSave } } - /* - private static void FixExtValue(ref float v) - { - if (v == 0f) - { - return; - } - - var b = Math.Abs(v); - v = (v - b) * 0.75f + b; - } - */ -} \ No newline at end of file +} diff --git a/PoolOpt/PoolOpt.cs b/PoolOpt/PoolOpt.cs index afa3ad6..d948952 100644 --- a/PoolOpt/PoolOpt.cs +++ b/PoolOpt/PoolOpt.cs @@ -24,23 +24,23 @@ public class PoolOptPatch : BaseUnityPlugin foreach (var planet in GameMain.data.factories) { if (planet == null) continue; - if (OptimizePool((in EntityData n) => n.id, () => + if (OptimizePool((in EntityData n, int index) => n.id == index, () => { planet.entityCapacity = 0; planet.SetEntityCapacity(1024); }, - ref planet.entityPool, ref planet.entityCursor, ref planet.entityCapacity, + ref planet.entityPool, ref planet.entityCursor, ref planet.entityRecycle, ref planet.entityRecycleCursor)) { Logger.LogDebug($"Optimized `{nameof(planet.entityPool)}` on Planet {planet.planetId}"); } - if (OptimizePool((in PrebuildData n) => n.id, () => + if (OptimizePool((in PrebuildData n, int index) => n.id == index, () => { planet.prebuildCapacity = 0; planet.SetPrebuildCapacity(256); }, - ref planet.prebuildPool, ref planet.prebuildCursor, ref planet.prebuildCapacity, + ref planet.prebuildPool, ref planet.prebuildCursor, ref planet.prebuildRecycle, ref planet.prebuildRecycleCursor)) { Logger.LogDebug($"Optimized `{nameof(planet.prebuildPool)}` on Planet {planet.planetId}"); @@ -49,152 +49,152 @@ public class PoolOptPatch : BaseUnityPlugin var cargoTraffic = planet.cargoTraffic; if (cargoTraffic != null) { - if (OptimizePool((in BeltComponent n) => n.id, () => + if (OptimizePool((in BeltComponent n, int index) => n.id == index, () => { cargoTraffic.beltCapacity = 0; cargoTraffic.SetBeltCapacity(16); }, - ref cargoTraffic.beltPool, ref cargoTraffic.beltCursor, ref cargoTraffic.beltCapacity, + ref cargoTraffic.beltPool, ref cargoTraffic.beltCursor, ref cargoTraffic.beltRecycle, ref cargoTraffic.beltRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.beltPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in CargoPath n) => n?.id ?? 0, () => + if (OptimizePool((in CargoPath n, int index) => (n?.id ?? 0) == index, () => { cargoTraffic.pathCapacity = 0; cargoTraffic.SetPathCapacity(16); }, - ref cargoTraffic.pathPool, ref cargoTraffic.pathCursor, ref cargoTraffic.pathCapacity, + ref cargoTraffic.pathPool, ref cargoTraffic.pathCursor, ref cargoTraffic.pathRecycle, ref cargoTraffic.pathRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.pathPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in SplitterComponent n) => n.id, () => + if (OptimizePool((in SplitterComponent n, int index) => n.id == index, () => { cargoTraffic.splitterCapacity = 0; cargoTraffic.SetSplitterCapacity(16); }, - ref cargoTraffic.splitterPool, ref cargoTraffic.splitterCursor, ref cargoTraffic.splitterCapacity, + ref cargoTraffic.splitterPool, ref cargoTraffic.splitterCursor, ref cargoTraffic.splitterRecycle, ref cargoTraffic.splitterRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.splitterPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in MonitorComponent n) => n.id, () => + if (OptimizePool((in MonitorComponent n, int index) => n.id == index, () => { cargoTraffic.monitorCapacity = 0; cargoTraffic.SetMonitorCapacity(16); }, - ref cargoTraffic.monitorPool, ref cargoTraffic.monitorCursor, ref cargoTraffic.monitorCapacity, + ref cargoTraffic.monitorPool, ref cargoTraffic.monitorCursor, ref cargoTraffic.monitorRecycle, ref cargoTraffic.monitorRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.monitorPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in SpraycoaterComponent n) => n.id, () => + if (OptimizePool((in SpraycoaterComponent n, int index) => n.id == index, () => { cargoTraffic.spraycoaterCapacity = 0; cargoTraffic.SetSpraycoaterCapacity(16); }, - ref cargoTraffic.spraycoaterPool, ref cargoTraffic.spraycoaterCursor, ref cargoTraffic.spraycoaterCapacity, + ref cargoTraffic.spraycoaterPool, ref cargoTraffic.spraycoaterCursor, ref cargoTraffic.spraycoaterRecycle, ref cargoTraffic.spraycoaterRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.spraycoaterPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PilerComponent n) => n.id, () => + if (OptimizePool((in PilerComponent n, int index) => n.id == index, () => { cargoTraffic.pilerCapacity = 0; cargoTraffic.SetPilerCapacity(16); }, - ref cargoTraffic.pilerPool, ref cargoTraffic.pilerCursor, ref cargoTraffic.pilerCapacity, + ref cargoTraffic.pilerPool, ref cargoTraffic.pilerCursor, ref cargoTraffic.pilerRecycle, ref cargoTraffic.pilerRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(cargoTraffic.pilerPool)}` on Planet {planet.planetId}"); } var factoryStorage = planet.factoryStorage; if (factoryStorage != null) { - if (OptimizePool((in StorageComponent n) => n?.id ?? 0, () => + if (OptimizePool((in StorageComponent n, int index) => (n?.id ?? 0) == index, () => { factoryStorage.storageCapacity = 0; factoryStorage.SetStorageCapacity(64); }, - ref factoryStorage.storagePool, ref factoryStorage.storageCursor, ref factoryStorage.storageCapacity, + ref factoryStorage.storagePool, ref factoryStorage.storageCursor, ref factoryStorage.storageRecycle, ref factoryStorage.storageRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factoryStorage.storagePool)}` on Planet {planet.planetId}"); - if (OptimizePool((in TankComponent n) => n.id, () => + if (OptimizePool((in TankComponent n, int index) => n.id == index, () => { factoryStorage.tankCapacity = 0; factoryStorage.SetTankCapacity(256); }, - ref factoryStorage.tankPool, ref factoryStorage.tankCursor, ref factoryStorage.tankCapacity, + ref factoryStorage.tankPool, ref factoryStorage.tankCursor, ref factoryStorage.tankRecycle, ref factoryStorage.tankRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factoryStorage.tankPool)}` on Planet {planet.planetId}"); } var factorySystem = planet.factorySystem; if (factorySystem != null) { - if (OptimizePool((in MinerComponent n) => n.id, () => + if (OptimizePool((in MinerComponent n, int index) => n.id == index, () => { factorySystem.minerCapacity = 0; factorySystem.SetMinerCapacity(256); }, - ref factorySystem.minerPool, ref factorySystem.minerCursor, ref factorySystem.minerCapacity, + ref factorySystem.minerPool, ref factorySystem.minerCursor, ref factorySystem.minerRecycle, ref factorySystem.minerRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.minerPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in InserterComponent n) => n.id, () => + if (OptimizePool((in InserterComponent n, int index) => n.id == index, () => { factorySystem.inserterCapacity = 0; factorySystem.SetInserterCapacity(256); }, - ref factorySystem.inserterPool, ref factorySystem.inserterCursor, ref factorySystem.inserterCapacity, + ref factorySystem.inserterPool, ref factorySystem.inserterCursor, ref factorySystem.inserterRecycle, ref factorySystem.inserterRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.inserterPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in AssemblerComponent n) => n.id, () => + if (OptimizePool((in AssemblerComponent n, int index) => n.id == index, () => { factorySystem.assemblerCapacity = 0; factorySystem.SetAssemblerCapacity(256); }, - ref factorySystem.assemblerPool, ref factorySystem.assemblerCursor, ref factorySystem.assemblerCapacity, + ref factorySystem.assemblerPool, ref factorySystem.assemblerCursor, ref factorySystem.assemblerRecycle, ref factorySystem.assemblerRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.assemblerPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in FractionatorComponent n) => n.id, () => + if (OptimizePool((in FractionatorComponent n, int index) => n.id == index, () => { factorySystem.fractionatorCapacity = 0; factorySystem.SetFractionatorCapacity(32); }, - ref factorySystem.fractionatorPool, ref factorySystem.fractionatorCursor, ref factorySystem.fractionatorCapacity, + ref factorySystem.fractionatorPool, ref factorySystem.fractionatorCursor, ref factorySystem.fractionatorRecycle, ref factorySystem.fractionatorRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.fractionatorPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in EjectorComponent n) => n.id, () => + if (OptimizePool((in EjectorComponent n, int index) => n.id == index, () => { factorySystem.ejectorCapacity = 0; factorySystem.SetEjectorCapacity(32); }, - ref factorySystem.ejectorPool, ref factorySystem.ejectorCursor, ref factorySystem.ejectorCapacity, + ref factorySystem.ejectorPool, ref factorySystem.ejectorCursor, ref factorySystem.ejectorRecycle, ref factorySystem.ejectorRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.ejectorPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in SiloComponent n) => n.id, () => + if (OptimizePool((in SiloComponent n, int index) => n.id == index, () => { factorySystem.siloCapacity = 0; factorySystem.SetSiloCapacity(32); }, - ref factorySystem.siloPool, ref factorySystem.siloCursor, ref factorySystem.siloCapacity, + ref factorySystem.siloPool, ref factorySystem.siloCursor, ref factorySystem.siloRecycle, ref factorySystem.siloRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.siloPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in LabComponent n) => n.id, () => + if (OptimizePool((in LabComponent n, int index) => n.id == index, () => { factorySystem.labCapacity = 0; factorySystem.SetLabCapacity(256); }, - ref factorySystem.labPool, ref factorySystem.labCursor, ref factorySystem.labCapacity, + ref factorySystem.labPool, ref factorySystem.labCursor, ref factorySystem.labRecycle, ref factorySystem.labRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(factorySystem.labPool)}` on Planet {planet.planetId}"); } var transport = planet.transport; if (transport != null) { - if (OptimizePool((in StationComponent n) => n?.id ?? 0, () => + if (OptimizePool((in StationComponent n, int index) => (n?.id ?? 0) == index, () => { transport.stationCapacity = 0; transport.SetStationCapacity(16); }, - ref transport.stationPool, ref transport.stationCursor, ref transport.stationCapacity, + ref transport.stationPool, ref transport.stationCursor, ref transport.stationRecycle, ref transport.stationRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(transport.stationPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in DispenserComponent n) => n?.id ?? 0, () => + if (OptimizePool((in DispenserComponent n, int index) => (n?.id ?? 0) == index, () => { transport.dispenserCapacity = 0; transport.SetDispenserCapacity(8); }, - ref transport.dispenserPool, ref transport.dispenserCursor, ref transport.dispenserCapacity, + ref transport.dispenserPool, ref transport.dispenserCursor, ref transport.dispenserRecycle, ref transport.dispenserRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(transport.dispenserPool)}` on Planet {planet.planetId}"); } @@ -202,54 +202,54 @@ public class PoolOptPatch : BaseUnityPlugin var powerSystem = planet.powerSystem; if (powerSystem != null) { - if (OptimizePool((in PowerGeneratorComponent n) => n.id, () => + if (OptimizePool((in PowerGeneratorComponent n, int index) => n.id == index, () => { powerSystem.genCapacity = 0; powerSystem.SetGeneratorCapacity(8); }, - ref powerSystem.genPool, ref powerSystem.genCursor, ref powerSystem.genCapacity, + ref powerSystem.genPool, ref powerSystem.genCursor, ref powerSystem.genRecycle, ref powerSystem.genRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.genPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PowerNodeComponent n) => n.id, () => + if (OptimizePool((in PowerNodeComponent n, int index) => n.id == index, () => { powerSystem.nodeCapacity = 0; powerSystem.SetNodeCapacity(8); }, - ref powerSystem.nodePool, ref powerSystem.nodeCursor, ref powerSystem.nodeCapacity, + ref powerSystem.nodePool, ref powerSystem.nodeCursor, ref powerSystem.nodeRecycle, ref powerSystem.nodeRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.nodePool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PowerConsumerComponent n) => n.id, () => + if (OptimizePool((in PowerConsumerComponent n, int index) => n.id == index, () => { powerSystem.consumerCapacity = 0; powerSystem.SetConsumerCapacity(8); }, - ref powerSystem.consumerPool, ref powerSystem.consumerCursor, ref powerSystem.consumerCapacity, + ref powerSystem.consumerPool, ref powerSystem.consumerCursor, ref powerSystem.consumerRecycle, ref powerSystem.consumerRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.consumerPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PowerAccumulatorComponent n) => n.id, () => + if (OptimizePool((in PowerAccumulatorComponent n, int index) => n.id == index, () => { powerSystem.accCapacity = 0; powerSystem.SetAccumulatorCapacity(8); }, - ref powerSystem.accPool, ref powerSystem.accCursor, ref powerSystem.accCapacity, + ref powerSystem.accPool, ref powerSystem.accCursor, ref powerSystem.accRecycle, ref powerSystem.accRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.accPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PowerExchangerComponent n) => n.id, () => + if (OptimizePool((in PowerExchangerComponent n, int index) => n.id == index, () => { powerSystem.excCapacity = 0; powerSystem.SetExchangerCapacity(8); }, - ref powerSystem.excPool, ref powerSystem.excCursor, ref powerSystem.excCapacity, + ref powerSystem.excPool, ref powerSystem.excCursor, ref powerSystem.excRecycle, ref powerSystem.excRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.excPool)}` on Planet {planet.planetId}"); - if (OptimizePool((in PowerNetwork n) => n?.id ?? 0, () => + if (OptimizePool((in PowerNetwork n, int index) => (n?.id ?? 0) == index, () => { powerSystem.netCapacity = 0; powerSystem.SetNetworkCapacity(8); powerSystem.netPool[0] = new PowerNetwork(); powerSystem.netPool[0].Reset(0); }, - ref powerSystem.netPool, ref powerSystem.netCursor, ref powerSystem.netCapacity, + ref powerSystem.netPool, ref powerSystem.netCursor, ref powerSystem.netRecycle, ref powerSystem.netRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(powerSystem.netPool)}` on Planet {planet.planetId}"); } @@ -257,12 +257,12 @@ public class PoolOptPatch : BaseUnityPlugin var trashContainer = GameMain.data.trashSystem?.container; if (trashContainer != null) { - if (OptimizePool((in TrashObject n) => n.item == 0, () => + if (OptimizePool((in TrashObject n, int index) => n.item != 0, () => { trashContainer.trashCapacity = 0; trashContainer.SetTrashCapacity(16); }, - ref trashContainer.trashObjPool, ref trashContainer.trashCursor, ref trashContainer.trashCapacity, + ref trashContainer.trashObjPool, ref trashContainer.trashCursor, ref trashContainer.trashRecycle, ref trashContainer.trashRecycleCursor)) { Logger.LogDebug($"Optimized `{nameof(trashContainer.trashObjPool)}`"); @@ -271,12 +271,12 @@ public class PoolOptPatch : BaseUnityPlugin var warningSystem = GameMain.data.warningSystem; if (warningSystem != null) { - if (OptimizePool((in WarningData n) => n.id, () => + if (OptimizePool((in WarningData n, int index) => n.id == index, () => { warningSystem.warningCapacity = 0; warningSystem.SetWarningCapacity(32); }, - ref warningSystem.warningPool, ref warningSystem.warningCursor, ref warningSystem.warningCapacity, + ref warningSystem.warningPool, ref warningSystem.warningCursor, ref warningSystem.warningRecycle, ref warningSystem.warningRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(warningSystem.warningPool)}`"); } @@ -286,48 +286,48 @@ public class PoolOptPatch : BaseUnityPlugin foreach (var dysonSphere in dysonSpheres) { if (dysonSphere == null) continue; - if (OptimizePool((in DysonRocket n) => n.id, () => + if (OptimizePool((in DysonRocket n, int index) => n.id == index, () => { dysonSphere.rocketCapacity = 0; dysonSphere.SetRocketCapacity(256); }, - ref dysonSphere.rocketPool, ref dysonSphere.rocketCursor, ref dysonSphere.rocketCapacity, + ref dysonSphere.rocketPool, ref dysonSphere.rocketCursor, ref dysonSphere.rocketRecycle, ref dysonSphere.rocketRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(dysonSphere.rocketPool)}` on Star {dysonSphere.starData.id}"); - if (OptimizePool((in DysonNodeRData n) => n.id, () => + if (OptimizePool((in DysonNodeRData n, int index) => n.id == index, () => { dysonSphere.nrdCapacity = 0; dysonSphere.SetNrdCapacity(128); }, - ref dysonSphere.nrdPool, ref dysonSphere.nrdCursor, ref dysonSphere.nrdCapacity, + ref dysonSphere.nrdPool, ref dysonSphere.nrdCursor, ref dysonSphere.nrdRecycle, ref dysonSphere.nrdRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(dysonSphere.nrdPool)}` on Star {dysonSphere.starData.id}"); if (dysonSphere.layersIdBased == null) continue; foreach (var layer in dysonSphere.layersSorted) { if (layer == null) continue; - if (OptimizePool((in DysonNode n) => n?.id ?? 0, () => + if (OptimizePool((in DysonNode n, int index) => (n?.id ?? 0) == index, () => { layer.nodeCapacity = 64; layer.SetNodeCapacity(64); }, - ref layer.nodePool, ref layer.nodeCursor, ref layer.nodeCapacity, + ref layer.nodePool, ref layer.nodeCursor, ref layer.nodeRecycle, ref layer.nodeRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(layer.nodePool)}` on Star {dysonSphere.starData.id} layer {layer.id}"); - if (OptimizePool((in DysonFrame n) => n?.id ?? 0, () => + if (OptimizePool((in DysonFrame n, int index) => (n?.id ?? 0) == index, () => { layer.frameCapacity = 64; layer.SetFrameCapacity(64); }, - ref layer.framePool, ref layer.frameCursor, ref layer.frameCapacity, + ref layer.framePool, ref layer.frameCursor, ref layer.frameRecycle, ref layer.frameRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(layer.framePool)}` on Star {dysonSphere.starData.id} layer {layer.id}"); - if (OptimizePool((in DysonShell n) => n?.id ?? 0, () => + if (OptimizePool((in DysonShell n, int index) => (n?.id ?? 0) == index, () => { layer.shellCapacity = 64; layer.SetShellCapacity(64); }, - ref layer.shellPool, ref layer.shellCursor, ref layer.shellCapacity, + ref layer.shellPool, ref layer.shellCursor, ref layer.shellRecycle, ref layer.shellRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(layer.shellPool)}` on Star {dysonSphere.starData.id} layer {layer.id}"); } @@ -335,12 +335,12 @@ public class PoolOptPatch : BaseUnityPlugin var swarm = dysonSphere.swarm; if (swarm != null) { - if (OptimizePool((in SailBullet n) => n.id, () => + if (OptimizePool((in SailBullet n, int index) => n.id == index, () => { swarm.bulletCapacity = 0; swarm.SetBulletCapacity(128); }, - ref swarm.bulletPool, ref swarm.bulletCursor, ref swarm.bulletCapacity, + ref swarm.bulletPool, ref swarm.bulletCursor, ref swarm.bulletRecycle, ref swarm.bulletRecycleCursor)) Logger.LogDebug($"Optimized `{nameof(swarm.bulletPool)}` on Star {dysonSphere.starData.id}"); } @@ -350,12 +350,10 @@ public class PoolOptPatch : BaseUnityPlugin GC.Collect(); } - private delegate int GetId(in T s); - - private delegate void SetToInitialCapacity(); + private delegate bool IsOccupied(in T s, int index); [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool OptimizePool(GetId getter, SetToInitialCapacity initCapacity, ref T[] pool, ref int cursor, ref int capacity, ref int[] recycle, ref int recycleCursor) + private static bool OptimizePool(IsOccupied isOccupied, Action initCapacity, ref T[] pool, ref int cursor, ref int[] recycle, ref int recycleCursor) { if (cursor <= 1) return false; if (recycleCursor == cursor - 1) @@ -369,7 +367,7 @@ public class PoolOptPatch : BaseUnityPlugin var pos = cursor - 1; while (pos > 0) { - if (getter(pool[pos]) == pos) break; + if (isOccupied(pool[pos], pos)) break; pos--; } @@ -391,41 +389,4 @@ public class PoolOptPatch : BaseUnityPlugin return true; } - private delegate bool IsEmpty(in T s); - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - private static bool OptimizePool(IsEmpty checker, SetToInitialCapacity initCapacity, ref T[] pool, ref int cursor, ref int capacity, ref int[] recycle, ref int recycleCursor) - { - if (cursor <= 1) return false; - if (recycleCursor == cursor - 1) - { - cursor = 1; - recycleCursor = 0; - initCapacity(); - Logger.LogDebug("Resetted pool to initial status"); - return true; - } - var pos = cursor - 1; - while (pos > 0) - { - if (!checker(pool[pos])) break; - pos--; - } - - if (pos + 1 == cursor) return false; - if (pos == 0) - { - cursor = 1; - recycleCursor = 0; - initCapacity(); - return true; - } - - cursor = pos + 1; - Array.Sort(recycle, 0, recycleCursor); - var idx = Array.BinarySearch(recycle, 0, recycleCursor, pos + 1); - recycleCursor = idx < 0 ? ~idx : idx; - Logger.LogDebug($"Shrinked pool size to {cursor} and recycle size to {recycleCursor}"); - return true; - } -} \ No newline at end of file +} diff --git a/UXAssist/Common/I18N.cs b/UXAssist/Common/I18N.cs index 1ecf80a..83a641b 100644 --- a/UXAssist/Common/I18N.cs +++ b/UXAssist/Common/I18N.cs @@ -133,21 +133,6 @@ public static class I18N ApplyIndexers(); } - /// - /// Returns the localized text for the given key in the currently active language, - /// falling back to the key itself when no entry is registered. - /// - /// The lookup key. - /// The localized text, or if no entry exists. - internal static string Translate(string key) - { - if (!Entries.TryGetValue(key, out var loc)) return key; - var languageIndex = Localization.currentLanguageIndex; - if (languageIndex >= 0 && languageIndex < Localization.Languages.Length && Localization.Languages[languageIndex].lcId == 2052) - return loc.Zh; - return loc.En; - } - [HarmonyPostfix, HarmonyPriority(Priority.Last), HarmonyPatch(typeof(Localization), nameof(Localization.LoadSettings))] private static void Localization_LoadSettings_Postfix() { diff --git a/UXAssist/Common/KnownItemId.cs b/UXAssist/Common/KnownItemId.cs index b24a299..16f477b 100644 --- a/UXAssist/Common/KnownItemId.cs +++ b/UXAssist/Common/KnownItemId.cs @@ -2,8 +2,8 @@ namespace UXAssist.Common; public enum KnownItemId : int { - Drone = 5001, - Ship = 5002, - Bot = 5003, - Warper = 1210, + Drone = GameConstants.ItemIds.LogisticsDrone, + Ship = GameConstants.ItemIds.LogisticsVessel, + Bot = GameConstants.ItemIds.LogisticsBot, + Warper = GameConstants.ItemIds.SpaceWarper, } diff --git a/UXAssist/Common/WinApi.cs b/UXAssist/Common/WinApi.cs index cabfb6b..746d4c4 100644 --- a/UXAssist/Common/WinApi.cs +++ b/UXAssist/Common/WinApi.cs @@ -80,12 +80,6 @@ public static class WinApi #endregion - #region Errors - - private const int ERROR_INSUFFICIENT_BUFFER = 122; - - #endregion - #region Structs [StructLayout(LayoutKind.Sequential)] diff --git a/UXAssist/Functions/UI/MenuButtonUI.cs b/UXAssist/Functions/UI/MenuButtonUI.cs index 288f062..91caf20 100644 --- a/UXAssist/Functions/UI/MenuButtonUI.cs +++ b/UXAssist/Functions/UI/MenuButtonUI.cs @@ -27,14 +27,6 @@ internal static class MenuButtonUI I18N.OnInitialized += RecreateConfigWindow; } - public static void Start() - { - } - - public static void Uninit() - { - } - public static void OnInputUpdate() { if (_toggleKey.keyValue) @@ -43,10 +35,6 @@ internal static class MenuButtonUI } } - public static void OnUpdate() - { - } - public static void ToggleConfigWindow() { if (!_configWinInitialized) diff --git a/UXAssist/Functions/UI/MilkyWayUI.cs b/UXAssist/Functions/UI/MilkyWayUI.cs index 23ef38a..d84b9d5 100644 --- a/UXAssist/Functions/UI/MilkyWayUI.cs +++ b/UXAssist/Functions/UI/MilkyWayUI.cs @@ -35,10 +35,6 @@ internal static class MilkyWayUI GameLogicProc.OnGameEnd += ResetState; } - public static void Start() - { - } - public static void Uninit() { GameLogicProc.OnGameEnd -= ResetState; @@ -50,14 +46,6 @@ internal static class MilkyWayUI _topTenPlayerData = null; } - public static void OnInputUpdate() - { - } - - public static void OnUpdate() - { - } - public static void AddClusterUploadResult(int result, float requestTime) { lock (_clusterUploadResultsLock) diff --git a/UXAssist/Functions/UI/StarmapFilterUI.cs b/UXAssist/Functions/UI/StarmapFilterUI.cs index 5714587..3bbb6b7 100644 --- a/UXAssist/Functions/UI/StarmapFilterUI.cs +++ b/UXAssist/Functions/UI/StarmapFilterUI.cs @@ -58,26 +58,6 @@ internal static class StarmapFilterUI {1000, 23}, }; - public static void Init() - { - } - - public static void Start() - { - } - - public static void Uninit() - { - } - - public static void OnInputUpdate() - { - } - - public static void OnUpdate() - { - } - public static void InitStarmapButtons() { var uiRoot = UIRoot.instance; diff --git a/UXAssist/Functions/UIFunctions.cs b/UXAssist/Functions/UIFunctions.cs index b31394f..bbf918e 100644 --- a/UXAssist/Functions/UIFunctions.cs +++ b/UXAssist/Functions/UIFunctions.cs @@ -10,7 +10,6 @@ public static class UIFunctions public static void Init() { MenuButtonUI.Init(); - StarmapFilterUI.Init(); MilkyWayUI.Init(); UXAssist.RegisterExporter(ExportClusterUploadResults); @@ -19,32 +18,22 @@ public static class UIFunctions public static void Start() { - MenuButtonUI.Start(); - StarmapFilterUI.Start(); - MilkyWayUI.Start(); } public static void Uninit() { - MenuButtonUI.Uninit(); - StarmapFilterUI.Uninit(); MilkyWayUI.Uninit(); } public static void OnInputUpdate() { MenuButtonUI.OnInputUpdate(); - StarmapFilterUI.OnInputUpdate(); - MilkyWayUI.OnInputUpdate(); } public static void OnUpdate() { - MenuButtonUI.OnUpdate(); AutoCruiseUI.OnUpdate(); AutoConstructUI.OnUpdate(); - StarmapFilterUI.OnUpdate(); - MilkyWayUI.OnUpdate(); } public static void InitMenuButtons() diff --git a/UXAssist/Functions/WindowFunctions.cs b/UXAssist/Functions/WindowFunctions.cs index f16613f..e0b55e8 100644 --- a/UXAssist/Functions/WindowFunctions.cs +++ b/UXAssist/Functions/WindowFunctions.cs @@ -46,19 +46,6 @@ public static class WindowFunctions process.PriorityClass = (ProcessPriorityClass)ProrityFlags[ProcessPriority.Value]; } - private static string GetPriorityName(int priority) - { - return priority switch - { - WinApi.HIGH_PRIORITY_CLASS => I18NKeys.High.Translate(), - WinApi.ABOVE_NORMAL_PRIORITY_CLASS => I18NKeys.AboveNormal.Translate(), - WinApi.NORMAL_PRIORITY_CLASS => I18NKeys.Normal.Translate(), - WinApi.BELOW_NORMAL_PRIORITY_CLASS => I18NKeys.BelowNormal.Translate(), - WinApi.IDLE_PRIORITY_CLASS => I18NKeys.Idle.Translate(), - _ => I18NKeys.Unknown.Translate() - }; - } - public static void SetWindowTitle() { // Get profile name from command line arguments, and set window title accordingly diff --git a/UXAssist/Patches/Factory/ArchitectModePatch.cs b/UXAssist/Patches/Factory/ArchitectModePatch.cs index ad92635..3ba2f60 100644 --- a/UXAssist/Patches/Factory/ArchitectModePatch.cs +++ b/UXAssist/Patches/Factory/ArchitectModePatch.cs @@ -10,15 +10,6 @@ namespace UXAssist.Patches.Factory; internal static class ArchitectModePatch { - public static void Enable(bool enable) - { - UnlimitInteractive.Enable(enable); - RemoveSomeConditionBuild.Enable(enable); - RemoveBuildRangeLimit.Enable(enable); - LargerAreaForUpgradeAndDismantle.Enable(enable); - LargerAreaForTerraform.Enable(enable); - } - internal class UnlimitInteractive : PatchImpl { // Harmony transpiler: PlayerAction_Inspect_GetObjectSelectDistance_Transpiler diff --git a/UXAssist/Patches/Factory/BeltSignalPatch.cs b/UXAssist/Patches/Factory/BeltSignalPatch.cs index 4396a0b..c132194 100644 --- a/UXAssist/Patches/Factory/BeltSignalPatch.cs +++ b/UXAssist/Patches/Factory/BeltSignalPatch.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Reflection; using HarmonyLib; using UXAssist.Common; @@ -14,11 +13,6 @@ namespace UXAssist.Patches.Factory; [ModFeature("BeltSignalsForBuyOut")] internal static class BeltSignalPatch { - public static void Enable(bool enable) - { - BeltSignalsForBuyOut.Enable(enable); - } - public static void InitPersist() { BeltSignalsForBuyOut.InitPersist(); @@ -125,23 +119,6 @@ internal static class BeltSignalPatch _loaded = true; } - private static void RemoveBeltSignalProtos() - { - if (!_initialized || !_loaded) return; - var signals = LDB._signals; - if (signals.dataIndices.TryGetValue(301, out var index)) - { - signals.dataArray = [.. signals.dataArray.Take(index), .. signals.dataArray.Skip(index + 6)]; - for (var id = 301; id <= 306; id++) - signals.dataIndices.Remove(id); - var len = signals.dataArray.Length; - for (; index < len; index++) - signals.dataIndices[signals.dataArray[index].ID] = index; - } - - _loaded = false; - } - private static void InitSignalBelts() { if (!GameMain.isRunning) return; diff --git a/UXAssist/Patches/Factory/BuildToolPatch.cs b/UXAssist/Patches/Factory/BuildToolPatch.cs index 10d4b70..e1d7a76 100644 --- a/UXAssist/Patches/Factory/BuildToolPatch.cs +++ b/UXAssist/Patches/Factory/BuildToolPatch.cs @@ -79,8 +79,6 @@ internal static class BuildToolPatch internal class OffGridBuilding : PatchImpl { - // private const float SteppedRotationDegrees = 15f; - private static bool _initialized; private static void SetupRichTextSupport() @@ -292,62 +290,6 @@ internal static class BuildToolPatch return matcher.InstructionEnumeration(); } - /* - public static IEnumerable PatchToPerformSteppedRotate(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - - MatchIgnoreGridAndCheckIfRotatable(matcher, out var ifBlockEntryLabel, out var elseBlockEntryLabel); - - if (matcher.IsInvalid) - return instructions; - - while (!matcher.Labels.Contains(elseBlockEntryLabel.Value)) - matcher.Advance(1); - - Label? ifBlockExitLabel = null; - - matcher.MatchBack(false, new CodeMatch(ci => ci.Branches(out ifBlockExitLabel))); - - if (matcher.IsInvalid) - return instructions; - - while (!matcher.Labels.Contains(ifBlockEntryLabel.Value)) - matcher.Advance(-1); - - var instructionToClone = matcher.Instruction.Clone(); - var overwriteWith = CodeInstruction.LoadField(typeof(VFInput), nameof(VFInput.control)); - - matcher.SetAndAdvance(overwriteWith.opcode, overwriteWith.operand); - matcher.Insert(instructionToClone); - matcher.CreateLabel(out var existingEntryLabel); - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Brfalse, existingEntryLabel), - new CodeInstruction(OpCodes.Ldarg_0), - CodeInstruction.Call(typeof(OffGridBuilding), nameof(RotateStepped)), - new CodeInstruction(OpCodes.Br, ifBlockExitLabel) - ); - - return matcher.InstructionEnumeration(); - } - - public static void RotateStepped(BuildTool_Click instance) - { - if (VFInput._rotate.onDown) - { - instance.yaw += SteppedRotationDegrees; - instance.yaw = Mathf.Repeat(instance.yaw, 360f); - instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees; - } - - if (VFInput._counterRotate.onDown) - { - instance.yaw -= SteppedRotationDegrees; - instance.yaw = Mathf.Repeat(instance.yaw, 360f); - instance.yaw = Mathf.Round(instance.yaw / SteppedRotationDegrees) * SteppedRotationDegrees; - } - } - */ } internal class TreatStackingAsSingle : PatchImpl diff --git a/UXAssist/Patches/Factory/BuildingBufferPatch.cs b/UXAssist/Patches/Factory/BuildingBufferPatch.cs index e88449b..2b63a25 100644 --- a/UXAssist/Patches/Factory/BuildingBufferPatch.cs +++ b/UXAssist/Patches/Factory/BuildingBufferPatch.cs @@ -8,11 +8,6 @@ namespace UXAssist.Patches.Factory; internal static class BuildingBufferPatch { - public static void Enable(bool enable) - { - TweakBuildingBuffer.Enable(enable); - } - internal class TweakBuildingBuffer : PatchImpl { public static void RefreshAssemblerBufferMultipliers() diff --git a/UXAssist/Patches/Factory/VeinProtectionPatch.cs b/UXAssist/Patches/Factory/VeinProtectionPatch.cs index 0dfad9e..1e3cfe0 100644 --- a/UXAssist/Patches/Factory/VeinProtectionPatch.cs +++ b/UXAssist/Patches/Factory/VeinProtectionPatch.cs @@ -10,11 +10,6 @@ namespace UXAssist.Patches.Factory; [ModFeature("VeinProtection")] internal static partial class VeinProtectionPatch { - public static void Enable(bool enable) - { - ProtectVeinsFromExhaustion.Enable(enable); - } - public static void InitConfig() { ProtectVeinsFromExhaustion.InitConfig(); diff --git a/UXAssist/Patches/GamePatch.cs b/UXAssist/Patches/GamePatch.cs index 2816947..c643d9e 100644 --- a/UXAssist/Patches/GamePatch.cs +++ b/UXAssist/Patches/GamePatch.cs @@ -19,7 +19,6 @@ public class GamePatch : PatchImpl public static ConfigEntry EnableWindowResizeEnabled; public static ConfigEntry LoadLastWindowRectEnabled; - // public static ConfigEntry AutoSaveOptEnabled; public static ConfigEntry ConvertSavesFromPeaceEnabled; public static ConfigEntry LastWindowRect; public static ConfigEntry ProfileBasedSaveFolderEnabled; @@ -81,7 +80,6 @@ public class GamePatch : PatchImpl FixLastWindowRect(); } }; - // AutoSaveOptEnabled.SettingChanged += (_, _) => AutoSaveOpt.Enable(AutoSaveOptEnabled.Value); ConvertSavesFromPeaceEnabled.SettingChanged += (_, _) => ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value); ProfileBasedSaveFolderEnabled.SettingChanged += (_, _) => RefreshSavePath(); ProfileBasedOptionEnabled.SettingChanged += (_, _) => ProfileBasedOption.Enable(ProfileBasedOptionEnabled.Value); @@ -112,7 +110,6 @@ public class GamePatch : PatchImpl } } EnableWindowResize.Enable(EnableWindowResizeEnabled.Value); - // AutoSaveOpt.Enable(AutoSaveOptEnabled.Value); ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value); Enable(true); @@ -123,7 +120,6 @@ public class GamePatch : PatchImpl { Enable(false); EnableWindowResize.Enable(false); - // AutoSaveOpt.Enable(false); ConvertSavesFromPeace.Enable(false); } @@ -311,145 +307,6 @@ public class GamePatch : PatchImpl } } - /* - private class AutoSaveOpt: PatchImpl - { - protected override void OnEnable() - { - Directory.CreateDirectory(GameConfig.gameSaveFolder + "AutoSaves/"); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.AutoSave))] - private static bool GameSave_AutoSave_Prefix(ref bool __result) - { - if (!GameSave.SaveCurrentGame(GameSave.AutoSaveTmp)) - { - GlobalObject.SaveOpCounter(); - __result = false; - return false; - } - - var tmpFilename = GameConfig.gameSaveFolder + GameSave.AutoSaveTmp + GameSave.saveExt; - var targetFilename = $"{GameConfig.gameSaveFolder}AutoSaves/[{GameMain.data.gameDesc.clusterString}] {DateTime.Now:yyyy-MM-dd_hh-mm-ss}{GameSave.saveExt}"; - File.Move(tmpFilename, targetFilename); - __result = true; - return false; - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.RefreshList))] - public static void UILoadGameWindow_RefreshList_Postfix(UILoadGameWindow __instance) - { - var baseDir = GameConfig.gameSaveFolder + "AutoSaves/"; - var files = Directory.GetFiles(baseDir, "*" + GameSave.saveExt, SearchOption.TopDirectoryOnly); - var entries = __instance.entries; - var entries2 = new List(); - var entryPrefab = __instance.entryPrefab; - var entryPrefabParent = entryPrefab.transform.parent; - foreach (var f in files) - { - var fileInfo = new FileInfo(f); - var entry = Object.Instantiate(entryPrefab, entryPrefabParent); - entry.fileInfo = fileInfo; - entries2.Add(entry); - } - entries2.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate)); - if (entries2.Count > 10) - entries2.RemoveRange(10, entries2.Count - 10); - var autoSaveText = ">> " + I18NKeys.AutoSaveEntry.Translate(); - foreach (var entry in entries2) - { - entry.indexText.text = ""; - var saveName = entry.saveName; - entry._saveName = $"AutoSaves/{saveName}"; - var quoteIndex = saveName.IndexOf('['); - if (quoteIndex >= 0) - { - var quoteIndex2 = saveName.IndexOf(']', quoteIndex + 1); - if (quoteIndex2 > 0) saveName = saveName.Substring(quoteIndex, quoteIndex2 + 1 - quoteIndex); - } - entry.nameText.text = $"{autoSaveText} {saveName}"; - entry.nameText.fontStyle = FontStyle.Italic; - entry.nameText.color = new Color(1f, 1f, 1f, 0.7f); - entry.timeText.text = $"{entry.fileDate:yyyy-MM-dd HH:mm:ss}"; - GameSave.ReadModes(entry.fileInfo.FullName, out var isSandbox, out var isPeace); - if (entry.sandboxIcon != null) - { - entry.sandboxIcon.gameObject.SetActive(isSandbox); - } - if (entry.combatIcon != null) - { - entry.combatIcon.gameObject.SetActive(!isPeace); - } - entry.selected = false; - entry.gameObject.SetActive(true); - } - entries.AddRange(entries2); - entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate)); - var displayIndex = 1; - for (var i = 0; i < entries.Count; i++) - { - var entry = entries[i]; - entry.index = i + 1; - entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i); - if (string.IsNullOrEmpty(entry.indexText.text)) continue; - entry.indexText.text = displayIndex.ToString(); - displayIndex++; - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(UISaveGameWindow), nameof(UISaveGameWindow.RefreshList))] - public static void UISaveGameWindow_RefreshList_Postfix(UISaveGameWindow __instance) - { - var entries = __instance.entries; - entries.Sort((x, y) => -x.fileDate.CompareTo(y.fileDate)); - for (var i = 0; i < entries.Count; i++) - { - var entry = entries[i]; - entry.index = i + 1; - entry.rectTrans.anchoredPosition = new Vector2(entry.rectTrans.anchoredPosition.x, -40 * i); - entry.indexText.text = (i + 1).ToString(); - } - } - // Harmony transpiler: UILoadGameWindow_ReplaceSaveName_Transpiler - // Target: UILoadGameWindow.DoLoadSelectedGame, UILoadGameWindow.OnSelectedChange - // Fallback: None — patch will fail loudly if the target method body changes. - [HarmonyTranspiler] - [HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.DoLoadSelectedGame))] - [HarmonyPatch(typeof(UILoadGameWindow), nameof(UILoadGameWindow.OnSelectedChange))] - private static IEnumerable UILoadGameWindow_ReplaceSaveName_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.Start().MatchForward(false, - new CodeMatch(OpCodes.Callvirt, AccessTools.PropertyGetter(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry.saveName))) - ); - matcher.Repeat(m => m.SetAndAdvance(OpCodes.Ldfld, AccessTools.Field(typeof(UIGameSaveEntry), nameof(UIGameSaveEntry._saveName)))); - return matcher.InstructionEnumeration(); - } - // Harmony transpiler: GameSave_RemoveValidateOnLoad_Transpiler - // Target: GameSave.LoadCurrentGame, GameSave.LoadGameDesc, GameSave.ReadHeader, GameSave.ReadHeaderAndDescAndProperty, GameSave.SaveExist, GameSave.SavePath - // Fallback: Checks CodeMatcher.IsInvalid/IsValid and returns original instructions on mismatch. - [HarmonyTranspiler] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadCurrentGame))] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.LoadGameDesc))] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeader))] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.ReadHeaderAndDescAndProperty))] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.SaveExist))] - [HarmonyPatch(typeof(GameSave), nameof(GameSave.SavePath))] - private static IEnumerable GameSave_RemoveValidateOnLoad_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.Start().MatchForward(false, - new CodeMatch(OpCodes.Call, AccessTools.Method(typeof(CommonUtils), nameof(CommonUtils.ValidFileName))) - ); - matcher.RemoveInstruction(); - return matcher.InstructionEnumeration(); - } - } - */ - private class ConvertSavesFromPeace : PatchImpl { private static bool _needConvert; diff --git a/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs b/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs index 046396d..5b3b451 100644 --- a/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs +++ b/UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs @@ -639,7 +639,7 @@ internal static class RealtimeLogisticsInfoPanel || rectPoint.x is < -4096f or > 4096f || rectPoint.y is < -4096f or > 4096f || Phys.RayCastSphere(localPosition, vec / magnitude, magnitude, Vector3.zero, realRadius, out _) - || storageArray.Select(x => x.itemId).All(x => x == 0)) + || storageArray.All(storage => storage.itemId == 0)) { stationTip.gameObject.SetActive(false); continue; diff --git a/UXAssist/Patches/PlayerPatch.cs b/UXAssist/Patches/PlayerPatch.cs index 1d7bb7a..4a2246c 100644 --- a/UXAssist/Patches/PlayerPatch.cs +++ b/UXAssist/Patches/PlayerPatch.cs @@ -204,110 +204,6 @@ public class PlayerPatch : PatchImpl { ShowAllStarsNameStatus = 0; } - /* - // Harmony transpiler: UIStarmapPlanet__OnLateUpdate_Transpiler - // Target: UIStarmapPlanet._OnLateUpdate - // Fallback: None — patch will fail loudly if the target method body changes. - [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStarmapPlanet), nameof(UIStarmapPlanet._OnLateUpdate))] - private static IEnumerable UIStarmapPlanet__OnLateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(OpCodes.Ldloc_3), - new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(UIStarmapPlanet), nameof(UIStarmapPlanet.projected))) - ); - matcher.Advance(3); - matcher.CreateLabel(out var jumpPos1); - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))), - new CodeInstruction(OpCodes.Ldc_I4_2), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brfalse, jumpPos1), - new CodeInstruction(OpCodes.Ldc_I4_0), - new CodeInstruction(OpCodes.Stloc_3) - ); - matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapPlanet), nameof(UIStarmapPlanet.gameHistory))), - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapPlanet), nameof(UIStarmapPlanet.planet))), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(PlanetData), nameof(PlanetData.id))), - new CodeMatch(OpCodes.Callvirt, AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.GetPlanetPin))), - new CodeMatch(OpCodes.Ldc_I4_1), - new CodeMatch(ci => ci.Branches(out _)), - new CodeMatch(OpCodes.Ldc_I4_1), - new CodeMatch(ci => ci.IsStloc()), - new CodeMatch(ci => ci.Branches(out _)) - ); - matcher.CreateLabelAt(matcher.Pos + 8, out var jumpPos); - var labels = matcher.Labels; - matcher.Labels = []; - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))).WithLabels(labels), - new CodeInstruction(OpCodes.Ldc_I4_1), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brtrue, jumpPos), - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(PlayerPatch), nameof(_showAllStarsNameKey))), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(KeyBindings), nameof(KeyBindings.IsKeyPressing))), - new CodeInstruction(OpCodes.Brtrue, jumpPos) - ); - return matcher.InstructionEnumeration(); - } - // Harmony transpiler: UIStarmapDFHive__OnLateUpdate_Transpiler - // Target: UIStarmapDFHive._OnLateUpdate - // Fallback: None — patch will fail loudly if the target method body changes. - [HarmonyTranspiler] - [HarmonyPatch(typeof(UIStarmapDFHive), nameof(UIStarmapDFHive._OnLateUpdate))] - private static IEnumerable UIStarmapDFHive__OnLateUpdate_Transpiler(IEnumerable instructions, ILGenerator generator) - { - var matcher = new CodeMatcher(instructions, generator); - matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(ci => ci.IsLdloc()), - new CodeMatch(OpCodes.Stfld, AccessTools.Field(typeof(UIStarmapDFHive), nameof(UIStarmapDFHive.projected))) - ); - matcher.Advance(3); - matcher.CreateLabel(out var jumpPos1); - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))), - new CodeInstruction(OpCodes.Ldc_I4_2), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brfalse, jumpPos1), - new CodeInstruction(OpCodes.Ldc_I4_0), - new CodeInstruction(OpCodes.Stloc_S, 4) - ); - matcher.MatchForward(false, - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapDFHive), nameof(UIStarmapDFHive.gameHistory))), - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(UIStarmapDFHive), nameof(UIStarmapDFHive.hive))), - new CodeMatch(OpCodes.Ldfld, AccessTools.Field(typeof(EnemyDFHiveSystem), nameof(EnemyDFHiveSystem.hiveStarId))), - new CodeMatch(OpCodes.Ldc_I4, 1000000), - new CodeMatch(OpCodes.Sub), - new CodeMatch(OpCodes.Callvirt, AccessTools.Field(typeof(GameHistoryData), nameof(GameHistoryData.GetHivePin))), - new CodeMatch(OpCodes.Ldc_I4_1), - new CodeMatch(ci => ci.Branches(out _)), - new CodeMatch(OpCodes.Ldc_I4_1), - new CodeMatch(ci => ci.IsStloc()), - new CodeMatch(ci => ci.Branches(out _)) - ); - matcher.CreateLabelAt(matcher.Pos + 10, out var jumpPos); - var labels = matcher.Labels; - matcher.Labels = []; - matcher.InsertAndAdvance( - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(ShortcutKeysForStarsName), nameof(_showAllStarsNameStatus))).WithLabels(labels), - new CodeInstruction(OpCodes.Ldc_I4_1), - new CodeInstruction(OpCodes.Ceq), - new CodeInstruction(OpCodes.Brtrue, jumpPos), - new CodeInstruction(OpCodes.Ldsfld, AccessTools.Field(typeof(PlayerPatch), nameof(_showAllStarsNameKey))), - new CodeInstruction(OpCodes.Call, AccessTools.Method(typeof(KeyBindings), nameof(KeyBindings.IsKeyPressing))), - new CodeInstruction(OpCodes.Brtrue, jumpPos) - ); - return matcher.InstructionEnumeration(); - } - */ } diff --git a/UXAssist/Patches/UIPatch.cs b/UXAssist/Patches/UIPatch.cs index 2d91f8c..bb00cec 100644 --- a/UXAssist/Patches/UIPatch.cs +++ b/UXAssist/Patches/UIPatch.cs @@ -106,11 +106,6 @@ public class UIPatch : PatchImpl } } - private static Vector2 GetAdjustedSizeDelta(Vector2 origSizeDelta) - { - return new Vector2(origSizeDelta.x + 40f, origSizeDelta.y); - } - protected override void OnDisable() { if (planetVeinCount != null) diff --git a/UXAssist/Production/BlueprintDescriptionText.cs b/UXAssist/Production/BlueprintDescriptionText.cs index b10b4ac..7fb1135 100644 --- a/UXAssist/Production/BlueprintDescriptionText.cs +++ b/UXAssist/Production/BlueprintDescriptionText.cs @@ -88,7 +88,8 @@ public static class BlueprintDescriptionFormatter var input = new List(); var output = new SortedDictionary(); var research = new SortedDictionary(); - foreach (var flow in report.ItemFlows.Values.OrderBy(flow => flow.ItemId)) + var orderedFlows = report.ItemFlows.Values.OrderBy(flow => flow.ItemId).ToArray(); + foreach (var flow in orderedFlows) { var shortage = Math.Min(flow.IntermediateShortage, flow.SteadyStateExternalSupply ?? flow.RequiredExternalSupply); @@ -98,14 +99,14 @@ public static class BlueprintDescriptionFormatter if (report.MaterialComplete) { - foreach (var flow in report.ItemFlows.Values.OrderBy(flow => flow.ItemId)) + foreach (var flow in orderedFlows) { if (flow.OverbuildSurplus.GetValueOrDefault() > Tolerance) excess.Add(FormatItem(flow.ItemId, flow.OverbuildSurplus.Value, itemTag)); } } - foreach (var flow in report.ItemFlows.Values.OrderBy(flow => flow.ItemId)) + foreach (var flow in orderedFlows) { var requiredSupply = flow.SteadyStateExternalSupply ?? flow.RequiredExternalSupply; if (requiredSupply > Tolerance && flow.IntermediateShortage <= Tolerance) diff --git a/UXAssist/Production/ProductionCatalogReader.cs b/UXAssist/Production/ProductionCatalogReader.cs index b63a52b..2b000b0 100644 --- a/UXAssist/Production/ProductionCatalogReader.cs +++ b/UXAssist/Production/ProductionCatalogReader.cs @@ -119,8 +119,7 @@ public static class ProductionCatalogReader } return new ProductionCatalog(items, recipes, buildings, - (double[])Cargo.accTableMilli.Clone(), (double[])Cargo.incTableMilli.Clone(), - (double[])Cargo.powerTableRatio.Clone(), technologies, matrixIds); + Cargo.accTableMilli, Cargo.incTableMilli, Cargo.powerTableRatio, technologies, matrixIds); } private static void AddSpecialRecipes(IEnumerable itemProtos, diff --git a/UXAssist/UI/MyKeyBinder.cs b/UXAssist/UI/MyKeyBinder.cs index 65d9d42..2443bd6 100644 --- a/UXAssist/UI/MyKeyBinder.cs +++ b/UXAssist/UI/MyKeyBinder.cs @@ -32,8 +32,6 @@ public class MyKeyBinder : MonoBehaviour [SerializeField] public UIButton setNoneKeyUIButton; - private bool _nextNotOn; - protected void OnDestroy() { OnFree?.Invoke(); @@ -223,11 +221,6 @@ public class MyKeyBinder : MonoBehaviour { inputUIButton.highlighted = true; - if (!_nextNotOn) return; - _nextNotOn = false; - inputUIButton.highlighted = false; - setTheKeyToggle.isOn = false; - waitingText.gameObject.SetActive(false); } public void OnSetDefaultKeyClick(int data) diff --git a/UXAssist/UI/MyWindow.cs b/UXAssist/UI/MyWindow.cs index 211f44f..9550665 100644 --- a/UXAssist/UI/MyWindow.cs +++ b/UXAssist/UI/MyWindow.cs @@ -559,15 +559,6 @@ public abstract class MyWindowManager win._Destroy(); } - /* - public static void SetRect(ManualBehaviour win, RectTransform rect) - { - var rectTransform = win.GetComponent(); - //rectTransform.position = - //rectTransform.sizeDelta = rect; - } - */ - public class Patch : PatchImpl { protected override void OnEnable() @@ -586,14 +577,6 @@ public abstract class MyWindowManager Initialized = true; } - /* - //_Create -> _Init - [HarmonyPostfix, HarmonyPatch(typeof(UIGame), nameof(UIGame._OnCreate))] - public static void UIGame__OnCreate_Postfix() - { - } - */ - [HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnDestroy))] public static void UIRoot__OnDestroy_Postfix() { @@ -612,17 +595,6 @@ public abstract class MyWindowManager InitAllWindows(); } - /* - [HarmonyPostfix, HarmonyPatch(typeof(UIGame), nameof(UIGame._OnFree))] - public static void UIGame__OnFree_Postfix() - { - foreach (var win in Windows) - { - win._Free(); - } - } - */ - [HarmonyPostfix, HarmonyPatch(typeof(UIRoot), nameof(UIRoot._OnUpdate))] public static void UIRoot__OnUpdate_Postfix() { diff --git a/UXAssist/UIConfigWindow.cs b/UXAssist/UIConfigWindow.cs index 62f0bb1..d9b519c 100644 --- a/UXAssist/UIConfigWindow.cs +++ b/UXAssist/UIConfigWindow.cs @@ -96,37 +96,19 @@ public static class UIConfigWindow private class AutoConfigDispenserChargePowerMapper() : MyWindow.RangeValueMapper(3, 30) { - public override string FormatValue(string format, int value) - { - var sb = new StringBuilder(" "); - StringBuilderUtility.WriteKMG(sb, 8, value * 300000L, false); - sb.Append('W'); - return sb.ToString().Trim(); - } + public override string FormatValue(string format, int value) => FormatPower(value * 300000L); } private class AutoConfigBattleBaseChargePowerMapper() : MyWindow.RangeValueMapper(4, 40) { - public override string FormatValue(string format, int value) - { - var sb = new StringBuilder(" "); - StringBuilderUtility.WriteKMG(sb, 8, value * 300000L, false); - sb.Append('W'); - return sb.ToString().Trim(); - } + public override string FormatValue(string format, int value) => FormatPower(value * 300000L); } private class AutoConfigPLSChargePowerMapper() : MyWindow.RangeValueMapper(2, 20) { - public override string FormatValue(string format, int value) - { - var sb = new StringBuilder(" "); - StringBuilderUtility.WriteKMG(sb, 8, value * 3000000L, false); - sb.Append('W'); - return sb.ToString().Trim(); - } + public override string FormatValue(string format, int value) => FormatPower(value * 3000000L); } private class AutoConfigCarrierMinDeliverMapper() : MyWindow.RangeValueMapper(0, 10) @@ -147,13 +129,7 @@ public static class UIConfigWindow private class AutoConfigILSChargePowerMapper() : MyWindow.RangeValueMapper(2, 20) { - public override string FormatValue(string format, int value) - { - var sb = new StringBuilder(" "); - StringBuilderUtility.WriteKMG(sb, 8, value * 15000000L, false); - sb.Append('W'); - return sb.ToString().Trim(); - } + public override string FormatValue(string format, int value) => FormatPower(value * 15000000L); } private class AutoConfigILSMaxTripShipMapper() : MyWindow.RangeValueMapper(1, 41) @@ -192,6 +168,14 @@ public static class UIConfigWindow } } + private static string FormatPower(long watts) + { + var sb = new StringBuilder(" "); + StringBuilderUtility.WriteKMG(sb, 8, watts, false); + sb.Append('W'); + return sb.ToString().Trim(); + } + private static void CreateUI(MyConfigWindow wnd, RectTransform trans) { UnityEngine.UI.Text txt; @@ -203,14 +187,6 @@ public static class UIConfigWindow wnd.AddCheckBox(x, y, tab1, GamePatch.EnableWindowResizeEnabled, I18NKeys.EnableGameWindowResize); y += 36f; wnd.AddCheckBox(x, y, tab1, GamePatch.LoadLastWindowRectEnabled, I18NKeys.RemeberWindowPositionAndSizeOnLastExit); - /* - y += 30f; - wnd.AddCheckBox(x, y, tab1, GamePatch.AutoSaveOptEnabled, "Better auto-save mechanism"); - x = 200f; - y += 6f; - wnd.AddTipsButton2(x, y, tab1, "Better auto-save mechanism", "Better auto-save mechanism tips", "auto-save-opt-tips"); - x = 0f; - */ y += 36f; wnd.AddCheckBox(x, y, tab1, GamePatch.ConvertSavesFromPeaceEnabled, I18NKeys.ConvertOldSavesToCombatModeOnLoading); MyCheckBox checkBoxForMeasureTextWidth; diff --git a/UXAssist/UXAssist.cs b/UXAssist/UXAssist.cs index b2c0355..bd6fbae 100644 --- a/UXAssist/UXAssist.cs +++ b/UXAssist/UXAssist.cs @@ -89,10 +89,6 @@ public class UXAssist : BaseUnityPlugin, IModCanSave "Profile-based option"); GamePatch.DefaultProfileName = Config.Bind("Game", "DefaultProfileName", "Default", "Default profile name, used when profile-based save folder is enabled. Use original game save folder if matched"); - /* - GamePatch.AutoSaveOptEnabled = Config.Bind("Game", "AutoSaveOpt", false, - "Better auto-save mechanism"); - */ GamePatch.ConvertSavesFromPeaceEnabled = Config.Bind("Game", "ConvertSavesFromPeace", false, "Convert saves from Peace mode to Combat mode on save loading"); GamePatch.GameUpsFactor = _dummyConfig.Bind("Game", "GameUpsFactor", 1.0, diff --git a/UniverseGenTweaks/Functions/GalaxyGenSave.cs b/UniverseGenTweaks/Functions/GalaxyGenSave.cs index 302b938..76a1458 100644 --- a/UniverseGenTweaks/Functions/GalaxyGenSave.cs +++ b/UniverseGenTweaks/Functions/GalaxyGenSave.cs @@ -1,9 +1,7 @@ using System.IO; -using UXAssist.Common.ModFeatures; namespace UniverseGenTweaks; -[ModFeature("UniverseGenSave", Order = 13)] public static class GalaxyGenSave { public static void Export(BinaryWriter w) diff --git a/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs b/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs index d305595..f3b51f0 100644 --- a/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs +++ b/UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs @@ -12,10 +12,6 @@ namespace UniverseGenTweaks; [ModFeature("UniverseGenGalaxySelectUI", Order = 10)] public static class GalaxySelectUIPatch { - private static Text _minDistTitle; - private static Text _minStepTitle; - private static Text _maxStepTitle; - private static Text _flattenTitle; private static Slider _minDistSlider; private static Slider _minStepSlider; private static Slider _maxStepSlider; @@ -62,28 +58,28 @@ public static class GalaxySelectUIPatch { __instance.starCountSlider.maxValue = MoreSettings.MaxStarCount.Value; - CreateSliderWithText(__instance.starCountSlider, out _minDistTitle, out _minDistSlider, out _minDistText, out var minDistLocalizer); - CreateSliderWithText(__instance.starCountSlider, out _minStepTitle, out _minStepSlider, out _minStepText, out var minStepLocalizer); - CreateSliderWithText(__instance.starCountSlider, out _maxStepTitle, out _maxStepSlider, out _maxStepText, out var maxStepLocalizer); - CreateSliderWithText(__instance.starCountSlider, out _flattenTitle, out _flattenSlider, out _flattenText, out var flattenLocalizer); + CreateSliderWithText(__instance.starCountSlider, out var minDistTitle, out _minDistSlider, out _minDistText, out var minDistLocalizer); + CreateSliderWithText(__instance.starCountSlider, out var minStepTitle, out _minStepSlider, out _minStepText, out var minStepLocalizer); + CreateSliderWithText(__instance.starCountSlider, out var maxStepTitle, out _maxStepSlider, out _maxStepText, out var maxStepLocalizer); + CreateSliderWithText(__instance.starCountSlider, out var flattenTitle, out _flattenSlider, out _flattenText, out var flattenLocalizer); minDistLocalizer.stringKey = Localization.StarDistanceMin; - _minDistTitle.text = Localization.StarDistanceMin.Translate(); + minDistTitle.text = Localization.StarDistanceMin.Translate(); minStepLocalizer.stringKey = Localization.StepDistanceMin; - _minStepTitle.text = Localization.StepDistanceMin.Translate(); + minStepTitle.text = Localization.StepDistanceMin.Translate(); maxStepLocalizer.stringKey = Localization.StepDistanceMax; - _maxStepTitle.text = Localization.StepDistanceMax.Translate(); + maxStepTitle.text = Localization.StepDistanceMax.Translate(); flattenLocalizer.stringKey = Localization.Flatness; - _flattenTitle.text = Localization.Flatness.Translate(); + flattenTitle.text = Localization.Flatness.Translate(); - _minDistTitle.name = "min-dist"; - _minStepTitle.name = "min-step"; - _maxStepTitle.name = "max-step"; - _flattenTitle.name = "flatten"; + minDistTitle.name = "min-dist"; + minStepTitle.name = "min-step"; + maxStepTitle.name = "max-step"; + flattenTitle.name = "flatten"; - TransformDeltaY(_minDistTitle.transform, UniverseGenConstants.SliderRowSpacing); - TransformDeltaY(_minStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 2); - TransformDeltaY(_maxStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 3); - TransformDeltaY(_flattenTitle.transform, UniverseGenConstants.SliderRowSpacing * 4); + TransformDeltaY(minDistTitle.transform, UniverseGenConstants.SliderRowSpacing); + TransformDeltaY(minStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 2); + TransformDeltaY(maxStepTitle.transform, UniverseGenConstants.SliderRowSpacing * 3); + TransformDeltaY(flattenTitle.transform, UniverseGenConstants.SliderRowSpacing * 4); TransformDeltaY(__instance.darkFogToggle.transform.parent, UniverseGenConstants.SliderRowSpacing * 4); TransformDeltaY(__instance.resourceMultiplierSlider.transform.parent, UniverseGenConstants.SliderRowSpacing * 4); TransformDeltaY(__instance.sandboxToggle.transform.parent, UniverseGenConstants.SliderRowSpacing * 4); @@ -113,10 +109,7 @@ public static class GalaxySelectUIPatch [HarmonyPatch(typeof(UIGalaxySelect), nameof(UIGalaxySelect._OnUnregEvent))] private static void UIGalaxySelect__OnUnregEvent_Postfix() { - _minDistSlider.onValueChanged.RemoveAllListeners(); - _minStepSlider.onValueChanged.RemoveAllListeners(); - _maxStepSlider.onValueChanged.RemoveAllListeners(); - _flattenSlider.onValueChanged.RemoveAllListeners(); + RemoveAllListeners(); } } diff --git a/UniverseGenTweaks/UIConfigWindow.cs b/UniverseGenTweaks/UIConfigWindow.cs index afb25a4..4be53cc 100644 --- a/UniverseGenTweaks/UIConfigWindow.cs +++ b/UniverseGenTweaks/UIConfigWindow.cs @@ -7,8 +7,6 @@ namespace UniverseGenTweaks; public static class UIConfigWindow { - private static RectTransform _windowTrans; - public static void Init() { MyConfigWindow.OnUICreated += CreateUI; @@ -16,13 +14,12 @@ public static class UIConfigWindow private static void CreateUI(MyConfigWindow wnd, RectTransform trans) { - _windowTrans = trans; // General tab var x = 0f; var y = 10f; wnd.AddSplitter(trans, 10f); wnd.AddTabGroup(trans, Localization.UniverseGen, "tab-group-galaxygen"); - var tab1 = wnd.AddTab(_windowTrans, "General"); + var tab1 = wnd.AddTab(trans, "General"); MyCheckBox.CreateCheckBox(x, y, tab1, MoreSettings.Enabled, Localization.EnableMoreSettingsOnUniverseGen); x += 20f; y += 26f; @@ -70,7 +67,7 @@ public static class UIConfigWindow EpicDifficulty.OilMultiplier.Value = val; sl2.SetLabelText(val.ToString(sl2.labelFormat)); }; - var tab2 = wnd.AddTab(_windowTrans, Localization.BirthStar); + var tab2 = wnd.AddTab(trans, Localization.BirthStar); x = 0f; y = 10f; MyCheckBox.CreateCheckBox(x, y, tab2, BirthPlanetPatch.SitiVeinsOnBirthPlanet, Localization.SiliconTitaniumOnBirthPlanet); @@ -94,4 +91,4 @@ public static class UIConfigWindow y += 36f; MyCheckBox.CreateCheckBox(x, y, tab2, BirthPlanetPatch.HighLuminosityBirthStar, Localization.BirthStarHasHighLuminosity); } -} \ No newline at end of file +} diff --git a/docs/design-cleanup/README.md b/docs/design-cleanup/README.md new file mode 100644 index 0000000..8819ee1 --- /dev/null +++ b/docs/design-cleanup/README.md @@ -0,0 +1,34 @@ +# Repository design cleanup + +Baseline: latest `origin/master` at the start and final synchronization check on 2026-11-04, `64a23e9772e7878f216cc2e281da2bc3f87d3140`. Branch: `cleanup-single-owner-abstractions`. Work is isolated in the registered `sharp-lamarr` worktree; PR #106 and other worktrees are untouched. + +## Outcome + +Review covered all 356 baseline tracked paths: 235 maintained first-party source/project/build paths, five retired source/project paths inspected read-only, three generated frontend outputs, and 113 supporting docs/config/assets. The [file inventory](coverage.md) records every disposition. This is a design audit of the whole maintained repository, using module inventories, connected flows, symbol/string searches and actual metadata contracts; it is not an exhaustive gameplay/correctness certification. + +Delete three owner-only helper files (`TechKeyCombo`, `TechLog`, `FastDronesRemover`), return their useful logic to its owner, and eliminate redundant private wrappers, state, parameters, allocations, sorting, no-op lifecycle dispatch and inactive experiments. Unify PoolOpt's duplicate managed bookkeeping. Preserve meaningful algorithms, independently checked boundaries, public compatibility facades, serializers and native patch signatures. No new runtime source file, dependency, framework, version or data format is introduced. + +The only diagnostic normalization is PoolOpt's existing DEBUG reset text also being emitted for the all-empty trash fallback. Pool state and all player-visible behavior remain the same. No active native Harmony target/IL body changes; the moved FastDrones prefix keeps its exact external target and false result. + +## Audit decisions + +- [UXAssist common, UI and features](ux-features.md) +- [Production calculations and tests](production.md) +- [Miner, build and player hot paths](ux-hot-paths.md) +- [CheatEnabler and UniverseGenTweaks](cheat-universe.md) +- [Other mods, transport, frontend and maintenance](remaining-mods-tools.md) +- [Test tools and retired modules](check-tools.md) + +## Independent review + +Three cross-reviews cover every implementation group, performed by workers who did not author that group: + +- [Small mods and PoolOpt](review-root.md): corrected required imports; no unresolved finding. +- [CheatEnabler and UniverseGenTweaks](review-cheat-universe.md): no findings. +- [UXAssist including production](review-uxassist.md): no findings. + +The root executor additionally reviewed the final diff and the acceptance-script simplification. No cleanup was replaced with a new single-purpose helper file or general framework. + +## Verification + +[Validation and limitations](validation.md) records passing builds/checks and the seven baseline dashboard fixture failures. The persistent delivery directory contains full diff, raw verification logs, temporary equivalence-check source and a PR receipt; game DLLs and decompiled game source are not included. diff --git a/docs/design-cleanup/cheat-universe.md b/docs/design-cleanup/cheat-universe.md new file mode 100644 index 0000000..dcc9748 --- /dev/null +++ b/docs/design-cleanup/cheat-universe.md @@ -0,0 +1,58 @@ +# CheatEnabler and UniverseGenTweaks design audit + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140` (`origin/master`, 2026-11-04). + +## Coverage + +Reviewed the design and call relationships of all 45 tracked C# sources (35 CheatEnabler, 10 UniverseGenTweaks) and both project files. Read the plugin entry points, configuration bindings, UI construction/update paths, all function classes, patch owners and their nested patch implementations, serialization, and localization registration. The original native methods are not reimplemented or changed by this cleanup; no claim of an in-game execution test is made. + +| Area | Files covered | Result | +| --- | --- | --- | +| CheatEnabler entry/config/localization | `CheatEnabler.cs`, `UIConfigWindow.cs`, `Localization.cs`, `CheatEnabler.csproj` | Retain config keys/defaults and public APIs; remove transient UI state and a forwarding method. | +| CheatEnabler functions | `Functions/{DysonSphereFunctions,PlanetFunctions,PlayerFunctions}.cs`; `Functions/DysonSphere/{DysonSphereResolver,FrameRemovalFunctions,GeometryHelpers,IllegalShellFunctions,ShellCompletionFunctions}.cs` | Remove empty feature registrations, an unused private argument, and unused local collections; preserve all operations and geometry algorithms. | +| CheatEnabler factory | `Patches/Factory/{ArchitectModePatch,BeltSignalPatch,BeltSignalSourceStats,FactoryPatch,ImmediateBuildPatch,LogisticsControlPatch,NoConditionBuildPatch,PowerBoostPatch}.cs`; `Patches/FactoryPatchCompat.cs` | Remove the duplicated signal-belt capacity; retain independent patch groups, statistics boundary and compatibility facade. | +| CheatEnabler general patches | `Patches/{CombatPatch,DysonSpherePatch,GamePatch,PlanetPatch,PlayerPatch,ResourcePatch,TechTweaksPatch}.cs` | Retain patch targeting, native contracts, option ownership and lifecycle. | +| CheatEnabler tech | `Patches/Tech/{DowngradeMode,TechClickHandler,TechDowngrade,TechFuncRevert,TechKeyCombo,TechLog,TechTreeUI,TechUnlock}.cs` | Merge the modifier decoder into the click handler; remove a prefix-only logging wrapper. Retain cascade planning, inverse/recomputation, session state and UI resource ownership. | +| UniverseGenTweaks | `UniverseGenTweaks.cs`, `UIConfigWindow.cs`, `Localization.cs`, `MoreSettings.cs`, `EpicDifficulty.cs`, `BirthPlanetPatch.cs`, `Functions/GalaxyGenSave.cs`, `Patches/{CombatSettingsPatch,GalaxyGenSettingsPatch,GalaxySelectUIPatch}.cs`, `UniverseGenTweaks.csproj` | Remove construction-only state, duplicate listener-removal code and the empty save-helper feature registration; preserve config, UI, patching and save layout. | + +Repository-wide searches included ordinary calls, string/type references, the feature registry's reflective lifecycle lookup, Harmony attributes, and linked source in test projects. Historical `docs/StaticStateInventory.md` is evidence from an earlier audit, not an executable caller. + +## Changes and evidence + +1. **Delete `TechKeyCombo.cs`.** `TryDecode` had exactly one consumer: `TechClickHandler.HandleClick`. Its modifier decoding now lives privately in that owner. `TechUnlock` and `TechDowngrade` compare the same `int.MaxValue` sentinel directly. All eight Shift/Ctrl/Alt combinations retain their previous meaning: none/Shift/Ctrl/both/Alt/Alt+Shift/Alt+Ctrl/all map to ignored/1/10/100/max/ignored/ignored/ignored. The injected Harmony entry method and its exception boundary remain unchanged. +2. **Delete `TechLog.cs`.** Its only action was to call the existing logger with a fixed prefix. All five call sites now call that logger directly with identical `[TechTweaks] ` text and warning severity. The log-once guard in `TechFuncRevert` remains in place. +3. **Remove eight ineffective `[ModFeature]` registrations.** Seven pure function classes in CheatEnabler and `GalaxyGenSave` had no working lifecycle methods. `ModFeatureRegistry` looks only for parameterless static `Init`, `Start`, `Uninit`, `OnInputUpdate`, and `OnUpdate`; its per-feature storage is private, and the attribute name has no lookup path. These classes are static and have no inherited lifecycle. The only two matching `Init` methods are empty. Removing the attributes prevents useless descriptors and per-frame null-delegate dispatches. Public types and their methods, including those two legacy empty `Init` methods, remain available. +4. **Remove `_signalBeltsCapacity`.** Every write copied the allocated `_signalBelts.Length` (64 initially, doubled on growth, zero after nulling). The single array now supplies its capacity directly. `GetSignalBelts` explicitly checks the array for null, preserving lookup behavior after disable/reset. `GetOrCreateSignalBelts` is called only after initialization creates the array; growth and copy lengths are identical. No native field or reflective reference uses this private field. +5. **Remove unused private finalization input and allocations.** `FinalizeDysonSphereChanges` never read its `DysonSphereLayer` argument. Its six calls now pass only the sphere and existing flags; one no-longer-needed `FirstOrDefault` layer search disappears. `availableFrames` and `unusedFrameIds` were allocated but never read in `CreateIllegalDysonShellsSpecially`; their declarations are removed. Shell search, ordering, synchronization and native mutations are unchanged. +6. **Stop storing construction-only UI references globally.** Both config windows copied `CreateUI`'s `trans` parameter into `_windowTrans` solely to read it during the same call. Tabs now use `trans` directly. Four galaxy-slider title fields were read only in `_OnCreate`; they are local variables now. The Unity hierarchy still owns these controls. Coordinates, parents, localization and creation order are unchanged. +7. **Reuse existing UI code without a new abstraction.** The body of CheatEnabler's `UpdateButtons` is placed into its sole private caller `UpdateUI`, which remains the same event delegate. Galaxy selection's `_OnUnregEvent` calls the already-existing `RemoveAllListeners` method, whose four statements match the former body exactly. Listener registration order and timing remain unchanged. + +No new source file, runtime abstraction, dependency, option, persistent field or compatibility wrapper was introduced. No version, README feature description or changelog was changed because this is an internal behavior-preserving cleanup. + +## Deliberately retained candidates + +| Candidate | Concrete reason to retain | +| --- | --- | +| `FactoryPatchCompat.cs` and `DysonSphereFunctions` forwarding methods | Public legacy type/method identities and external reflection are documented compatibility contracts. Removing these would make reducing file count more important than callers. | +| `DysonSphereResolver.cs` | Resolves editor/local targets and supplies consistent user-facing errors to eight operation call sites across three classes; it has real shared responsibility. | +| `FrameRemovalFunctions` / `ShellCompletionFunctions` | Complete independent public operations with confirmation, native resource mutations and statistics/render reconciliation, not a few-line helper split. | +| `GeometryHelpers.cs` | Shared specialized geometry/pool operations. The triangle-count path has thread-local maps for parallel search; full mesh creation uses native shared maps and mutates shells. Similar loops have different contracts; merging them would couple parallel evaluation to game state or add parameterized machinery. | +| `BeltSignalSourceStats.cs` and `BeltSignalSourcePreset` | Pure-managed conversion/accumulation/request selection linked explicitly into `ProductionCheck.csproj`; existing checks exercise fractional rates and recipe preferences. This boundary keeps solver work out of the logic tick. | +| `SourceCache`, `PendingSources`, `FailedSources`, `_sourceCatalog` | Avoid solver execution in ticks, deduplicate pending frame work and warnings, and invalidate results when catalog ownership changes. They are not duplicate game values. | +| `CargoTrafficPatch` batch flags and sets | Building and subsequent renderer flush are distinct phases. `_disableRefreshBatchesBuffers` intentionally remains true while `_isBatchBuilding` is already false, preventing intermediate refreshes during flush. Sets coalesce native renderer work. | +| Multiple factory patch classes/files | Independently activated config options and distinct Harmony targets; combining them into a common dispatcher would obscure patch ownership. The apparently similar logistics transpilers match different native property getters. | +| `DowngradeMode`, `TechTreeUI`, `TechDowngrade`, `TechFuncRevert`, `TechUnlock` | Separate session state, Unity resource lifetime, validation/cascade planning, inverse/recompute rules, and upgrade semantics. Native capacity/data checks and non-invertible bonuses must not be collapsed into generic subtraction. | +| `TechFuncRevert` rounding helpers | Native functions use different rounding/truncation sequences; superficially similar conversions are not equivalent. | +| `SkipBulletPatch` sail caches and `_instantAbsorb` | Bounded per-star buffers and a derived fast-path flag are consumed in performance-sensitive patches; restructuring that algorithm without an output/performance proof would not be a safe design cleanup. | +| `MoreSettings.cs` | Shared public config identity used by plugin binding, both UIs and three patch owners; its `MaxStarCount` field is explicitly referenced by injected IL. | +| `GalaxyGenSave.cs` | A compact, explicit public binary-serialization boundary. Export/import order remains four doubles; it no longer registers as a lifecycle feature. Removing its public identity is unnecessary. | +| Galaxy generation live versus selected settings | `MinDist`/`MinStep`/`MaxStep`/`Flatten` describe selection controls; `Game*` fields describe the current saved game's generation parameters. They can intentionally differ while another galaxy is previewed. | +| `BirthPlanetPatch.BackupData` | Captures originals for repeated configuration changes; restoration state is necessary, not a redundant copy. The lifecycle/preload sequence is not changed. | +| Combat slider mapping table | Seven actual slider handlers share the mapper. Separate UI display and difficulty thresholds implement inverse/display/scoring semantics, so replacing them with one table would change boundaries. | +| Empty public `Init` methods in two function facades | Kept to avoid gratuitous public method removal; no longer discovered or invoked by the feature registry. | + +## Validation scope + +Root execution owns the Release builds and existing production regression checks so game-reference generation is not run concurrently. See the consolidated validation record for command output and results. Scoped `git diff --check -- CheatEnabler UniverseGenTweaks` is required before handoff. + +This audit checks repository design and behavior-preserving source transformations. It does not certify unrelated native patch patterns against a new game release or execute Unity/in-game interactions. No game method body needed a new semantic interpretation for these changes; native patch targets and injected IL are unchanged. diff --git a/docs/design-cleanup/check-tools.md b/docs/design-cleanup/check-tools.md new file mode 100644 index 0000000..8054c83 --- /dev/null +++ b/docs/design-cleanup/check-tools.md @@ -0,0 +1,32 @@ +# Test tools and retired-code coverage + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140` (`origin/master`, 2026-11-04). + +## First-party check tools + +Reviewed all tracked executable sources and project definitions in these requested partitions. Generated `obj`/`bin` outputs are excluded; the tracked lock file and runtime config are retained dependency/runtime inputs. + +| Partition | Files | Design decision | +| --- | --- | --- | +| Reflection reader executable | `LiveStreamAssist/tools/ReflectionReaderCheck/{Program.cs,ReflectionReaderCheck.csproj,Copy-GameFacades.ps1}` | Retain: its fixtures explicitly exercise inherited private fields, denied getters, runtime type/assembly boundaries, collections, cycles, integers and non-finite values. The game facade copy script is reused by both executable checks. | +| Transport and production executable checks | `LiveStreamAssist/tools/WebSocketTransportCheck/{Program.cs,ProductionChecks.cs,ProductionStatisticsChecks.cs,WebSocketTransportCheck.csproj,App.config,packages.lock.json}` | Retain: the echo host checks the actual desktop transport; regression mode exercises production server/dispatcher lifetime. Partial files split a 533-line production regression group from the statistics-specific scenarios; they introduce no runtime abstraction or forwarding type. | +| Running API acceptance script | `LiveStreamAssist/tools/Test-WebSocketApi.ps1` | Simplify its speculative connection wrapper; retain socket lifetime, timeout, fragmented-message and response assertion helpers, which have multiple real uses. | +| Browser checks | `LiveStreamAssist/js/scripts/{test_helpers.js,test_client.js,test_query.js,test_text.js,test_overlays.js,test_dashboard.js}` | Retain: `test_helpers.js` is shared by all five suites and supplies deterministic timers/WebSockets/VM loading. Overlay and dashboard DOM fixtures intentionally model different UI needs; merging them would create an unnecessary DOM abstraction. | +| Python checks | `LiveStreamAssist/js/scripts/test_text.py` | Retain standalone assertions against generators and locale parsing; test fixtures are local and use standard-library temporary directories/mocks. | +| Repository check scripts | `tools/tests/{Test-PublishMod.ps1,Test-QuickMinerPlacement.ps1,QuickMinerPlacementTests.cs}` | Retain: publication fixtures isolate synthetic credentials/network/package outputs; miner checks link production source and original DLLs into an excluded `obj` test executable with independent geometry oracles and exact sequential/parallel layout checks. | + +The C# transport fake socket/context/probe are nested in the checks that own them. The CLR facade exception and binding redirects distinguish desktop Kestrel from Unity's Mono facade dependencies; consolidating the projects would erase that useful runtime boundary. The publication wrapper's argument flexibility is exercised by build, restore, metadata, tool-version and upload simulations, so it is not speculative generalization. + +## Applied simplification + +`Get-ConnSocket` in `Test-WebSocketApi.ps1` supported hashtables and arbitrary property-bearing objects. All non-null connection values in this standalone script come from `Connect-Api`, which returns exactly `[pscustomobject]@{ Ws = $ws }`. There is no export/module entry, alternate constructor, or external caller. Its four consumers now read `.Ws` directly. `Close-Api` retains an explicit null-connection guard and its existing null-socket guard. This removes a standalone forwarding/shape-decoding function without changing valid inputs, close/dispose behavior, exception handling or deadlines. + +Focused validation: PowerShell parser plus three synthetic cleanup cases passed in `LiveStreamAssist/obj/design-cleanup-websocket-check.ps1`: null connection, known connection with closed mock socket (disposed once), and known connection with null socket. No network or game was used. Scoped `git diff --check -- LiveStreamAssist/tools/Test-WebSocketApi.ps1` passed. The real `-RequireGame` acceptance path still requires a running DSP save and was not executed by this audit. + +The root verification also found a pre-existing dashboard fixture failure: its `FakeQuery` lacks `getClusterString`, while the dashboard invokes that real query method. Root owns baseline reproduction and the final test receipt. This test source was not changed as part of a design-only cleanup. + +## Retired modules + +`LabOpt` and `LabOptPreloader` are covered by read-only structure inspection, not maintenance. The repository README explicitly marks LabOpt obsolete, and the persistent project guidance excludes it from routine mod maintenance. Inspected their project/README/entry/preloader structure and the lab-function boundary. `LabOpt.cs` owns Harmony hooks; `Functions.cs` owns the actual stacked-lab operations; the separate preloader injects `LabComponent.rootLabId` through Mono.Cecil. These are meaningful compilation/runtime boundaries, not one-use few-line helpers. + +No retired source, package or version was edited or built. This entry does not certify retired native method compatibility or audit the full lab algorithm for gameplay correctness. diff --git a/docs/design-cleanup/coverage.md b/docs/design-cleanup/coverage.md new file mode 100644 index 0000000..0922ca7 --- /dev/null +++ b/docs/design-cleanup/coverage.md @@ -0,0 +1,364 @@ +# Baseline file coverage + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140`. All 356 tracked paths are classified below. This is a one-time inventory, not a new scanning framework. Source review combines complete partition mapping with connected-flow and candidate review; it is not a claim of exhaustive gameplay testing. Generated binaries/assets are not reimplemented. + +{'remaining-mods-tools': 61, 'cheat-universe': 47, 'check-tools': 18, 'ux-features / ux-hot-paths': 83, 'production': 26} + +| Baseline path | Disposition | +| --- | --- | +| `.config/dotnet-tools.json` | Supporting docs/config/assets; no executable first-party source | +| `.editorconfig` | Supporting docs/config/assets; no executable first-party source | +| `.github/workflows/build.yml` | Reviewed: remaining-mods-tools | +| `.gitignore` | Supporting docs/config/assets; no executable first-party source | +| `.markdownlint.json` | Supporting docs/config/assets; no executable first-party source | +| `AGENTS.md` | Supporting docs/config/assets; no executable first-party source | +| `AssemblyFromGame/Assembly-CSharp.dll` | Supporting docs/config/assets; no executable first-party source | +| `AssemblyFromGame/UnityEngine.UI.dll` | Supporting docs/config/assets; no executable first-party source | +| `CheatEnabler/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `CheatEnabler/CheatEnabler.cs` | Reviewed: cheat-universe | +| `CheatEnabler/CheatEnabler.csproj` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphere/DysonSphereResolver.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphere/FrameRemovalFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphere/GeometryHelpers.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphere/IllegalShellFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphere/ShellCompletionFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/DysonSphereFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/PlanetFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Functions/PlayerFunctions.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Localization.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/CombatPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/DysonSpherePatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/ArchitectModePatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/BeltSignalPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/BeltSignalSourceStats.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/FactoryPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/ImmediateBuildPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/LogisticsControlPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/NoConditionBuildPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Factory/PowerBoostPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/FactoryPatchCompat.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/GamePatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/PlanetPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/PlayerPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/ResourcePatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/DowngradeMode.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechClickHandler.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechDowngrade.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechFuncRevert.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechKeyCombo.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechLog.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechTreeUI.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/Tech/TechUnlock.cs` | Reviewed: cheat-universe | +| `CheatEnabler/Patches/TechTweaksPatch.cs` | Reviewed: cheat-universe | +| `CheatEnabler/README.md` | Supporting docs/config/assets; no executable first-party source | +| `CheatEnabler/TODO.md` | Supporting docs/config/assets; no executable first-party source | +| `CheatEnabler/UIConfigWindow.cs` | Reviewed: cheat-universe | +| `CheatEnabler/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `CheatEnabler/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `CompressSave/README.md` | Supporting docs/config/assets; no executable first-party source | +| `DSP_Mods.sln` | Reviewed: remaining-mods-tools | +| `Directory.Build.props` | Reviewed: remaining-mods-tools | +| `Directory.Build.targets` | Reviewed: remaining-mods-tools | +| `Dustbin/BeltSignal.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `Dustbin/Dustbin.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/Dustbin.csproj` | Reviewed: remaining-mods-tools | +| `Dustbin/GenerateGameReference.ps1` | Reviewed: remaining-mods-tools | +| `Dustbin/NebulaSupport/Packets.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/README.md` | Supporting docs/config/assets; no executable first-party source | +| `Dustbin/StoragePatch.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/TankPatch.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/UI/MyCheckbox.cs` | Reviewed: remaining-mods-tools | +| `Dustbin/assets/icon/signal-410.png` | Supporting docs/config/assets; no executable first-party source | +| `Dustbin/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `Dustbin/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `DustbinPreloader/DustbinPreloader.cs` | Reviewed: remaining-mods-tools | +| `DustbinPreloader/DustbinPreloader.csproj` | Reviewed: remaining-mods-tools | +| `HideTips/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `HideTips/HideTips.cs` | Reviewed: remaining-mods-tools | +| `HideTips/HideTips.csproj` | Reviewed: remaining-mods-tools | +| `HideTips/README.md` | Supporting docs/config/assets; no executable first-party source | +| `HideTips/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `HideTips/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `LICENSE` | Supporting docs/config/assets; no executable first-party source | +| `LabOpt/Functions.cs` | Retired; read-only design inventory, no maintenance/build | +| `LabOpt/LabOpt.cs` | Retired; read-only design inventory, no maintenance/build | +| `LabOpt/LabOpt.csproj` | Retired; read-only design inventory, no maintenance/build | +| `LabOpt/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LabOpt/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `LabOpt/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `LabOptPreloader/LabOptPreloader.cs` | Retired; read-only design inventory, no maintenance/build | +| `LabOptPreloader/LabOptPreloader.csproj` | Retired; read-only design inventory, no maintenance/build | +| `LabOptPreloader/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/Api/ApiProtocol.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Api/MainThreadDispatcher.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Api/ProductionExtraInfoRefresh.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Api/ReflectionReader.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Api/WebSocketApiFeature.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Api/WebSocketApiServer.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/LiveStreamAssist.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/LiveStreamAssist.csproj` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/Properties/InternalsVisibleTo.cs` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/docs/WebSocketApi.md` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/docs/WebSocketDesign.md` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/examples/live-dashboard.html` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/examples/research-overlay.html` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/examples/stats-overlay.html` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/js/generated/dsp-icons.js` | Generated output; audit source/generator and verify bundle parity | +| `LiveStreamAssist/js/generated/dsp-text.js` | Generated output; audit source/generator and verify bundle parity | +| `LiveStreamAssist/js/livestream-assist.js` | Generated output; audit source/generator and verify bundle parity | +| `LiveStreamAssist/js/scripts/generate-text.py` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/scripts/generate_icons.py` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/scripts/generate_text.py` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/scripts/kmg.py` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/scripts/pack_js.py` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/scripts/requirements.txt` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/js/scripts/test_client.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_dashboard.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_helpers.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_overlays.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_query.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_text.js` | Reviewed: check-tools | +| `LiveStreamAssist/js/scripts/test_text.py` | Reviewed: check-tools | +| `LiveStreamAssist/js/src/client.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/footer.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/format.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/header.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/icons.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/query.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/js/src/text.js` | Reviewed: remaining-mods-tools | +| `LiveStreamAssist/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/packages.lock.json` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/tools/ReflectionReaderCheck/Copy-GameFacades.ps1` | Reviewed: check-tools | +| `LiveStreamAssist/tools/ReflectionReaderCheck/Program.cs` | Reviewed: check-tools | +| `LiveStreamAssist/tools/ReflectionReaderCheck/ReflectionReaderCheck.csproj` | Reviewed: check-tools | +| `LiveStreamAssist/tools/Test-WebSocketApi.ps1` | Reviewed: check-tools | +| `LiveStreamAssist/tools/WebSocketTransportCheck/App.config` | Supporting docs/config/assets; no executable first-party source | +| `LiveStreamAssist/tools/WebSocketTransportCheck/ProductionChecks.cs` | Reviewed: check-tools | +| `LiveStreamAssist/tools/WebSocketTransportCheck/ProductionStatisticsChecks.cs` | Reviewed: check-tools | +| `LiveStreamAssist/tools/WebSocketTransportCheck/Program.cs` | Reviewed: check-tools | +| `LiveStreamAssist/tools/WebSocketTransportCheck/WebSocketTransportCheck.csproj` | Reviewed: check-tools | +| `LiveStreamAssist/tools/WebSocketTransportCheck/packages.lock.json` | Supporting docs/config/assets; no executable first-party source | +| `LogisticMiner/LogisticMiner.cs` | Reviewed: remaining-mods-tools | +| `LogisticMiner/LogisticMiner.csproj` | Reviewed: remaining-mods-tools | +| `LogisticMiner/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LogisticMiner/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `LuaScriptEngine/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `LuaScriptEngine/LuaScriptEngine.cs` | Reviewed: remaining-mods-tools | +| `LuaScriptEngine/LuaScriptEngine.csproj` | Reviewed: remaining-mods-tools | +| `LuaScriptEngine/LuaState.cs` | Reviewed: remaining-mods-tools | +| `LuaScriptEngine/README.md` | Supporting docs/config/assets; no executable first-party source | +| `LuaScriptEngine/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `LuaScriptEngine/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `MechaDronesTweaks/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `MechaDronesTweaks/FastDronesRemover.cs` | Reviewed: remaining-mods-tools | +| `MechaDronesTweaks/MechaDronesTweaks.cs` | Reviewed: remaining-mods-tools | +| `MechaDronesTweaks/MechaDronesTweaks.csproj` | Reviewed: remaining-mods-tools | +| `MechaDronesTweaks/README.md` | Supporting docs/config/assets; no executable first-party source | +| `MechaDronesTweaks/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `MechaDronesTweaks/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `OverclockEverything/BeltFix.cs` | Reviewed: remaining-mods-tools | +| `OverclockEverything/Cfg.cs` | Reviewed: remaining-mods-tools | +| `OverclockEverything/OverclockEverything.cs` | Reviewed: remaining-mods-tools | +| `OverclockEverything/OverclockEverything.csproj` | Reviewed: remaining-mods-tools | +| `OverclockEverything/README.md` | Supporting docs/config/assets; no executable first-party source | +| `OverclockEverything/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `OverclockEverything/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `PoolOpt/PoolOpt.cs` | Reviewed: remaining-mods-tools | +| `PoolOpt/PoolOpt.csproj` | Reviewed: remaining-mods-tools | +| `PoolOpt/README.md` | Supporting docs/config/assets; no executable first-party source | +| `PoolOpt/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `PoolOpt/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `Publish-Mod.ps1` | Reviewed: remaining-mods-tools | +| `README.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/Common/Config/FactoryConfigProvider.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Config/LogisticsConfigProvider.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameConstants/DysonSphereConstants.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameConstants/ItemIds.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameConstants/LogisticsConstants.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameConstants/TechIds.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameConstants/UniverseGenConstants.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameEvent.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/GameLogic.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/I18N.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/I18NKeys.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/KeyBindings.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/KnownItemId.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/ModCompat/ModCompatHelper.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/ModFeatures/IModFeature.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/ModFeatures/ModFeatureAttribute.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/ModFeatures/ModFeatureRegistry.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/PatchImpl.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Patching/TranspilerGuard.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Util.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Utils/DysonSphereReflection.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Utils/PathUtil.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Utils/PlayerInputUtil.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Utils/ReflectionUtil.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/Utils/ResourceUtil.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Common/WinApi.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/DysonSphereFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/Factory/MinerPlacementDebug.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/Factory/MinerPlacementGeometry.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/Factory/MinerPlacementSolver.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/Factory/QuickMinerBuild.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/FactoryFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/PlanetFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/TechFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UI/AutoConstructUI.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UI/AutoCruiseUI.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UI/MenuButtonUI.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UI/MilkyWayUI.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UI/StarmapFilterUI.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/UIFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Functions/WindowFunctions.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/ModsCompat/BulletTimeWrapper.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/ModsCompat/CommonAPIWrapper.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/ModsCompat/PlanetVeinUtilization.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/BlueprintDescriptionPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/DysonSpherePatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/ArchitectModePatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/BeltSignalPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/BuildToolPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/BuildingBufferPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/FactoryBuildPatches.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/FactoryPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/RenderingPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/VeinProtectionPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Factory/VeinProtectionUIPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/GamePatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Logistics/AutoConfigPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Logistics/CapacityPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Logistics/LogisticsPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Logistics/OverflowPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/PersistPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/PlanetPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/PlayerPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/TechPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Patches/UIPatch.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/Production/AccumulatorExchangeAdapter.cs` | Reviewed: production | +| `UXAssist/Production/BlackBoxMaterialClassifier.cs` | Reviewed: production | +| `UXAssist/Production/BlueprintBottleneckBalance.cs` | Reviewed: production | +| `UXAssist/Production/BlueprintDescriptionText.cs` | Reviewed: production | +| `UXAssist/Production/BlueprintSelectionReader.cs` | Reviewed: production | +| `UXAssist/Production/FactoryBlackBoxAnalyzer.cs` | Reviewed: production | +| `UXAssist/Production/FractionationProcessAdapter.cs` | Reviewed: production | +| `UXAssist/Production/FuelGenerationAdapter.cs` | Reviewed: production | +| `UXAssist/Production/GasCollectionAdapter.cs` | Reviewed: production | +| `UXAssist/Production/LaunchProcessAdapter.cs` | Reviewed: production | +| `UXAssist/Production/MiningProcessAdapter.cs` | Reviewed: production | +| `UXAssist/Production/ProcessEvaluator.cs` | Reviewed: production | +| `UXAssist/Production/ProductionCatalogReader.cs` | Reviewed: production | +| `UXAssist/Production/ProductionModel.cs` | Reviewed: production | +| `UXAssist/Production/ProductionPlanRequest.cs` | Reviewed: production | +| `UXAssist/Production/ProductionPlanner.Report.cs` | Reviewed: production | +| `UXAssist/Production/ProductionPlanner.cs` | Reviewed: production | +| `UXAssist/Production/ProductionReports.cs` | Reviewed: production | +| `UXAssist/Production/RayReceiverAdapter.cs` | Reviewed: production | +| `UXAssist/Production/RenewableGenerationAdapter.cs` | Reviewed: production | +| `UXAssist/Production/ResearchProcessAdapter.cs` | Reviewed: production | +| `UXAssist/Production/SandboxBoost.cs` | Reviewed: production | +| `UXAssist/Production/TwoPhaseSimplex.cs` | Reviewed: production | +| `UXAssist/README.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/TODO.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/UI/ConfigTabGroup.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/LayoutHelper.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyCheckButton.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyCheckbox.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyComboBox.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyConfigWindow.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyCornerComboBox.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyFlatButton.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyKeyBinder.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MySideSlider.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MySlider.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/MyWindow.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UI/Util.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UIConfigWindow.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UXAssist.cs` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/UXAssist.csproj` | Reviewed: ux-features / ux-hot-paths | +| `UXAssist/assets/cursor/cursor-ban.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-blank.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-delete.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-downgrade.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-dyson-node-create.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-eraser.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-eyedropper.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-painter.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-reform.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-remove.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-target-a.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-target-b.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-target-in.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-target-out.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-transfer.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor-upgrade.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/cursor/cursor.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/icon/in.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/icon/keep.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/icon/out.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/07.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/09.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/10.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/13.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/14.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/15.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/16.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/17.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/19.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/20.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/21.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/22.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/23.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/24.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/planet_icon/25.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/core-element.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/dark-fog-matrix.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/energy-shard.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/matter-recombinator.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/negentropy-singularity.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/assets/signal/silicon-based-neuron.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/docs/BlueprintDescriptionValidation.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/docs/ProductionArchitecture.md` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `UXAssist/tools/ProductionCheck/Directory.Build.props` | Reviewed: production | +| `UXAssist/tools/ProductionCheck/ProductionCheck.csproj` | Reviewed: production | +| `UXAssist/tools/ProductionCheck/Program.cs` | Reviewed: production | +| `UniverseGenTweaks/BirthPlanetPatch.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/CHANGELOG.md` | Supporting docs/config/assets; no executable first-party source | +| `UniverseGenTweaks/EpicDifficulty.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/Functions/GalaxyGenSave.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/Localization.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/MoreSettings.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/Patches/CombatSettingsPatch.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/Patches/GalaxyGenSettingsPatch.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/Patches/GalaxySelectUIPatch.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/README.md` | Supporting docs/config/assets; no executable first-party source | +| `UniverseGenTweaks/UIConfigWindow.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/UniverseGenTweaks.cs` | Reviewed: cheat-universe | +| `UniverseGenTweaks/UniverseGenTweaks.csproj` | Reviewed: cheat-universe | +| `UniverseGenTweaks/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `UniverseGenTweaks/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `UpdateGameDlls.ps1` | Reviewed: remaining-mods-tools | +| `UpdateGameDlls/Directory.Build.props` | Reviewed: remaining-mods-tools | +| `UpdateGameDlls/Directory.Build.targets` | Reviewed: remaining-mods-tools | +| `UpdateGameDlls/UpdateGameDlls.csproj` | Reviewed: remaining-mods-tools | +| `UserCloak/README.md` | Supporting docs/config/assets; no executable first-party source | +| `UserCloak/UserCloak.cs` | Reviewed: remaining-mods-tools | +| `UserCloak/UserCloak.csproj` | Reviewed: remaining-mods-tools | +| `UserCloak/package/icon.png` | Supporting docs/config/assets; no executable first-party source | +| `UserCloak/package/manifest.json` | Supporting docs/config/assets; no executable first-party source | +| `docs/GitHubIssueReview-2026-10-11.md` | Supporting docs/config/assets; no executable first-party source | +| `docs/PublicApiSurface.md` | Supporting docs/config/assets; no executable first-party source | +| `docs/StaticStateInventory.md` | Supporting docs/config/assets; no executable first-party source | +| `docs/ThunderstorePublishingPlan.md` | Supporting docs/config/assets; no executable first-party source | +| `tools/tests/QuickMinerPlacementTests.cs` | Reviewed: check-tools | +| `tools/tests/Test-PublishMod.ps1` | Reviewed: check-tools | +| `tools/tests/Test-QuickMinerPlacement.ps1` | Reviewed: check-tools | diff --git a/docs/design-cleanup/production.md b/docs/design-cleanup/production.md new file mode 100644 index 0000000..9f97043 --- /dev/null +++ b/docs/design-cleanup/production.md @@ -0,0 +1,47 @@ +# Production calculation audit + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140` (`origin/master`, 2026-11-04). + +## Coverage + +Read all 23 C# files in `UXAssist/Production/`, the complete 2,670-line `UXAssist/tools/ProductionCheck/Program.cs`, its project and local build properties, and `UXAssist/docs/ProductionArchitecture.md`. Traced repository callers of the planner, analyzer, formatter, capture API, adapters and catalog lifecycle. Generated `bin/` and `obj/` contents are build products, not audit input. + +| Files | Responsibilities checked | +| --- | --- | +| `ProductionModel.cs`, `ProductionPlanRequest.cs`, `ProductionReports.cs` | Public immutable snapshots and report contracts; mutable requests; units and shared numeric helpers | +| `ProductionCatalogReader.cs` | Main-thread Proto/Cargo capture, synthetic recipes, default routes, catalog change subscriptions and clear/rebuild ownership | +| `BlueprintSelectionReader.cs` | Existing entities, prebuilds and offline blueprints; native parameter decoding; supplied context; validation diagnostics | +| `ProcessEvaluator.cs` | Ordinary recipes and ordered dispatch to special mechanics | +| `AccumulatorExchangeAdapter.cs`, `FractionationProcessAdapter.cs`, `FuelGenerationAdapter.cs`, `GasCollectionAdapter.cs`, `LaunchProcessAdapter.cs`, `MiningProcessAdapter.cs`, `RayReceiverAdapter.cs`, `RenewableGenerationAdapter.cs`, `ResearchProcessAdapter.cs` | All nine special mechanics; prerequisites; independent material/power completeness; no speculative merging of distinct calculations | +| `SandboxBoost.cs` | Shared boost-mode resolution and validation for capture, launch and fuel paths | +| `ProductionPlanner.cs`, `ProductionPlanner.Report.cs`, `TwoPhaseSimplex.cs` | Target expansion, material ledger, spray reuse, constraints, cancellation/budget, stable numerical solve and report assembly | +| `FactoryBlackBoxAnalyzer.cs`, `BlackBoxMaterialClassifier.cs`, `BlueprintBottleneckBalance.cs` | Fixed-capacity analysis, whole-building redundancy, bounded fractional reduction, bottleneck basis and uncertainty propagation | +| `BlueprintDescriptionText.cs` | Deterministic item order, category formatting, native field validation/replacement and public result types | +| `tools/ProductionCheck/*` (three tracked files) | Existing managed checks and their linked-source boundary; fixture helpers remain beside their owner | + +## Changes + +1. **Remove duplicate immutable-array copies.** `ProductionCatalogReader.Capture` previously cloned all three Cargo proliferation arrays before passing them to `ProductionCatalog`, whose constructor clones the same arrays again. Pass the source arrays directly to that constructor. It still owns the immutable copy; its public API and all other callers retain exactly the same isolation. Capture remains synchronous on the game thread, and no source array is stored directly in the catalog. This removes three temporary arrays per capture without removing the snapshot boundary. +2. **Sort description flows once.** `BlueprintDescriptionFormatter.Format` previously independently sorted the same immutable report values for shortages, excess and normal material categories. Materialize one ordered array for those three passes. Preserve category order and every `itemTag` callback's order; formatting, rounding, missing/unknown behavior and serialized text are unchanged. This is per-call temporary data, not persistent derived state. + +No files, public types, methods, configuration fields or data formats were removed in this partition. No native game mechanics, production equations, solver ordering, placement or UI geometry changed. + +## Candidates deliberately retained + +- **`IProductionProcessAdapter` and the evaluator constructor:** nine real implementations, not a one-product interface/factory. These are public extension contracts shared by both `ProductionPlanner` and `FactoryBlackBoxAnalyzer`; custom adapters have priority before native implementations. Replacing them with a switch would remove compatibility and extension behavior. +- **`RenewableGenerationAdapter.cs` (34 lines):** small, but a complete named public mechanic with its own validation and generation-only result. It is not an owner-specific helper pretending to be a utility. +- **`SandboxBoost.cs` (50 lines):** genuinely shared by fuel generation, launches and blueprint/live capture. It centralizes the distinction between stored mode and applied sandbox state, including conflict diagnostics. +- **`BlueprintBottleneckBalance.cs`:** one owning analyzer call, but 148 lines implement an independent constrained optimization problem with normalization, residual validation and material classification. It shares the numerical solver with global planning. Merging it into the analyzer would hide a substantive algorithm, not eliminate an abstraction. +- **`BlackBoxMaterialClassifier.cs`:** stable grouping, whole-building removal, joint-product accounting and bounded fractional propagation are substantial pure calculation responsibilities. `BlackBoxProcessGroup` and `BlackBoxItemClassification` already live beside their owner instead of occupying extra files, and are also consumed by bottleneck calculation. +- **`ProductionPlanner.Report.cs`:** an existing partial of the same class, containing 202 lines of report construction. It adds no forwarding object, interface or lifecycle; merging would only enlarge the 337-line solver file. +- **Public request/report/capture types:** external mod APIs need immutable inputs and independently incomplete material/power outputs. Similar-looking fields have different meanings (gross/net, required/steady-state, equivalent/rounded, grid/Dyson, factory/logistics); they are not duplicate caches. +- **Catalog event state:** `_initialized` prevents duplicate subscriptions; `Current` is a captured snapshot used by UXAssist and CheatEnabler, not a redundant mirror of live Proto state. Clear notifications invalidate belt-derived reports at session boundaries. +- **Capture diagnostics plus evaluator validation:** capture reports unavailable game context while the pure evaluator validates manually constructed requests too. Removing one would weaken a real input boundary. +- **Test fixtures and native escaping helpers:** local to the existing test owner, reused by distinct checks and intentionally independent of the implementation. No new test framework or helper file was introduced. + +## Validation + +- `dotnet run --project UXAssist/tools/ProductionCheck/ProductionCheck.csproj -c Release`: **569 checks passed before and after changes**. +- `git diff --check -- UXAssist/Production UXAssist/tools/ProductionCheck`: passed. +- Release game-linked project builds are coordinated by the root audit and recorded in its final validation report. +- No original game method-body claim or Harmony target/IL change was made in these edits. The native mechanics were retained verbatim; this audit does not claim in-game execution or Unity UI validation. diff --git a/docs/design-cleanup/remaining-mods-tools.md b/docs/design-cleanup/remaining-mods-tools.md new file mode 100644 index 0000000..ef1019e --- /dev/null +++ b/docs/design-cleanup/remaining-mods-tools.md @@ -0,0 +1,35 @@ +# Other mods, transport, frontend and repository tools + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140`, 2026-11-04. See [coverage](coverage.md) for every tracked path. This partition contains 61 maintained source/project/build paths; test-tool details are in [check-tools](check-tools.md). + +## Applied cleanup + +| Owner | Evidence and final change | Preserved contract | +| --- | --- | --- | +| MechaDronesTweaks | `FastDronesRemover` was an internal 25-line type used only by the plugin constructor and its dependency attribute. Move the version gate, suppression patch and constant into that plugin; delete the file and helper type. Remove the identical second `EnergyMultiplier` binding. | Same soft-dependency GUID, version `0.0.5` gate, external `Start` target, false prefix result, log/error boundary, config key/default/range and patch timing. Private prefix is resolved with `nameof`/AccessTools. | +| Dustbin | Three private resource-to-texture-to-sprite wrappers existed only to load one owned embedded icon. Combine them into `LoadDustbinSprite`, remove unused optional assembly/path generality. | Same `Dustbin.assets.icon.signal-410.png`, Texture2D size/load, sprite rectangle/pivot, stream disposal and preload callback. The project resource include and assembly name resolve to that exact name. | +| PoolOpt | ID and trash-sentinel overloads duplicated the same tail scan/reset/recycle algorithm. Use one local occupancy predicate taking the slot index; remove unused `ref capacity` arguments from all 33 calls and replace the no-argument delegate with `Action`. | Same occupied-slot criteria, `in T` passing, all native reset callbacks, capacities, cursor/recycle results and game-load hook. The fallback for an empty trash pool now emits the same existing DEBUG reset message as other pools; this diagnostic normalization has no state or UI effect. No per-slot closure allocation. Exhaustive before/after state checks are recorded in validation. | +| HideTips | Remove the entirely commented HideMenuDemo experiment, its commented config wiring and the never-assigned private `_patch` field/no-op destroy callback. | Existing active Harmony registration and all suppression/progression behavior remain unchanged. No disabled option becomes active. | +| OverclockEverything | Remove entirely commented GalacticScale belt/collider experiments and their dead helper. | All live patches, prefab updates, serialized configuration order and multiplier defaults remain unchanged. | + +No runtime source file was added. No version, changelog, feature README, package manifest, user data or public API was changed. These changes do not introduce new user-visible features or fixes requiring release notes. + +## Reviewed and retained + +| Scope | Design decision and evidence | +| --- | --- | +| Dustbin / DustbinPreloader | Storage and tank patches each own different native component and UI paths; shared checkbox has two actual users. Packet classes have serializer constructors and processor discovery attributes; empty save callback implements DSPModSave. Preloader is a separate process-phase boundary consumed through generated compile references. Keep old negative-ban import migration because it reads legacy user data. Similar save loops carry different byte tags/reference-vs-struct contracts; adding a serializer framework would increase complexity. | +| HideTips / UserCloak | Existing small single-file plugins have no extra helper layer. Keep distinct patch callbacks even if bodies coincide: Harmony target descriptors and native argument contracts are executable metadata. UserCloak config state and account/Steam interception remain untouched. | +| LogisticMiner | Standalone project is absent from solution, so validate it separately. VeinCacheData is already nested beside its sole owner and avoids repeated per-frame dictionaries; technology-derived caches update at explicit game/tech/vein boundaries. PRNG and mining state are authoritative, not disposable derived state. No algorithm change. | +| LuaScriptEngine | LuaState owns interpreter/callback/timer/OBS resources independently of BepInEx hook wiring. Lua function names and returned Timer instances are dynamic API contracts; preserve them. Temporary timer-removal list avoids mutating enumeration. OBS callbacks capture connection credentials: changing reconnect/registration ownership requires a behavioral fix and acceptance test, so no speculative lifecycle rewrite is included. | +| OverclockEverything | Public Cfg is also the serialized multiplier shape; `_oldCfg` holds imported values needed for migration, not a cache of current config. BeltFix contains its own native visual correction rules and multiple patches; it is not a few-line helper. | +| PoolOpt | Keep per-pool native capacity-reset callbacks; replacing them with reflection or raw array resizing would remove mod-compatible initialization behavior. Only the duplicate managed bookkeeping is unified. | +| LiveStreamAssist C# | Reviewed all seven API/entry C# sources, InternalsVisibleTo and project. ApiProtocol owns input/wire limits; ReflectionReader owns shallow allowlisted traversal and bounded type metadata; MainThreadDispatcher owns Unity affinity/watchdog; ApiConnection/server own concurrent transport. These are distinct responsibilities, not forwarding services. Session generation, owner token, readiness and version snapshots prevent stale asynchronous work. ProductionExtraInfoRefresh is small but contains a stateful, independently checked throttling/batch algorithm. Keep its test boundary. | +| LiveStreamAssist browser | Reviewed all seven `js/src` chunks and all three maintained HTML examples. Client, GameQuery, GameText and GameIcons expose documented separate API responsibilities; text/icons remain offline. Header/footer are syntactic bundle boundaries. Positive-only product cache, `_active` reservation count, generation checks, allReads draining and single-flight page polling have distinct roles; do not remove them as duplicate state. Independent examples intentionally remain copyable pages; a shared polling/UI framework would add a deployment dependency. | +| JS/Python generation | Reviewed all six Python scripts. `generate_icons` reuses actual extraction/discovery from `generate_text`; no new common module is needed. `generate-text.py` preserves an earlier CLI spelling. `kmg.py` is an independent formatting reference used by tests, not a production duplicate to route back into JS. `pack_js.py` is a direct ordered concatenation. Generated locale/icon maps and bundle are outputs, not separate first-party implementations; repacking produces no content diff. | +| Repository maintenance | Read Publish-Mod.ps1, UpdateGameDlls.ps1, Directory.Build.props/targets, UpdateGameDlls project and local imports, solution, workflow and tool pinning. Keep private publish validation/token/path helpers: they isolate real security/compatibility checks and existing stub-test seams. Dotnet/PowerShell JSON evaluation, preloader compile injection and package runtime lists serve different platform boundaries. No new scanner or generic build framework is introduced. | +| Retired/moved modules | CompressSave has documentation only and lives in another repository. LabOpt/LabOptPreloader are read-only inventory per retirement guidance, not revived or built; their details are in check-tools. | + +## Limits + +This is a repository design audit with connected-call and metadata checks, not a full correctness/security or gameplay certification. No game mechanics were rederived from stripped references. No original game method body, native patch target, injected instruction pattern or active UI geometry was changed. DSP/Unity/OBS/LAN interactive validation was not run. Existing dashboard mock failures are reproduced from the exact baseline and reported separately. diff --git a/docs/design-cleanup/review-cheat-universe.md b/docs/design-cleanup/review-cheat-universe.md new file mode 100644 index 0000000..3ae4b9a --- /dev/null +++ b/docs/design-cleanup/review-cheat-universe.md @@ -0,0 +1,48 @@ +# Independent review: CheatEnabler and UniverseGenTweaks + +What this change does: removes two internal helper files, ineffective feature registrations, duplicate array-capacity state and construction-only UI fields. The review assumes the normal single-player game/main-thread lifecycle and existing dependent-mod APIs; it does not assume that a missing ordinary text call makes a Harmony or reflection target unused. + +Reviewed independently from the implementation author, against baseline `64a23e9772e7878f216cc2e281da2bc3f87d3140`. Scope: the complete 18-file CheatEnabler/UniverseGenTweaks working diff, connected owners and callers, registry implementation, current configuration/save entry points and relevant README contracts. No code was edited during this independent review. + +## Findings + +No actionable regression or replacement abstraction found. The changes are appropriately focused and retain existing public type identities. + +## Evidence checked + +| Change | Independent check and conclusion | +| --- | --- | +| `TechKeyCombo.cs` removal | The deleted class is internal. Repository-wide text/string searches find no remaining runtime reference. `TechClickHandler.HandleClick` was its sole decoder consumer; its injected public entry method and exception boundary remain unchanged. The private decoder preserves all eight modifier cases, listed below. `TechUnlock.Run` and `TechDowngrade.Run` use the identical `int.MaxValue` sentinel. No cascade or capacity-validation code was moved or removed. | +| `TechLog.cs` removal | Its internal method only prefixed `[TechTweaks] ` and called `Logger.LogWarning`. All five replacement calls retain the same prefix, message and severity. `UnknownFuncsWarned.Add(func)` still gates repeated unsupported-function logs. No alternate logger, service or helper file replaces it. | +| Eight `[ModFeature]` removals | Checked `ModFeatureRegistry.Discover`, `StaticFeature` and `InitStatic`: only parameterless `Init`, `Start`, `Uninit`, `OnInputUpdate` and `OnUpdate` affect runtime work. The seven CheatEnabler function classes and `GalaxyGenSave` have no working lifecycle callbacks or static constructors; the only two matching `Init` bodies are empty and their public methods remain available. The registry's stored list is private and feature names have no consumer/lookup. Removing empty records preserves the order and work of the remaining real features. | +| `GalaxyGenSave` registration removal | `UniverseGenTweaks` still implements `IModCanSave` and directly calls `GalaxyGenSave.Export/Import`. The save version and the sequence of four doubles are unchanged. The serializer class, namespace and methods retain their public identities. | +| `_signalBeltsCapacity` removal | Every original assignment equalled the allocated array length, or zero after setting the array null. Initial size 64, doubling and copy lengths remain the same. `GetSignalBelts` now explicitly checks null; this matches the former zero-capacity short circuit on disabled/reset state. `GetOrCreateSignalBelts` is reached during initialization after array allocation, or from `_initialized`-guarded callbacks. Constructor/removal callbacks can safely read the null array. Existing growth policy is unchanged. | +| Dyson-shell finalization simplification | The deleted layer argument was private and unread. All six calls preserve the existing `notify` and `resetRenderMasks` values; eliminating `FirstOrDefault(l => l != null)` removes only a side-effect-free selection. Native mutations and their order are unchanged. The two deleted local collections were constructed but never read. | +| Config-window parent fields | Both `_windowTrans` fields were assigned from the current `CreateUI` argument and used only during that same call. Direct `trans` use preserves object identity, tab order and geometry. No listener or deferred callback captured the removed fields. | +| `UpdateButtons` merge | `UpdateUI` remains the delegate subscribed to `MyConfigWindow.OnUpdateUI`. It now contains exactly its sole callee's former body, including all readiness guards. Native account/achievement state and button activation conditions are unchanged. | +| Galaxy-title fields | The four title references were used only during `_OnCreate` and now remain locals there. The instantiated controls remain owned by Unity's transform hierarchy. Names, localizer keys, parent objects, spacing constants and creation order are unchanged; slider/value fields needed later remain stored. | +| Galaxy listener removal | `_OnUnregEvent` calls the existing `RemoveAllListeners`, whose four statements exactly match the former body. `_OnCreate`/`_OnOpen` still remove, update, then add listeners in the same order. No extra subscription or event path was introduced. | + +Modifier mapping verified against the deleted body: + +| Shift | Ctrl | Alt | Result | +| --- | --- | --- | --- | +| false | false | false | Ignore | +| true | false | false | 1 level | +| false | true | false | 10 levels | +| true | true | false | 100 levels | +| false | false | true | `int.MaxValue` (all available levels) | +| true | false | true | Ignore | +| false | true | true | Ignore | +| true | true | true | Ignore | + +## Checks and limits + +- `git diff --check -- CheatEnabler UniverseGenTweaks`: passed. +- Existing managed production checks had already passed 569 checks in this reviewer's production partition, including belt-source conversion/preset behavior; full affected Release builds and original-DLL target checks are coordinated and recorded by the root audit. +- No C# signature used by injected IL, native game method body, public compatibility facade, configuration key/default or saved data layout was removed by this partition. +- No new abstraction, forwarding file, generic factory, persistent cache, dependency or test framework was added. + +Verdict: Ship. + +Not checked: manual Unity interaction and in-game execution; this review does not claim them from compilation or static inspection. diff --git a/docs/design-cleanup/review-root.md b/docs/design-cleanup/review-root.md new file mode 100644 index 0000000..99b6269 --- /dev/null +++ b/docs/design-cleanup/review-root.md @@ -0,0 +1,26 @@ +# Independent review of small-mod cleanup + +Reviewer: UXAssist audit worker, independent of the implementation author. +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140`. + +Reviewed the full diffs and connected callers/ownership for Dustbin/BeltSignal.cs, MechaDronesTweaks, HideTips, OverclockEverything and PoolOpt. + +## Finding corrected during review + +**Required imports removed with commented code.** OverclockEverything still has a live MechaForge_GameTick_Transpiler that uses `IEnumerable` and `OpCodes`. Removing System.Collections.Generic and System.Reflection.Emit would break the normal build. The implementer restored both imports in their original order. Read-back verified the correction. No unresolved finding remains in this review scope. + +## Behavior and boundary checks + +- **Dustbin:** All three generic resource-loading helpers were private and used only to load the one belt-signal icon. `Dustbin.assets.icon.signal-410.png` matches the existing assembly/root namespace and EmbeddedResource path. Signal ID, name, grid index, public IconPath, Texture2D construction, LoadImage bytes, Sprite rectangle/pivot and stream-read behavior remain the same. The loader stays in its owning BeltSignal class. No new helper file or dependency is introduced. +- **MechaDronesTweaks:** Removed FastDronesRemover was an internal type with a single Run caller in the plugin constructor. The same plugin GUID, exact version gate (`0.0.5`), external class/Start target, Harmony instance, prefix return value, catch and log behavior remain in that constructor. `AccessTools.Method` resolves the new private prefix explicitly. The soft-dependency attribute keeps the same constant value. The moved helper is not an exported public type. Duplicate EnergyMultiplier binding had an identical key, value, description and range; one real binding is retained, with every other option/default unchanged. +- **HideTips:** Removed HideMenuDemo code/configuration was wholly commented. `_patch` had no live assignment, so its OnDestroy cleanup could only observe null. Existing live Harmony setup and all presentation guards/defaults remain. No progression/statistics/event setter is bypassed by the cleanup. +- **OverclockEverything:** Removed GalacticScale collision/transpiler experiments were comments. Export/Import save order, SaveVersion, ConfigEntry bindings/defaults and live Harmony patches remain unchanged. Required live transpiler imports are now retained. +- **PoolOpt:** Both old algorithms used the same reset, tail search, cursor update, recycle sort/search and shrink flow. The new occupied predicate is exactly `id == index` for ordinary pools (including the previous null-to-zero handling) and `item != 0` for trash, complementing its old `item == 0` empty predicate. Index zero remains excluded by the loop. Every caller keeps its existing initial-capacity callback and capacity mutation. The removed ref capacity parameter was never read or written by either algorithm. `Action` replaces a private parameterless void delegate without changing callback timing. No public type/config/save format/native patch target changes. + +PoolOpt has one intentional diagnostic normalization: the existing DEBUG reset message now also appears when an all-empty trash pool takes the tail-search reset branch. Pool, cursor, recycle, capacity and return-value behavior is unchanged. This does not justify adding a logging-mode parameter or retaining a duplicate state algorithm; the implementation report records it explicitly. + +## Completeness and validation + +No stale FastDronesRemover/GetId/IsEmpty/SetToInitialCapacity reference or abandoned private loader chain remains in these scopes. The refactors reduce actual wrappers and duplicate implementations without replacing them with new files or speculative abstractions. + +`git diff --check` passed for all five reviewed module groups. The implementer ran the exhaustive 16,382-case old/new PoolOpt state comparison; this reviewer additionally checked predicate mapping and every category of capacity callback in source. Parent executor owns normal Release builds and final validation logs. No in-game or third-party runtime integration was executed by this reviewer. diff --git a/docs/design-cleanup/review-uxassist.md b/docs/design-cleanup/review-uxassist.md new file mode 100644 index 0000000..3f31fea --- /dev/null +++ b/docs/design-cleanup/review-uxassist.md @@ -0,0 +1,26 @@ +# Independent UXAssist change review + +What this change does: removes inactive scaffolding, unused internal members, duplicate array copies/sorts and repeated UI formatting. It keeps the existing feature, calculation and native patch contracts. Expected load is one running DSP process, including frame/tick-sensitive paths and occasional snapshot/description creation. + +Reviewer: the CheatEnabler/UniverseGenTweaks audit worker, independent of both UXAssist implementation workers. Reviewed the complete UXAssist diff against baseline `64a23e9772e7878f216cc2e281da2bc3f87d3140`, then connected source and callers. No source was changed during this review. + +Looks good. Ship. + +## Evidence + +- **All 23 changed UXAssist files checked.** Common: `I18N`, `KnownItemId`, `WinApi`. Functions: three UI owners, `UIFunctions`, `WindowFunctions`. Patches: four removed bulk-enable facades, inactive build-tool/game/player experiments, logistics item projection and an unused UI size helper. UI: key binder, commented window hooks and shared charge-power formatting. Production: catalog capture and blueprint text. Entry point: commented autosave binding. +- **Deleted methods are not runtime entry points.** Repository searches include ordinary and quoted method names, static imports, feature discovery and Harmony attributes. Removed factory bulk-enable methods belong to internal outer types; actual config handlers and Start/Uninit still call each nested patch directly. Removed UI lifecycle methods have empty bodies and are called explicitly rather than discovered. Public `UIFunctions.Start` is retained. Active lifecycle order and patch ownership are unchanged. +- **Localization remains native.** Removed `I18N.Translate` is internal, has no `this` receiver, no caller/static import, and no quoted reflection lookup. It is unrelated to native string `.Translate()` calls. Apply/register/language-change hooks remain intact. +- **The key-binder branch is unreachable.** Baseline `_nextNotOn` is private, not `[SerializeField]`, and has no true assignment or quoted reflective reference. Its only assignment is false inside the branch. Removing that field/branch preserves the click handler's reachable assignment and all serialized UI control fields. +- **Public enum contract is stable.** Compared `KnownItemId` constants to `GameConstants.ItemIds`: 5001, 5002, 5003 and 1210 are unchanged, as are enum/member names and underlying `int` type. Existing logistics/player callers keep their values. +- **UI formatting is exactly reused.** All four mapper multipliers remain `long` arithmetic with their original constants. The shared private method retains the nine-space StringBuilder, WriteKMG width/flags, W suffix and Trim. Mapper ranges and creation geometry are unchanged. The overlay predicate directly tests each original storage item ID, retaining short-circuit and empty-array behavior. +- **Cargo snapshots still own their arrays.** Read the `ProductionCatalog` constructor: it clones each of speed, extra and power arrays into private arrays after copying model inputs. Capture remains synchronous on the game thread. Removing clones immediately before the constructor eliminates duplicate allocations while keeping the defensive-copy boundary and public constructor behavior. +- **Description order stays deterministic.** `ProductionReport` creates its own read-only ItemFlows dictionary from copied inputs. Sorting its values once by ItemId and retaining one per-call array produces the same missing/excess/input/output/research passes and `itemTag` call order. No persistent cache or solver ordering changed. +- **Removed patches were already comments.** The autosave experiment, stepped rotation experiment, two star/hive display experiments and three window snippets were fully commented at baseline. Deleting them removes no compiled Harmony method or active setting. The live IL matching/injection bodies are unchanged. +- **No replacement fragmentation.** No new C# file, runtime type, dependency, generic framework or broad utility container was introduced. The one shared formatting method stays private in its actual four-call owner. Existing compatibility facades, pure production adapters, miner geometry/solver/replay boundaries and distinct UI ownership were retained for concrete reasons in the audit reports. + +## Checks and limits + +Scoped `git diff --check -- UXAssist` passed during review. Existing production checks and normal game-linked Release builds are recorded by the root executor and production worker; this review does not invent additional runtime results. + +Not checked: in-game/Unity execution, third-party reflection into private/internal implementation details, or unrelated native target compatibility after a game update. No changed code needs a new native-method semantic interpretation; active Harmony targets and IL bodies were retained. diff --git a/docs/design-cleanup/ux-features.md b/docs/design-cleanup/ux-features.md new file mode 100644 index 0000000..9434651 --- /dev/null +++ b/docs/design-cleanup/ux-features.md @@ -0,0 +1,157 @@ +# UXAssist feature and shared-library audit + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140` (`origin/master`). + +## Coverage + +The owned inventory contains 82 C# files and `UXAssist.csproj`: Common (26), Functions (15), Patches (22), UI (13), ModsCompat (4), and root entry/configuration (2 C# plus the project). +Every file was included in the structural/member/reference audit. Candidate implementations and their connected lifecycle/configuration/UI/native-patch paths were read and traced. Localization registration/constant tables were treated as data, not a source of deletions based on text-reference counts. The seven large hot-path files have a separate supplementary audit in [ux-hot-paths.md](ux-hot-paths.md). Production and its check tool are covered separately in [production.md](production.md). + +Checks included single-owner files and small types; public compatibility documentation; regular and string/reflection references; feature discovery; enabled/disabled/session lifetime; cached state; duplicate transformations and implementations; and abandoned commented experiments. This is an overdesign audit, not an assertion that every game interaction has been executed. + +## Applied cleanup and evidence + +| Change | Evidence and behavior preserved | +| --- | --- | +| Remove 11 empty methods from the internal MenuButtonUI, MilkyWayUI and StarmapFilterUI classes, plus 11 forwarding calls from UIFunctions | Empty bodies perform no work. These types are in `UXAssist.Functions.UI`, lack ModFeature attributes, and are not independently reflection-discovered. Keep public `UIFunctions.Start()` and all remaining lifecycle calls in the same order. | +| Remove unused bulk Enable facades from ArchitectModePatch, BeltSignalPatch, BuildingBufferPatch and VeinProtectionPatch | Whole-tree source/string searches find no callers. Config handlers and startup already invoke each nested owning patch directly. Their internal outer classes are neither discovered through the entry-point's exact namespace search nor through an Enable lifecycle convention. No nested patch or target identity changes. | +| Remove `WindowFunctions.GetPriorityName`, `WinApi.ERROR_INSUFFICIENT_BUFFER`, `UIPatch.PlanetVeinUtilization.GetAdjustedSizeDelta`, and `BeltSignalsForBuyOut.RemoveBeltSignalProtos` | Private members have no source/string/attribute references. The signal proto removal helper is not invoked on disable; deleting it preserves the existing persistence behavior and stock order. The only LINQ use in BeltSignalPatch was inside this dead helper, so remove its unused import too. | +| Remove unused internal `I18N.Translate` | No calls, string lookups or Harmony attributes refer to it. It is not an extension method. Existing localization registration and all native `.Translate()` call sites remain unchanged. | +| Remove MyKeyBinder's never-true `_nextNotOn` and its unreachable branch | Private field has no SerializeField attribute and is only assigned false; it cannot enter the branch through any first-party caller or Unity serialized field. Public click/reset/none-key APIs remain intact. | +| Delete fully commented AutoSaveOpt experiment and its commented config/UI wiring | The class, field, activation and configuration were all comments at baseline. Keep public localization keys, current save behavior, current options, and data formats unchanged. | +| Delete three commented abandoned window methods | The SetRect/UIGame create/free snippets were block comments, not live Harmony patches. No hook is removed. | +| Reuse ItemIds constants from the public KnownItemId enum | Enum identity, names, underlying type and compiled values (5001, 5002, 5003, 1210) remain the same; four independent literal definitions are eliminated. | +| Collapse four identical charge-power text formatting bodies into private `UIConfigWindow.FormatPower` | Four real call sites share the same owning UI class. Each retains its range mapper, multiplier, nine-space StringBuilder, WriteKMG arguments, W suffix and Trim. No new source file, public abstraction, or cross-feature utility. | +| Replace `storageArray.Select(x => x.itemId).All(x => x == 0)` with `storageArray.All(storage => storage.itemId == 0)` | Same empty-array result, short-circuit order, and itemId comparison; avoids an unnecessary projection iterator in the periodic overlay update. | + +No version, config key/default, user data format, public type/member identity, live Harmony target or IL pattern is changed by this section. No new C# file or type was introduced. + +## Boundaries deliberately retained + +| Candidate | Concrete reason to retain | +| --- | --- | +| Common/Config providers, Common.Util, PathUtil, KnownItemId, GameEvent, ReflectionUtil, ResourceUtil, LayoutHelper, ConfigTabGroup, UI window/control wrappers | Public contracts are explicitly recorded in `docs/PublicApiSurface.md`. Removing a public forwarding API because only this repository has one caller would break dependent mods. Config providers retain one actual ConfigEntry owner. Helpers own distinct operations or shared UI primitives, rather than duplicating state. | +| GameEvent vs GameLogic | Safe invocation is a documented shared event helper API. GameLogic raises three events, and each handler must remain isolated from exceptions. Moving methods to GameLogic would still need the compatibility facade. | +| PlayerInputUtil | Both auto-construct and auto-cruise consume the same six-axis override rule. It prevents behavioral drift between two automation features. | +| ModFeatureRegistry, ModFeatureAttribute and IModFeature | Discovery crosses UXAssist, CheatEnabler and UniverseGenTweaks. Cached delegates avoid per-frame reflection; frame and started guards protect real lifecycle boundaries. Instance support is a public extension contract, even if current first-party features are static. | +| PatchImpl and TranspilerGuard | Real consumers across multiple mods. Rollback/fail-soft behavior and mismatch diagnostics cannot be flattened into callers without duplication and exception-chain changes. | +| ModCompatHelper and four ModsCompat files | Shared external plugin/type/member lookup plus independent plugin-specific compatibility rules. Existing public spelling/identity and optional-dependency boundaries remain. | +| AutoConstructUI and AutoCruiseUI | Each owns actual controls, state synchronization and label sizing for a distinct feature. They are not isolated one-line calculation helpers. Periodic reconciliation remains because callbacks can be missed. | +| MenuButtonUI, MilkyWayUI and StarmapFilterUI | Substantial feature-specific UI/state, not trivial extracted helpers. Public UIFunctions forwarding entry points are retained for compatibility. Only proven no-op internals were removed. | +| MyCheckBox/MyCheckButton, MyComboBox/MyCornerComboBox, MySlider/MySideSlider | Different native clone sources, layouts, visuals and event behavior. Introducing a generic component base would add an abstraction and risk inherited Unity behavior merely to reduce text similarity. | +| Value/range/array mapper types and feature mapper subclasses | Multiple real slider callers need discrete choices, ranges, inverses and localized formatting. Reuse their shared formatting operation locally; keep explicit range/semantic types. | +| Real-time logistics cached component arrays, stock state, pixel scales and recycling pool | Reused every frame to avoid repeated hierarchy lookup, allocations, text updates and orphan UI objects. Invalidate/recycle at actual transport replacement boundaries. These are performance caches with specific ownership, not duplicate authoritative game state. | +| Blueprint description, miner geometry/solver/debug and automation recovery | Blueprint behavior belongs to the separate in-flight UI task; the baseline popup helper example is absent here. Miner geometry/solver have independent pure test/replay boundaries, and hot-path caches/recovery have bounded work contracts. See supplementary audit. | +| VeinProtectionPatch/VeinProtectionUIPatch partial split | Simulation replacement and UI/statistics presentation contain substantial different native integration logic. Shared nested identity ensures Harmony activation includes both. Not a tiny single-use helper file. | +| Per-target PlayerOrder transpilers in PersistPatch | Identical matcher bodies were considered, but constructor vs normal-method Harmony descriptors carry different method-kind semantics. Keep their separate descriptors rather than assume multiple attributes form an independent target list. No experimental merge remains. | +| Config/session/enable reset paths | Some resets look similar, but native lifecycle and callback order matter. Keep separate real boundaries unless event-order equivalence is established; do not infer redundancy from matching assignments alone. | + +## Validation + +- Whole-tree source/string and public API checks were performed before deleting internal/private members. +- `git diff --check -- UXAssist` passed after edits. +- Parent executor owns the normal UXAssist/CheatEnabler/UniverseGenTweaks Release builds and final regression checks, avoiding concurrent UpdateGameDlls writes. +- No in-game rendering, mouse interaction, game-session event execution or third-party compatibility runtime was exercised by this audit worker. The patch/IL bodies themselves remain unchanged. + +## Inventory + +### Common + +- `UXAssist/Common/Config/FactoryConfigProvider.cs` +- `UXAssist/Common/Config/LogisticsConfigProvider.cs` +- `UXAssist/Common/GameConstants/DysonSphereConstants.cs` +- `UXAssist/Common/GameConstants/ItemIds.cs` +- `UXAssist/Common/GameConstants/LogisticsConstants.cs` +- `UXAssist/Common/GameConstants/TechIds.cs` +- `UXAssist/Common/GameConstants/UniverseGenConstants.cs` +- `UXAssist/Common/GameEvent.cs` +- `UXAssist/Common/GameLogic.cs` +- `UXAssist/Common/I18N.cs` +- `UXAssist/Common/I18NKeys.cs` +- `UXAssist/Common/KeyBindings.cs` +- `UXAssist/Common/KnownItemId.cs` +- `UXAssist/Common/ModCompat/ModCompatHelper.cs` +- `UXAssist/Common/ModFeatures/IModFeature.cs` +- `UXAssist/Common/ModFeatures/ModFeatureAttribute.cs` +- `UXAssist/Common/ModFeatures/ModFeatureRegistry.cs` +- `UXAssist/Common/PatchImpl.cs` +- `UXAssist/Common/Patching/TranspilerGuard.cs` +- `UXAssist/Common/Util.cs` +- `UXAssist/Common/Utils/DysonSphereReflection.cs` +- `UXAssist/Common/Utils/PathUtil.cs` +- `UXAssist/Common/Utils/PlayerInputUtil.cs` +- `UXAssist/Common/Utils/ReflectionUtil.cs` +- `UXAssist/Common/Utils/ResourceUtil.cs` +- `UXAssist/Common/WinApi.cs` + +### Functions + +- `UXAssist/Functions/DysonSphereFunctions.cs` +- `UXAssist/Functions/Factory/MinerPlacementDebug.cs` +- `UXAssist/Functions/Factory/MinerPlacementGeometry.cs` +- `UXAssist/Functions/Factory/MinerPlacementSolver.cs` +- `UXAssist/Functions/Factory/QuickMinerBuild.cs` +- `UXAssist/Functions/FactoryFunctions.cs` +- `UXAssist/Functions/PlanetFunctions.cs` +- `UXAssist/Functions/TechFunctions.cs` +- `UXAssist/Functions/UI/AutoConstructUI.cs` +- `UXAssist/Functions/UI/AutoCruiseUI.cs` +- `UXAssist/Functions/UI/MenuButtonUI.cs` +- `UXAssist/Functions/UI/MilkyWayUI.cs` +- `UXAssist/Functions/UI/StarmapFilterUI.cs` +- `UXAssist/Functions/UIFunctions.cs` +- `UXAssist/Functions/WindowFunctions.cs` + +### Patches + +- `UXAssist/Patches/BlueprintDescriptionPatch.cs` +- `UXAssist/Patches/DysonSpherePatch.cs` +- `UXAssist/Patches/Factory/ArchitectModePatch.cs` +- `UXAssist/Patches/Factory/BeltSignalPatch.cs` +- `UXAssist/Patches/Factory/BuildToolPatch.cs` +- `UXAssist/Patches/Factory/BuildingBufferPatch.cs` +- `UXAssist/Patches/Factory/FactoryBuildPatches.cs` +- `UXAssist/Patches/Factory/FactoryPatch.cs` +- `UXAssist/Patches/Factory/RenderingPatch.cs` +- `UXAssist/Patches/Factory/VeinProtectionPatch.cs` +- `UXAssist/Patches/Factory/VeinProtectionUIPatch.cs` +- `UXAssist/Patches/GamePatch.cs` +- `UXAssist/Patches/Logistics/AutoConfigPatch.cs` +- `UXAssist/Patches/Logistics/CapacityPatch.cs` +- `UXAssist/Patches/Logistics/LogisticsPatch.cs` +- `UXAssist/Patches/Logistics/OverflowPatch.cs` +- `UXAssist/Patches/Logistics/RealtimeInfoPanelPatch.cs` +- `UXAssist/Patches/PersistPatch.cs` +- `UXAssist/Patches/PlanetPatch.cs` +- `UXAssist/Patches/PlayerPatch.cs` +- `UXAssist/Patches/TechPatch.cs` +- `UXAssist/Patches/UIPatch.cs` + +### UI + +- `UXAssist/UI/ConfigTabGroup.cs` +- `UXAssist/UI/LayoutHelper.cs` +- `UXAssist/UI/MyCheckButton.cs` +- `UXAssist/UI/MyCheckbox.cs` +- `UXAssist/UI/MyComboBox.cs` +- `UXAssist/UI/MyConfigWindow.cs` +- `UXAssist/UI/MyCornerComboBox.cs` +- `UXAssist/UI/MyFlatButton.cs` +- `UXAssist/UI/MyKeyBinder.cs` +- `UXAssist/UI/MySideSlider.cs` +- `UXAssist/UI/MySlider.cs` +- `UXAssist/UI/MyWindow.cs` +- `UXAssist/UI/Util.cs` + +### ModsCompat + +- `UXAssist/ModsCompat/AuxilaryfunctionWrapper.cs` +- `UXAssist/ModsCompat/BulletTimeWrapper.cs` +- `UXAssist/ModsCompat/CommonAPIWrapper.cs` +- `UXAssist/ModsCompat/PlanetVeinUtilization.cs` + +### root + +- `UXAssist/UIConfigWindow.cs` +- `UXAssist/UXAssist.cs` +- `UXAssist/UXAssist.csproj` diff --git a/docs/design-cleanup/ux-hot-paths.md b/docs/design-cleanup/ux-hot-paths.md new file mode 100644 index 0000000..0fe558f --- /dev/null +++ b/docs/design-cleanup/ux-hot-paths.md @@ -0,0 +1,47 @@ +# UXAssist construction and movement audit + +Baseline: `64a23e9772e7878f216cc2e281da2bc3f87d3140` (`origin/master`, 2026-11-04). + +## Coverage + +Supplemental structural review of all seven requested hot-path files (5,861 lines at baseline): + +| File | Baseline lines | Reviewed responsibilities | +| --- | ---: | --- | +| `Patches/Factory/BuildToolPatch.cs` | 942 | Always-on patch owner, off-grid geometry/text, stacking, drag-build poles, tank transfer, whole-belt transfer | +| `Patches/Factory/FactoryBuildPatches.cs` | 1,786 | Auto-construct planner, material eligibility cache, bounded candidate scans, construction order ownership, flight settling, recovery detours, lab stack operations | +| `Patches/PlayerPatch.cs` | 1,235 | Feature activation, starmap names, native presentation patches, auto-cruise target resolution, navigation lifecycle, local/sailing movement, obstacle avoidance, warp and approach controls | +| `Functions/Factory/QuickMinerBuild.cs` | 1,084 | Job lifecycle, main-thread capture, candidate generation, coroutine/worker scheduling, current-state validation, native placement commit and rollback, diagnostics | +| `Functions/Factory/MinerPlacementSolver.cs` | 552 | Deterministic greedy starts, stable pose keys, coordinated repacking, seed collision reuse, incremental burial/coverage accounting, cancellation and bounded worker count | +| `Functions/Factory/MinerPlacementGeometry.cs` | 124 | Individual oriented colliders, bounding rejection, separating-axis tests and exact segment/box distance | +| `Functions/Factory/MinerPlacementDebug.cs` | 138 | Debug-only serializable replay records and shared capture/restore serializer | + +Traced references to the three miner modules throughout game sources and `tools/tests/QuickMinerPlacementTests.cs` / `Test-QuickMinerPlacement.ps1`, and feature activation in `FactoryPatch`, `PlayerPatch` and the auto-construct/auto-cruise UI owners. No new general-purpose abstraction was introduced. + +## Changes + +- Delete the entirely block-commented `PatchToPerformSteppedRotate` / `RotateStepped` experiment and its commented `SteppedRotationDegrees` declaration from `BuildToolPatch.cs` (58 lines). It has no compiled method, active Harmony attribute, config entry or caller. Git history already retains the discarded experiment. +- Delete the entirely block-commented `UIStarmapPlanet__OnLateUpdate_Transpiler` / `UIStarmapDFHive__OnLateUpdate_Transpiler` experiment from `PlayerPatch.cs` (104 lines). It references the stale `_showAllStarsNameStatus` spelling and has no compiled patch or runtime use. + +Both changes remove comment text only; they do not remove or modify a compiled method, Harmony target, IL matcher, navigation state, option, geometry rule or placement algorithm. The original UTF-8 BOM on `PlayerPatch.cs` is preserved. + +## Candidates deliberately retained + +- **Miner geometry and solver files:** substantive, independent algorithm boundaries shared by in-game placement and the existing offline linked-source regression runner. The geometry class implements complete collision mathematics, and the solver coordinates searches over captured immutable candidate data; neither is a few-line one-use helper. +- **`MinerPlacementDebug.cs`:** the runtime Debug path and offline replay checks share these records and serializer. Serialization field names and schema are actual persisted replay contracts. Release excludes this file through the project, avoiding a release dependency on diagnostic serialization. Folding records into the Unity/game-facing owner would destroy the current game-free replay boundary. +- **Candidate arrays and probe cache:** `QuickMinerBuild` reuses build boxes, nearby colliders and covered/reachable lists across candidate attempts, cloning only the captured arrays retained by a candidate. The probe avoids repeated spatial work across yaw angles. Removing this derived state would increase hot-path work or let later probes mutate prior candidates. +- **Solver collision caches and separate score counters:** verified-prefix arrays and seed blockers avoid repeated separating-axis tests. `RawScore`, burial counts, usage counts and actual score encode different quantities for pruning and reversible layout updates. Treating them as duplicate state would change either output or performance. +- **Coroutine and worker paths:** both are required: the worker count becomes zero on a single-core machine, while background workers operate only on captured geometry. Main-thread yield points bound frame work; cancellation ownership waits for worker completion before disposing resources. +- **Auto-construct fixed arrays and eligibility cache:** capacities explicitly bound planning work and allocations. Current-site, proposed-site, launched-target and refinement statistics are distinct decisions, and per-pass reset prevents inventory data leaking between plans. No replacement collection framework is warranted. +- **Arrival, settling, deferred-route and recovery state:** these describe different temporal stages. The actual native order is retained separately so disabling or changing planets clears only the planner-owned order. Recovery history, pending second waypoints and failed-route retries preserve progress and altitude. Simplifying them solely by field count would alter movement behavior. +- **Auto-cruise target snapshot and obstacle list:** resolution unifies planet/star/hive/carrier identity and changing world positions; the reusable list is cleared each calculation/session. It is not a cache of permanent world state. NavigationTarget and Obstacle records already live within the owning source file. +- **Private tiny movement/collision helpers:** local mathematical operations are reused or name a necessary calculation within the feature owner. They do not create cross-file abstractions. Parameter-rich calls pass value types without introducing request/config objects or hot-loop allocation. +- **Native replacement signatures:** `PlanetGridSnapDotsNonAllocNotAligned` / `PlanetAuxDataSnapDotsNonAllocNotAligned` retain apparently unused native `yaw`/`gap` arguments. The injected replacement call must consume the exact native operand stack; removing arguments for cosmetic simplicity would break IL stack behavior. +- **Harmony callbacks with no ordinary C# caller:** preserved. Attributes, emitted delegates and `AccessTools` member lookup are real uses. Patch group separation preserves configuration-controlled activation and does not introduce extra lifecycle ownership. +- **Similar preview/transfer loops:** different traversal, refund, target and native-stack contracts prevent mechanical deduplication. No new wrapper or factory was added to hide those distinctions. + +## Validation and limits + +- Scoped `git diff --check` passed after deleting the two inactive experiments. +- These edits change only comments. Runtime patch application/target checks and affected Release builds are coordinated by the root audit and recorded in its final validation report. +- This review does not claim native method-body equivalence from the publicized DLL or manual in-game execution. No algorithm improvement was attempted, so no replay inputs or expected placement output were changed. diff --git a/docs/design-cleanup/validation.md b/docs/design-cleanup/validation.md new file mode 100644 index 0000000..1e4903d --- /dev/null +++ b/docs/design-cleanup/validation.md @@ -0,0 +1,33 @@ +# Validation receipt + +Date: 2026-11-04. Baseline and final fetched `origin/master`: `64a23e9772e7878f216cc2e281da2bc3f87d3140`. + +## Builds and checks + +| Command/check | Result | +| --- | --- | +| `dotnet restore DSP_Mods.sln` | Passed using the existing dependency graph. | +| `dotnet build DSP_Mods.sln -c Release --no-restore` | Passed after final edits: 0 warnings, 0 errors; all 13 solution projects including UpdateGameDlls and DustbinPreloader. | +| `dotnet build LogisticMiner/LogisticMiner.csproj -c Release --no-restore` | Passed: 0 warnings, 0 errors; project is not listed in solution. | +| `dotnet run --project UXAssist/tools/ProductionCheck/ProductionCheck.csproj -c Release` | 569 checks passed; production worker also ran them before and after its edits. | +| PoolOpt before/after managed comparison | 16,382 cases passed: every occupancy mask through cursor 13 for ID-based and trash-sentinel pools; return value, cursor, recycle cursor/array and reset count match. Temporary project stays in excluded `PoolOpt/obj/design-cleanup-check`; source is copied to delivery artifacts. | +| `powershell.exe -NoProfile -File tools/tests/Test-QuickMinerPlacement.ps1` | 6,620 checks passed, including captured replay roundtrip and sequential/parallel output checks. Placement algorithms are unchanged. | +| ReflectionReaderCheck Release runner | 40 checks passed, final OK; runtime boundary and allowlist cases included. | +| WebSocketTransportCheck Release runner | Echo/fragmentation check passed, final OK. | +| WebSocketTransportCheck `--regression` | Production transport, dispatcher, bounds, session, refresh, shutdown and failure regressions passed, final OK. Expected timeout/occupied-port logs are deliberate cases. | +| `python LiveStreamAssist/js/scripts/pack_js.py` | Packed output matches existing tracked sources; no frontend content changes. | +| Documented five-suite `node --test` command | 43 passed, 7 failed. All seven failures are independently reproduced from exact baseline files; see below. | +| `python LiveStreamAssist/js/scripts/test_text.py` | Passed, including installed locale checks. | +| `powershell.exe -NoProfile -File tools/tests/Test-PublishMod.ps1` | 318 assertions passed with synthetic credentials; no real upload/remote lookup. | +| WebSocket acceptance-script focused check | Parser and three synthetic connection/null/disposal cases passed. Running DSP acceptance was not executed. | +| `git diff --check` | Passed after final source edits and again for staged delivery. | + +Existing warning policy is unchanged. Steam registry resolved `d:/steam`, `libraryfolders.vdf` listed the DSP library, and the original DLL exists at `D:/Steam/steamapps/common/Dyson Sphere Program/DSPGAME_Data/Managed/Assembly-CSharp.dll`. Normal UpdateGameDlls publicizing/content comparison reported both compile references current. Original game method-body analysis was unnecessary for final changes: no native method semantics, active IL injection pattern or patch target was changed. No reference DLL or decompilation was used as a substitute for an original method body. + +## Baseline dashboard failure + +`live-dashboard.html` calls the real `GameQuery.getClusterString`. The existing dashboard suite's FakeQuery lacks that method, so seven cases fail with unchanged placeholder values or `query.getClusterString is not a function`. The initialization-error case still passes. Copied exact `git show 64a23e9:` frontend/example files into excluded `LiveStreamAssist/obj/design-cleanup-baseline` and ran the same dashboard suite: the same seven named tests fail for the same reason. No frontend, generated-data or dashboard-test content is changed in this PR. This unrelated existing fixture defect is reported rather than mixed into design cleanup. + +## Limits + +No interactive DSP/Unity/OBS/LAN session, saved-game mutation, Thunderstore publication or native mod-compatibility acceptance was performed. The retired LabOpt pair was inventoried read-only and not built or revived. Publicized compile references were used for compilation only. Existing native patch correctness outside the unchanged contracts is not certified by this audit. No dependency advisories or external API changes are claimed as part of this behavior-preserving design audit.