using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using MenuLib;
using MenuLib.MonoBehaviors;
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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("PotatoPcMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PotatoPcMod")]
[assembly: AssemblyTitle("PotatoPcMod")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("mga-potatopcmod", "Potato Pc Mod", "1.0")]
public class PotatoPcMod : BaseUnityPlugin
{
private ConfigEntry<bool> disableShadows;
private ConfigEntry<bool> disableAntiAliasing;
private ConfigEntry<bool> disablePixelLights;
private ConfigEntry<bool> disableLodBias;
private ConfigEntry<bool> disableFog;
private ConfigEntry<bool> disableSoftParticles;
private ConfigEntry<bool> disableSoftVegetation;
private ConfigEntry<bool> disableRealtimeReflectionProbes;
private ConfigEntry<bool> disablePostProcessing;
private static bool restartneeded;
private void Awake()
{
disableShadows = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableShadows", true, "Disable shadows");
disableAntiAliasing = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableAntiAliasing", true, "Disable anti-aliasing");
disablePixelLights = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisablePixelLights", true, "Disable pixel lights");
disableLodBias = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableLodBias", true, "Disable LOD bias");
disableFog = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableFog", false, "Disable fog");
disableSoftParticles = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableSoftParticles", true, "Disable soft particles");
disableSoftVegetation = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableSoftVegetation", true, "Disable soft vegetation");
disableRealtimeReflectionProbes = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisableRealtimeReflectionProbes", true, "Disable realtime reflection probes");
disablePostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "DisablePostProcessing", true, "Disable post-processing effects");
disableShadows.SettingChanged += OnAnyConfigChanged;
disableAntiAliasing.SettingChanged += OnAnyConfigChanged;
disablePixelLights.SettingChanged += OnAnyConfigChanged;
disableLodBias.SettingChanged += OnAnyConfigChanged;
disableFog.SettingChanged += OnAnyConfigChanged;
disableSoftParticles.SettingChanged += OnAnyConfigChanged;
disableSoftVegetation.SettingChanged += OnAnyConfigChanged;
disablePostProcessing.SettingChanged += OnAnyConfigChanged;
disableRealtimeReflectionProbes.SettingChanged += OnAnyConfigChanged;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Potato Pc Mod loaded!");
SceneManager.sceneLoaded += OnSceneLoaded;
}
private void OnAnyConfigChanged(object sender, EventArgs e)
{
if (!restartneeded)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"You need to restart to apply changes!");
restartneeded = true;
ShowPopup();
}
}
private void ShowPopup()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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)
REPOPopupPage val = MenuAPI.CreateREPOPopupPage("Restart needed", false, false, 3f, (Vector2?)null);
Vector2 sizeDelta = default(Vector2);
((Vector2)(ref sizeDelta))..ctor((float)Screen.width, (float)Screen.height);
RectTransform component = ((Component)val).GetComponent<RectTransform>();
component.sizeDelta = sizeDelta;
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.pivot = Vector2.one * 0.5f;
val.OpenPage(false);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Popup menu showed");
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Scene loaded: " + ((Scene)(ref scene)).name));
RemoveEffects();
}
private void RemoveEffects()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Activating performance settings...");
if (disableShadows.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Shadows disabled.");
QualitySettings.shadows = (ShadowQuality)0;
QualitySettings.shadowDistance = 0f;
}
if (disableAntiAliasing.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Anti-aliasing disabled.");
QualitySettings.antiAliasing = 0;
}
if (disablePixelLights.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Pixel lights disabled.");
QualitySettings.pixelLightCount = 0;
}
if (disableLodBias.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"LOD bias disabled.");
QualitySettings.lodBias = 0f;
}
if (disableFog.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Fog disabled.");
RenderSettings.fog = false;
}
if (disableSoftParticles.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Soft particles disabled.");
QualitySettings.softParticles = false;
}
if (disableSoftVegetation.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Soft vegetation disabled.");
QualitySettings.softVegetation = false;
}
if (disableRealtimeReflectionProbes.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Realtime reflection probes disabled.");
QualitySettings.realtimeReflectionProbes = false;
}
if (disablePostProcessing.Value)
{
DisablePostProcessingEffects();
}
}
private void DisablePostProcessingEffects()
{
string[] source = new string[8] { "post", "color", "grade", "grain", "vignette", "bloom", "blur", "tone" };
if (!disablePostProcessing.Value)
{
return;
}
Camera[] allCameras = Camera.allCameras;
foreach (Camera val in allCameras)
{
Behaviour[] components = ((Component)val).GetComponents<Behaviour>();
foreach (Behaviour val2 in components)
{
if (!((Object)(object)val2 == (Object)null))
{
string name = ((object)val2).GetType().Name.ToLower();
if (source.Any((string k) => name.Contains(k)))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Disabling post-processing effect: " + ((object)val2).GetType().Name));
val2.enabled = false;
}
}
}
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Post-processing effects disabled.");
}
}