using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using Photon.Realtime; 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("InfiniteEnergy")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InfiniteEnergy")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6d8aeaff-cded-4f1d-8294-64fa1a97e48f")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace LateJoin; [BepInPlugin("knightmike.latejoin", "Late Join", "1.0.0")] public class Plugin : BaseUnityPlugin { public static HashSet playersLoaded = new HashSet(); public const string modGUID = "knightmike.latejoin"; public const string modName = "Late Join"; public const string modVersion = "1.0.0"; public static bool levelLoaded = false; public static bool playerSpawned = false; public static bool isRunLobbyShop = false; public static ManualLogSource MLS; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) MLS = ((BaseUnityPlugin)this).Logger; new Harmony("knightmike.latejoin").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"loaded"); } public static void LobbyClose() { Room currentRoom = PhotonNetwork.CurrentRoom; if (currentRoom != null) { SteamManager.instance.LockLobby(); currentRoom.IsOpen = false; currentRoom.IsVisible = false; } } public static void LobbyOpen() { Room currentRoom = PhotonNetwork.CurrentRoom; if (currentRoom != null && playerSpawned && levelLoaded) { currentRoom.IsOpen = true; currentRoom.IsVisible = true; SteamManager.instance.UnlockLobby(true); } } } [HarmonyPatch(typeof(PlayerAvatar), "Spawn")] public class PlayerAvatar_Spawn { [HarmonyPrefix] private static bool Prefix(PlayerAvatar __instance) { if ((Object)(object)__instance == (Object)null || !Plugin.isRunLobbyShop) { return true; } int ownerActorNr = __instance.photonView.OwnerActorNr; return Plugin.playersLoaded.Add(ownerActorNr); } [HarmonyPostfix] private static void Postfix(PlayerAvatar __instance) { if (!Plugin.playerSpawned && !((Object)(object)__instance == (Object)null)) { PhotonView photonView = __instance.photonView; if (!((Object)(object)photonView == (Object)null) && photonView.IsMine && Plugin.isRunLobbyShop) { Plugin.playerSpawned = true; Plugin.LobbyOpen(); } } } } [HarmonyPatch(typeof(TruckScreenText), "ChatMessageSend")] public class TruckScreenText_ChatMessageSend { [HarmonyPrefix] private static void Prefix() { if (Plugin.isRunLobbyShop) { Plugin.LobbyClose(); } } } [HarmonyPatch(typeof(TruckScreenText), "GotoNextLevel")] public static class TruckScreenText_GotoNextLevel { [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public TruckScreenText instance; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(6f); <>1__state = 1; return true; case 1: <>1__state = -1; instance.GotoNextLevel(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static bool hasInvoked; [HarmonyPrefix] public static bool Prefix(TruckScreenText __instance) { if (!Plugin.isRunLobbyShop || hasInvoked) { return true; } hasInvoked = true; ((MonoBehaviour)__instance).StartCoroutine(DelayedGotoNextLevel(__instance)); return false; } [IteratorStateMachine(typeof(d__2))] public static IEnumerator DelayedGotoNextLevel(TruckScreenText instance) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0) { instance = instance }; } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] public class RunManager_ChangeLevel { [HarmonyPrefix] private static void Prefix() { Plugin.levelLoaded = false; Plugin.playerSpawned = false; Plugin.playersLoaded.Clear(); TruckScreenText_GotoNextLevel.hasInvoked = false; } [HarmonyPostfix] private static void Postfix() { Plugin.isRunLobbyShop = SemiFunc.RunIsLobby() || SemiFunc.RunIsShop(); } } [HarmonyPatch(typeof(RunManager), "Update")] public class RunManager_Update { private static bool wasRestarting; [HarmonyPostfix] private static void Postfix(object __instance) { bool value = Traverse.Create(__instance).Field("restarting").GetValue(); if (wasRestarting && !value && Plugin.isRunLobbyShop) { Plugin.levelLoaded = true; Plugin.LobbyOpen(); } wasRestarting = value; } }