refactor: phase 5 transpiler docs, mod-compat helpers, and build quality gates

This commit is contained in:
2026-06-23 23:03:13 +08:00
parent cca8b8594d
commit c2016909ff
43 changed files with 2327 additions and 135 deletions
+14 -13
View File
@@ -1,7 +1,7 @@
using System;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using UXAssist.Common.ModCompat;
using UXAssist.Patches;
namespace UXAssist.ModsCompat;
@@ -13,27 +13,28 @@ public static class AuxilaryfunctionWrapper
public static void Start(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return;
var assembly = pluginInfo.Instance.GetType().Assembly;
try
if (!ModCompatHelper.TryGetLoadedPluginInfo(AuxilaryfunctionGuid, out var pluginInfo)) return;
if (!ModCompatHelper.TryGetPluginType(pluginInfo, "Auxilaryfunction.Auxilaryfunction", out var classType))
{
var classType = assembly.GetType("Auxilaryfunction.Auxilaryfunction");
ShowStationInfo = (ConfigEntry<bool>)AccessTools.Field(classType, "ShowStationInfo").GetValue(pluginInfo.Instance);
UXAssist.Logger.LogWarning("Failed to locate Auxilaryfunction main type");
return;
}
catch
if (!ModCompatHelper.TryGetFieldValue<ConfigEntry<bool>>(classType, "ShowStationInfo", pluginInfo.Instance, out ShowStationInfo))
{
UXAssist.Logger.LogWarning("Failed to get ShowStationInfo from Auxilaryfunction");
}
try
if (!ModCompatHelper.TryGetPluginType(pluginInfo, "Auxilaryfunction.Patch.SpeedUpPatch", out var speedUpPatchType))
{
var classType = assembly.GetType("Auxilaryfunction.Patch.SpeedUpPatch");
harmony.Patch(AccessTools.PropertySetter(classType, "Enable"),
new HarmonyMethod(AccessTools.Method(typeof(AuxilaryfunctionWrapper), nameof(PatchSpeedUpPatchEnable))));
UXAssist.Logger.LogWarning("Failed to locate Auxilaryfunction SpeedUpPatch");
return;
}
catch
if (!ModCompatHelper.TryGetPropertySetter(speedUpPatchType, "Enable", out var setter))
{
UXAssist.Logger.LogWarning("Failed to patch SpeedUpPatch.set_Enable() from Auxilaryfunction");
UXAssist.Logger.LogWarning("Failed to resolve SpeedUpPatch.set_Enable() from Auxilaryfunction");
return;
}
harmony.Patch(setter,
new HarmonyMethod(AccessTools.Method(typeof(AuxilaryfunctionWrapper), nameof(PatchSpeedUpPatchEnable))));
}
public static void PatchSpeedUpPatchEnable(bool value)
+7 -7
View File
@@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using UnityEngine;
using UXAssist.Common.ModCompat;
using UXAssist.Functions;
namespace UXAssist.ModsCompat;
@@ -17,13 +18,12 @@ class BlueprintTweaks
public static bool Run(Harmony harmony)
{
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(BlueprintTweaksGuid, out var pluginInfo)) return false;
var assembly = pluginInfo.Instance.GetType().Assembly;
var classTypeDragRemoveBuildTool = assembly.GetType("BlueprintTweaks.DragRemoveBuildTool");
if (classTypeDragRemoveBuildTool == null) return false;
if (AccessTools.Method(classTypeDragRemoveBuildTool, "DetermineMorePreviews") != null) return true;
classTypeBlueprintTweaksPlugin = assembly.GetType("BlueprintTweaks.BlueprintTweaksPlugin");
classTypeUIBuildingGridPatch2 = assembly.GetType("BlueprintTweaks.UIBuildingGridPatch2");
if (!ModCompatHelper.TryGetLoadedPluginInfo(BlueprintTweaksGuid, out var pluginInfo)) return false;
if (!ModCompatHelper.TryGetPluginType(pluginInfo, "BlueprintTweaks.DragRemoveBuildTool", out var classTypeDragRemoveBuildTool)) return false;
if (ModCompatHelper.TryGetMethod(classTypeDragRemoveBuildTool, "DetermineMorePreviews", out _)) return true;
ModCompatHelper.TryGetPluginType(pluginInfo, "BlueprintTweaks.BlueprintTweaksPlugin", out classTypeBlueprintTweaksPlugin);
ModCompatHelper.TryGetPluginType(pluginInfo, "BlueprintTweaks.UIBuildingGridPatch2", out classTypeUIBuildingGridPatch2);
if (classTypeBlueprintTweaksPlugin == null || classTypeUIBuildingGridPatch2 == null) return false;
var UIBuildingGrid_Update = AccessTools.Method(typeof(UIBuildingGrid), nameof(UIBuildingGrid.Update));
harmony.Patch(AccessTools.Method(classTypeUIBuildingGridPatch2, "UpdateGrid"), null, null, new HarmonyMethod(AccessTools.Method(typeof(BlueprintTweaks), nameof(PatchUpdateGrid))));
selectObjIdsField = AccessTools.Field(classTypeDragRemoveBuildTool, "selectObjIds");
+3 -3
View File
@@ -1,5 +1,5 @@
using BepInEx.Bootstrap;
using HarmonyLib;
using HarmonyLib;
using UXAssist.Common.ModCompat;
namespace UXAssist.ModsCompat;
@@ -10,6 +10,6 @@ public static class BulletTimeWrapper
public static void Start(Harmony _)
{
HasBulletTime = Chainloader.PluginInfos.TryGetValue(BulletTimeGuid, out var _);
HasBulletTime = ModCompatHelper.TryGetLoadedPluginInfo(BulletTimeGuid, out var _);
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
using BepInEx.Bootstrap;
using CommonAPI;
using HarmonyLib;
using UXAssist.Common.ModCompat;
namespace UXAssist.ModsCompat;
@@ -8,7 +8,7 @@ public static class CommonAPIWrapper
{
public static void Run(Harmony harmony)
{
if (!Chainloader.PluginInfos.TryGetValue(CommonAPIPlugin.GUID, out var commonAPIPlugin) ||
if (!ModCompatHelper.TryGetLoadedPluginInfo(CommonAPIPlugin.GUID, out var commonAPIPlugin) ||
commonAPIPlugin.Metadata.Version > new System.Version(1, 6, 7, 0)) return;
harmony.Patch(AccessTools.Method(typeof(GameOption), nameof(GameOption.InitKeys)), new HarmonyMethod(AccessTools.Method(typeof(CommonAPIWrapper), nameof(PatchInitKeys)), Priority.First));
}
+3 -3
View File
@@ -1,4 +1,5 @@
using HarmonyLib;
using UXAssist.Common.ModCompat;
namespace UXAssist.ModsCompat;
@@ -8,9 +9,8 @@ class PlanetVeinUtilization
public static bool Run(Harmony harmony)
{
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(PlanetVeinUtilizationGuid, out var pluginInfo)) return false;
var assembly = pluginInfo.Instance.GetType().Assembly;
var classType = assembly.GetType("PlanetVeinUtilization.PlanetVeinUtilization");
if (!ModCompatHelper.TryGetLoadedPluginInfo(PlanetVeinUtilizationGuid, out var pluginInfo)) return false;
if (!ModCompatHelper.TryGetPluginType(pluginInfo, "PlanetVeinUtilization.PlanetVeinUtilization", out var classType)) return false;
harmony.Patch(AccessTools.Method(classType, "Awake"),
new HarmonyMethod(typeof(PlanetVeinUtilization).GetMethod("PatchPlanetVeinUtilizationAwake")));
return true;