refactor: remove single-owner helpers and redundant plumbing

Return feature-only helpers to their owners, remove inactive scaffolding and duplicate state, and reuse existing calculation and UI work without changing public contracts or gameplay.

Record repository-wide coverage, justified retentions, independent reviews and validation, including baseline dashboard fixture failures.

Assisted-by: Cindy (https://cindy.app)
This commit is contained in:
soarqin committed 2026-11-04 23:06:50 +08:00
1 parent 64a23e9772
commit e35fba88ae
60 files changed
+1094 -994

No files matched your search

-15
View File
@@ -133,21 +133,6 @@ public static class I18N
ApplyIndexers();
}
/// <summary>
/// Returns the localized text for the given key in the currently active language,
/// falling back to the key itself when no entry is registered.
/// </summary>
/// <param name="key">The lookup key.</param>
/// <returns>The localized text, or <paramref name="key"/> if no entry exists.</returns>
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()
{
+4 -4
View File
@@ -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,
}
-6
View File
@@ -80,12 +80,6 @@ public static class WinApi
#endregion
#region Errors
private const int ERROR_INSUFFICIENT_BUFFER = 122;
#endregion
#region Structs
[StructLayout(LayoutKind.Sequential)]
-12
View File
@@ -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)
-12
View File
@@ -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)
-20
View File
@@ -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;
-11
View File
@@ -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()
-13
View File
@@ -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
@@ -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<UnlimitInteractive>
{
// Harmony transpiler: PlayerAction_Inspect_GetObjectSelectDistance_Transpiler
@@ -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;
@@ -79,8 +79,6 @@ internal static class BuildToolPatch
internal class OffGridBuilding : PatchImpl<OffGridBuilding>
{
// 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<CodeInstruction> PatchToPerformSteppedRotate(IEnumerable<CodeInstruction> 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<TreatStackingAsSingle>
@@ -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<TweakBuildingBuffer>
{
public static void RefreshAssemblerBufferMultipliers()
@@ -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();
-143
View File
@@ -19,7 +19,6 @@ public class GamePatch : PatchImpl<GamePatch>
public static ConfigEntry<bool> EnableWindowResizeEnabled;
public static ConfigEntry<bool> LoadLastWindowRectEnabled;
// public static ConfigEntry<bool> AutoSaveOptEnabled;
public static ConfigEntry<bool> ConvertSavesFromPeaceEnabled;
public static ConfigEntry<Vector4> LastWindowRect;
public static ConfigEntry<bool> ProfileBasedSaveFolderEnabled;
@@ -81,7 +80,6 @@ public class GamePatch : PatchImpl<GamePatch>
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<GamePatch>
}
}
EnableWindowResize.Enable(EnableWindowResizeEnabled.Value);
// AutoSaveOpt.Enable(AutoSaveOptEnabled.Value);
ConvertSavesFromPeace.Enable(ConvertSavesFromPeaceEnabled.Value);
Enable(true);
@@ -123,7 +120,6 @@ public class GamePatch : PatchImpl<GamePatch>
{
Enable(false);
EnableWindowResize.Enable(false);
// AutoSaveOpt.Enable(false);
ConvertSavesFromPeace.Enable(false);
}
@@ -311,145 +307,6 @@ public class GamePatch : PatchImpl<GamePatch>
}
}
/*
private class AutoSaveOpt: PatchImpl<AutoSaveOpt>
{
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<UIGameSaveEntry>();
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<CodeInstruction> UILoadGameWindow_ReplaceSaveName_Transpiler(IEnumerable<CodeInstruction> 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<CodeInstruction> GameSave_RemoveValidateOnLoad_Transpiler(IEnumerable<CodeInstruction> 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<ConvertSavesFromPeace>
{
private static bool _needConvert;
@@ -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;
-104
View File
@@ -204,110 +204,6 @@ public class PlayerPatch : PatchImpl<PlayerPatch>
{
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<CodeInstruction> UIStarmapPlanet__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> 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<CodeInstruction> UIStarmapDFHive__OnLateUpdate_Transpiler(IEnumerable<CodeInstruction> 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();
}
*/
}
-5
View File
@@ -106,11 +106,6 @@ public class UIPatch : PatchImpl<UIPatch>
}
}
private static Vector2 GetAdjustedSizeDelta(Vector2 origSizeDelta)
{
return new Vector2(origSizeDelta.x + 40f, origSizeDelta.y);
}
protected override void OnDisable()
{
if (planetVeinCount != null)
@@ -88,7 +88,8 @@ public static class BlueprintDescriptionFormatter
var input = new List<string>();
var output = new SortedDictionary<int, double>();
var research = new SortedDictionary<int, double>();
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)
@@ -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<ItemProto> itemProtos,
-7
View File
@@ -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)
-28
View File
@@ -559,15 +559,6 @@ public abstract class MyWindowManager
win._Destroy();
}
/*
public static void SetRect(ManualBehaviour win, RectTransform rect)
{
var rectTransform = win.GetComponent<RectTransform>();
//rectTransform.position =
//rectTransform.sizeDelta = rect;
}
*/
public class Patch : PatchImpl<Patch>
{
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()
{
+12 -36
View File
@@ -96,37 +96,19 @@ public static class UIConfigWindow
private class AutoConfigDispenserChargePowerMapper() : MyWindow.RangeValueMapper<int>(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<int>(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<int>(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<int>(0, 10)
@@ -147,13 +129,7 @@ public static class UIConfigWindow
private class AutoConfigILSChargePowerMapper() : MyWindow.RangeValueMapper<int>(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<int>(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;
-4
View File
@@ -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,