using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AsyncLoggers.DBAPI;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using ImmovablePlayers.Dependency;
using LobbyCompatibility.Enums;
using LobbyCompatibility.Features;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: AssemblyCompany("ImmovablePlayers")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4a5bdc3d25d43d05583463bc32b05c3f89d5b429")]
[assembly: AssemblyProduct("Lobby Control")]
[assembly: AssemblyTitle("ImmovablePlayers")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 ImmovablePlayers
{
[HarmonyPatch]
[BepInPlugin("mattymatty.ImmovablePlayers", "ImmovablePlayers", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class ImmovablePlayers : BaseUnityPlugin
{
public const string GUID = "mattymatty.ImmovablePlayers";
public const string NAME = "ImmovablePlayers";
public const string VERSION = "1.0.0";
internal static ManualLogSource Log;
private void Awake()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
try
{
if (LobbyCompatibilityChecker.Enabled)
{
LobbyCompatibilityChecker.Init();
}
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("ImmovablePlayers", "Awake", "Initializing");
}
Log.LogInfo((object)"Patching Methods");
Harmony val = new Harmony("mattymatty.ImmovablePlayers");
val.PatchAll();
Log.LogInfo((object)"ImmovablePlayers v1.0.0 Loaded!");
if (AsyncLoggerProxy.Enabled)
{
AsyncLoggerProxy.WriteEvent("ImmovablePlayers", "Awake", "Finished Initializing");
}
}
catch (Exception ex)
{
Log.LogError((object)("Exception while initializing: \n" + ex));
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(PlayerControllerB), "Update")]
private static IEnumerable<CodeInstruction> StopPlayerPush(IEnumerable<CodeInstruction> instructions)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
List<CodeInstruction> list = instructions.ToList();
FieldInfo field = typeof(StartOfRound).GetField("playersMask");
Log.LogDebug((object)$"fldInfo is {field}");
for (int i = 0; i < list.Count; i++)
{
CodeInstruction val = list[i];
if (CodeInstructionExtensions.LoadsField(val, field, false))
{
CodeInstruction val2 = list[i + 2];
if (CodeInstructionExtensions.IsStloc(val2, (LocalBuilder)null))
{
list.InsertRange(i + 1, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2]
{
new CodeInstruction(OpCodes.Pop, (object)null)
{
blocks = val2.blocks
},
new CodeInstruction(OpCodes.Ldc_I4_0, (object)null)
{
blocks = val2.blocks
}
});
Log.LogDebug((object)"Patched Player Push!");
break;
}
}
}
return list;
}
}
}
namespace ImmovablePlayers.Dependency
{
public static class AsyncLoggerProxy
{
private static bool? _enabled;
public static bool Enabled
{
get
{
if (_enabled.HasValue)
{
return _enabled.Value;
}
try
{
_enabled = isDbEnabled();
}
catch (Exception)
{
_enabled = false;
return false;
}
return _enabled.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void WriteEvent(string source, string tag, string data, DateTime? timestamp = null)
{
SqliteLogger.WriteEvent(source, tag, data, timestamp);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void WriteData(string source, string tag, string data, DateTime? timestamp = null)
{
SqliteLogger.WriteData(source, tag, data, timestamp);
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static bool isDbEnabled()
{
return SqliteLogger.Enabled;
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static int getExecutionID()
{
return SqliteLogger.ExecutionId;
}
}
public static class LobbyCompatibilityChecker
{
public static bool Enabled => Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility");
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
public static void Init()
{
PluginHelper.RegisterPlugin("mattymatty.ImmovablePlayers", Version.Parse("1.0.0"), (CompatibilityLevel)1, (VersionStrictness)0);
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}