using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using FlowCanvas;
using GK2.FlowCanvasNodes;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace QuarryDemolishHotfix;
[BepInPlugin("local.quarry-demolish-hotfix", "Quarry Demolish Hotfix", "1.0.1")]
public sealed class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Flow_GoTo), "GoTo")]
private static class MissingQuarryPointPatch
{
private const string PointId = "gd_quarry_block_demolish";
private static bool Prefix(Flow flow, bool ___movePlayer, bool ___useGdDataInsteadId, ValueInput<string> ___gdPointId, FlowOutput ___onFinish)
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
if (!___movePlayer || ___useGdDataInsteadId)
{
return true;
}
if (___gdPointId == null || ___gdPointId.value != "gd_quarry_block_demolish")
{
return true;
}
GameSave gameSave = MainGame.Instance.GameSave;
if (gameSave == null || gameSave.worldData == null || gameSave.worldData.gdPointsData == null)
{
return true;
}
if (gameSave.worldData.gdPointsData.GetGDPointDataById("gd_quarry_block_demolish") != null)
{
return true;
}
if (___onFinish == null)
{
return true;
}
Logger.CreateLogSource("QuarryDemolishHotfix").LogWarning((object)"Missing quarry demolish point; skipping only the move and continuing the demolish flow.");
___onFinish.Call(flow);
return false;
}
}
private Harmony harmony;
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
harmony = new Harmony("local.quarry-demolish-hotfix");
harmony.PatchAll(typeof(Plugin).Assembly);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Quarry demolish hotfix loaded");
}
private void OnDestroy()
{
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}