From 565de9995ab8264f2adc6f79743c661abbb7d579 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Thu, 9 Feb 2023 21:39:36 +0800 Subject: [PATCH] work in progress: MechaDronesTweaks --- DSP_Mods.sln | 6 +++++ MechaDronesTweaks/FastDronesRemover.cs | 25 ++++++++++++++++++++ MechaDronesTweaks/MechaDronesTweaks.cs | 26 +++++++++++++++++++++ MechaDronesTweaks/MechaDronesTweaks.csproj | 27 ++++++++++++++++++++++ MechaDronesTweaks/README.md | 8 +++++++ MechaDronesTweaks/package/manifest.json | 9 ++++++++ 6 files changed, 101 insertions(+) create mode 100644 MechaDronesTweaks/FastDronesRemover.cs create mode 100644 MechaDronesTweaks/MechaDronesTweaks.cs create mode 100644 MechaDronesTweaks/MechaDronesTweaks.csproj create mode 100644 MechaDronesTweaks/README.md create mode 100644 MechaDronesTweaks/package/manifest.json diff --git a/DSP_Mods.sln b/DSP_Mods.sln index 4435c63..34a987c 100644 --- a/DSP_Mods.sln +++ b/DSP_Mods.sln @@ -16,6 +16,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniverseGenTweaks", "Univer EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OverclockEverything", "OverclockEverything\OverclockEverything.csproj", "{0168941C-EEA6-49CF-9A67-E829FE06CF9B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MechaDronesTweaks", "MechaDronesTweaks\MechaDronesTweaks.csproj", "{15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -54,5 +56,9 @@ Global {0168941C-EEA6-49CF-9A67-E829FE06CF9B}.Debug|Any CPU.Build.0 = Debug|Any CPU {0168941C-EEA6-49CF-9A67-E829FE06CF9B}.Release|Any CPU.ActiveCfg = Release|Any CPU {0168941C-EEA6-49CF-9A67-E829FE06CF9B}.Release|Any CPU.Build.0 = Release|Any CPU + {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {15B8BC2E-93E0-4454-8F8F-BF1FA8DC90F4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/MechaDronesTweaks/FastDronesRemover.cs b/MechaDronesTweaks/FastDronesRemover.cs new file mode 100644 index 0000000..822bee7 --- /dev/null +++ b/MechaDronesTweaks/FastDronesRemover.cs @@ -0,0 +1,25 @@ +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 new file mode 100644 index 0000000..4d7e42d --- /dev/null +++ b/MechaDronesTweaks/MechaDronesTweaks.cs @@ -0,0 +1,26 @@ +using System; +using BepInEx; +using HarmonyLib; + +namespace MechaDronesTweaks; + +[BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] +[BepInDependency(FastDronesRemover.FastDronesGuid, BepInDependency.DependencyFlags.SoftDependency)] +public class MechaDronesTweaksPlugin : BaseUnityPlugin +{ + public MechaDronesTweaksPlugin() + { + var harmony = new Harmony(PluginInfo.PLUGIN_GUID); + /* Remove FastDrones MOD if loaded */ + try { + if (FastDronesRemover.Run(harmony)) + { + Logger.LogInfo("Unpatch FastDrones - OK"); + } + } + catch (Exception e) + { + Logger.LogWarning($"Failed to unpatch FastDrones: {e}"); + } + } +} diff --git a/MechaDronesTweaks/MechaDronesTweaks.csproj b/MechaDronesTweaks/MechaDronesTweaks.csproj new file mode 100644 index 0000000..24d045d --- /dev/null +++ b/MechaDronesTweaks/MechaDronesTweaks.csproj @@ -0,0 +1,27 @@ + + + + net472 + MechaDronesTweaks + org.soardev.mechadronestweaks + DSP MOD - MechaDronesTweaks + 1.0.0 + true + latest + + + + + + + + + + + + + + + + + diff --git a/MechaDronesTweaks/README.md b/MechaDronesTweaks/README.md new file mode 100644 index 0000000..47b4714 --- /dev/null +++ b/MechaDronesTweaks/README.md @@ -0,0 +1,8 @@ +# MechaDronesTweaks + +#### Some tweaks for mecha drones(Successor to FastDrones MOD) +#### 机甲建设机调整(FastDrones MOD的后继者) + +## Usage + +## 使用说明 diff --git a/MechaDronesTweaks/package/manifest.json b/MechaDronesTweaks/package/manifest.json new file mode 100644 index 0000000..372d88d --- /dev/null +++ b/MechaDronesTweaks/package/manifest.json @@ -0,0 +1,9 @@ +{ + "name": "MechaDronesTweaks", + "version_number": "1.0.0", + "website_url": "https://github.com/soarqin/DSP_Mods/tree/master/MechaDronesTweaks", + "description": "Some tweaks for mecha drones(Successor to FastDrones MOD) / 机甲建设机调整(FastDrones MOD的后继者)", + "dependencies": [ + "xiaoye97-BepInEx-5.4.17" + ] +}