Decompiled source of VibrantVisuals v1.1.0

plugins/VibrantVisuals.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VibrantVisuals")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f7f20007994b5be1ac97fa771ded7c6b62bc05a1")]
[assembly: AssemblyProduct("VibrantVisuals")]
[assembly: AssemblyTitle("VibrantVisuals")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 VibrantVisuals
{
	[BepInPlugin("groovesalad.VibrantVisuals", "VibrantVisuals", "1.1.0")]
	public class VibrantVisualsPlugin : BaseUnityPlugin
	{
		public enum PostProcessingType
		{
			Vanilla,
			Vibrant,
			Classic
		}

		public const string GUID = "groovesalad.VibrantVisuals";

		public const string NAME = "VibrantVisuals";

		public const string VERSION = "1.1.0";

		public ConfigEntry<PostProcessingType> postProcessingType;

		public ConfigEntry<PostProcessingType> golemplainsPostProcessingType;

		public ConfigEntry<bool> snowyforestAurora;

		public ConfigEntry<bool> foggyswampPostProcessing;

		public ConfigEntry<bool> helminthroostVisibility;

		private void Awake()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			postProcessingType = ((BaseUnityPlugin)this).Config.Bind<PostProcessingType>("Global", "Post Processing Type", PostProcessingType.Vibrant, "Vanilla: no changes\r\nVibrant: custom tone mapping to saturate the game in a stylized way\r\nClassic: a simple saturation increase to match early versions of the game");
			AsyncOperationHandle<PostProcessProfile> val;
			if (postProcessingType.Value != 0)
			{
				val = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppRunBase.asset");
				val.Completed += delegate(AsyncOperationHandle<PostProcessProfile> handle)
				{
					ColorGrading val19 = default(ColorGrading);
					if (handle.Result.TryGetSettings<ColorGrading>(ref val19))
					{
						switch (postProcessingType.Value)
						{
						case PostProcessingType.Vibrant:
							((ParameterOverride<Tonemapper>)(object)val19.tonemapper).Override((Tonemapper)3);
							((ParameterOverride<float>)(object)val19.toneCurveToeStrength).Override(0.35f);
							((ParameterOverride<float>)(object)val19.toneCurveToeLength).Override(0.6f);
							((ParameterOverride<float>)(object)val19.toneCurveShoulderStrength).Override(1f);
							((ParameterOverride<float>)(object)val19.toneCurveShoulderLength).Override(2f);
							break;
						case PostProcessingType.Classic:
							((ParameterOverride<float>)(object)val19.saturation).Override(7.1f);
							break;
						}
					}
				};
			}
			golemplainsPostProcessingType = ((BaseUnityPlugin)this).Config.Bind<PostProcessingType>("Titanic Plains", "Post Processing Type", PostProcessingType.Vibrant, "Vanilla: no changes\r\nVibrant: make the stage a little less foggy\r\nClassic: a mostly faithful recreation of the first version of the stage, before Hopoo made it \"depressing\"");
			if (golemplainsPostProcessingType.Value == PostProcessingType.Vibrant)
			{
				val = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppSceneGolemplainsFoggy.asset");
				val.Completed += delegate(AsyncOperationHandle<PostProcessProfile> handle)
				{
					RampFog val18 = default(RampFog);
					if (handle.Result.TryGetSettings<RampFog>(ref val18))
					{
						((ParameterOverride<float>)(object)val18.fogPower).Override(0.5f);
					}
				};
			}
			if (golemplainsPostProcessingType.Value != 0)
			{
				SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode loadSceneMode)
				{
					//IL_0097: Unknown result type (might be due to invalid IL or missing references)
					//IL_009c: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
					if (((Scene)(ref scene)).name == "golemplains" || ((Scene)(ref scene)).name == "golemplains2")
					{
						GameObject val13 = Array.Find(((Scene)(ref scene)).GetRootGameObjects(), (GameObject x) => ((Object)x).name == "Weather, Golemplains");
						if (!((Object)(object)val13 == (Object)null))
						{
							Transform val14 = val13.transform.Find("Directional Light (SUN)");
							Light val15 = default(Light);
							if (Object.op_Implicit((Object)(object)val14) && ((Component)val14).TryGetComponent<Light>(ref val15))
							{
								val15.color = Color32.op_Implicit(new Color32((byte)190, (byte)229, (byte)233, byte.MaxValue));
								if (golemplainsPostProcessingType.Value == PostProcessingType.Classic)
								{
									val15.intensity = 1.34f;
								}
							}
							if (golemplainsPostProcessingType.Value == PostProcessingType.Classic)
							{
								Transform val16 = val13.transform.Find("PP + Amb");
								PostProcessVolume val17 = default(PostProcessVolume);
								if (Object.op_Implicit((Object)(object)val16) && ((Component)val16).TryGetComponent<PostProcessVolume>(ref val17))
								{
									val17.sharedProfile = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppSceneGolemplains.asset").WaitForCompletion();
								}
							}
						}
					}
				};
			}
			snowyforestAurora = ((BaseUnityPlugin)this).Config.Bind<bool>("Siphoned Forest", "Brighter Aurora", true, "Make the aurora above Siphoned Forest more visible and colorful");
			if (snowyforestAurora.Value)
			{
				AsyncOperationHandle<Material> val2 = Addressables.LoadAssetAsync<Material>((object)"RoR2/DLC1/snowyforest/matSFAurora.mat");
				val2.Completed += delegate(AsyncOperationHandle<Material> handle)
				{
					//IL_001c: 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)
					handle.Result.SetColor("_TintColor", Color32.op_Implicit(new Color32((byte)207, (byte)0, (byte)140, byte.MaxValue)));
					handle.Result.SetFloat("_Boost", 2f);
					handle.Result.SetFloat("_AlphaBoost", 0.15f);
				};
			}
			foggyswampPostProcessing = ((BaseUnityPlugin)this).Config.Bind<bool>("Wetland Aspect", "New Post Processing", true, "Tweak the fog on Wetland Aspect");
			if (foggyswampPostProcessing.Value)
			{
				val = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppSceneFoggyswamp.asset");
				val.Completed += delegate(AsyncOperationHandle<PostProcessProfile> handle)
				{
					//IL_0041: Unknown result type (might be due to invalid IL or missing references)
					//IL_0046: 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_0066: Unknown result type (might be due to invalid IL or missing references)
					RampFog val12 = default(RampFog);
					if (handle.Result.TryGetSettings<RampFog>(ref val12))
					{
						((ParameterOverride<float>)(object)val12.fogZero).Override(-0.01f);
						((ParameterOverride<float>)(object)val12.fogOne).Override(0.4f);
						((ParameterOverride<Color>)(object)val12.fogColorStart).Override(Color32.op_Implicit(new Color32((byte)111, (byte)132, (byte)124, (byte)20)));
						((ParameterOverride<Color>)(object)val12.fogColorMid).Override(Color32.op_Implicit(new Color32((byte)76, (byte)97, (byte)92, (byte)230)));
					}
				};
			}
			helminthroostVisibility = ((BaseUnityPlugin)this).Config.Bind<bool>("Helminth Hatchery", "Improved Visibility", true, "Tweak the lighting and post-processing on Helminth Hatchery to brighten the stage");
			if (!helminthroostVisibility.Value)
			{
				return;
			}
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode loadSceneMode)
			{
				if (((Scene)(ref scene)).name == "helminthroost")
				{
					GameObject val5 = Array.Find(((Scene)(ref scene)).GetRootGameObjects(), (GameObject x) => ((Object)x).name == "HOLDER: Lighting");
					if (Object.op_Implicit((Object)(object)val5))
					{
						Transform val6 = val5.transform.Find("Weather, Helminthroost/Directional Light (SUN)");
						Light val7 = default(Light);
						if (Object.op_Implicit((Object)(object)val6) && ((Component)val6).TryGetComponent<Light>(ref val7))
						{
							val7.intensity = 0.35f;
						}
						Transform val8 = val5.transform.Find("Sky Point Light");
						Light val9 = default(Light);
						if (Object.op_Implicit((Object)(object)val8) && ((Component)val8).TryGetComponent<Light>(ref val9))
						{
							val9.intensity = 10f;
						}
						Transform val10 = val5.transform.Find("Weather, Helminthroost/PP + Amb");
						PostProcessVolume val11 = default(PostProcessVolume);
						if (Object.op_Implicit((Object)(object)val10) && ((Component)val10).TryGetComponent<PostProcessVolume>(ref val11))
						{
							val11.priority = 5f;
						}
					}
				}
			};
			val = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/DLC2/helminthroost/ppSceneHelminth.asset");
			val.Completed += delegate(AsyncOperationHandle<PostProcessProfile> handle)
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				RampFog val3 = default(RampFog);
				if (handle.Result.TryGetSettings<RampFog>(ref val3))
				{
					((ParameterOverride<float>)(object)val3.fogPower).Override(1.85f);
					((ParameterOverride<float>)(object)val3.fogZero).Override(-0.28f);
					((ParameterOverride<Color>)(object)val3.fogColorMid).Override(Color32.op_Implicit(new Color32((byte)132, (byte)85, (byte)69, (byte)170)));
				}
				ColorGrading val4 = default(ColorGrading);
				if (handle.Result.TryGetSettings<ColorGrading>(ref val4))
				{
					((ParameterOverride<GradingMode>)(object)val4.gradingMode).Override((GradingMode)1);
					((ParameterOverride<float>)(object)val4.postExposure).Override(1.1f);
				}
			};
		}
	}
}