Decompiled source of REPONetworkTweaks v1.0.3

plugins/REPONetworkTweaks.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("REPONetworkTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("REPONetworkTweaks")]
[assembly: AssemblyCopyright("Copyright © BlueAmulet 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b71c6ed6-b7be-40af-a0ab-023cbc72986c")]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace REPONetworkTweaks
{
	public class PhotonTransformViewTweak : MonoBehaviour
	{
		private class TransformSnapshot
		{
			internal Vector3 position;

			internal Quaternion rotation;

			internal Vector3 velocity;

			internal Vector3 angularVelocity;

			internal TransformSnapshot(Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				this.position = position;
				this.rotation = rotation;
				this.velocity = velocity;
				this.angularVelocity = angularVelocity;
			}
		}

		private Rigidbody rigidBody;

		private PhotonTransformView photonTransformView;

		private PhysGrabHinge hinge;

		private Vector3 m_StoredPosition;

		private bool teleport;

		private bool isSleeping;

		private bool isKinematic;

		private Vector3 interpVelocity;

		private Vector3 interpAngularVelocity;

		private readonly LinkedList<TransformSnapshot> snapshots = new LinkedList<TransformSnapshot>();

		private TransformSnapshot prevSnapshot;

		private float interpolationStartTime = -1f;

		private float smoothUpdateFrequency = (float)PhotonNetwork.serializationFrequency / 1000f;

		private float lastSerializationFrequency = -1f;

		private int lastSendTimestamp;

		private bool haveFirstSend;

		private float interpFactor
		{
			get
			{
				if (!(smoothUpdateFrequency <= 0f) && !(interpolationStartTime < 0f))
				{
					return (Time.timeSinceLevelLoad - interpolationStartTime) / smoothUpdateFrequency;
				}
				return 1f;
			}
		}

		public void Awake()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			rigidBody = ((Component)this).GetComponent<Rigidbody>();
			photonTransformView = ((Component)this).GetComponent<PhotonTransformView>();
			hinge = ((Component)this).GetComponent<PhysGrabHinge>();
			m_StoredPosition = ((Component)this).transform.position;
		}

		public void OnEnable()
		{
			snapshots.Clear();
			prevSnapshot = null;
		}

		internal void Teleport(Vector3 _position, Quaternion _rotation)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			teleport = true;
			((Component)this).transform.position = _position;
			((Component)this).transform.rotation = _rotation;
			m_StoredPosition = _position;
			isSleeping = false;
			if (Object.op_Implicit((Object)(object)rigidBody))
			{
				rigidBody.position = _position;
				rigidBody.rotation = _rotation;
				rigidBody.WakeUp();
			}
		}

		private Vector3 HermiteInterpolatePosition(Vector3 startPos, Vector3 startVel, Vector3 endPos, Vector3 endVel, float interpolation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = startPos + startVel * (smoothUpdateFrequency * interpolation) / 3f;
			Vector3 val2 = endPos - endVel * (smoothUpdateFrequency * (1f - interpolation)) / 3f;
			return Vector3.Lerp(val, val2, interpolation);
		}

		private Quaternion HermiteInterpolateRotation(Quaternion startRot, Vector3 startSpin, Quaternion endRot, Vector3 endSpin, float interpolation)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = startRot * Quaternion.Euler(startSpin * (smoothUpdateFrequency * interpolation) / 3f);
			Quaternion val2 = endRot * Quaternion.Euler(endSpin * (-1f * smoothUpdateFrequency * (1f - interpolation)) / 3f);
			return Quaternion.Slerp(val, val2, interpolation);
		}

		public void Update()
		{
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)rigidBody))
			{
				rigidBody = ((Component)this).GetComponent<Rigidbody>();
			}
			Transform transform = ((Component)this).transform;
			if (PhotonNetwork.IsMasterClient)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)rigidBody))
			{
				rigidBody.isKinematic = true;
				rigidBody.interpolation = (RigidbodyInterpolation)0;
			}
			if (snapshots.Count < 1)
			{
				return;
			}
			while (interpFactor >= 1f && snapshots.Count > 1)
			{
				prevSnapshot = snapshots.First.Value;
				snapshots.RemoveFirst();
				interpolationStartTime += smoothUpdateFrequency;
			}
			if (snapshots.Count == 1)
			{
				TransformSnapshot value = snapshots.First.Value;
				if (prevSnapshot != null && Settings.Extrapolate.Value)
				{
					float num = 2f - Mathf.Pow(MathF.E, 0f - interpFactor);
					transform.position = value.position + Vector3.SlerpUnclamped(prevSnapshot.velocity, value.velocity, num) * ((num - 1f) * smoothUpdateFrequency);
					transform.rotation = Quaternion.SlerpUnclamped(prevSnapshot.rotation, value.rotation, num);
				}
				else
				{
					transform.position = value.position;
					transform.rotation = value.rotation;
				}
				interpVelocity = value.velocity;
				interpAngularVelocity = value.angularVelocity;
			}
			else
			{
				LinkedListNode<TransformSnapshot>? first = snapshots.First;
				TransformSnapshot value2 = first.Value;
				TransformSnapshot value3 = first.Next.Value;
				transform.position = HermiteInterpolatePosition(value2.position, value2.velocity, value3.position, value3.velocity, interpFactor);
				transform.rotation = HermiteInterpolateRotation(value2.rotation, value2.angularVelocity, value3.rotation, value3.angularVelocity, interpFactor);
				interpVelocity = Vector3.Slerp(value2.velocity, value3.velocity, interpFactor);
				interpAngularVelocity = Vector3.Lerp(value2.angularVelocity, value3.angularVelocity, interpFactor);
			}
		}

		internal void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			if (stream.IsWriting)
			{
				stream.SendNext((object)rigidBody.IsSleeping());
				stream.SendNext((object)teleport);
				teleport = false;
				isKinematic = rigidBody.isKinematic;
				stream.SendNext((object)isKinematic);
				stream.SendNext((object)rigidBody.velocity);
				stream.SendNext((object)rigidBody.angularVelocity);
				Vector3 val = transform.position - m_StoredPosition;
				m_StoredPosition = transform.position;
				stream.SendNext((object)transform.position);
				stream.SendNext((object)val);
				stream.SendNext((object)transform.rotation);
				return;
			}
			if (!Object.op_Implicit((Object)(object)rigidBody))
			{
				rigidBody = ((Component)this).GetComponent<Rigidbody>();
			}
			isSleeping = (bool)stream.ReceiveNext();
			if (isSleeping)
			{
				rigidBody.Sleep();
			}
			else
			{
				rigidBody.WakeUp();
			}
			teleport = (bool)stream.ReceiveNext();
			isKinematic = (bool)stream.ReceiveNext();
			Vector3 velocity = (Vector3)stream.ReceiveNext();
			Vector3 angularVelocity = (Vector3)stream.ReceiveNext();
			Vector3 position = (Vector3)stream.ReceiveNext();
			Vector3 val2 = (Vector3)stream.ReceiveNext();
			Quaternion rotation = (Quaternion)stream.ReceiveNext();
			if ((Object)(object)hinge != (Object)null && !hinge.broken)
			{
				velocity = ((!haveFirstSend) ? (val2 / smoothUpdateFrequency) : (val2 / (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) * 1000f));
			}
			if (teleport)
			{
				snapshots.Clear();
				prevSnapshot = null;
			}
			float num = Mathf.Max(Settings.Future.Value * smoothUpdateFrequency, 0f);
			TransformSnapshot transformSnapshot = new TransformSnapshot(position, rotation, velocity, angularVelocity);
			if (snapshots.Count > 0 && (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) / 1000f < Settings.TimingThreshold.Value)
			{
				TransformSnapshot value = snapshots.Last.Value;
				Vector3 val3 = (transformSnapshot.velocity - value.velocity) / smoothUpdateFrequency;
				transformSnapshot.position += transformSnapshot.velocity * num + 0.5f * val3 * num * num;
				Vector3 val4 = (transformSnapshot.angularVelocity - value.angularVelocity) / smoothUpdateFrequency;
				Quaternion val5 = Quaternion.Euler((transformSnapshot.angularVelocity + val4 * num) * num);
				transformSnapshot.rotation *= val5;
			}
			else
			{
				transformSnapshot.position += transformSnapshot.velocity * num;
				transformSnapshot.rotation *= Quaternion.Euler(transformSnapshot.angularVelocity * num);
			}
			snapshots.AddLast(transformSnapshot);
			if (snapshots.Count == 2)
			{
				interpolationStartTime = Time.timeSinceLevelLoad;
			}
			else if (snapshots.Count >= 4)
			{
				snapshots.RemoveFirst();
				TransformSnapshot value2 = snapshots.First.Value;
				value2.position = transform.position;
				value2.rotation = transform.rotation;
				value2.velocity = interpVelocity;
				value2.angularVelocity = interpAngularVelocity;
				interpolationStartTime = Time.timeSinceLevelLoad;
			}
			if (haveFirstSend)
			{
				lastSerializationFrequency = (float)(((PhotonMessageInfo)(ref info)).SentServerTimestamp - lastSendTimestamp) / 1000f;
				if (lastSerializationFrequency >= Settings.TimingThreshold.Value)
				{
					lastSerializationFrequency = (float)PhotonNetwork.serializationFrequency / 1000f;
					smoothUpdateFrequency = lastSerializationFrequency;
				}
				else
				{
					smoothUpdateFrequency = Mathf.Lerp(smoothUpdateFrequency, lastSerializationFrequency, Settings.RateSmoothing.Value);
				}
			}
			else
			{
				haveFirstSend = true;
			}
			lastSendTimestamp = ((PhotonMessageInfo)(ref info)).SentServerTimestamp;
		}
	}
	[BepInPlugin("BlueAmulet.REPONetworkTweaks", "REPONetworkTweaks", "1.0.3")]
	public class REPONetworkTweaks : BaseUnityPlugin
	{
		internal const string Name = "REPONetworkTweaks";

		internal const string Author = "BlueAmulet";

		internal const string ID = "BlueAmulet.REPONetworkTweaks";

		internal const string Version = "1.0.3";

		internal static ManualLogSource Log;

		public void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			Settings.InitConfig(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("BlueAmulet.REPONetworkTweaks");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying Harmony patches");
			val.PatchAll(Assembly.GetExecutingAssembly());
			int num = 0;
			foreach (MethodBase patchedMethod in val.GetPatchedMethods())
			{
				_ = patchedMethod;
				num++;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)(num + " patches applied"));
		}
	}
	internal static class Settings
	{
		internal static ConfigEntry<bool> DisableTimeout;

		internal static ConfigEntry<bool> PhotonLateUpdate;

		internal static ConfigEntry<bool> Extrapolate;

		internal static ConfigEntry<float> RateSmoothing;

		internal static ConfigEntry<float> Future;

		internal static ConfigEntry<float> TimingThreshold;

		public static void InitConfig(ConfigFile config)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			DisableTimeout = config.Bind<bool>("NetworkTweaks", "DisableTimeout", true, "Remove client sided Photon timeout");
			PhotonLateUpdate = config.Bind<bool>("NetworkTweaks", "PhotonLateUpdate", true, "Run Photon networking in LateUpdate instead of FixedUpdate");
			Extrapolate = config.Bind<bool>("NetworkTweaks", "Extrapolate", true, "Extrapolate position and rotations when out of data");
			RateSmoothing = config.Bind<float>("NetworkTweaks", "RateSmoothing", 0.1f, new ConfigDescription("How much to smooth the guessed sending rate", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			Future = config.Bind<float>("NetworkTweaks", "Future", 1f, new ConfigDescription("How much to project data into the future", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			TimingThreshold = config.Bind<float>("NetworkTweaks", "TimingThreshold", 1f, "Threshold in seconds for when data is considered discontinuous");
		}
	}
}
namespace REPONetworkTweaks.Patches
{
	[HarmonyPatch(typeof(PhotonHandler))]
	internal static class PhotonHandlerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Awake")]
		public static void PrefixAwake()
		{
			if (Settings.PhotonLateUpdate.Value)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Changing PhotonHandler to run in LateUpdate");
				PhotonNetwork.MinimalTimeScaleToDispatchInFixedUpdate = float.PositiveInfinity;
			}
		}
	}
	[HarmonyPatch(typeof(PhotonTransformView))]
	internal static class PhotonTransformViewPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		public static void PostfixAwake(ref PhotonTransformView __instance)
		{
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).gameObject.AddComponent<PhotonTransformViewTweak>();
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("OnPhotonSerializeView")]
		public static bool PrefixOnPhotonSerializeView(ref PhotonTransformView __instance, PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).GetComponent<PhotonTransformViewTweak>().OnPhotonSerializeView(stream, info);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Teleport")]
		public static bool PrefixTeleport(ref PhotonTransformView __instance, Vector3 _position, Quaternion _rotation)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				((Component)__instance).GetComponent<PhotonTransformViewTweak>().Teleport(_position, _rotation);
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("Update")]
		public static bool PrefixUpdate()
		{
			return !SemiFunc.IsMultiplayer();
		}
	}
	[HarmonyPatch]
	internal static class TimeoutDisconnectPatch
	{
		private static readonly MethodInfo debugOut = AccessTools.PropertyGetter(typeof(PeerBase), "debugOut");

		private static readonly MethodInfo EnqueueStatusCallback = AccessTools.Method(typeof(PeerBase), "EnqueueStatusCallback", (Type[])null, (Type[])null);

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(EnetPeer), "SendOutgoingCommands")]
		internal static IEnumerable<CodeInstruction> TranspilerEnetPeer(IEnumerable<CodeInstruction> instructions)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			if (!Settings.DisableTimeout.Value)
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 1; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Call && (MethodInfo)val.operand == debugOut && list[i + 1].opcode == OpCodes.Ldc_I4_2 && list[i - 3].opcode == OpCodes.Brfalse)
				{
					list.Insert(i - 2, new CodeInstruction(OpCodes.Br, list[i - 3].operand));
					list[i - 3].opcode = OpCodes.Pop;
					list[i - 3].operand = null;
					flag = true;
					break;
				}
			}
			if (flag)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Removed TimeoutDisconnect from EnetPeer");
			}
			else
			{
				REPONetworkTweaks.Log.LogWarning((object)"Failed to locate patch to remove EnetPeer triggering TimeoutDisconnect");
			}
			return list;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(TPeer), "DispatchIncomingCommands")]
		internal static IEnumerable<CodeInstruction> TranspilerTPeer(IEnumerable<CodeInstruction> instructions)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			if (!Settings.DisableTimeout.Value)
			{
				return instructions;
			}
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 1; i < list.Count; i++)
			{
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Ldc_I4 && (int)val.operand == 1040 && list[i + 1].opcode == OpCodes.Call && (MethodInfo)list[i + 1].operand == EnqueueStatusCallback && list[i - 3].opcode == OpCodes.Brfalse)
				{
					list.Insert(i - 2, new CodeInstruction(OpCodes.Br, list[i - 3].operand));
					list[i - 3].opcode = OpCodes.Pop;
					list[i - 3].operand = null;
					flag = true;
					break;
				}
			}
			if (flag)
			{
				REPONetworkTweaks.Log.LogInfo((object)"Removed TimeoutDisconnect from TPeer");
			}
			else
			{
				REPONetworkTweaks.Log.LogWarning((object)"Failed to locate patch to remove TPeer triggering TimeoutDisconnect");
			}
			return list;
		}
	}
}