using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using BepInEx.Logging;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ModList;
using SteamworksNative;
using UnhollowerBaseLib;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 FloatingPlayerPatch
{
internal static class ModListCompatibility
{
internal const string GUID = "lammas123.ModList";
internal static bool? enabled;
internal static bool Enabled
{
get
{
if (enabled.HasValue)
{
return enabled.Value;
}
bool? flag = (enabled = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("lammas123.ModList"));
return flag.Value;
}
}
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
internal static void AddMod(string guid, bool required = false)
{
Api.AddMod(guid, required);
}
}
internal static class Patches
{
[HarmonyPatch(typeof(MonoBehaviourPublicGataInefObInUnique), "Method_Private_Void_GameObject_Boolean_Vector3_Quaternion_0")]
[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "Method_Private_Void_0")]
[HarmonyPrefix]
internal static bool PreBepinexDetection()
{
return false;
}
[HarmonyPatch(typeof(MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique), "PlayerPosition")]
[HarmonyPostfix]
internal static void PostServerHandlePlayerPosition(ulong param_0, ObjectPublicIDisposableLi1ByInByBoUnique param_1)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
{
MonoBehaviourPublicInInUnique.PlayerPosition(param_0, new Vector3(BitConverter.ToSingle(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 8), BitConverter.ToSingle(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 12), BitConverter.ToSingle(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 16)));
}
}
[HarmonyPatch(typeof(MonoBehaviourPublicPlVoUI9GaVoUI9UsPlUnique), "PlayerRotation")]
[HarmonyPostfix]
internal static void PostServerHandlePlayerRotation(ulong param_0, ObjectPublicIDisposableLi1ByInByBoUnique param_1)
{
if (MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
{
MonoBehaviourPublicInInUnique.PlayerRotation(param_0, BitConverter.ToSingle(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 8), BitConverter.ToSingle(Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)param_1.field_Private_ArrayOf_Byte_0), 12));
}
}
[HarmonyPatch(typeof(MonoBehaviourPublicTrrocaTrInSiVeSipoObUnique), "Method_Private_Void_Vector3_EnumNPublicSealedvaClMeFaAn5vUnique_0")]
[HarmonyPrefix]
internal static void PrePlayerCommunicationUpdatePosition(MonoBehaviourPublicTrrocaTrInSiVeSipoObUnique __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
{
__instance.idToDistance[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_1.m_SteamID] = (EnumNPublicSealedvaClMeFaAn5vUnique)0;
}
}
[HarmonyPatch(typeof(MonoBehaviourPublicTrrocaTrInSiVeSipoObUnique), "Method_Private_Void_Single_Single_EnumNPublicSealedvaClMeFaAn5vUnique_0")]
[HarmonyPrefix]
internal static void PrePlayerCommunicationUpdateRotation(MonoBehaviourPublicTrrocaTrInSiVeSipoObUnique __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner())
{
__instance.idToDistance[MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_1.m_SteamID] = (EnumNPublicSealedvaClMeFaAn5vUnique)0;
}
}
[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "StartLobby")]
[HarmonyPatch(typeof(MonoBehaviourPublicCSDi2UIInstObUIloDiUnique), "StartPracticeLobby")]
[HarmonyPostfix]
internal static void PostLobbyManagerStartLobby()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
SteamMatchmaking.SetLobbyData(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.currentLobby, "lammas123.FloatingPlayerPatch", "1.3.0");
}
}
internal static class OnlyConnectToHostPatches
{
[CompilerGenerated]
private sealed class <TryEnterGame>d__0 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TryEnterGame>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.Method_Private_Void_PDM_1();
if (Object.op_Implicit((Object)(object)MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance) && !ShouldSend(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_0.m_SteamID))
{
Enumerator<ulong, MonoBehaviourPublicCSstReshTrheObplBojuUnique> enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.activePlayers.Keys.GetEnumerator();
while (enumerator.MoveNext())
{
ulong current = enumerator.Current;
if (current != MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_1.m_SteamID)
{
MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.StopP2P(new CSteamID(current));
}
}
enumerator = MonoBehaviourPublicDi2UIObacspDi2UIObUnique.Instance.spectators.Keys.GetEnumerator();
while (enumerator.MoveNext())
{
ulong current2 = enumerator.Current;
if (current2 != MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_1.m_SteamID)
{
MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.StopP2P(new CSteamID(current2));
}
}
}
}
else
{
<>1__state = -1;
}
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[IteratorStateMachine(typeof(<TryEnterGame>d__0))]
internal static IEnumerator TryEnterGame()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TryEnterGame>d__0(0);
}
internal static bool ShouldSend(ulong clientId)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if (!MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.IsLobbyOwner() && !string.IsNullOrEmpty(SteamMatchmaking.GetLobbyData(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.currentLobby, "lammas123.FloatingPlayerPatch")))
{
return clientId == MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.field_Private_CSteamID_1.m_SteamID;
}
return true;
}
[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "OnEnable")]
[HarmonyPrefix]
internal static bool PreSteamManagerOnEnable()
{
MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance, TryEnterGame());
return false;
}
[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "NewAcceptP2P", new Type[] { typeof(CSteamID) })]
[HarmonyPrefix]
internal static bool PreSteamManagerNewAcceptP2P(CSteamID param_1)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return ShouldSend(param_1.m_SteamID);
}
[HarmonyPatch(typeof(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique), "NewAcceptP2P", new Type[] { typeof(SteamNetworkingIdentity) })]
[HarmonyPrefix]
internal static bool PreSteamManagerNewAcceptP2P(SteamNetworkingIdentity param_1)
{
return ShouldSend(param_1.GetSteamID64());
}
[HarmonyPatch(typeof(MonoBehaviourPublicInpabyInInInUnique), "HandShake")]
[HarmonyPrefix]
internal static bool PreClientSendHandShake(ulong param_0)
{
return ShouldSend(param_0);
}
[HarmonyPatch(typeof(MonoBehaviourPublicInpabyInInInUnique), "PlayerPosition")]
[HarmonyPrefix]
internal static bool PreClientSendPlayerPosition(ulong param_1)
{
return ShouldSend(param_1);
}
[HarmonyPatch(typeof(MonoBehaviourPublicInpabyInInInUnique), "PlayerRotation")]
[HarmonyPrefix]
internal static bool PreClientSendPlayerRotation(ulong param_2)
{
return ShouldSend(param_2);
}
}
[BepInPlugin("lammas123.FloatingPlayerPatch", "FloatingPlayerPatch", "1.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class FloatingPlayerPatch : BasePlugin
{
internal static FloatingPlayerPatch Instance { get; private set; }
public override void Load()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Expected O, but got Unknown
CultureInfo.CurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;
CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;
Instance = this;
if (ModListCompatibility.Enabled)
{
ModListCompatibility.AddMod("lammas123.FloatingPlayerPatch");
}
Harmony val = new Harmony("FloatingPlayerPatch");
val.PatchAll(typeof(Patches));
if (((BasePlugin)this).Config.Bind<bool>("FloatingPlayerPatch", "OnlyEstablishConnectionWithHostAsClient", false, "This will make you only establish a connection with the host, if that host is sharing that they have FloatingPlayerPatch via ModList. This may allow you to join the game a bit faster (as you won't have to establish a bunch of pointless connections) and will make you not send any packets to any other players besides the host, saving some bandwidth. This will also only make you accept player position and rotation packets from the host, meaning that no one can lie to you about their positon.").Value)
{
val.PatchAll(typeof(OnlyConnectToHostPatches));
}
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(15, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Initialized [");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("FloatingPlayerPatch");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.3.0");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("]");
}
log.LogInfo(val2);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "lammas123.FloatingPlayerPatch";
public const string PLUGIN_NAME = "FloatingPlayerPatch";
public const string PLUGIN_VERSION = "1.3.0";
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}