using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
[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("RoomFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+39bcfdc7a941463de4abc2244c3af461e83e0221")]
[assembly: AssemblyProduct("PEAK RoomFix")]
[assembly: AssemblyTitle("RoomFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 RoomFix
{
[BepInPlugin("RoomFix", "PEAK RoomFix", "1.0.1")]
public class Plugin : BaseUnityPlugin
{
private readonly Harmony harmony = new Harmony("RoomFix");
private void Awake()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
Type type = AccessTools.TypeByName("MainMenuJoinRoomPage");
MethodInfo methodInfo = AccessTools.Method(type, "JoinRoomAndWaitForSpawn", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.EnumeratorMoveNext((MethodBase)methodInfo);
MethodInfo method = typeof(Plugin).GetMethod("DoTranspile");
if (type != null && methodInfo != null && methodInfo2 != null && method != null)
{
harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null);
}
}
private void OnDestroy()
{
harmony.UnpatchSelf();
}
public static IEnumerable<CodeInstruction> DoTranspile(IEnumerable<CodeInstruction> instructions)
{
Type networkType = AccessTools.TypeByName("NetworkingUtilities");
Type type = AccessTools.TypeByName("PhotonNetwork");
MethodInfo photonMethod = AccessTools.Method(type, "JoinRoom", (Type[])null, (Type[])null);
IEnumerator<CodeInstruction> enumer = instructions.GetEnumerator();
while (enumer.MoveNext())
{
CodeInstruction current = enumer.Current;
if (CodeInstructionExtensions.Calls(current, photonMethod))
{
yield return current;
enumer.MoveNext();
current = enumer.Current;
if (current.opcode == OpCodes.Pop)
{
yield return CodeInstruction.StoreField(networkType, "EnteringRoom");
}
else
{
yield return current;
}
}
else
{
yield return current;
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RoomFix";
public const string PLUGIN_NAME = "PEAK RoomFix";
public const string PLUGIN_VERSION = "1.0.1";
}
}