Decompiled source of RepoNetworkFix v1.0.0

RepoNetworkFix.dll

Decompiled 3 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
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: AssemblyVersion("0.0.0.0")]
[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 RepoNetworkFix
{
	[BepInPlugin("com.antigravity.reponetworkfix", "RepoNetworkFix", "1.0.0")]
	public class RepoNetworkFixPlugin : BaseUnityPlugin
	{
		public static RepoNetworkFixPlugin Instance;

		private static float deltaTime = 0f;

		private GUIStyle guiStyle = new GUIStyle();

		public static readonly Dictionary<float, WaitForSeconds> YieldPool = new Dictionary<float, WaitForSeconds>();

		private static readonly List<Action> TickQueue = new List<Action>();

		private static readonly StringBuilder HullStringBuilder = new StringBuilder(256);

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			new Harmony("com.antigravity.reponetworkfix").PatchAll();
			guiStyle.fontSize = 18;
			guiStyle.fontStyle = (FontStyle)1;
			guiStyle.normal.textColor = Color.white;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RepoNetworkFix v1.0.0: Система запущена.");
		}

		public static void Log(string msg)
		{
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)msg);
		}

		public static WaitForSeconds GetWait(float seconds)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!YieldPool.TryGetValue(seconds, out var value))
			{
				value = new WaitForSeconds(seconds);
				YieldPool[seconds] = value;
			}
			return value;
		}

		private void Update()
		{
			deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
			for (int i = 0; i < TickQueue.Count; i++)
			{
				TickQueue[i]?.Invoke();
			}
		}

		private void OnGUI()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			if (PhotonNetwork.InRoom)
			{
				float num = 1f / deltaTime;
				HullStringBuilder.Clear();
				HullStringBuilder.Append("FPS: ").Append(num.ToString("0")).Append(" | Ping: ")
					.Append(PhotonNetwork.GetPing())
					.Append(" ms | v1.0.0");
				guiStyle.normal.textColor = ((PhotonNetwork.GetPing() > 100) ? Color.yellow : Color.white);
				GUI.Label(new Rect(15f, 15f, 800f, 30f), HullStringBuilder.ToString(), guiStyle);
			}
		}

		public static void SendGrandpaChat(string msg)
		{
			//IL_0020: 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)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				SemiFunc.UIBigMessage("Дед: " + msg, "\ud83d\udc74", 2.5f, Color.red, Color.yellow);
			}
		}
	}
	public static class PeakProxy
	{
		private static Camera _mainCam;

		private static readonly ConditionalWeakTable<GameObject, Transform> TransformCache = new ConditionalWeakTable<GameObject, Transform>();

		public static Camera MainCamera
		{
			get
			{
				if ((Object)(object)_mainCam == (Object)null)
				{
					_mainCam = Camera.main;
				}
				return _mainCam;
			}
		}

		public static Transform GetTransform(GameObject go)
		{
			if (!TransformCache.TryGetValue(go, out var value))
			{
				value = go.transform;
				TransformCache.Add(go, value);
			}
			return value;
		}
	}
	public static class Accessors
	{
		public static readonly FieldRef<Enemy, float> GetEnemyHealth = AccessTools.FieldRefAccess<Enemy, float>("Health");

		public static readonly FieldRef<ValuableDirector, List<GameObject>> GetMediumPool = AccessTools.FieldRefAccess<ValuableDirector, List<GameObject>>("mediumValuables");

		public static readonly FieldRef<ValuableDirector, List<GameObject>> GetBigPool = AccessTools.FieldRefAccess<ValuableDirector, List<GameObject>>("bigValuables");

		public static readonly FieldRef<EnemyHunter, object> GetInvestigatePoint = AccessTools.FieldRefAccess<EnemyHunter, object>("investigatePoint");
	}
	[HarmonyPatch(typeof(MonoBehaviour), "StartCoroutine", new Type[] { typeof(IEnumerator) })]
	public static class CoroutinePurgePatch
	{
		[HarmonyPrefix]
		public static bool Prefix(MonoBehaviour __instance, ref IEnumerator routine)
		{
			return true;
		}
	}
	[HarmonyPatch(typeof(SemiFunc), "UIWorldToCanvasPosition")]
	public static class FastWorldPosPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(ref Vector2 __result, Vector3 worldPosition)
		{
			Camera mainCamera = PeakProxy.MainCamera;
			if ((Object)(object)mainCamera == (Object)null)
			{
				return true;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(EnemyHunter), "UpdateState")]
	public static class SupremeGrandpaPatch
	{
		[HarmonyPrefix]
		public static void Prefix(EnemyHunter __instance)
		{
			//IL_0030: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Enemy component = ((Component)__instance).GetComponent<Enemy>();
			if (!((Object)(object)component == (Object)null))
			{
				float num = Accessors.GetEnemyHealth.Invoke(component);
				if (num < 50f && ((Component)__instance).transform.localScale.x > 0.51f)
				{
					((Component)__instance).transform.localScale = Vector3.Lerp(((Component)__instance).transform.localScale, new Vector3(0.5f, 0.5f, 0.5f), Time.deltaTime);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Light), "OnPreRender")]
	public static class SupremeShadowPatch
	{
		[HarmonyPrefix]
		public static void Prefix(Light __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.type == 2 || (int)__instance.type == 0)
			{
				float num;
				if (!((Object)(object)PeakProxy.MainCamera != (Object)null))
				{
					num = 0f;
				}
				else
				{
					Vector3 val = ((Component)PeakProxy.MainCamera).transform.position - ((Component)__instance).transform.position;
					num = ((Vector3)(ref val)).sqrMagnitude;
				}
				float num2 = num;
				if (num2 > 225f)
				{
					__instance.shadows = (LightShadows)0;
				}
				else if (num2 < 100f)
				{
					__instance.shadows = (LightShadows)2;
				}
			}
		}
	}
	[HarmonyPatch(typeof(MenuPageServerList), "ButtonCreateNew")]
	public static class SupremeLobbyPatch
	{
		[HarmonyPostfix]
		public static void Postfix()
		{
			if (PhotonNetwork.CurrentRoom != null)
			{
				PhotonNetwork.CurrentRoom.MaxPlayers = 30;
				PhotonNetwork.CurrentRoom.IsOpen = true;
				PhotonNetwork.CurrentRoom.IsVisible = true;
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")]
	public static class SupremePhysPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(PhysGrabObject __instance)
		{
			if (__instance.grabbedLocal || __instance.playerGrabbing.Count > 0)
			{
				return true;
			}
			if (Time.frameCount % 4 != ((Object)((Component)__instance).gameObject).GetInstanceID() % 4)
			{
				return false;
			}
			return (Object)(object)__instance.rb != (Object)null && !__instance.rb.IsSleeping();
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "OnPhotonSerializeView")]
	public static class FinalDeltaSyncPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(PlayerAvatar __instance, PhotonStream stream)
		{
			if (stream.IsWriting)
			{
				return true;
			}
			return true;
		}
	}
}