Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DevelopmentStartup v1.2.0
BepInEx/plugins/DevelopmentStartup.dll
Decompiled 2 years agousing 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 BepInEx; using BepInEx.Logging; using DevelopmentStartup.Utilities; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("DevelopmentStartup")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("My first plugin")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("DevelopmentStartup")] [assembly: AssemblyTitle("DevelopmentStartup")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.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 DevelopmentStartup { [BepInPlugin("DevelopmentStartup", "DevelopmentStartup", "1.2.0")] public class Plugin : BaseUnityPlugin { public enum LaunchMode { Online, LAN } public static LaunchMode launchMode = LaunchMode.LAN; public static bool autoJoinLan; public static bool autoPullLever; public static bool tpToEntrance; public static bool teleportInside; internal static bool IsHostInstance; public static ManualLogSource CLog; private readonly Harmony harmony = new Harmony("com.ctnoriginals.DevelopmentStartup"); private static Mutex AppMutex; private void Awake() { CLog = Logger.CreateLogSource("DevelopmentStartup"); CLog.LogInfo((object)"Plugin DevelopmentStartup is loaded! Version: 1.2.0 (Release)"); ConfigFile(); harmony.PatchAll(); IsHostInstance = !autoJoinLan || !CheckMutex(); } private void ConfigFile() { autoJoinLan = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoJoinLAN", true, "Automatically join LAN lobbies when game is launched more than once.").Value; autoPullLever = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoPullLever", false, "Automatically pull the ship's lever on startup.").Value; tpToEntrance = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TeleportToEntrance", false, "Automatically teleports you to the main entrance on level load (Requires 'AutoPullLever' enabled).").Value; teleportInside = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TeleportInside", false, "Teleports you inside the facility instead (Requires 'TeleportToEntrance' enabled).").Value; } internal static bool CheckMutex() { try { if (AppMutex == null) { AppMutex = new Mutex(initiallyOwned: true, "LethalCompany-DevelopmentStartup"); } return AppMutex != null && !AppMutex.WaitOne(TimeSpan.Zero, exitContext: true); } catch { return false; } } } [HarmonyPatch(typeof(IngamePlayerSettings))] internal class IngamePlayerSettingsPatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePatch(IngamePlayerSettings __instance) { DevelopmentStartup.Utilities.Console.LogMessage("Loading settings from prefs before the game loads default settings"); __instance.LoadSettingsFromPrefs(); __instance.UpdateGameToMatchSettings(); } } [HarmonyPatch(typeof(MenuManager))] internal class MenuManagerPatch { private static bool firstTimeLoad = true; [HarmonyPostfix] [HarmonyPatch("OnEnable")] public static void OnEnablePatch(MenuManager __instance) { if (firstTimeLoad) { DevelopmentStartup.Utilities.Console.LogMessage("To change the launch mode (Online | Lan), edit the config file for the \"FastStartup\" plugin"); if ((Object)(object)__instance.menuButtons != (Object)null && ((Object)__instance.menuButtons).name == "MainButtons") { DevelopmentStartup.Utilities.Console.LogInfo("MenuManager.OnEnablePatch() called - MainButtons"); JumpInGame(__instance); } else { DevelopmentStartup.Utilities.Console.LogInfo("MenuManager.OnEnablePatch() called - not MainButtons"); } } } private static void JumpInGame(MenuManager __instance) { DevelopmentStartup.Utilities.Console.LogDebug("Entering lobby name"); __instance.lobbyNameInputField.text = "DevelopmentStartup Lobby"; DevelopmentStartup.Utilities.Console.LogDebug("Confirm Host Button"); if (Plugin.IsHostInstance) { __instance.ConfirmHostButton(); } else { __instance.StartAClient(); } firstTimeLoad = false; } } [HarmonyPatch(typeof(StartMatchLever))] internal class StartMatchLeverPatch { private static bool hasPulledLever; [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPatch(StartMatchLever __instance) { if (Plugin.autoPullLever && !hasPulledLever) { DevelopmentStartup.Utilities.Console.LogDebug("Pullling Ship Lever"); hasPulledLever = true; __instance.leverHasBeenPulled = true; __instance.leverAnimatorObject.SetBool("pullLever", true); __instance.triggerScript.interactable = false; __instance.PullLever(); } } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { private static bool attemptedTp; [HarmonyPatch("TeleportPlayerInShipIfOutOfRoomBounds")] [HarmonyPostfix] public static void TeleportPlayerInShipIfOutOfRoomBoundsStats(StartOfRound __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (Plugin.tpToEntrance && !attemptedTp && __instance.shipDoorsEnabled) { DevelopmentStartup.Utilities.Console.LogDebug("Teleporting to entrance..."); EntranceTeleport val = (EntranceTeleport)AccessTools.Method(typeof(RoundManager), "FindMainEntranceScript", (Type[])null, (Type[])null).Invoke(null, new object[1] { Plugin.teleportInside }); if ((Object)(object)val != (Object)null) { val.TeleportPlayer(); DevelopmentStartup.Utilities.Console.LogDebug("Player teleported to entrance"); } else { DevelopmentStartup.Utilities.Console.LogError("Failed to find entrance"); } attemptedTp = true; } } } public static class PluginInfo { public const string PLUGIN_GUID = "com.ctnoriginals.DevelopmentStartup"; public const string PLUGIN_NAME = "DevelopmentStartup"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace DevelopmentStartup.Utilities { public static class Console { public const bool DebugState = false; 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 LogDebug(string message) { SendLog(message, "LogDebug"); } public static void LogFatal(string message) { SendLog(message, "LogFatal"); } public static void LogMessage(string message) { SendLog(message, "LogMessage"); } private static void SendLog(string message, string level = null) { if (level == "LogDebug" || level == "LogInfo") { return; } switch (level) { case "LogInfo": Plugin.CLog.LogInfo((object)message); return; case "LogError": Plugin.CLog.LogError((object)message); return; case "LogWarning": Plugin.CLog.LogWarning((object)message); return; case "LogDebug": Plugin.CLog.LogDebug((object)message); return; case "LogFatal": Plugin.CLog.LogFatal((object)message); return; case "LogMessage": Plugin.CLog.LogMessage((object)message); return; } if (level != "Log") { Debug.Log((object)("[" + level + "]: " + message)); } else { Debug.Log((object)message); } } } }