using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PEAKFastStartup;
using PEAKProto.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("Zorro.Core.Runtime")]
[assembly: AssemblyCompany("com.CTNOriginals.peak.PEAKFastStartup")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Skip the lengthy splash screen when the game starts and start loading the game right away!")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+fe9d980d37ecb12452809b587fdefaa67bd4b926")]
[assembly: AssemblyProduct("PEAKFastStartup")]
[assembly: AssemblyTitle("com.CTNOriginals.peak.PEAKFastStartup")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
[HarmonyPatch(typeof(Character))]
public static class CharacterPatch
{
[HarmonyPrefix]
[HarmonyPatch("StartPassedOutOnTheBeach")]
public static bool StartPassedOutOnTheBeachPatch(ref Character __instance)
{
CLogger.LogInfo($"Character.StartPassedOutOnTheBeach | Startup: {SceneLoader.LoadedIslandStartup}");
if (!SceneLoader.LoadedIslandStartup)
{
return true;
}
SceneLoader.LoadedIslandStartup = false;
return false;
}
}
[HarmonyPatch(typeof(Pretitle))]
public static class PretitlePatch
{
[HarmonyPrefix]
[HarmonyPatch("Update")]
public static bool UpdatePatch(ref Pretitle __instance)
{
if (!Plugin.SkipSplashScreens)
{
return true;
}
__instance.allowedToSwitch = true;
return false;
}
}
public static class SceneLoader
{
public static bool LoadedIslandStartup = true;
public static void Start()
{
if (Plugin.LoadIslandOnStart)
{
SceneManager.sceneLoaded += OnSceneLoaded;
}
}
public static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
CLogger.LogInfo($"Scene Loaded: {((Scene)(ref scene)).name} | {mode}");
if ((Plugin.SkipSplashScreens && ((Scene)(ref scene)).name == "Pretitle") || (!Plugin.SkipSplashScreens && ((Scene)(ref scene)).name == "Title"))
{
CLogger.LogInfo("Skipping pretitle, loading main menu");
SceneManager.LoadScene("WilIsland");
}
}
}
namespace PEAKProto.Utils
{
public static class CLogger
{
public static void Log(string message)
{
SendLog(message, "Log");
}
public static void LogInfo(string message)
{
SendLog(message, "LogInfo");
}
public static void LogError(string message)
{
SendLog(message, "LogError");
}
public static void LogWarning(string message)
{
SendLog(message, "LogWarning");
}
public static void LogFatal(string message)
{
SendLog(message, "LogFatal");
}
public static void LogMessage(string message)
{
SendLog(message, "LogMessage");
}
public static void LogException(string message, SystemException exception)
{
SendLog(message, "LogException", exception);
}
public static void LogException(string message, Exception exception)
{
SendLog(message, "LogException", exception);
}
private static void SendLog(string message, string level = null, Exception exception = null)
{
if (!Plugin.DebugMode && (level == "LogDebug" || level == "LogInfo"))
{
return;
}
switch (level)
{
case "LogInfo":
Plugin.Logger.LogInfo((object)message);
break;
case "LogError":
Plugin.Logger.LogError((object)message);
break;
case "LogWarning":
Plugin.Logger.LogWarning((object)message);
break;
case "LogDebug":
Plugin.Logger.LogDebug((object)message);
break;
case "LogFatal":
Plugin.Logger.LogFatal((object)message);
break;
case "LogMessage":
Plugin.Logger.LogMessage((object)message);
break;
case "LogException":
if (exception == null)
{
Plugin.Logger.LogError((object)(message ?? ""));
}
Plugin.Logger.LogError((object)(message + "\nMessage: " + exception.Message + "\nSource: " + exception.Source + "\n" + exception.GetBaseException().StackTrace + "\n"));
break;
default:
if (level != "Log")
{
Debug.Log((object)("[" + level + "]: " + message));
}
else
{
Debug.Log((object)message);
}
break;
}
}
}
}
namespace PEAKFastStartup
{
[BepInPlugin("com.CTNOriginals.peak.PEAKFastStartup", "PEAKFastStartup", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
public static ManualLogSource Logger;
public static Harmony Harmony = new Harmony("com.CTNOriginals.peak.PEAKFastStartup");
public static bool DebugMode = false;
public static bool SkipSplashScreens;
public static bool LoadIslandOnStart;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)("Plugin com.CTNOriginals.peak.PEAKFastStartup 1.1.2 is loaded! (" + (DebugMode ? "Debug" : "Release") + ")"));
InitializeConfig();
Harmony.PatchAll();
Start();
}
private void InitializeConfig()
{
SkipSplashScreens = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SkipSplashScreens", true, "Wether or not to automatically skip the splash screens that the game shows on startup.").Value;
LoadIslandOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LoadIslandOnStart", false, "Wether or not to load a solo play game right after the game starts, skipping the main menu and airport entirely.").Value;
CLogger.LogInfo($"SkipSplashScreens: {SkipSplashScreens}");
CLogger.LogInfo($"LoadIslandOnStart: {LoadIslandOnStart}");
}
private void Start()
{
SceneLoader.Start();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "com.CTNOriginals.peak.PEAKFastStartup";
public const string PLUGIN_NAME = "PEAKFastStartup";
public const string PLUGIN_VERSION = "1.1.2";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}