Decompiled source of RepoOptimizer v1.0.0

RepoOptimizer.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Logging;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.Scripting;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RepoOptimizationMod;

[BepInPlugin("com.yourname.repo.optimization", "RepoOptimizer Ultra", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ManualLogSource Log;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		Log.LogInfo((object)"!!! [RepoOptimizer Ultra] Мега-сборка успешно запущена! !!!");
		GarbageCollector.GCMode = (Mode)1;
		SceneManager.sceneLoaded += OnSceneLoaded;
		((MonoBehaviour)this).StartCoroutine(CullPhysicsAndGraphicsRoutine());
	}

	private void Start()
	{
		ApplyGlobalSettings();
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		ApplyGlobalSettings();
		OptimizeCamera();
		ExecuteDeepClean();
		((MonoBehaviour)this).StartCoroutine(DrawInterfaceWithDelayRoutine());
	}

	private void ApplyGlobalSettings()
	{
		Application.targetFrameRate = 144;
		QualitySettings.vSyncCount = 0;
		QualitySettings.antiAliasing = 0;
		QualitySettings.anisotropicFiltering = (AnisotropicFiltering)0;
		QualitySettings.pixelLightCount = 1;
		QualitySettings.shadowCascades = 1;
		QualitySettings.shadowDistance = 15f;
		QualitySettings.globalTextureMipmapLimit = 0;
		QualitySettings.particleRaycastBudget = 4;
		Time.fixedDeltaTime = 0.033f;
	}

	private void OptimizeCamera()
	{
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)null)
		{
			main.farClipPlane = 45f;
		}
	}

	private IEnumerator DrawInterfaceWithDelayRoutine()
	{
		yield return (object)new WaitForSeconds(2f);
		try
		{
			Assembly assembly = Assembly.GetExecutingAssembly();
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly2 in assemblies)
			{
				if (assembly2.FullName.Contains("Assembly-CSharp"))
				{
					assembly = assembly2;
					break;
				}
			}
			Type type = assembly.GetType("MenuAPI");
			if (type != null)
			{
				MethodInfo method = type.GetMethod("CreateREPOLabel", new Type[3]
				{
					typeof(string),
					typeof(Transform),
					typeof(Vector2)
				});
				if (method != null)
				{
					method.Invoke(null, new object[3]
					{
						"<color=green><b>REPO OPTIMIZER: ACTIVE</b></color>",
						null,
						(object)new Vector2(20f, 20f)
					});
					Log.LogInfo((object)"[RepoOptimizer] Официальная надпись успешно создана через MenuAPI игры!");
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("Не удалось вызвать MenuAPI (возможно, сцена еще не готова): " + ex.Message));
		}
	}

	private IEnumerator CullPhysicsAndGraphicsRoutine()
	{
		yield return (object)new WaitForSeconds(5f);
		while (true)
		{
			Camera mainCam = Camera.main;
			if ((Object)(object)mainCam != (Object)null)
			{
				Vector3 position = ((Component)mainCam).transform.position;
				Rigidbody[] array = Object.FindObjectsOfType<Rigidbody>();
				Rigidbody[] array2 = array;
				foreach (Rigidbody val in array2)
				{
					if (!((Object)(object)val == (Object)null) && !val.isKinematic)
					{
						float num = Vector3.Distance(position, ((Component)val).transform.position);
						int num2;
						if (num > 35f)
						{
							Vector3 velocity = val.velocity;
							num2 = ((!(((Vector3)(ref velocity)).sqrMagnitude < 0.1f)) ? 1 : 0);
						}
						else
						{
							num2 = 1;
						}
						if (num2 == 0)
						{
							val.Sleep();
						}
					}
				}
				MeshRenderer[] array3 = Object.FindObjectsOfType<MeshRenderer>();
				MeshRenderer[] array4 = array3;
				foreach (MeshRenderer val2 in array4)
				{
					if ((Object)(object)val2 == (Object)null)
					{
						continue;
					}
					float num = Vector3.Distance(position, ((Component)val2).transform.position);
					if (num > 25f)
					{
						if ((int)((Renderer)val2).shadowCastingMode != 0)
						{
							((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
							((Renderer)val2).receiveShadows = false;
						}
					}
					else if ((int)((Renderer)val2).shadowCastingMode == 0)
					{
						((Renderer)val2).shadowCastingMode = (ShadowCastingMode)1;
						((Renderer)val2).receiveShadows = true;
					}
				}
			}
			yield return (object)new WaitForSeconds(3f);
		}
	}

	private void ExecuteDeepClean()
	{
		try
		{
			Resources.UnloadUnusedAssets();
			GC.Collect();
		}
		catch (Exception)
		{
		}
	}

	private void OnDestroy()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}
}