using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FastStartup.Config;
using FastStartup.Patches;
using FastStartup.TimeSavers;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
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: AssemblyCompany("FastStartup")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mod to skip the animations / splashes that play on game startup.")]
[assembly: AssemblyFileVersion("1.1.2.0")]
[assembly: AssemblyInformationalVersion("1.1.2+58d788a3ce3dcd761a31ffed5a19aa83f35ae609")]
[assembly: AssemblyProduct("FastStartup")]
[assembly: AssemblyTitle("FastStartup")]
[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;
}
}
}
namespace FastStartup
{
[BepInPlugin("dev.flero.lethal.FastStartup", "FastStartup", "1.1.2")]
public class Plugin : BaseUnityPlugin
{
public const string ModId = "dev.flero.lethal.FastStartup";
public const string ModName = "FastStartup";
public const string ModVersion = "1.1.2";
public static FastStartup.Config.Config Config { get; private set; }
public static bool Initialized { get; private set; }
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
switch (((Scene)(ref scene)).name)
{
case "InitScene":
case "InitSceneLANMode":
BootAnimSaver.Start();
break;
case "MainMenu":
MenuAnimSaver.Start();
LanPopupSaver.Start();
break;
}
}
private void Initialize()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
if (!Initialized)
{
Initialized = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading Configuration");
Config = new FastStartup.Config.Config(((BaseUnityPlugin)this).Config);
SceneManager.sceneLoaded += OnSceneLoaded;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin dev.flero.lethal.FastStartup is loaded!");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loading patches...");
new Harmony("dev.flero.lethal.FastStartup").PatchAll(typeof(PreInitSceneScriptPatch));
}
}
private void Awake()
{
Initialize();
SplashSaver.Start();
}
private void Start()
{
Initialize();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "FastStartup";
public const string PLUGIN_NAME = "FastStartup";
public const string PLUGIN_VERSION = "1.1.2";
}
}
namespace FastStartup.TimeSavers
{
internal static class BootAnimSaver
{
private static readonly ManualLogSource LogSource;
static BootAnimSaver()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup.Savers.BootAnim");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
internal static void Start()
{
if (Plugin.Config.SkipBootAnim.Value)
{
InitializeGame val = Object.FindObjectOfType<InitializeGame>();
if (!((Object)(object)val == (Object)null))
{
LogSource.LogInfo((object)"Skipping boot animation");
val.runBootUpScreen = false;
val.bootUpAnimation = null;
val.bootUpAudio = null;
}
}
}
}
internal static class LanPopupSaver
{
private static readonly ManualLogSource LogSource;
static LanPopupSaver()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup.Savers.LanPopup");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
internal static void Start()
{
if (Plugin.Config.DisableLanPopup.Value)
{
MenuManager val = Object.FindObjectOfType<MenuManager>();
if (!((Object)(object)val == (Object)null))
{
LogSource.LogInfo((object)"Destroying LAN popup");
Object.Destroy((Object)(object)val.lanWarningContainer);
}
}
}
}
internal static class LaunchOptionsSaver
{
private static readonly ManualLogSource LogSource;
public static bool HasRan;
static LaunchOptionsSaver()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup.Savers.LaunchOptions");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
internal static void Start()
{
if (Plugin.Config.SkipLaunchMode.Value && !HasRan)
{
HasRan = true;
LaunchMode value = Plugin.Config.AutoLaunchMode.Value;
LogSource.LogInfo((object)$"Skipping launch options, defaulting to {Plugin.Config.AutoLaunchMode.Value}.");
switch (value)
{
case LaunchMode.Online:
SceneManager.LoadScene("InitScene");
break;
case LaunchMode.Lan:
SceneManager.LoadScene("InitSceneLANMode");
break;
default:
throw new ArgumentOutOfRangeException();
}
}
}
}
internal static class MenuAnimSaver
{
private static readonly ManualLogSource LogSource;
static MenuAnimSaver()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup.Savers.MenuAnim");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
internal static void Start()
{
if (Plugin.Config.SkipMenuAnim.Value)
{
LogSource.LogInfo((object)"Disabling menu open animation");
GameNetworkManager.Instance.firstTimeInMenu = false;
}
}
}
internal static class SplashSaver
{
private static readonly ManualLogSource LogSource;
static SplashSaver()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup.Savers.Splash");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
internal static void Start()
{
if (!Plugin.Config.SkipSplashes.Value)
{
return;
}
Task.Factory.StartNew(delegate
{
int value = Plugin.Config.SplashDelay.Value;
int value2 = Plugin.Config.SplashDuration.Value;
if (value > 0)
{
LogSource.LogInfo((object)$"Waiting for {value} seconds before skipping splashes.");
Thread.Sleep(TimeSpan.FromSeconds(value));
}
LogSource.LogInfo((object)$"Trying to stop splash screen. Cancelling after {value2} seconds.");
while (!LaunchOptionsSaver.HasRan)
{
SplashScreen.Stop((StopBehavior)0);
if (!(Time.realtimeSinceStartup < (float)value2))
{
LogSource.LogError((object)$"Failed to remove splash screen: {value2} seconds has passed since startup!");
break;
}
}
});
}
}
}
namespace FastStartup.Patches
{
[HarmonyPatch(typeof(PreInitSceneScript))]
public static class PreInitSceneScriptPatch
{
[HarmonyPrefix]
[HarmonyPatch("SkipToFinalSetting")]
public static bool SkipToFinalSetting(PreInitSceneScript __instance)
{
if (!Plugin.Config.SkipLaunchMode.Value)
{
return true;
}
__instance.launchSettingsPanelsContainer.SetActive(false);
LaunchOptionsSaver.Start();
return false;
}
}
}
namespace FastStartup.Config
{
public class Config
{
private const int CurrentVersion = 2;
public readonly ConfigEntry<int> ConfigVersion;
public readonly ConfigEntry<bool> SkipLaunchMode;
public readonly ConfigEntry<LaunchMode> AutoLaunchMode;
public readonly ConfigEntry<bool> DisableLanPopup;
public readonly ConfigEntry<bool> SkipMenuAnim;
public readonly ConfigEntry<bool> SkipBootAnim;
public readonly ConfigEntry<bool> SkipSplashes;
public readonly ConfigEntry<int> SplashDelay;
public readonly ConfigEntry<int> SplashDuration;
internal readonly ConfigFile File;
private readonly ManualLogSource LogSource = new ManualLogSource("FastStartup > Config");
public Config(ConfigFile file)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
File = file;
Logger.Sources.Add((ILogSource)(object)LogSource);
new ConfigBuilder<int>(this).SetSection("FastStartup").SetKey("ConfigVersion").SetDefault(2)
.SetDescription("Version of this configuration file. DO NOT CHANGE THIS")
.Build(out ConfigVersion);
if (ConfigVersion.Value < 2)
{
LogSource.LogWarning((object)"You are using an outdated config file! This may cause issues.");
LogSource.LogWarning((object)"It is recommended to regenerate the config by removing the file and restarting Lethal Company.");
}
else if (ConfigVersion.Value > 2)
{
LogSource.LogWarning((object)"You are using an outdated mod version with a newer config version!");
LogSource.LogWarning((object)"This is not supported. Please delete the config file to regenerate it.");
}
new ConfigBuilder<bool>(this).SetSection("LaunchMode").SetKey("Enabled").SetDefault(value: true)
.SetDescription("Whether we should skip the launch mode screen.")
.Build(out SkipLaunchMode);
new ConfigBuilder<LaunchMode>(this).SetSection("LaunchMode").SetKey("DefaultMode").SetDefault(LaunchMode.Online)
.SetDescription("Default mode to launch into.")
.Build(out AutoLaunchMode);
new ConfigBuilder<bool>(this).SetSection("LaunchMode").SetKey("DisableLanPopup").SetDefault(value: true)
.SetDescription("Whether to disable the 'You are in LAN mode' popup.")
.Build(out DisableLanPopup);
new ConfigBuilder<bool>(this).SetSection("Splashes").SetKey("Enabled").SetDefault(value: true)
.SetDescription("Whether we should skip the splash screens.")
.Build(out SkipSplashes);
new ConfigBuilder<int>(this).SetSection("Splashes").SetKey("Delay").SetDefault(0)
.SetDescription("Delay in seconds before starting the splash skip.")
.Build(out SplashDelay);
new ConfigBuilder<int>(this).SetSection("Splashes").SetKey("Duration").SetDefault(15)
.SetDescription("Duration in seconds of how long the loop runs for before cancelling.")
.Build(out SplashDuration);
new ConfigBuilder<bool>(this).SetSection("Skips").SetKey("BootAnim").SetDefault(value: true)
.SetDescription("Whether we should skip the terminal-like boot animation.")
.Build(out SkipBootAnim);
new ConfigBuilder<bool>(this).SetSection("Skips").SetKey("MenuAnim").SetDefault(value: true)
.SetDescription("Whether we should skip the small squash animation of the main menu.")
.Build(out SkipMenuAnim);
}
}
internal class ConfigBuilder<T>
{
private static readonly ManualLogSource LogSource;
private readonly Config Config;
private T Default;
private string Description;
private string Key;
private string Section;
static ConfigBuilder()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
LogSource = new ManualLogSource("FastStartup > Config");
Logger.Sources.Add((ILogSource)(object)LogSource);
}
public ConfigBuilder(Config config)
{
Config = config;
}
public void Build(out ConfigEntry<T> entry)
{
entry = Config.File.Bind<T>(Section, Key, Default, Description);
}
public bool TryGet(out ConfigEntry<T> entry)
{
return Config.File.TryGetEntry<T>(Section, Key, ref entry);
}
public ConfigBuilder<T> SetSection(string section)
{
Section = section;
return this;
}
public ConfigBuilder<T> SetKey(string key)
{
Key = key;
return this;
}
public ConfigBuilder<T> SetDescription(string description)
{
Description = description;
return this;
}
public ConfigBuilder<T> SetDefault(T value)
{
Default = value;
return this;
}
}
public enum LaunchMode
{
Online,
Lan
}
}