diff --git a/Dustbin/BeltSignal.cs b/Dustbin/BeltSignal.cs index d0063c7..2a02901 100644 --- a/Dustbin/BeltSignal.cs +++ b/Dustbin/BeltSignal.cs @@ -60,7 +60,7 @@ public static class BeltSignal } [HarmonyPostfix, HarmonyPriority(Priority.Last)] - [HarmonyPatch(typeof(VFPreload), "InvokeOnLoadWorkEnded")] + [HarmonyPatch(typeof(VFPreload), nameof(VFPreload.InvokeOnLoadWorkEnded))] private static void VFPreload_InvokeOnLoadWorkEnded_Postfix() { if (_initialized) return; @@ -198,7 +198,7 @@ public static class BeltSignal } [HarmonyTranspiler] - [HarmonyPatch(typeof(GameData), "GameTick")] + [HarmonyPatch(typeof(GameData), nameof(GameData.GameTick))] public static IEnumerable GameData_GameTick_Transpiler(IEnumerable instructions, ILGenerator generator) { var matcher = new CodeMatcher(instructions, generator); diff --git a/Dustbin/StoragePatch.cs b/Dustbin/StoragePatch.cs index ad5aa48..63e84b8 100644 --- a/Dustbin/StoragePatch.cs +++ b/Dustbin/StoragePatch.cs @@ -96,14 +96,14 @@ public static class StoragePatch } [HarmonyPrefix] - [HarmonyPatch(typeof(GameMain), "Start")] + [HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))] private static void GameMain_Start_Prefix() { Reset(); } [HarmonyPostfix] - [HarmonyPatch(typeof(UIStorageWindow), "_OnCreate")] + [HarmonyPatch(typeof(UIStorageWindow), nameof(UIStorageWindow._OnCreate))] private static void UIStorageWindow__OnCreate_Postfix(UIStorageWindow __instance) { _storageDustbinCheckBox = UI.MyCheckBox.CreateCheckBox(false, __instance.transform, 50f, 50f, Localization.CurrentLanguageLCID == Localization.LCID_ZHCN ? "垃圾桶" : "Dustbin"); @@ -123,7 +123,7 @@ public static class StoragePatch } [HarmonyPostfix] - [HarmonyPatch(typeof(UIStorageWindow), "_OnUpdate")] + [HarmonyPatch(typeof(UIStorageWindow), nameof(UIStorageWindow._OnUpdate))] private static void UIStorageWindow__OnUpdate_Postfix(UIStorageWindow __instance) { var storageId = __instance.storageId; @@ -141,7 +141,7 @@ public static class StoragePatch /* Adopt fix from starfi5h's NebulaCompatiblilityAssist */ [HarmonyPostfix] - [HarmonyPatch(typeof(UIStorageGrid), "OnStorageSizeChanged")] + [HarmonyPatch(typeof(UIStorageGrid), nameof(UIStorageGrid.OnStorageSizeChanged))] private static void UIStorageGrid_OnStorageSizeChanged_Postfix() { // Due to storage window is empty when open in client, the size will change after receiving data from host @@ -149,8 +149,8 @@ public static class StoragePatch } [HarmonyTranspiler] - [HarmonyPatch(typeof(StorageComponent), "AddItem", new[] { typeof(int), typeof(int), typeof(int), typeof(int), typeof(bool) }, - new[] { ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal })] + [HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.AddItem), [typeof(int), typeof(int), typeof(int), typeof(int), typeof(bool)], + [ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Normal])] private static IEnumerable StorageComponent_AddItem_HarmonyTranspiler(IEnumerable instructions, ILGenerator generator) { var matcher = new CodeMatcher(instructions, generator); @@ -172,7 +172,7 @@ public static class StoragePatch /* We keep this to make MOD compatible with older version */ [HarmonyPostfix] - [HarmonyPatch(typeof(StorageComponent), "Import")] + [HarmonyPatch(typeof(StorageComponent), nameof(StorageComponent.Import))] private static void StorageComponent_Import_Postfix(StorageComponent __instance) { if (__instance.bans >= 0) diff --git a/Dustbin/TankPatch.cs b/Dustbin/TankPatch.cs index a31d676..94cf8ae 100644 --- a/Dustbin/TankPatch.cs +++ b/Dustbin/TankPatch.cs @@ -100,14 +100,14 @@ public static class TankPatch } [HarmonyPrefix] - [HarmonyPatch(typeof(GameMain), "Start")] + [HarmonyPatch(typeof(GameMain), nameof(GameMain.Start))] private static void GameMain_Start_Prefix() { Reset(); } [HarmonyPostfix] - [HarmonyPatch(typeof(UITankWindow), "_OnCreate")] + [HarmonyPatch(typeof(UITankWindow), nameof(UITankWindow._OnCreate))] private static void UITankWindow__OnCreate_Postfix(UITankWindow __instance) { _tankDustbinCheckBox = UI.MyCheckBox.CreateCheckBox(false, __instance.transform, 120f, 20f, Localization.CurrentLanguageLCID == Localization.LCID_ZHCN ? "垃圾桶" : "Dustbin"); @@ -127,7 +127,7 @@ public static class TankPatch } [HarmonyPostfix] - [HarmonyPatch(typeof(UITankWindow), "_OnUpdate")] + [HarmonyPatch(typeof(UITankWindow), nameof(UITankWindow._OnUpdate))] private static void UITankWindow__OnUpdate_Postfix(UITankWindow __instance) { var tankId = __instance.tankId; @@ -142,7 +142,7 @@ public static class TankPatch } [HarmonyPrefix] - [HarmonyPatch(typeof(TankComponent), "GameTick")] + [HarmonyPatch(typeof(TankComponent), nameof(TankComponent.GameTick))] private static bool TankComponent_GameTick_Prefix(ref TankComponent __instance, PlanetFactory factory) { if (__instance.fluidInc < 0)