Decompiled source of VibrantVisuals v1.0.1

VibrantVisuals.dll

Decompiled 3 months 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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("VibrantVisuals")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c74b11b74d818cd0f2ec58156879b09cf0be8c48")]
[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.0.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.0.0";

		public ConfigEntry<PostProcessingType> postProcessingType;

		public ConfigEntry<PostProcessingType> golemplainsPostProcessingType;

		public ConfigEntry<bool> snowyforestAurora;

		public ConfigEntry<bool> foggyswampPostProcessing;

		public void Awake()
		{
			//IL_003a: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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 val10 = default(ColorGrading);
					if (handle.Result.TryGetSettings<ColorGrading>(ref val10))
					{
						switch (postProcessingType.Value)
						{
						case PostProcessingType.Vibrant:
							((ParameterOverride<Tonemapper>)(object)val10.tonemapper).Override((Tonemapper)3);
							((ParameterOverride<float>)(object)val10.toneCurveToeStrength).Override(0.35f);
							((ParameterOverride<float>)(object)val10.toneCurveToeLength).Override(0.6f);
							((ParameterOverride<float>)(object)val10.toneCurveShoulderStrength).Override(1f);
							((ParameterOverride<float>)(object)val10.toneCurveShoulderLength).Override(2f);
							break;
						case PostProcessingType.Classic:
							((ParameterOverride<float>)(object)val10.saturation).Override(7.1f);
							break;
						}
					}
				};
			}
			golemplainsPostProcessingType = ((BaseUnityPlugin)this).Config.Bind<PostProcessingType>("Titanic Plains", "Post Processing Type", PostProcessingType.Vibrant, "Vanilla: no changes\r\nVibrant: makes 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 val9 = default(RampFog);
					if (handle.Result.TryGetSettings<RampFog>(ref val9))
					{
						((ParameterOverride<float>)(object)val9.fogPower).Override(0.5f);
					}
				};
			}
			if (golemplainsPostProcessingType.Value != 0)
			{
				SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode loadSceneMode)
				{
					//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
					//IL_0130: Unknown result type (might be due to invalid IL or missing references)
					//IL_0135: Unknown result type (might be due to invalid IL or missing references)
					if (((Scene)(ref scene)).name == "golemplains" || ((Scene)(ref scene)).name == "golemplains2")
					{
						GameObject[] rootGameObjects = ((Scene)(ref scene)).GetRootGameObjects();
						GameObject val4 = Array.Find(rootGameObjects, (GameObject x) => ((Object)x).name == "Weather, Golemplains");
						if (!((Object)(object)val4 == (Object)null))
						{
							Transform val5 = val4.transform.Find("Directional Light (SUN)");
							Light val6 = default(Light);
							if (Object.op_Implicit((Object)(object)val5) && ((Component)val5).TryGetComponent<Light>(ref val6))
							{
								val6.color = Color32.op_Implicit(new Color32((byte)190, (byte)229, (byte)233, byte.MaxValue));
								if (golemplainsPostProcessingType.Value == PostProcessingType.Classic)
								{
									val6.intensity = 1.34f;
								}
							}
							if (golemplainsPostProcessingType.Value == PostProcessingType.Classic)
							{
								Transform val7 = val4.transform.Find("PP + Amb");
								PostProcessVolume val8 = default(PostProcessVolume);
								if (Object.op_Implicit((Object)(object)val7) && ((Component)val7).TryGetComponent<PostProcessVolume>(ref val8))
								{
									val8.sharedProfile = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppSceneGolemplains.asset").WaitForCompletion();
								}
							}
						}
					}
				};
			}
			snowyforestAurora = ((BaseUnityPlugin)this).Config.Bind<bool>("Siphoned Forest", "Brighter Aurora", true, "Makes 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_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0022: 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, "Tweaks the fog on Wetland Aspect");
			if (!foggyswampPostProcessing.Value)
			{
				return;
			}
			val = Addressables.LoadAssetAsync<PostProcessProfile>((object)"RoR2/Base/title/PostProcessing/ppSceneFoggyswamp.asset");
			val.Completed += delegate(AsyncOperationHandle<PostProcessProfile> handle)
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: 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.fogZero).Override(-0.01f);
					((ParameterOverride<float>)(object)val3.fogOne).Override(0.4f);
					((ParameterOverride<Color>)(object)val3.fogColorStart).Override(Color32.op_Implicit(new Color32((byte)111, (byte)132, (byte)124, (byte)20)));
					((ParameterOverride<Color>)(object)val3.fogColorMid).Override(Color32.op_Implicit(new Color32((byte)76, (byte)97, (byte)92, (byte)230)));
				}
			};
		}
	}
}