Skip to content

Commit

Permalink
chore!: Remove SMLHelper compatibility patches (#465)
Browse files Browse the repository at this point in the history
* Revert "fix: SML Load Order Issues (#449)"

This reverts commit ce7a814.

* Remove SML Compatibility patches
  • Loading branch information
LeeTwentyThree committed Sep 25, 2023
1 parent 6004b7a commit 6596dc6
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 301 deletions.
1 change: 0 additions & 1 deletion Nautilus/Initializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ static Initializer()
SpritePatcher.Patch(_harmony);
KnownTechPatcher.Patch(_harmony);
OptionsPanelPatcher.Patch(_harmony);
SMLHelperCompatibilityPatcher.Patch(_harmony);
ItemsContainerPatcher.Patch(_harmony);
PDALogPatcher.Patch(_harmony);
PDAPatcher.Patch(_harmony);
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/ConsoleCommandsPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Nautilus.Patchers;

[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static class ConsoleCommandsPatcher
{
private static Dictionary<string, ConsoleCommand> ConsoleCommands = new();
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/CraftDataPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Nautilus.Patchers;

[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal partial class CraftDataPatcher
{
#region Internal Fields
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/CraftTreePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace Nautilus.Patchers;

[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal class CraftTreePatcher
{
#region Internal Fields
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/CustomSoundPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace Nautilus.Patchers;

[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal class CustomSoundPatcher
{
internal static readonly SelfCheckingDictionary<string, Sound> CustomSounds = new("CustomSounds");
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/EnumPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace Nautilus.Patchers;

[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static class EnumPatcher
{
internal static void Patch(Harmony harmony)
Expand Down
6 changes: 3 additions & 3 deletions Nautilus/Patchers/ItemActionPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ internal static void Patch(Harmony harmony)
// See README.md for details.

harmony.Patch(AccessTools.Method(typeof(uGUI_InventoryTab), nameof(uGUI_InventoryTab.OnPointerClick)),
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(OnPointerClick_Prefix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(ItemActionPatcher.OnPointerClick_Prefix))));

harmony.Patch(AccessTools.Method(typeof(Inventory), nameof(Inventory.ExecuteItemAction),new Type[] { typeof(ItemAction), typeof(InventoryItem) }),
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(ExecuteItemAction_Prefix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(ItemActionPatcher.ExecuteItemAction_Prefix))));

harmony.Patch(AccessTools.Method(typeof(TooltipFactory), nameof(TooltipFactory.ItemActions)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(ItemActions_Postfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemActionPatcher), nameof(ItemActionPatcher.ItemActions_Postfix))));

if (MiddleClickActions.Count > 0 && LeftClickActions.Count > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions Nautilus/Patchers/ItemsContainerPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ internal static class ItemsContainerPatcher
internal static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(ItemsContainer), nameof(ItemsContainer.HasRoomFor), new Type[] { typeof(int), typeof(int) }),
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(HasRoomFor_XY_Prefix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(HasRoomFor_Postfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
prefix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(ItemsContainerPatcher.HasRoomFor_XY_Prefix))),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(ItemsContainerPatcher.HasRoomFor_Postfix))));

harmony.Patch(AccessTools.Method(typeof(ItemsContainer), nameof(ItemsContainer.NotifyAddItem)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(NotifyChangeItem_Postfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(ItemsContainerPatcher.NotifyChangeItem_Postfix))));

harmony.Patch(AccessTools.Method(typeof(ItemsContainer), nameof(ItemsContainer.NotifyRemoveItem)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(NotifyChangeItem_Postfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(ItemsContainerPatcher.NotifyChangeItem_Postfix))));

harmony.Patch(AccessTools.Method(typeof(ItemsContainer), nameof(ItemsContainer.NotifyResize)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(NotifyChangeItem_Postfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(ItemsContainerPatcher), nameof(ItemsContainerPatcher.NotifyChangeItem_Postfix))));

InternalLogger.Log($"ItemsContainerPatcher is done.", LogLevel.Debug);
}
Expand Down
6 changes: 3 additions & 3 deletions Nautilus/Patchers/LanguagePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ private static void LoadLanguageFilePrefix(string language)

internal static void Patch(Harmony harmony)
{
HarmonyMethod repatchCheckMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(RepatchCheck)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance});
HarmonyMethod insertLinesMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(InsertCustomLines)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance});
HarmonyMethod loadLanguagesMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(LoadLanguageFilePrefix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance});
HarmonyMethod repatchCheckMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(RepatchCheck)));
HarmonyMethod insertLinesMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(InsertCustomLines)));
HarmonyMethod loadLanguagesMethod = new(AccessTools.Method(typeof(LanguagePatcher), nameof(LoadLanguageFilePrefix)));

harmony.Patch(AccessTools.Method(typeof(Language), nameof(Language.ParseMetaData)), prefix: insertLinesMethod);
harmony.Patch(AccessTools.Method(typeof(Language), nameof(Language.GetKeysFor)), prefix: insertLinesMethod);
Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Patchers/LargeWorldStreamerPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class LargeWorldStreamerPatcher
internal static void Patch(Harmony harmony)
{
System.Reflection.MethodInfo initializeOrig = AccessTools.Method(typeof(LargeWorldStreamer), nameof(LargeWorldStreamer.Initialize));
HarmonyMethod initPostfix = new(AccessTools.Method(typeof(LargeWorldStreamerPatcher), nameof(InitializePostfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance});
HarmonyMethod initPostfix = new(AccessTools.Method(typeof(LargeWorldStreamerPatcher), nameof(InitializePostfix)));
harmony.Patch(initializeOrig, postfix: initPostfix);
}

Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Patchers/LootDistributionPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ internal class LootDistributionPatcher
internal static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(LootDistributionData), nameof(LootDistributionData.Initialize)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(LootDistributionPatcher), nameof(InitializePostfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(LootDistributionPatcher), nameof(LootDistributionPatcher.InitializePostfix))));

InternalLogger.Log("LootDistributionPatcher is done.", LogLevel.Debug);
}
Expand Down
3 changes: 0 additions & 3 deletions Nautilus/Patchers/OptionsPanelPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ internal static void Patch(Harmony harmony)
// 'Mods' tab also added in QModManager, so we can't rely on 'modsTab' in AddTabs_Postfix
[HarmonyPostfix]
[HarmonyPatch(typeof(uGUI_TabbedControlsPanel), nameof(uGUI_TabbedControlsPanel.AddTab))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static void AddTab_Postfix(uGUI_TabbedControlsPanel __instance, string label, int __result)
{
if(__instance is not uGUI_OptionsPanel)
Expand All @@ -48,7 +47,6 @@ internal static void AddTab_Postfix(uGUI_TabbedControlsPanel __instance, string

[HarmonyPrefix]
[HarmonyPatch(typeof(uGUI_Binding), nameof(uGUI_Binding.RefreshValue))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static bool RefreshValue_Prefix(uGUI_Binding __instance)
{
if (__instance.gameObject.GetComponent<ModBindingTag>() is null)
Expand All @@ -63,7 +61,6 @@ internal static bool RefreshValue_Prefix(uGUI_Binding __instance)

[HarmonyPostfix]
[HarmonyPatch(typeof(uGUI_OptionsPanel), nameof(uGUI_OptionsPanel.AddTabs))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static void AddTabs_Postfix(uGUI_OptionsPanel __instance)
{
uGUI_OptionsPanel optionsPanel = __instance;
Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Patchers/PDAEncyclopediaPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class PDAEncyclopediaPatcher
internal static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(PDAEncyclopedia), nameof(PDAEncyclopedia.Initialize)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDAEncyclopediaPatcher), nameof(InitializePostfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDAEncyclopediaPatcher), nameof(PDAEncyclopediaPatcher.InitializePostfix))));
}

internal static void InitializePostfix()
Expand Down
1 change: 0 additions & 1 deletion Nautilus/Patchers/PDAEncyclopediaTabPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ internal static void Patch(Harmony harmony)
}
[HarmonyPatch(typeof(uGUI_EncyclopediaTab))]
[HarmonyPatch(nameof(uGUI_EncyclopediaTab.Awake))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
[HarmonyPostfix]
internal static void EncyTabAwakePostfix(uGUI_EncyclopediaTab __instance)
{
Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Patchers/PDALogPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class PDALogPatcher
internal static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(PDALog), nameof(PDALog.Initialize)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDALogPatcher), nameof(InitializePostfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDALogPatcher), nameof(InitializePostfix))));
}

internal static void InitializePostfix()
Expand Down
2 changes: 1 addition & 1 deletion Nautilus/Patchers/PdaPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class PDAPatcher
internal static void Patch(Harmony harmony)
{
harmony.Patch(AccessTools.Method(typeof(PDAScanner), nameof(PDAScanner.Initialize)),
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDAPatcher), nameof(PDAPatcher.InitializePostfix)), after: new []{SMLHelperCompatibilityPatcher.SMLHarmonyInstance}));
postfix: new HarmonyMethod(AccessTools.Method(typeof(PDAPatcher), nameof(PDAPatcher.InitializePostfix))));

InternalLogger.Log($"PDAPatcher is done.", LogLevel.Debug);
}
Expand Down
5 changes: 0 additions & 5 deletions Nautilus/Patchers/PrefabDatabasePatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ private static class PostPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PrefabDatabase), nameof(PrefabDatabase.LoadPrefabDatabase))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static void LoadPrefabDatabase_Postfix()
{
foreach (var prefab in PrefabHandler.Prefabs)
Expand All @@ -29,7 +28,6 @@ internal static void LoadPrefabDatabase_Postfix()

[HarmonyPrefix]
[HarmonyPatch(typeof(PrefabDatabase), nameof(PrefabDatabase.TryGetPrefabFilename))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static bool TryGetPrefabFilename_Prefix(string classId, ref string filename, ref bool __result)
{
if (!PrefabHandler.Prefabs.TryGetInfoForClassId(classId, out PrefabInfo prefabInfo))
Expand All @@ -44,7 +42,6 @@ internal static bool TryGetPrefabFilename_Prefix(string classId, ref string file

[HarmonyPrefix]
[HarmonyPatch(typeof(DeferredSpawner.AddressablesTask), nameof(DeferredSpawner.AddressablesTask.SpawnAsync))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static bool DeferredSpawner_AddressablesTask_Spawn_Prefix(DeferredSpawner.AddressablesTask __instance, ref IEnumerator __result)
{
if (!PrefabHandler.Prefabs.TryGetInfoForFileName(__instance.key, out PrefabInfo prefabInfo))
Expand Down Expand Up @@ -93,7 +90,6 @@ private static IPrefabRequest GetModPrefabAsync(string classId)

[HarmonyPrefix]
[HarmonyPatch(typeof(PrefabDatabase), nameof(PrefabDatabase.GetPrefabAsync))]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static bool GetPrefabAsync_Prefix(ref IPrefabRequest __result, string classId)
{
__result ??= GetModPrefabAsync(classId);
Expand All @@ -105,7 +101,6 @@ internal static bool GetPrefabAsync_Prefix(ref IPrefabRequest __result, string c
{
typeof(string), typeof(IOut<GameObject>), typeof(Transform), typeof(Vector3), typeof(Quaternion), typeof(bool)
})]
[HarmonyAfter(SMLHelperCompatibilityPatcher.SMLHarmonyInstance)]
internal static bool InstantiateAsync_Prefix(ref IEnumerator __result,string key, IOut<GameObject> result, Transform parent, Vector3 position, Quaternion rotation, bool awake)
{
if (!PrefabHandler.Prefabs.TryGetInfoForFileName(key, out var prefabInfo) && !PrefabHandler.Prefabs.TryGetInfoForClassId(key, out prefabInfo))
Expand Down
Loading

0 comments on commit 6596dc6

Please sign in to comment.