LTS.Integrated_Implants-Forked/Source/PatchBootStrap.cs
MADxingjin 36977d9928 Moved Source out from assemblies folder to avoid dll dupe errors.
Confirmed CE compat on biotech mechanitor control range works.
now heads to next part.
2025-02-25 14:19:17 +08:00

60 lines
2.5 KiB
C#

using System.Reflection;
using HarmonyLib;
using RimWorld;
using Verse;
namespace LTS_Implants
{
[StaticConstructorOnStartup]
public static class HarmonyPatches
{
public static bool IsCombatExtended = false;
static HarmonyPatches()
{
Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap");
Harmony harmony = new Harmony("rimworld.LTS.implants");
Harmony.DEBUG = false;
//Check if we are in a CE enabled env
if(ModLister.GetModWithIdentifier("ceteam.combatextended")!=null)
IsCombatExtended = true;
if (ModLister.BiotechInstalled)
{
Verse.Log.Message("[LTS-II-Forked]Biotech found, harmony patch running");
if (IsCombatExtended)
{
Verse.Log.Message("[LTS-II-Forked]Unpatching CE patches to reduce overlap");
var mechanitorCanCommand = typeof(Pawn_MechanitorTracker).GetMethod("CanCommandTo");
harmony.Unpatch(mechanitorCanCommand,HarmonyPatchType.All,"CombatExtended.HarmonyCE");
var mechanitorDrawCommandRange = typeof(Pawn_MechanitorTracker).GetMethod("DrawCommandRadius");
harmony.Unpatch(mechanitorDrawCommandRange,HarmonyPatchType.All,"CombatExtended.HarmonyCE");
}
harmony.PatchCategory(Assembly.GetExecutingAssembly(), "Biotech");
}
harmony.PatchAllUncategorized(Assembly.GetExecutingAssembly());
#if DEBUG
foreach (var method in harmony.GetPatchedMethods())
{
Verse.Log.Message($"[LTSIIF]Patched Method {method.Name}");
var patchinfo = Harmony.GetPatchInfo(method);
foreach (var VARIABLE in patchinfo.Owners)
{
Verse.Log.Message("The Method has been patched by:" + VARIABLE);
}
foreach (var VARIABLE in patchinfo.Prefixes)
{
Verse.Log.Message("has Prefix:" + VARIABLE.PatchMethod);
}
foreach (var VARIABLE in patchinfo.Postfixes)
{
Verse.Log.Message("has Postfix:" + VARIABLE.PatchMethod);
}
foreach (var VARIABLE in patchinfo.Transpilers)
{
Verse.Log.Message("has Transpiler:" + VARIABLE.PatchMethod);
}
Verse.Log.Message("Displaying next method");
}
#endif
}
}
}