Decompiled source of OptmizationMod v1.0.2

Antro.Optimization.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Antro.Optimization")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.Optimization")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.Optimization")]
[assembly: AssemblyTitle("Antro.Optimization")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 GnomeOptimization
{
	[BepInPlugin("nos.optimization.mod", "Gnome Safe GPU Fix", "1.4.0")]
	public class OptimizationPlugin : BaseUnityPlugin
	{
		private Harmony harmony;

		private void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			harmony = new Harmony("nos.optimization.mod");
			harmony.PatchAll();
			((MonoBehaviour)this).StartCoroutine(AggressiveFPSLock());
			((MonoBehaviour)this).StartCoroutine(OptimizationRoutine());
			((MonoBehaviour)this).StartCoroutine(SafeParticleCullingRoutine());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Optimization Mod] V5 Loaded! Reverted aggressive culling and blur. 100% Visual Safe Mode.");
		}

		private IEnumerator AggressiveFPSLock()
		{
			while (true)
			{
				if (QualitySettings.vSyncCount != 0)
				{
					QualitySettings.vSyncCount = 0;
				}
				if (Application.targetFrameRate != 60)
				{
					Application.targetFrameRate = 60;
				}
				yield return (object)new WaitForSeconds(2f);
			}
		}

		private IEnumerator OptimizationRoutine()
		{
			while (true)
			{
				RealtimeReflection[] array = Object.FindObjectsByType<RealtimeReflection>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				foreach (RealtimeReflection rr in array)
				{
					((Behaviour)rr).enabled = false;
				}
				PlanarReflectionsSM_LWRP[] array2 = Object.FindObjectsByType<PlanarReflectionsSM_LWRP>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				foreach (PlanarReflectionsSM_LWRP pr in array2)
				{
					((Behaviour)pr).enabled = false;
				}
				PlanarRefractionsSM_LWRP[] array3 = Object.FindObjectsByType<PlanarRefractionsSM_LWRP>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				foreach (PlanarRefractionsSM_LWRP pRef in array3)
				{
					((Behaviour)pRef).enabled = false;
				}
				ORION_SkyMaster_Controller[] array4 = Object.FindObjectsByType<ORION_SkyMaster_Controller>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				foreach (ORION_SkyMaster_Controller clouds in array4)
				{
					((Behaviour)clouds).enabled = false;
				}
				yield return (object)new WaitForSeconds(5f);
			}
		}

		private IEnumerator SafeParticleCullingRoutine()
		{
			while (true)
			{
				ParticleSystem[] particles = Object.FindObjectsByType<ParticleSystem>((FindObjectsInactive)0, (FindObjectsSortMode)0);
				ParticleSystem[] array = particles;
				foreach (ParticleSystem ps in array)
				{
					MainModule main = ps.main;
					if ((int)((MainModule)(ref main)).cullingMode == 3)
					{
						((MainModule)(ref main)).cullingMode = (ParticleSystemCullingMode)1;
					}
					main = default(MainModule);
				}
				yield return (object)new WaitForSeconds(10f);
			}
		}
	}
	[HarmonyPatch(typeof(volumeLightStreamerSM), "Update")]
	internal static class OptimizeLightsPatch
	{
		[HarmonyPrefix]
		private static void Prefix(volumeLightStreamerSM __instance)
		{
			if (__instance.maxLightsCount > 4)
			{
				__instance.maxLightsCount = 4;
			}
		}
	}
	[HarmonyPatch(typeof(RealtimeReflection), "Update")]
	internal static class StopReflectionSpamPatch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PlanarReflectionsSM_LWRP), "DoReflections")]
	internal static class StopPlanarReflectionsPatch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(PlanarRefractionsSM_LWRP), "DoReflections")]
	internal static class StopPlanarRefractionsPatch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
	[HarmonyPatch(typeof(ORION_SkyMaster_Controller), "Update")]
	internal static class StopSkyMasterPatch
	{
		[HarmonyPrefix]
		private static bool Prefix()
		{
			return false;
		}
	}
}