Decompiled source of GammaSettingFix v0.1.2

GammaSettingFix.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: RefSafetyRules(11)]
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 Prototype
{
	[BepInPlugin("prototype.fix.gamma", "GammaSettingFix", "0.1.2")]
	internal class GammaSettingFix : BaseUnityPlugin
	{
		public const string version = "0.1.2";

		public const string identifier = "prototype.fix.gamma";

		protected void Awake()
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				((ParameterOverride)PpGammaConVar.colorGradingSettings.gamma).overrideState = true;
				Harmony.CreateAndPatchAll(typeof(Patcher), (string)null);
			});
		}
	}
	internal class Patcher
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static SceneCameraDelegate <0>__update;
		}

		[HarmonyPatch(typeof(PpGammaConVar), "SetString")]
		[HarmonyPostfix]
		private static void OnSettingChanged()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__update;
			if (obj == null)
			{
				SceneCameraDelegate val = update;
				<>O.<0>__update = val;
				obj = (object)val;
			}
			SceneCamera.onSceneCameraPreRender += (SceneCameraDelegate)obj;
			static void update(SceneCamera instance)
			{
				//IL_0021: 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_002c: Expected O, but got Unknown
				PostProcessLayer component = ((Component)instance).GetComponent<PostProcessLayer>();
				if (component != null)
				{
					component.OnVolumeSettingsChanged();
				}
				object obj2 = <>O.<0>__update;
				if (obj2 == null)
				{
					SceneCameraDelegate val2 = update;
					<>O.<0>__update = val2;
					obj2 = (object)val2;
				}
				SceneCamera.onSceneCameraPreRender -= (SceneCameraDelegate)obj2;
			}
		}
	}
}