using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FastTravelEnabler")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FastTravelEnabler")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3425ed94-6056-42f1-9533-ac1b9d622925")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace FastTravelEnablerMod;
[BepInPlugin("com.hetima.dsp.FastTravelEnabler", "FastTravelEnabler", "1.0.1")]
public class FastTravelEnabler : BaseUnityPlugin
{
private static class Patch
{
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIGlobemap), "_OnUpdate")]
public static IEnumerable<CodeInstruction> UIGlobemap__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "_OnUpdate")]
public static IEnumerable<CodeInstruction> UIStarmap__OnUpdate_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "UpdateCursorView")]
public static IEnumerable<CodeInstruction> UIStarmap_UpdateCursorView_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "StartFastTravelToPlanet")]
public static IEnumerable<CodeInstruction> UIStarmap_StartFastTravelToPlanet_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "StartFastTravelToUPosition")]
public static IEnumerable<CodeInstruction> UIStarmap_TeleportToUPosition_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "OnScreenClick")]
public static IEnumerable<CodeInstruction> UIStarmap_OnScreenClick_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "SandboxRightClickFastTravelLogic")]
public static IEnumerable<CodeInstruction> UIStarmap_SandboxRightClickFastTravelLogic_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "DoRightClickFastTravel")]
public static IEnumerable<CodeInstruction> UIStarmap_DoRightClickFastTravel_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(UIStarmap), "OnFastTravelButtonClick")]
public static IEnumerable<CodeInstruction> UIStarmap_OnFastTravelButtonClick_Transpiler(IEnumerable<CodeInstruction> instructions)
{
return PatchSandboxToolsEnabled(instructions);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(ABN_MechaPosition), "OnGameTick")]
public static bool ABN_MechaPosition_OnGameTick_Prefix(ABN_MechaPosition __instance)
{
return false;
}
}
public const string __NAME__ = "FastTravelEnabler";
public const string __GUID__ = "com.hetima.dsp.FastTravelEnabler";
internal static ManualLogSource Logger;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
new Harmony("com.hetima.dsp.FastTravelEnabler").PatchAll(typeof(Patch));
}
public static bool ModSandboxToolsEnabled()
{
return (Object)(object)GameMain.instance != (Object)null;
}
public static IEnumerable<CodeInstruction> PatchSandboxToolsEnabled(IEnumerable<CodeInstruction> instructions)
{
MethodInfo target = typeof(GameMain).GetMethod("get_sandboxToolsEnabled");
MethodInfo rep = typeof(FastTravelEnabler).GetMethod("ModSandboxToolsEnabled");
foreach (CodeInstruction ins in instructions)
{
int num;
if (ins.opcode == OpCodes.Call)
{
object operand = ins.operand;
if (operand is MethodInfo o)
{
num = ((o == target) ? 1 : 0);
goto IL_00e6;
}
}
num = 0;
goto IL_00e6;
IL_00e6:
if (num != 0)
{
ins.operand = rep;
yield return ins;
}
else
{
yield return ins;
}
}
}
}