private void UpdateConfigSubscriptions(bool unsubscribe = false)
{
if (!unsubscribe && !configurations.IsLoaded)
{
return;
}
if (!unsubscribe && configurations.SupplyDrop.Enabled && FancyDrop == null && LootDefender == null)
{
Subscribe(nameof(OnExplosiveDropped));
Subscribe(nameof(OnExplosiveThrown));
}
else
{
Unsubscribe(nameof(OnExplosiveDropped));
Unsubscribe(nameof(OnExplosiveThrown));
}
// Always unpatch to prevent double patches
HarmonyInstance.Unpatch(AccessTools.Method(typeof(BaseOven), "Cook"), HarmonyPatchType.Prefix, HarmonyId);
HarmonyInstance.Unpatch(AccessTools.Method(typeof(BaseOven), "GetSmeltingSpeed"), HarmonyPatchType.Postfix, HarmonyId);
if (!unsubscribe && configurations.Smelting.Enabled && SimpleSplitter == null)
{
HarmonyInstance.Patch(AccessTools.Method(typeof(BaseOven), "Cook"),
prefix: AccessTools.Method(typeof(BaseOven_Patches), nameof(BaseOven_Patches.Cook_Prefix)));
if (Config.SmeltingOptions.AdjustProgressIndicator)
{
HarmonyInstance.Patch(AccessTools.Method(typeof(BaseOven), "GetSmeltingSpeed"),
postfix: AccessTools.Method(typeof(BaseOven_Patches), nameof(BaseOven_Patches.GetSmeltingSpeed_Postfix)));
}
Subscribe(nameof(OnMixingTableToggle));
}
else
{
Unsubscribe(nameof(OnMixingTableToggle));
}
if (!unsubscribe && configurations.Smelting.RecyclerEnabled)
{
Subscribe(nameof(OnRecyclerToggle));
}
else
{
Unsubscribe(nameof(OnRecyclerToggle));
}
}
© 2023 Quttera Ltd. All rights reserved.