Decompiled source of FramePerSecondPlus v1.4.0

vsp.FramePerSecondPlus.dll

Decompiled 5 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 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FramePerSecondPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FramePerSecondPlus")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("29e9acb2-0bb6-4c4e-b615-90240624b221")]
[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.4.0")]
public class FramePerSecondPlus : BaseUnityPlugin
{
	[HarmonyPatch(typeof(ClutterSystem), "Awake")]
	private static class ClutterSystem_Awake_Patch
	{
		private static void Prefix(ClutterSystem __instance)
		{
			__instance.m_grassPatchSize = 20f;
		}
	}

	[HarmonyPatch(typeof(LightFlicker), "CustomUpdate")]
	private class LightFlicker_Update_Patch : MonoBehaviour
	{
		private static bool Prefix(LightFlicker __instance)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)__instance.m_light))
			{
				return false;
			}
			if (Settings.ReduceFlashingLights)
			{
				if ((int)__instance.m_flashingLightsSetting == 2)
				{
					__instance.m_light.intensity = 0f;
					return false;
				}
				if ((int)__instance.m_flashingLightsSetting == 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, float time)
		{
			//IL_0037: 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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			__instance.m_alpha = Mathf.Clamp01(__instance.m_time);
			__instance.m_time += deltaTime;
			__instance.m_body.mass = 0.75f;
			Vector3 velocity = __instance.m_body.velocity;
			Vector3 vel = __instance.m_vel;
			vel.y *= 0.75f;
			Vector3 val = vel - velocity;
			__instance.m_body.AddForce(val * (__instance.m_force * deltaTime), (ForceMode)2);
			if (__instance.m_fadeTimer >= 0f)
			{
				__instance.m_fadeTimer += deltaTime;
				__instance.m_alpha *= 0.5f;
				if (__instance.m_fadeTimer >= __instance.m_fadetime)
				{
					Object.Destroy((Object)(object)((Component)__instance).gameObject);
				}
			}
			if (__instance.m_added)
			{
				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 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_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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;
	}
}