using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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("ShipFastLanding")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShipFastLanding")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("39c4159e-c663-4bf9-a9f3-eca72a3696b6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShipFastLanding
{
[BepInPlugin("oe.tweaks.qol.faster_company_landing", "Faster Company Landing", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("oe.tweaks.qol.faster_company_landing");
private const string GUID = "oe.tweaks.qol.faster_company_landing";
private const string NAME = "Faster Company Landing";
private const string VERSION = "1.0.0";
internal static Plugin instance;
internal static ManualLogSource log;
internal static ConfigEntry<bool> config_fastTravelToAllPlanets;
private void Awake()
{
log = ((BaseUnityPlugin)this).Logger;
log.LogInfo((object)("'" + ((Object)this).name + "' is loading..."));
if ((Object)(object)instance == (Object)null)
{
instance = this;
}
config_fastTravelToAllPlanets = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FastTravelToAll", false, "Allows you to fast travel to all planets, not just the company.");
harmony.PatchAll();
log.LogInfo((object)"'Faster Company Landing' loaded!");
}
}
}
namespace ShipFastLanding.Patches
{
[HarmonyPatch(typeof(StartOfRound))]
internal class ShipHubPatch
{
internal static GameObject shipHub;
[HarmonyPatch("SetMapScreenInfoToCurrentLevel")]
[HarmonyPrefix]
private static void speedUpShipOnCompany(StartOfRound __instance)
{
if ((Object)(object)shipHub == (Object)null)
{
shipHub = GameObject.Find("Environment/HangarShip");
if ((Object)(object)shipHub == (Object)null)
{
Plugin.log.LogError((object)"Didn't find ship!");
return;
}
Plugin.log.LogInfo((object)"Found ship!");
}
GameObject obj = shipHub;
if ((Object)(object)((obj != null) ? obj.GetComponent<Animator>() : null) != (Object)null)
{
if (__instance.currentLevelID == 3 || Plugin.config_fastTravelToAllPlanets.Value)
{
Plugin.log.LogInfo((object)"Speeding up ship!");
shipHub.GetComponent<Animator>().speed = 10f;
}
else
{
Plugin.log.LogInfo((object)"Regular speed!");
shipHub.GetComponent<Animator>().speed = 1f;
}
}
else
{
Plugin.log.LogError((object)"Didn't find ship animator!");
}
}
}
}