Decompiled source of PerformanceEnhancer v1.3.6

BepInEx/plugins/PerformanceEnhancer.dll

Decompiled 10 months ago
using System;
using System.Diagnostics;
using System.IO;
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 HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SolarBooster")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SolarBooster")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1794c9e2-6213-4024-b55e-67f56da5b373")]
[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 SolarPerformanceEnhancer;

[BepInPlugin("Solar.Performance", "SolarPerformanceEnhancer", "1.3.6")]
public class PerformanceEnhancerStart : BaseUnityPlugin
{
	private const string modGUID = "Solar.Performance";

	private const string modName = "SolarPerformanceEnhancer";

	private const string modVersion = "1.3.6";

	private readonly Harmony harmony;

	public ConfigEntry<int> startingAmount;

	public static PerformanceEnhancerStart Instance;

	public bool init;

	private static bool OnGUIEnabled;

	private Rect windowRect;

	private float deltaTime;

	public string folderPath;

	private bool showFiles;

	private bool showPCSpecs;

	private bool showscreendisplay;

	private bool showappdisplay;

	private bool shownetworkinfo;

	private bool showtimeinfo;

	private bool showInfo = true;

	private bool showinputinfo;

	private bool showSceneinfo;

	private bool showotherinfo;

	public PerformanceEnhancerStart()
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: 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)
		//IL_0047: Expected O, but got Unknown
		folderPath = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\Lethal Company\\BepInEx\\plugins";
		windowRect = new Rect(20f, 20f, 280f, 350f);
		harmony = new Harmony("Solar.Performance");
	}

	private void OnGUI()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		Scene activeScene = SceneManager.GetActiveScene();
		new Rect((float)Screen.width - 220f, 20f, 195f, 500f);
		Mathf.RoundToInt(1f / deltaTime);
		Color val = default(Color);
		((Color)(ref val))..ctor(0f, 0.8f, 0f);
		new GUIStyle(GUI.skin.label).normal.textColor = val;
		int num = Mathf.RoundToInt(1f / Time.deltaTime);
		new Color(0f, 1f, 0f);
		DrawFormattedText(new Rect(10f, 10f, 200f, 30f), "FPS: {0}", val, 14, (FontStyle)1, num);
		if (((Scene)(ref activeScene)).name == "InitSceneLaunchOptions" || ((Scene)(ref activeScene)).name == "InitScene" || ((Scene)(ref activeScene)).name == "MainMenu")
		{
			GUILayout.Space(35f);
			GUILayout.Label("Note: Buttons Go Once In Game", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Display PC Specs", Array.Empty<GUILayoutOption>()))
			{
				showPCSpecs = !showPCSpecs;
			}
			if (showPCSpecs)
			{
				DisplayPCSpecs();
			}
			if (GUILayout.Button("Display App Info", Array.Empty<GUILayoutOption>()))
			{
				showappdisplay = !showappdisplay;
			}
			if (showappdisplay)
			{
				DisplayAppInfo();
			}
			if (GUILayout.Button("Display Screen Info", Array.Empty<GUILayoutOption>()))
			{
				showscreendisplay = !showscreendisplay;
			}
			if (showscreendisplay)
			{
				DisplayScreenTime();
			}
			if (GUILayout.Button("Display Network Info", Array.Empty<GUILayoutOption>()))
			{
				shownetworkinfo = !shownetworkinfo;
			}
			if (shownetworkinfo)
			{
				DisplayNetworkInfo();
			}
			if (GUILayout.Button("Display Audio Info", Array.Empty<GUILayoutOption>()))
			{
				showinputinfo = !showinputinfo;
			}
			if (showinputinfo)
			{
				DisplayInputs();
			}
			if (GUILayout.Button("Display Scene Info", Array.Empty<GUILayoutOption>()))
			{
				showSceneinfo = !showSceneinfo;
			}
			if (showSceneinfo)
			{
				DisplayScene();
			}
			if (GUILayout.Button("Display Other Info ", Array.Empty<GUILayoutOption>()))
			{
				showotherinfo = !showotherinfo;
			}
			if (showotherinfo)
			{
				DisplayOther();
			}
			if (GUILayout.Button("Display Enabled Mods", Array.Empty<GUILayoutOption>()))
			{
				showFiles = !showFiles;
			}
			if (showFiles)
			{
				DisplayFilesInFolder();
			}
		}
	}

	private void WindowFunction(int windowID)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		GUI.DragWindow(new Rect(0f, 0f, 10000f, 20f));
	}

	static PerformanceEnhancerStart()
	{
		OnGUIEnabled = true;
	}

	public static void DrawText(Rect rect, string text, Color color, int fontSize = 12, FontStyle fontStyle = 0)
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		GUIStyle val = new GUIStyle(GUI.skin.label);
		val.fontSize = fontSize;
		val.normal.textColor = color;
		val.fontStyle = fontStyle;
		GUI.Label(rect, new GUIContent(text), val);
	}

	private void Update()
	{
		deltaTime += (Time.unscaledDeltaTime - deltaTime) * 0.1f;
		if (Application.targetFrameRate != 500)
		{
			Application.targetFrameRate = 500;
		}
		if (QualitySettings.vSyncCount != 0)
		{
			QualitySettings.vSyncCount = 0;
		}
	}

	private void Start()
	{
		Application.targetFrameRate = 500;
		QualitySettings.vSyncCount = 0;
	}

	private void DisplaySpec(string label, string value, GUIStyle style, ref float yPosition, float labelHeight)
	{
		GUILayout.Label(label + " " + value, style, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(labelHeight) });
		yPosition += labelHeight;
	}

	private void DisplayFilesInFolder()
	{
		try
		{
			string[] files = Directory.GetFiles(folderPath);
			for (int i = 0; i < files.Length; i++)
			{
				GUILayout.Label(files[i], Array.Empty<GUILayoutOption>());
			}
		}
		catch (Exception ex)
		{
			GUILayout.Label("Error: " + ex.Message, Array.Empty<GUILayoutOption>());
		}
	}

	private void DisplayPCSpecs()
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label("PC / OS Information:", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Operating System: " + SystemInfo.operatingSystem, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Processor: " + SystemInfo.processorType, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Processor Ammount: {SystemInfo.processorCount}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"System Memory: {SystemInfo.systemMemorySize} MB", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Graphics Card: " + SystemInfo.graphicsDeviceName, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Graphics Memory: {SystemInfo.graphicsMemorySize} MB", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"System Language: {Application.systemLanguage}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"System TimeZone: {TimeZoneInfo.Local}", Array.Empty<GUILayoutOption>());
	}

	private void DisplayScreenTime()
	{
		GUILayout.Label($"Screen Resolution: {Screen.width} x {Screen.height}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Screen DPI: {Screen.dpi}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"FullScreen: {Screen.fullScreen}", Array.Empty<GUILayoutOption>());
	}

	private void DisplayAppInfo()
	{
		GUILayout.Label("Unity Version: " + Application.unityVersion, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Application Version: " + Application.version, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Target Frame Rate: {Application.targetFrameRate}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Is Mobile Platform: {Application.isMobilePlatform}", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Data Path: " + Application.dataPath, Array.Empty<GUILayoutOption>());
	}

	private void DisplayNetworkInfo()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label($"Internet Reachability: {Application.internetReachability}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Current Time: {Time.time}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Realtime Since Game Launch: {Time.realtimeSinceStartup}", Array.Empty<GUILayoutOption>());
	}

	private void DisplayInputs()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label($"Audio Sample Rate: {AudioSettings.outputSampleRate}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Audio Configuration: {AudioSettings.speakerMode}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Master Volume: {AudioListener.volume:F2}", Array.Empty<GUILayoutOption>());
	}

	private void DisplayScene()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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)
		Scene activeScene = SceneManager.GetActiveScene();
		GUILayout.Label("Active Scene: " + ((Scene)(ref activeScene)).name, Array.Empty<GUILayoutOption>());
		activeScene = SceneManager.GetActiveScene();
		GUILayout.Label("Scene Path: " + ((Scene)(ref activeScene)).path, Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Gravity: {Physics.gravity}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Physics Frame Rate: {1f / Time.fixedDeltaTime}", Array.Empty<GUILayoutOption>());
	}

	private void DisplayOther()
	{
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.Label($"Quality Level: {QualitySettings.GetQualityLevel()}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Pixel Light Count: {QualitySettings.pixelLightCount}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Anti-Aliasing: {QualitySettings.antiAliasing}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Anisotropic Filtering: {QualitySettings.anisotropicFiltering}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Solver Iterations: {Physics.defaultSolverIterations}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Default Contact Offset: {Physics.defaultContactOffset}", Array.Empty<GUILayoutOption>());
		GUILayout.Label($"Platform: {Application.platform}", Array.Empty<GUILayoutOption>());
		GUILayout.Label("Cloud Project ID: " + Application.cloudProjectId, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Build Version: " + Application.version, Array.Empty<GUILayoutOption>());
		GUILayout.Label("Build Number: " + Application.buildGUID, Array.Empty<GUILayoutOption>());
	}

	public static void DrawFormattedText(Rect rect, string format, Color color, int fontSize = 12, FontStyle fontStyle = 0, params object[] args)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		string text = string.Format(format, args);
		DrawText(rect, text, color, fontSize, fontStyle);
	}
}