mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2025-12-09 04:53:30 +08:00
50 lines
1.8 KiB
C#
50 lines
1.8 KiB
C#
using System;
|
|
using BepInEx.Bootstrap;
|
|
using BepInEx.Configuration;
|
|
using HarmonyLib;
|
|
using UXAssist.Patches;
|
|
|
|
namespace UXAssist.ModsCompat;
|
|
|
|
public static class AuxilaryfunctionWrapper
|
|
{
|
|
private const string AuxilaryfunctionGuid = "cn.blacksnipe.dsp.Auxilaryfunction";
|
|
public static ConfigEntry<bool> ShowStationInfo;
|
|
|
|
public static void Start(Harmony harmony)
|
|
{
|
|
if (!Chainloader.PluginInfos.TryGetValue(AuxilaryfunctionGuid, out var pluginInfo)) return;
|
|
var assembly = pluginInfo.Instance.GetType().Assembly;
|
|
try
|
|
{
|
|
var classType = assembly.GetType("Auxilaryfunction.Auxilaryfunction");
|
|
ShowStationInfo = (ConfigEntry<bool>)AccessTools.Field(classType, "ShowStationInfo").GetValue(pluginInfo.Instance);
|
|
}
|
|
catch
|
|
{
|
|
UXAssist.Logger.LogWarning("Failed to get ShowStationInfo from Auxilaryfunction");
|
|
}
|
|
try
|
|
{
|
|
var classType = assembly.GetType("Auxilaryfunction.Patch.SpeedUpPatch");
|
|
harmony.Patch(AccessTools.PropertySetter(classType, "Enable"),
|
|
new HarmonyMethod(AccessTools.Method(typeof(AuxilaryfunctionWrapper), nameof(PatchSpeedUpPatchEnable))));
|
|
}
|
|
catch
|
|
{
|
|
UXAssist.Logger.LogWarning("Failed to patch SpeedUpPatch.set_Enable() from Auxilaryfunction");
|
|
}
|
|
}
|
|
|
|
public static void PatchSpeedUpPatchEnable(bool value)
|
|
{
|
|
if (!value)
|
|
{
|
|
GamePatch.EnableGameUpsFactor = true;
|
|
return;
|
|
}
|
|
if (Math.Abs(GamePatch.GameUpsFactor.Value - 1.0) < 0.001) return;
|
|
GamePatch.EnableGameUpsFactor = false;
|
|
UXAssist.Logger.LogInfo("Game UPS changing is disabled when using Auxilaryfunction's speed up feature");
|
|
}
|
|
} |