using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("LateJoin")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LateJoin")] [assembly: AssemblyTitle("LateJoin")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace LateJoin { [BepInPlugin("ozoka.latejoin", "LateJoin", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Log; internal static ConfigEntry AllowLateJoin; internal static ConfigEntry AllowJoinInShop; private readonly Harmony _harmony = new Harmony("ozoka.latejoin"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; AllowLateJoin = ((BaseUnityPlugin)this).Config.Bind("General", "Allow Late Join", true, "Allows players to join a running game."); AllowJoinInShop = ((BaseUnityPlugin)this).Config.Bind("General", "Allow Join In Shop", true, "Allows players to join during the shop phase."); Log.LogInfo((object)"LateJoin geladen!"); _harmony.PatchAll(); } } [HarmonyPatch(typeof(RunManager))] internal class RunManagerPatch { private static readonly FieldInfo _lobbyTypeField = typeof(GameManager).GetField("lobbyType", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); [HarmonyPatch("ChangeLevel", new Type[] { typeof(bool), typeof(bool), typeof(ChangeLevelType) })] [HarmonyPostfix] internal static void ChangeLevelPatch(bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Invalid comparison between Unknown and I4 //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 if (PhotonNetwork.IsMasterClient && Plugin.AllowLateJoin.Value) { bool flag = SemiFunc.RunIsLobbyMenu() || SemiFunc.RunIsLobby() || (SemiFunc.RunIsShop() && Plugin.AllowJoinInShop.Value); object obj = _lobbyTypeField?.GetValue(GameManager.instance); bool flag2 = obj != null && (int)(LobbyTypes)obj == 1; bool flag3 = obj != null && (int)(LobbyTypes)obj == 2; if (flag) { PhotonNetwork.CurrentRoom.IsOpen = true; PhotonNetwork.CurrentRoom.IsVisible = flag2 || flag3; SteamManager.instance.UnlockLobby(true); Plugin.Log.LogInfo((object)("[LateJoin] Lobby geƶffnet, sichtbar: " + (flag2 || flag3))); } else { PhotonNetwork.CurrentRoom.IsOpen = false; PhotonNetwork.CurrentRoom.IsVisible = false; SteamManager.instance.LockLobby(); Plugin.Log.LogInfo((object)"[LateJoin] Lobby geschlossen"); } } } } [HarmonyPatch(typeof(PlayerAvatar))] internal class PlayerAvatarPatch { [HarmonyPatch("Spawn", new Type[] { typeof(Vector3), typeof(Quaternion) })] [HarmonyPrefix] internal static bool SpawnPatch(PlayerAvatar __instance) { bool flag = (bool)(typeof(PlayerAvatar).GetField("spawned", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(__instance) ?? ((object)false)); return !flag; } } [HarmonyPatch(typeof(PlayerAvatar))] internal class PlayerAvatarStartPatch { [HarmonyPatch("Start")] [HarmonyPostfix] internal static void StartPatch(PlayerAvatar __instance) { if (PhotonNetwork.IsMasterClient && !SemiFunc.RunIsLobby()) { __instance.photonView.RPC("LoadingLevelAnimationCompletedRPC", (RpcTarget)0, Array.Empty()); } } } }