Decompiled source of NoDirtyLens v1.0.0

NoDirtyLens.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("NoDirtyLens")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoDirtyLens")]
[assembly: AssemblyTitle("NoDirtyLens")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 NoDirtyLens
{
	[BepInPlugin("Iteravio.NoDirtyLens", "NoDirtyLens", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "Iteravio.NoDirtyLens";

		public const string PluginName = "NoDirtyLens";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<int> PercentLensDirtStrength;

		private static ManualLogSource Log;

		private static readonly Dictionary<PostProcessingProfile, float> VanillaIntensity = new Dictionary<PostProcessingProfile, float>();

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			PercentLensDirtStrength = ((BaseUnityPlugin)this).Config.Bind<int>("No Dirty Lens", "PercentLensDirtStrength", 0, new ConfigDescription("How strongly smudges show on the screen when looking toward bright light. Vanilla: 100%. [Not synced with Server]", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			PercentLensDirtStrength.SettingChanged += delegate
			{
				if ((Object)(object)CameraEffects.instance != (Object)null)
				{
					Apply(CameraEffects.instance);
				}
			};
			new Harmony("Iteravio.NoDirtyLens").PatchAll();
		}

		internal static void Apply(CameraEffects effects)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			PostProcessingBehaviour component = ((Component)effects).GetComponent<PostProcessingBehaviour>();
			if (!((Object)(object)component == (Object)null) && !((Object)(object)component.profile == (Object)null))
			{
				PostProcessingProfile profile = component.profile;
				Settings settings = profile.bloom.settings;
				if (!VanillaIntensity.TryGetValue(profile, out var value))
				{
					value = (VanillaIntensity[profile] = settings.lensDirt.intensity);
					Log.LogInfo((object)$"Lens dirt strength on {((Object)profile).name}: set to {PercentLensDirtStrength.Value}%.");
				}
				settings.lensDirt.intensity = value * (float)PercentLensDirtStrength.Value / 100f;
				profile.bloom.settings = settings;
			}
		}
	}
	[HarmonyPatch(typeof(CameraEffects), "Awake")]
	internal static class CameraEffectsAwakePatch
	{
		private static void Postfix(CameraEffects __instance)
		{
			Plugin.Apply(__instance);
		}
	}
}