Fix mod for new game version

This commit is contained in:
Guus Waals 2024-01-06 11:59:17 +01:00
parent 347a838704
commit 54b75a869d
3 changed files with 72 additions and 52 deletions

View File

@ -1,14 +1,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Reflection.Emit; using System.Reflection.Emit;
using System;
using HarmonyLib; using HarmonyLib;
using KMod; using KMod;
namespace PriorityUX { namespace PriorityUX
{
[HarmonyDebug] [HarmonyDebug]
[HarmonyPatch(typeof(Deconstructable))] [HarmonyPatch(typeof(Deconstructable))]
public class DeconstructablePatches { public class DeconstructablePatches
public static PrioritySetting getChorePriority() { {
public static PrioritySetting getChorePriority()
{
Debug.Log("Getting deconstruct chore priority"); Debug.Log("Getting deconstruct chore priority");
if (Options.Instance.deconstructInheritPriority) if (Options.Instance.deconstructInheritPriority)
return Utils.getLastPriority(); return Utils.getLastPriority();
@ -16,15 +20,19 @@ namespace PriorityUX {
return Utils.getDefaultPriority(); return Utils.getDefaultPriority();
} }
[HarmonyPatch(new Type[] { typeof(bool) })]
[HarmonyPatch("QueueDeconstruction")] [HarmonyPatch("QueueDeconstruction")]
[HarmonyPostfix] [HarmonyPostfix]
static void QueueDeconstruction_Postfix(Deconstructable __instance) { static void QueueDeconstruction_Postfix(Deconstructable __instance)
{
Prioritizable prioritizable = __instance.GetComponent<Prioritizable>(); Prioritizable prioritizable = __instance.GetComponent<Prioritizable>();
if (prioritizable != null) { if (prioritizable != null)
{
Debug.Log("Updating deconstruct priority"); Debug.Log("Updating deconstruct priority");
prioritizable.SetMasterPriority(getChorePriority()); prioritizable.SetMasterPriority(getChorePriority());
} }
} }
/* /*
[HarmonyPatch("QueueDeconstruction")] [HarmonyPatch("QueueDeconstruction")]
[HarmonyTranspiler] [HarmonyTranspiler]

View File

@ -12,10 +12,20 @@ namespace PriorityUX {
public static LocString TOOLTIP = "Used for reset and as a default priority"; public static LocString TOOLTIP = "Used for reset and as a default priority";
public static LocString CATEGORY = "Tweaks"; public static LocString CATEGORY = "Tweaks";
} }
public static class ENABLEPRIORITYHOTKEYSEVERYWHERE { public static class ENABLEKEYSFORBUILDING {
public static LocString NAME = "Enable priority keys everywhere"; public static LocString NAME = "Enable priority keys in the build menu";
public static LocString TOOLTIP = "Allows the 1-9 keys to select priority for all tools. Close the tool to open the building menus."; public static LocString TOOLTIP = "Allows the 1-9 keys to select priority in the building menu. Close the tool to open the building menus.";
public static LocString CATEGORY = "Tweaks"; public static LocString CATEGORY = "Toggles";
}
public static class DECONSTRUCTINHERITPRIORITY {
public static LocString NAME = "Use last priority for deconstruction";
public static LocString TOOLTIP = "Use the last priority for deconstruction. If disabled, the default priority will be used every time the menu is opened.";
public static LocString CATEGORY = "Toggles";
}
public static class ENABLEKEYSFORALLTOOLS {
public static LocString NAME = "Enable priority keys for all tools";
public static LocString TOOLTIP = "Will enable the 1-9 keys for all tools.";
public static LocString CATEGORY = "Toggles";
} }
} }
} }

View File

@ -6,10 +6,12 @@ ROOT=$( cd "$(dirname "$0")" ; pwd -P )
pushd $ROOT pushd $ROOT
# Do the build (need to use mono) # Do the build (need to use mono)
$msbuild # $msbuild
$msbuild -p:Configuration=Release
set -x set -x
rm -rf dist rm -rf dist
mkdir dist mkdir dist
cp bin/Debug/net48/oni-prio.dll dist/ # cp bin/Debug/net48/oni-prio.dll dist/
cp bin/Release/net48/oni-prio.dll dist/
cp -r meta/* dist/ cp -r meta/* dist/