Decompiled source of FramePerSecondPlus v1.1.0

vsp.FramePerSecondPlus.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("FramePerSecondPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FramePerSecondPlus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e8413e90-900c-4622-86e9-34dd746fc473")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FramePerSecondPlus;

[BepInPlugin("vsp.FramePerSecondPlus", "FramePerSecondPlus", "1.1.0")]
public class Class1 : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ClutterSystem), "Awake")]
	private static class ClutterSystem_Awake_Patch
	{
		private static void Prefix(ClutterSystem __instance)
		{
			__instance.m_grassPatchSize = 20f;
		}
	}

	[HarmonyPatch(typeof(LightFlicker), "Update")]
	private class LightFlicker_Update_Patch : MonoBehaviour
	{
		private static bool Prefix(LightFlicker __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)__instance.m_light))
			{
				return false;
			}
			if (Settings.ReduceFlashingLights)
			{
				if ((int)__instance.m_flashingLightingsAccessibility == 2)
				{
					__instance.m_light.intensity = 0f;
					return false;
				}
				if ((int)__instance.m_flashingLightingsAccessibility == 3)
				{
					__instance.m_light.intensity = 1f;
					return false;
				}
			}
			__instance.m_light.intensity = __instance.m_baseIntensity;
			return false;
		}
	}

	[HarmonyPatch(typeof(SceneLoader), "Start")]
	private class SceneLoaderOff
	{
		private static void Prefix(SceneLoader __instance)
		{
			__instance._showLogos = !skipIntro.Value;
		}
	}

	[HarmonyPatch(typeof(Smoke), "CustomUpdate")]
	private class SlowUpdaterFix
	{
		private static bool Prefix(Smoke __instance, float deltaTime)
		{
			//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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			__instance.m_time += deltaTime;
			float num = 1f - Mathf.Clamp01(__instance.m_time / __instance.m_ttl);
			__instance.m_body.mass = num * num;
			Vector3 velocity = __instance.m_body.velocity;
			Vector3 val = __instance.m_vel - velocity;
			__instance.m_body.AddForce(val * __instance.m_force * deltaTime, (ForceMode)2);
			if (__instance.m_fadeTimer >= 0f)
			{
				__instance.m_fadeTimer += deltaTime;
				if (__instance.m_fadeTimer >= __instance.m_fadetime)
				{
					Object.Destroy((Object)(object)((Component)__instance).gameObject);
				}
			}
			if (__instance.m_time <= 1f || __instance.m_fadeTimer > 0f)
			{
				Color color = __instance.m_propertyBlock.GetColor(Smoke.m_colorProp);
				color.a = __instance.m_alpha;
				__instance.m_propertyBlock.SetColor(Smoke.m_colorProp, color);
				((Renderer)__instance.m_mr).SetPropertyBlock(__instance.m_propertyBlock);
			}
			return false;
		}
	}

	private static Thread thread;

	private static ManualLogSource Log;

	private string[] names = new string[6] { "piece_groundtorch", "piece_groundtorch_blue", "piece_groundtorch_green", "piece_groundtorch_mist", "piece_groundtorch_wood", "piece_walltorch" };

	private static ConfigEntry<bool> skipIntro;

	private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description)
	{
		return ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description);
	}

	private void ConfigAdd()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		skipIntro = config("General", "SkipIntro", value: true, new ConfigDescription("Skip the game logo to speed up the loading of the game", (AcceptableValueBase)null, Array.Empty<object>()));
	}

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		ConfigAdd();
		Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		QualitySettings.realtimeReflectionProbes = false;
		QualitySettings.softParticles = false;
		QualitySettings.particleRaycastBudget = 1024;
		QualitySettings.softVegetation = false;
		PrefabManager.OnPrefabsRegistered += Awk;
	}

	private void Awk()
	{
		for (int i = 0; i < names.Length; i++)
		{
			Torch(PrefabManager.Instance.GetPrefab(names[i]));
		}
	}

	private void Torch(GameObject gameObject)
	{
		string text = "fx_Torch_Basic";
		if (((Object)gameObject).name == "piece_groundtorch_blue")
		{
			text = "fx_Torch_Blue";
		}
		else if (((Object)gameObject).name == "piece_groundtorch_green")
		{
			text = "fx_Torch_Green";
		}
		else if (((Object)gameObject).name == "piece_groundtorch_mist")
		{
			text = "sparcs_front";
		}
		ParticleSystem component = ((Component)ExposedGameObjectExtension.FindDeepChild(gameObject, text, (IterativeSearchType)1)).GetComponent<ParticleSystem>();
		component.startLifetime = 0.2f;
		component.gravityModifier = -0.3f;
	}
}