using HarmonyLib; using PeterHan.PLib.Core; using PeterHan.PLib.Database; using PeterHan.PLib.Options; namespace PriorityUX { public class Mod : KMod.UserMod2 { // public static readonly Type[] ToolTypes = { // typeof(AttackTool), // typeof(CaptureTool), // typeof(ClearTool), // typeof(DeconstructTool), // typeof(DigTool), // typeof(EmptyPipeTool), // typeof(HarvestTool), // typeof(MopTool), // typeof(PrioritizeTool), // }; public override void OnLoad(Harmony harmony) { Debug.Log("UX Mod Load"); // Harmony.DEBUG = true; base.OnLoad(harmony); // Debug.Log("UX Mod PostLoad base"); PUtil.InitLibrary(); LocString.CreateLocStringKeys(typeof(Strings.PRIORITYUX)); new PLocalization().Register(); new POptions().RegisterOptions(this, typeof(Options)); // MethodInfo patchMethod = typeof(GenericToolPatches).GetMethod(nameof(GenericToolPatches.OnActivateTranspiler)); // foreach (var toolType in ToolTypes) { // MethodInfo method = toolType.GetMethod("OnActivateTool", BindingFlags.NonPublic); // harmony.Patch(method, postfix: new HarmonyMethod(patchMethod)); // } } } // static class DefaultPriorityFixes { // [HarmonyPatch(typeof(Capturable), nameof(Capturable.MarkForCapture))] // [HarmonyPrefix] // static bool Capturable_MarkForCapture(Capturable __instance, bool mark) { // Debug.Log("[PriorityUX] >> Capturable_MarkForCapture"); // PrioritySetting priority = new PrioritySetting(PriorityScreen.PriorityClass.basic, 5); // __instance.MarkForCapture(mark, priority); // return true; // } // static readonly FieldInfo masterPrioritySetting = typeof(Prioritizable).GetField("masterPrioritySetting", BindingFlags.NonPublic); // [HarmonyPatch(typeof(Prioritizable), "OnSpawn")] // [HarmonyPrefix] // static void OnSpawn(object __instance) { // if (Options.Instance.buildingsInheritPriority) { // Debug.Log("[PriorityUX] >> Set Prioritizable.OnSpawn"); // masterPrioritySetting.SetValue(__instance, Utils.getLastPriority()); // } // } // } }