Decompiled source of BetterView v4.0.0

BetterView.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
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 BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("REPOJP")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("zabuMod")]
[assembly: AssemblyTitle("zabuMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 BetterView
{
	[BepInPlugin("REPOJP.BetterView", "BetterView", "2.0.0")]
	public class BetterViewPlugin : BaseUnityPlugin
	{
		internal class BetterViewRuntime : MonoBehaviour
		{
			private const float ZoomHoldSeconds = 0.15f;

			private const int ZoomPriority = 0;

			private const int ZoomDisplayFontSize = 28;

			private float visualApplyTimer;

			private float glowApplyTimer;

			private bool zoomKeyWasDown;

			private CameraZoom boundedCameraZoom;

			private bool hasOriginalMinimumZoom;

			private float originalMinimumZoom;

			private float zoomBoundsRestoreTimer;

			private Canvas zoomDisplayCanvas;

			private Text zoomDisplayText;

			private float zoomDisplayTimer;

			private void Update()
			{
				try
				{
					HandleDebugToggleKey();
					UpdatePeriodicApply();
					UpdateZoom();
				}
				catch (Exception ex)
				{
					if (Log != null)
					{
						Log.LogError((object)("Failure: Runtime Update\n" + ex));
					}
				}
			}

			private void UpdatePeriodicApply()
			{
				visualApplyTimer -= Time.deltaTime;
				if (visualApplyTimer <= 0f)
				{
					visualApplyTimer = 0.5f;
					ApplyDistanceSettings(force: false);
					ApplyPostProcessingSettings(PostProcessing.Instance, beforeUpdate: false);
					ApplyRenderTextureSettings(force: false);
				}
				glowApplyTimer -= Time.deltaTime;
				if (glowApplyTimer <= 0f)
				{
					glowApplyTimer = 2f;
					ApplyGlowSettings(force: false);
				}
			}

			private void UpdateZoom()
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				UpdateZoomBoundsRestoreTimer();
				bool key = Input.GetKey(GetKeyCode(ZoomKey, (KeyCode)122));
				if (!key && !zoomKeyWasDown)
				{
					HideZoomRateDisplay();
					return;
				}
				if (!CanApplyNow())
				{
					ResetZoomStateOnly();
					return;
				}
				if (!key)
				{
					StartZoomRelease();
					return;
				}
				if (ApplyWheelZoomAdjustment())
				{
					ShowZoomRateDisplay(Clamp(GetFloat(ZoomRate, 5f), 1f, 20f));
				}
				UpdateZoomRateDisplayTimer();
				CameraZoom instance = CameraZoom.Instance;
				if ((Object)(object)instance == (Object)null)
				{
					RestoreCameraZoomBounds();
					zoomKeyWasDown = true;
					return;
				}
				float num = ((instance.playerZoomDefault > 0f) ? instance.playerZoomDefault : 60f);
				float num2 = Clamp(GetFloat(ZoomRate, 5f), 1f, 20f);
				float num3 = Clamp(GetFloat(ZoomMinimumFov, 0.1f), 0.1f, 30f);
				float num4 = Mathf.Clamp(num / num2, num3, instance.MaximumZoom);
				EnsureCameraZoomBounds(instance, num4, num3);
				instance.OverrideZoomSet(num4, 0.15f, Clamp(GetFloat(ZoomSmoothInSpeed, 6f), 0.1f, 60f), Clamp(GetFloat(ZoomSmoothOutSpeed, 5f), 0.1f, 60f), ((Component)this).gameObject, 0);
				zoomKeyWasDown = true;
			}

			internal void ResetZoomStateOnly()
			{
				zoomKeyWasDown = false;
				zoomBoundsRestoreTimer = 0f;
				RestoreCameraZoomBounds();
				HideZoomRateDisplay();
			}

			private void StartZoomRelease()
			{
				zoomKeyWasDown = false;
				HideZoomRateDisplay();
				if (hasOriginalMinimumZoom)
				{
					zoomBoundsRestoreTimer = Mathf.Max(0.25f, 1f / Mathf.Max(Clamp(GetFloat(ZoomSmoothOutSpeed, 5f), 0.1f, 60f), 0.1f) + 0.2f);
				}
			}

			private void UpdateZoomBoundsRestoreTimer()
			{
				if (!(zoomBoundsRestoreTimer <= 0f))
				{
					zoomBoundsRestoreTimer -= Time.deltaTime;
					if (zoomBoundsRestoreTimer <= 0f)
					{
						RestoreCameraZoomBounds();
					}
				}
			}

			private bool ApplyWheelZoomAdjustment()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				float y = Input.mouseScrollDelta.y;
				if (Mathf.Abs(y) <= 0.001f)
				{
					return false;
				}
				float num = Clamp(GetFloat(ZoomRate, 5f), 1f, 20f);
				float num2 = Clamp(GetFloat(ZoomWheelStep, 0.1f), 0.1f, 5f);
				float num3 = num + ((y > 0f) ? num2 : (0f - num2));
				num3 = Mathf.Round(num3 * 10f) / 10f;
				num3 = Clamp(num3, 1f, 20f);
				if (NearlyEqual(num, num3))
				{
					return false;
				}
				if (ZoomRate != null)
				{
					ZoomRate.Value = num3;
					if (GetBool(SaveWheelZoomToConfig, fallback: true) && configFile != null)
					{
						configFile.Save();
					}
				}
				return true;
			}

			private void EnsureCameraZoomBounds(CameraZoom cameraZoom, float targetZoom, float minFov)
			{
				if ((Object)(object)cameraZoom == (Object)null)
				{
					RestoreCameraZoomBounds();
					return;
				}
				if ((Object)(object)boundedCameraZoom != (Object)null && (Object)(object)boundedCameraZoom != (Object)(object)cameraZoom)
				{
					RestoreCameraZoomBounds();
				}
				if (!hasOriginalMinimumZoom)
				{
					boundedCameraZoom = cameraZoom;
					originalMinimumZoom = cameraZoom.MinimumZoom;
					hasOriginalMinimumZoom = true;
				}
				float num = Mathf.Max(minFov, targetZoom - 0.1f);
				if (cameraZoom.MinimumZoom > num)
				{
					cameraZoom.MinimumZoom = num;
				}
			}

			private void RestoreCameraZoomBounds()
			{
				if (hasOriginalMinimumZoom && (Object)(object)boundedCameraZoom != (Object)null)
				{
					boundedCameraZoom.MinimumZoom = originalMinimumZoom;
				}
				zoomBoundsRestoreTimer = 0f;
				boundedCameraZoom = null;
				hasOriginalMinimumZoom = false;
				originalMinimumZoom = 0f;
			}

			private void EnsureZoomRateDisplay()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Expected O, but got Unknown
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b8: Expected O, but got Unknown
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: 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_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_0183: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)zoomDisplayCanvas != (Object)null) || !((Object)(object)zoomDisplayText != (Object)null))
				{
					GameObject val = new GameObject("BetterViewZoomDisplayCanvas");
					val.transform.parent = null;
					((Object)val).hideFlags = (HideFlags)61;
					Object.DontDestroyOnLoad((Object)(object)val);
					zoomDisplayCanvas = val.AddComponent<Canvas>();
					zoomDisplayCanvas.renderMode = (RenderMode)0;
					zoomDisplayCanvas.sortingOrder = 32767;
					CanvasScaler val2 = val.AddComponent<CanvasScaler>();
					val2.uiScaleMode = (ScaleMode)1;
					val2.referenceResolution = new Vector2(1920f, 1080f);
					val2.matchWidthOrHeight = 0.5f;
					GameObject val3 = new GameObject("BetterViewZoomDisplayText");
					val3.transform.SetParent(val.transform, false);
					RectTransform val4 = val3.AddComponent<RectTransform>();
					val4.anchorMin = new Vector2(0.5f, 0f);
					val4.anchorMax = new Vector2(0.5f, 0f);
					val4.pivot = new Vector2(0.5f, 0f);
					val4.anchoredPosition = new Vector2(0f, 120f);
					val4.sizeDelta = new Vector2(640f, 64f);
					zoomDisplayText = val3.AddComponent<Text>();
					zoomDisplayText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
					zoomDisplayText.fontSize = 28;
					zoomDisplayText.alignment = (TextAnchor)4;
					((Graphic)zoomDisplayText).color = Color.white;
					((Graphic)zoomDisplayText).raycastTarget = false;
					Shadow val5 = val3.AddComponent<Shadow>();
					val5.effectColor = new Color(0f, 0f, 0f, 0.85f);
					val5.effectDistance = new Vector2(2f, -2f);
					((Behaviour)zoomDisplayCanvas).enabled = false;
				}
			}

			private void ShowZoomRateDisplay(float zoomRate)
			{
				EnsureZoomRateDisplay();
				if (!((Object)(object)zoomDisplayCanvas == (Object)null) && !((Object)(object)zoomDisplayText == (Object)null))
				{
					zoomDisplayText.text = "Zoom x" + zoomRate.ToString("0.0");
					zoomDisplayTimer = Clamp(GetFloat(ZoomDisplaySeconds, 1.25f), 0f, 10f);
					((Behaviour)zoomDisplayCanvas).enabled = zoomDisplayTimer > 0f;
				}
			}

			private void UpdateZoomRateDisplayTimer()
			{
				if (!((Object)(object)zoomDisplayCanvas == (Object)null) && ((Behaviour)zoomDisplayCanvas).enabled)
				{
					zoomDisplayTimer -= Time.deltaTime;
					if (zoomDisplayTimer <= 0f)
					{
						HideZoomRateDisplay();
					}
				}
			}

			private void HideZoomRateDisplay()
			{
				zoomDisplayTimer = 0f;
				if ((Object)(object)zoomDisplayCanvas != (Object)null)
				{
					((Behaviour)zoomDisplayCanvas).enabled = false;
				}
			}
		}

		private struct PostProcessingState
		{
			internal int LevelId;

			internal float BloomIntensity;

			internal float BloomThreshold;

			internal float LensDistortionIntensity;

			internal Color VignetteColor;

			internal float VignetteIntensity;

			internal float VignetteSmoothness;

			internal float ColorTemperature;

			internal Color ColorFilter;

			internal float Saturation;

			internal float Contrast;

			internal float GrainIntensity;

			internal float GrainSize;

			internal float MotionBlurShutter;

			internal float ChromaticAberrationIntensity;
		}

		private struct PropLightState
		{
			internal float OriginalIntensity;

			internal float CurrentIntensity;

			internal float OriginalRange;
		}

		private struct PropEmissionState
		{
			internal Color OriginalEmission;

			internal Color CurrentEmission;
		}

		private struct ItemLightState
		{
			internal float OriginalIntensity;

			internal float OriginalRange;

			internal float OriginalFresnel;

			internal float CurrentIntensity;

			internal float CurrentRange;
		}

		[HarmonyPatch(typeof(EnvironmentDirector), "Setup")]
		internal static class EnvironmentDirectorSetupPatch
		{
			private static void Postfix()
			{
				ApplyDistanceSettings(force: true);
			}
		}

		[HarmonyPatch(typeof(EnvironmentDirector), "Update")]
		internal static class EnvironmentDirectorUpdatePatch
		{
			private static void Postfix()
			{
				ApplyDistanceSettings(force: false);
			}
		}

		[HarmonyPatch(typeof(SpectateCamera), "StateNormal")]
		internal static class SpectateCameraStateNormalPatch
		{
			private static void Postfix()
			{
				ApplyDistanceSettings(force: false);
			}
		}

		[HarmonyPatch(typeof(SpectateCamera), "StopSpectate")]
		internal static class SpectateCameraStopSpectatePatch
		{
			private static void Postfix()
			{
				ApplyDistanceSettings(force: true);
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "Setup")]
		internal static class PostProcessingSetupPatch
		{
			private static void Postfix(PostProcessing __instance)
			{
				CapturePostProcessingState(__instance, force: true);
				ApplyPostProcessingSettings(__instance, beforeUpdate: false);
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "Update")]
		internal static class PostProcessingUpdatePatch
		{
			private static void Prefix(PostProcessing __instance)
			{
				ApplyPostProcessingSettings(__instance, beforeUpdate: true);
			}

			private static void Postfix(PostProcessing __instance)
			{
				ApplyPostProcessingSettings(__instance, beforeUpdate: false);
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "LensDistortionOverride")]
		internal static class PostProcessingLensDistortionOverridePatch
		{
			private static void Prefix(ref float _intensity)
			{
				if (CanApplyNow())
				{
					_intensity *= Clamp(GetFloat(DynamicLensDistortionMultiplier, 0.25f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "VignetteOverride")]
		internal static class PostProcessingVignetteOverridePatch
		{
			private static void Prefix(ref float _intensity, ref float _smoothness)
			{
				if (CanApplyNow())
				{
					_intensity *= Clamp(GetFloat(DynamicVignetteIntensityMultiplier, 0.4f), 0f, 10f);
					_smoothness *= Clamp(GetFloat(DynamicVignetteSmoothnessMultiplier, 1f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "BloomOverride")]
		internal static class PostProcessingBloomOverridePatch
		{
			private static void Prefix(ref float _intensity, ref float _threshold)
			{
				if (CanApplyNow())
				{
					_intensity *= Clamp(GetFloat(DynamicBloomIntensityMultiplier, 0.75f), 0f, 10f);
					_threshold *= Clamp(GetFloat(DynamicBloomThresholdMultiplier, 1.2f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "SaturationOverride")]
		internal static class PostProcessingSaturationOverridePatch
		{
			private static void Prefix(ref float _amount)
			{
				if (CanApplyNow())
				{
					_amount *= Clamp(GetFloat(DynamicSaturationAmountMultiplier, 0.5f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "ContrastOverride")]
		internal static class PostProcessingContrastOverridePatch
		{
			private static void Prefix(ref float _amount)
			{
				if (CanApplyNow())
				{
					_amount *= Clamp(GetFloat(DynamicContrastAmountMultiplier, 0.5f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessing), "GrainIntensityOverride")]
		internal static class PostProcessingGrainIntensityOverridePatch
		{
			private static void Prefix(ref float _amount)
			{
				if (CanApplyNow())
				{
					_amount *= Clamp(GetFloat(DynamicGrainIntensityMultiplier, 0.35f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(GraphicsManager), "UpdateAll")]
		internal static class GraphicsManagerUpdateAllPatch
		{
			private static void Postfix()
			{
				ApplyPostProcessingSettings(PostProcessing.Instance, beforeUpdate: false);
				ApplyRenderTextureSettings(force: true);
			}
		}

		[HarmonyPatch(typeof(GraphicsManager), "UpdateRenderSize")]
		internal static class GraphicsManagerUpdateRenderSizePatch
		{
			private static void Postfix()
			{
				ApplyRenderTextureSettings(force: true);
			}
		}

		[HarmonyPatch(typeof(GraphicsManager), "UpdateGlitchLoop")]
		internal static class GraphicsManagerUpdateGlitchLoopPatch
		{
			private static void Postfix()
			{
				if (CanApplyNow() && graphicsGlitchLoopField != null && (Object)(object)GraphicsManager.instance != (Object)null && Clamp(GetFloat(CameraGlitchChanceMultiplier, 0.15f), 0f, 1f) <= 0f)
				{
					graphicsGlitchLoopField.SetValue(GraphicsManager.instance, false);
				}
			}
		}

		[HarmonyPatch(typeof(RenderTextureMain), "Start")]
		internal static class RenderTextureMainStartPatch
		{
			private static void Postfix()
			{
				ApplyRenderTextureSettings(force: true);
			}
		}

		[HarmonyPatch(typeof(RenderTextureMain), "Update")]
		internal static class RenderTextureMainUpdatePatch
		{
			private static void Postfix()
			{
				ApplyRenderTextureSettings(force: false);
			}
		}

		[HarmonyPatch(typeof(RenderTextureMain), "ChangeResolution")]
		internal static class RenderTextureMainChangeResolutionPatch
		{
			private static bool Prefix()
			{
				if (!CanApplyNow())
				{
					return true;
				}
				return !GetBool(BlockTemporaryResolutionDrop, fallback: true);
			}
		}

		[HarmonyPatch(typeof(RenderTextureMain), "ChangeSize")]
		internal static class RenderTextureMainChangeSizePatch
		{
			private static bool Prefix()
			{
				if (!CanApplyNow())
				{
					return true;
				}
				return !GetBool(BlockRenderTextureSizeChange, fallback: true);
			}
		}

		[HarmonyPatch(typeof(RenderTextureMain), "Shake")]
		internal static class RenderTextureMainShakePatch
		{
			private static bool Prefix()
			{
				if (!CanApplyNow())
				{
					return true;
				}
				return !GetBool(BlockRenderTextureShake, fallback: true);
			}
		}

		[HarmonyPatch(typeof(VideoOverlay), "Override")]
		internal static class VideoOverlayOverridePatch
		{
			private static void Prefix(ref float amount)
			{
				if (CanApplyNow())
				{
					amount *= Clamp(GetFloat(VideoOverlayAmountMultiplier, 0.3f), 0f, 10f);
				}
			}
		}

		[HarmonyPatch(typeof(CameraGlitch), "PlayLong")]
		internal static class CameraGlitchPlayLongPatch
		{
			private static bool Prefix()
			{
				return AllowCameraGlitch(doNotLook: false);
			}
		}

		[HarmonyPatch(typeof(CameraGlitch), "PlayShort")]
		internal static class CameraGlitchPlayShortPatch
		{
			private static bool Prefix()
			{
				return AllowCameraGlitch(doNotLook: false);
			}
		}

		[HarmonyPatch(typeof(CameraGlitch), "PlayTiny")]
		internal static class CameraGlitchPlayTinyPatch
		{
			private static bool Prefix()
			{
				return AllowCameraGlitch(doNotLook: false);
			}
		}

		[HarmonyPatch(typeof(CameraGlitch), "DoNotLookEffectSet")]
		internal static class CameraGlitchDoNotLookEffectSetPatch
		{
			private static bool Prefix()
			{
				return AllowCameraGlitch(doNotLook: true);
			}
		}

		[HarmonyPatch(typeof(PropLight), "Awake")]
		internal static class PropLightAwakePatch
		{
			private static void Postfix(PropLight __instance)
			{
				ApplyPropLight(__instance);
			}
		}

		[HarmonyPatch(typeof(PropLight), "Start")]
		internal static class PropLightStartPatch
		{
			private static void Postfix(PropLight __instance)
			{
				ApplyPropLight(__instance);
			}
		}

		[HarmonyPatch(typeof(PropLightEmission), "Awake")]
		internal static class PropLightEmissionAwakePatch
		{
			private static void Postfix(PropLightEmission __instance)
			{
				ApplyPropEmission(__instance);
			}
		}

		[HarmonyPatch(typeof(ItemLight), "Start")]
		internal static class ItemLightStartPatch
		{
			private static void Postfix(ItemLight __instance)
			{
				ApplyItemLight(__instance);
			}
		}

		[HarmonyPatch(typeof(LightManager), "Setup")]
		internal static class LightManagerSetupPatch
		{
			private static void Postfix()
			{
				ApplyGlowSettings(force: true);
			}
		}

		public const string PluginGuid = "REPOJP.BetterView";

		public const string PluginName = "BetterView";

		public const string PluginVersion = "2.0.0";

		internal static ManualLogSource Log;

		private static Harmony harmony;

		private static BetterViewRuntime runtime;

		private static ConfigFile configFile;

		private static FieldInfo environmentMainCameraField;

		private static FieldInfo postBloomIntensityField;

		private static FieldInfo postBloomThresholdField;

		private static FieldInfo postLensDistortionIntensityField;

		private static FieldInfo postColorGradingSaturationField;

		private static FieldInfo postColorGradingContrastField;

		private static FieldInfo postVignetteColorField;

		private static FieldInfo postVignetteIntensityField;

		private static FieldInfo postVignetteSmoothnessField;

		private static FieldInfo postGrainIntensityDefaultField;

		private static FieldInfo postGrainSizeDefaultField;

		private static FieldInfo postMotionBlurDefaultField;

		private static FieldInfo graphicsGlitchLoopField;

		private static FieldInfo renderTextureWidthOriginalField;

		private static FieldInfo renderTextureHeightOriginalField;

		private static FieldInfo renderTextureShakeActiveField;

		private static FieldInfo renderTextureShakeTimerField;

		private static FieldInfo renderTextureSizeResetTimerField;

		private static FieldInfo renderTextureOriginalSizeField;

		private static FieldInfo propLightComponentField;

		private static FieldInfo propLightOriginalIntensityField;

		private static FieldInfo propEmissionMaterialField;

		private static FieldInfo propEmissionOriginalEmissionField;

		private static FieldInfo itemLightIntensityOriginalField;

		private static FieldInfo itemLightRangeOriginalField;

		private static FieldInfo itemLightFresnelScaleOriginalField;

		private static FieldInfo levelFogStartDistanceField;

		private static FieldInfo levelFogEndDistanceField;

		private static FieldInfo levelFogColorField;

		private static FieldInfo levelAmbientColorField;

		private static FieldInfo levelAmbientColorAdaptationField;

		private static FieldInfo levelColorTemperatureField;

		private static FieldInfo levelColorFilterField;

		private static FieldInfo levelBloomIntensityField;

		private static FieldInfo levelBloomThresholdField;

		private static FieldInfo levelLensDistortionIntensityField;

		private static FieldInfo levelVignetteColorField;

		private static FieldInfo levelVignetteIntensityField;

		private static FieldInfo levelVignetteSmoothnessField;

		private static readonly Dictionary<int, PostProcessingState> postProcessingStates = new Dictionary<int, PostProcessingState>();

		private static readonly Dictionary<PropLight, PropLightState> propLightStates = new Dictionary<PropLight, PropLightState>();

		private static readonly Dictionary<PropLightEmission, PropEmissionState> propEmissionStates = new Dictionary<PropLightEmission, PropEmissionState>();

		private static readonly Dictionary<ItemLight, ItemLightState> itemLightStates = new Dictionary<ItemLight, ItemLightState>();

		private static bool debugForceVanillaView;

		private static bool hasDistanceState;

		private static int distanceCameraId = -1;

		private static float distanceOriginalFarClip = -1f;

		private static float originalFogStart = -1f;

		private static float originalFogEnd = -1f;

		private static Color originalFogColor = Color.black;

		private static bool originalFogEnabled;

		private static float originalShadowDistance = -1f;

		private static bool hasRenderTextureState;

		private static float originalTextureWidthOriginal;

		private static float originalTextureHeightOriginal;

		private static Vector3 originalRenderTextureSize;

		internal static ConfigEntry<bool> EnableMod;

		internal static ConfigEntry<bool> ApplyToLevel;

		internal static ConfigEntry<bool> ApplyToArena;

		internal static ConfigEntry<bool> ApplyToSpectateCamera;

		internal static ConfigEntry<bool> EnableDebugToggleKey;

		internal static ConfigEntry<KeyCode> DebugToggleKey;

		internal static ConfigEntry<float> FogStartDistance;

		internal static ConfigEntry<float> FogEndDistance;

		internal static ConfigEntry<float> CameraFarClipDistance;

		internal static ConfigEntry<float> ShadowDistance;

		internal static ConfigEntry<bool> DisableFogCompletely;

		internal static ConfigEntry<float> FogColorBlendToBlack;

		internal static ConfigEntry<float> AmbientLightMultiplier;

		internal static ConfigEntry<float> AmbientLightMaxValue;

		internal static ConfigEntry<float> ColorTemperatureOffset;

		internal static ConfigEntry<float> ColorFilterBlendToWhite;

		internal static ConfigEntry<float> SaturationOffset;

		internal static ConfigEntry<float> ContrastOffset;

		internal static ConfigEntry<float> BloomIntensityMultiplier;

		internal static ConfigEntry<float> BloomThresholdMultiplier;

		internal static ConfigEntry<float> LensDistortionMultiplier;

		internal static ConfigEntry<float> VignetteIntensityMultiplier;

		internal static ConfigEntry<float> VignetteSmoothnessMultiplier;

		internal static ConfigEntry<float> MotionBlurShutterMultiplier;

		internal static ConfigEntry<float> ChromaticAberrationMultiplier;

		internal static ConfigEntry<float> GrainIntensityMultiplier;

		internal static ConfigEntry<float> GrainSizeMultiplier;

		internal static ConfigEntry<float> DynamicLensDistortionMultiplier;

		internal static ConfigEntry<float> DynamicVignetteIntensityMultiplier;

		internal static ConfigEntry<float> DynamicVignetteSmoothnessMultiplier;

		internal static ConfigEntry<float> DynamicBloomIntensityMultiplier;

		internal static ConfigEntry<float> DynamicBloomThresholdMultiplier;

		internal static ConfigEntry<float> DynamicSaturationAmountMultiplier;

		internal static ConfigEntry<float> DynamicContrastAmountMultiplier;

		internal static ConfigEntry<float> DynamicGrainIntensityMultiplier;

		internal static ConfigEntry<float> VideoOverlayAmountMultiplier;

		internal static ConfigEntry<float> CameraGlitchChanceMultiplier;

		internal static ConfigEntry<float> DoNotLookGlitchChanceMultiplier;

		internal static ConfigEntry<float> RenderResolutionScale;

		internal static ConfigEntry<bool> BlockTemporaryResolutionDrop;

		internal static ConfigEntry<bool> BlockRenderTextureShake;

		internal static ConfigEntry<bool> BlockRenderTextureSizeChange;

		internal static ConfigEntry<bool> EnhancePropLights;

		internal static ConfigEntry<float> PropLightIntensityMultiplier;

		internal static ConfigEntry<float> PropLightRangeMultiplier;

		internal static ConfigEntry<bool> EnhancePropEmissions;

		internal static ConfigEntry<float> PropEmissionMultiplier;

		internal static ConfigEntry<float> PropEmissionMaxValue;

		internal static ConfigEntry<bool> EnhanceItemLights;

		internal static ConfigEntry<float> ItemLightIntensityMultiplier;

		internal static ConfigEntry<float> ItemLightRangeMultiplier;

		internal static ConfigEntry<float> ItemFresnelMultiplier;

		internal static ConfigEntry<float> ItemFresnelMaxValue;

		internal static ConfigEntry<KeyCode> ZoomKey;

		internal static ConfigEntry<float> ZoomRate;

		internal static ConfigEntry<bool> SaveWheelZoomToConfig;

		internal static ConfigEntry<float> ZoomWheelStep;

		internal static ConfigEntry<float> ZoomSmoothInSpeed;

		internal static ConfigEntry<float> ZoomSmoothOutSpeed;

		internal static ConfigEntry<float> ZoomMinimumFov;

		internal static ConfigEntry<float> ZoomDisplaySeconds;

		private void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			try
			{
				Log = ((BaseUnityPlugin)this).Logger;
				configFile = ((BaseUnityPlugin)this).Config;
				((Component)this).transform.parent = null;
				((Object)this).hideFlags = (HideFlags)61;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
				BindConfigEntries();
				CacheReflectionFields();
				harmony = new Harmony("REPOJP.BetterView");
				harmony.PatchAll(typeof(EnvironmentDirectorSetupPatch));
				harmony.PatchAll(typeof(EnvironmentDirectorUpdatePatch));
				harmony.PatchAll(typeof(SpectateCameraStateNormalPatch));
				harmony.PatchAll(typeof(SpectateCameraStopSpectatePatch));
				harmony.PatchAll(typeof(PostProcessingSetupPatch));
				harmony.PatchAll(typeof(PostProcessingUpdatePatch));
				harmony.PatchAll(typeof(PostProcessingLensDistortionOverridePatch));
				harmony.PatchAll(typeof(PostProcessingVignetteOverridePatch));
				harmony.PatchAll(typeof(PostProcessingBloomOverridePatch));
				harmony.PatchAll(typeof(PostProcessingSaturationOverridePatch));
				harmony.PatchAll(typeof(PostProcessingContrastOverridePatch));
				harmony.PatchAll(typeof(PostProcessingGrainIntensityOverridePatch));
				harmony.PatchAll(typeof(GraphicsManagerUpdateAllPatch));
				harmony.PatchAll(typeof(GraphicsManagerUpdateRenderSizePatch));
				harmony.PatchAll(typeof(GraphicsManagerUpdateGlitchLoopPatch));
				harmony.PatchAll(typeof(RenderTextureMainStartPatch));
				harmony.PatchAll(typeof(RenderTextureMainUpdatePatch));
				harmony.PatchAll(typeof(RenderTextureMainChangeResolutionPatch));
				harmony.PatchAll(typeof(RenderTextureMainChangeSizePatch));
				harmony.PatchAll(typeof(RenderTextureMainShakePatch));
				harmony.PatchAll(typeof(VideoOverlayOverridePatch));
				harmony.PatchAll(typeof(CameraGlitchPlayLongPatch));
				harmony.PatchAll(typeof(CameraGlitchPlayShortPatch));
				harmony.PatchAll(typeof(CameraGlitchPlayTinyPatch));
				harmony.PatchAll(typeof(CameraGlitchDoNotLookEffectSetPatch));
				harmony.PatchAll(typeof(PropLightAwakePatch));
				harmony.PatchAll(typeof(PropLightStartPatch));
				harmony.PatchAll(typeof(PropLightEmissionAwakePatch));
				harmony.PatchAll(typeof(ItemLightStartPatch));
				harmony.PatchAll(typeof(LightManagerSetupPatch));
				CreateRuntimeController();
				Log.LogInfo((object)"Success: BetterView loaded. Version 2.0.0");
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failure: Awake\n" + ex));
			}
		}

		private void OnDestroy()
		{
			try
			{
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failure: OnDestroy\n" + ex));
			}
		}

		private void BindConfigEntries()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Expected O, but got Unknown
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Expected O, but got Unknown
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Expected O, but got Unknown
			//IL_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Expected O, but got Unknown
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Expected O, but got Unknown
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Expected O, but got Unknown
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Expected O, but got Unknown
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ad: Expected O, but got Unknown
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Expected O, but got Unknown
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Expected O, but got Unknown
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Expected O, but got Unknown
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Expected O, but got Unknown
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Expected O, but got Unknown
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Expected O, but got Unknown
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Expected O, but got Unknown
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Expected O, but got Unknown
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Expected O, but got Unknown
			//IL_0705: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Expected O, but got Unknown
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Expected O, but got Unknown
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Expected O, but got Unknown
			//IL_07bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Expected O, but got Unknown
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0803: Expected O, but got Unknown
			//IL_0836: Unknown result type (might be due to invalid IL or missing references)
			//IL_0840: Expected O, but got Unknown
			//IL_0873: Unknown result type (might be due to invalid IL or missing references)
			//IL_087d: Expected O, but got Unknown
			//IL_0930: Unknown result type (might be due to invalid IL or missing references)
			//IL_093a: Expected O, but got Unknown
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0977: Expected O, but got Unknown
			//IL_09ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d4: Expected O, but got Unknown
			//IL_0a07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a11: Expected O, but got Unknown
			//IL_0a64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6e: Expected O, but got Unknown
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aab: Expected O, but got Unknown
			//IL_0ade: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae8: Expected O, but got Unknown
			//IL_0b1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b25: Expected O, but got Unknown
			//IL_0b79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b83: Expected O, but got Unknown
			//IL_0bd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be0: Expected O, but got Unknown
			//IL_0c13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1d: Expected O, but got Unknown
			//IL_0c50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5a: Expected O, but got Unknown
			//IL_0c8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c97: Expected O, but got Unknown
			//IL_0cca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd4: Expected O, but got Unknown
			EnableMod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableMod", true, "Enable this mod.このMODを有効化");
			ApplyToLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyToLevel", true, "Apply settings in normal levels.通常レベルで設定を適用");
			ApplyToArena = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyToArena", true, "Apply settings in arenas.アリーナで設定を適用");
			ApplyToSpectateCamera = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyToSpectateCamera", true, "Apply view settings while spectating.観戦カメラにも視界設定を適用");
			EnableDebugToggleKey = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDebugToggleKey", false, "Enable a temporary vanilla-view toggle key.一時的なバニラ表示切替キーを有効化");
			DebugToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DebugToggleKey", (KeyCode)102, "Toggle key used with Shift when EnableDebugToggleKey is true.EnableDebugToggleKey有効時にShiftと同時押しする切替キー");
			FogStartDistance = ((BaseUnityPlugin)this).Config.Bind<float>("ClearDistance", "FogStartDistance", 180f, new ConfigDescription("Linear fog start distance.線形Fog開始距離", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>()));
			FogEndDistance = ((BaseUnityPlugin)this).Config.Bind<float>("ClearDistance", "FogEndDistance", 300f, new ConfigDescription("Linear fog end distance.線形Fog終了距離", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 1500f), Array.Empty<object>()));
			CameraFarClipDistance = ((BaseUnityPlugin)this).Config.Bind<float>("ClearDistance", "CameraFarClipDistance", 350f, new ConfigDescription("Camera far clip distance.カメラ描画距離", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 2000f), Array.Empty<object>()));
			ShadowDistance = ((BaseUnityPlugin)this).Config.Bind<float>("ClearDistance", "ShadowDistance", 100f, new ConfigDescription("Unity shadow distance.影の描画距離", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 500f), Array.Empty<object>()));
			DisableFogCompletely = ((BaseUnityPlugin)this).Config.Bind<bool>("ClearDistance", "DisableFogCompletely", false, "Disable RenderSettings fog completely.REPOのFog自体を完全無効化");
			FogColorBlendToBlack = ((BaseUnityPlugin)this).Config.Bind<float>("ClearDistance", "FogColorBlendToBlack", 0f, new ConfigDescription("Blend fog color to black. 0 keeps vanilla. Fog色を黒へ寄せる割合。0でバニラ", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			AmbientLightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "AmbientLightMultiplier", 1.35f, new ConfigDescription("Ambient light brightness multiplier.環境光の明るさ倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			AmbientLightMaxValue = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "AmbientLightMaxValue", 1f, new ConfigDescription("Maximum RGB value after ambient multiplier.環境光補正後のRGB最大値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			ColorTemperatureOffset = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "ColorTemperatureOffset", 0f, new ConfigDescription("Color temperature offset.色温度の加算値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			ColorFilterBlendToWhite = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "ColorFilterBlendToWhite", 0.08f, new ConfigDescription("Blend level color filter toward white.レベル色フィルターを白へ寄せる割合", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			SaturationOffset = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "SaturationOffset", 0f, new ConfigDescription("Color grading saturation offset.彩度の加算値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			ContrastOffset = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "ContrastOffset", 5f, new ConfigDescription("Color grading contrast offset.コントラストの加算値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-100f, 100f), Array.Empty<object>()));
			BloomIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "BloomIntensityMultiplier", 0.75f, new ConfigDescription("Bloom intensity multiplier. Bloom強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			BloomThresholdMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "BloomThresholdMultiplier", 1.2f, new ConfigDescription("Bloom threshold multiplier. Bloomしきい値倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			LensDistortionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "LensDistortionMultiplier", 0f, new ConfigDescription("Lens distortion multiplier. 0 disables it.レンズ歪み倍率。0で無効化", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			VignetteIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "VignetteIntensityMultiplier", 0.25f, new ConfigDescription("Vignette intensity multiplier.ビネット強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			VignetteSmoothnessMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "VignetteSmoothnessMultiplier", 1f, new ConfigDescription("Vignette smoothness multiplier.ビネット滑らかさ倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			MotionBlurShutterMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "MotionBlurShutterMultiplier", 0f, new ConfigDescription("Motion blur shutter multiplier. 0 disables it.モーションブラー倍率。0で無効化", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			ChromaticAberrationMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "ChromaticAberrationMultiplier", 0f, new ConfigDescription("Chromatic aberration multiplier. 0 disables it.色収差倍率。0で無効化", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			GrainIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "GrainIntensityMultiplier", 0.25f, new ConfigDescription("Grain intensity multiplier.粒状ノイズ強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			GrainSizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CleanVisual", "GrainSizeMultiplier", 1f, new ConfigDescription("Grain size multiplier.粒状ノイズサイズ倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicLensDistortionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicLensDistortionMultiplier", 0.25f, new ConfigDescription("Temporary lens distortion override multiplier.一時レンズ歪み演出倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicVignetteIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicVignetteIntensityMultiplier", 0.4f, new ConfigDescription("Temporary vignette intensity override multiplier.一時ビネット強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicVignetteSmoothnessMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicVignetteSmoothnessMultiplier", 1f, new ConfigDescription("Temporary vignette smoothness override multiplier.一時ビネット滑らかさ倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicBloomIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicBloomIntensityMultiplier", 0.75f, new ConfigDescription("Temporary bloom intensity override multiplier.一時Bloom強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicBloomThresholdMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicBloomThresholdMultiplier", 1.2f, new ConfigDescription("Temporary bloom threshold override multiplier.一時Bloomしきい値倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicSaturationAmountMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicSaturationAmountMultiplier", 0.5f, new ConfigDescription("Temporary saturation override amount multiplier.一時彩度演出倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicContrastAmountMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicContrastAmountMultiplier", 0.5f, new ConfigDescription("Temporary contrast override amount multiplier.一時コントラスト演出倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			DynamicGrainIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DynamicGrainIntensityMultiplier", 0.35f, new ConfigDescription("Temporary grain intensity override amount multiplier.一時粒状ノイズ演出倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			VideoOverlayAmountMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "VideoOverlayAmountMultiplier", 0.3f, new ConfigDescription("Video overlay override amount multiplier.映像オーバーレイ演出倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			CameraGlitchChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "CameraGlitchChanceMultiplier", 0.15f, new ConfigDescription("Non-hurt camera glitch chance multiplier.被弾以外のカメラグリッチ発生倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			DoNotLookGlitchChanceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("DynamicEffects", "DoNotLookGlitchChanceMultiplier", 0.15f, new ConfigDescription("Do-not-look glitch chance multiplier.見てはいけない系グリッチ発生倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			RenderResolutionScale = ((BaseUnityPlugin)this).Config.Bind<float>("RenderTexture", "RenderResolutionScale", 1f, new ConfigDescription("Render texture scale based on the game's large resolution.ゲーム内Large解像度基準の描画テクスチャ倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 2f), Array.Empty<object>()));
			BlockTemporaryResolutionDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("RenderTexture", "BlockTemporaryResolutionDrop", true, "Block temporary low-resolution effects.一時的な低解像度化を防止");
			BlockRenderTextureShake = ((BaseUnityPlugin)this).Config.Bind<bool>("RenderTexture", "BlockRenderTextureShake", true, "Block render texture shake effects.描画テクスチャ揺れを防止");
			BlockRenderTextureSizeChange = ((BaseUnityPlugin)this).Config.Bind<bool>("RenderTexture", "BlockRenderTextureSizeChange", true, "Block render texture size changes.描画テクスチャ拡縮を防止");
			EnhancePropLights = ((BaseUnityPlugin)this).Config.Bind<bool>("Glow", "EnhancePropLights", true, "Enhance map prop lights.マップ設置ライトを強化");
			PropLightIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "PropLightIntensityMultiplier", 1.25f, new ConfigDescription("Prop light intensity multiplier.マップ設置ライト強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			PropLightRangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "PropLightRangeMultiplier", 1.1f, new ConfigDescription("Prop light range multiplier.マップ設置ライト範囲倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			EnhancePropEmissions = ((BaseUnityPlugin)this).Config.Bind<bool>("Glow", "EnhancePropEmissions", true, "Enhance emissive map objects.発光マップオブジェクトを強化");
			PropEmissionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "PropEmissionMultiplier", 1.25f, new ConfigDescription("Prop emission color multiplier.マップオブジェクト発光色倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			PropEmissionMaxValue = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "PropEmissionMaxValue", 3f, new ConfigDescription("Maximum HDR emission RGB value.発光HDR RGB最大値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			EnhanceItemLights = ((BaseUnityPlugin)this).Config.Bind<bool>("Glow", "EnhanceItemLights", true, "Enhance item lights and fresnel glow.アイテムライトとフレネル発光を強化");
			ItemLightIntensityMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "ItemLightIntensityMultiplier", 1.35f, new ConfigDescription("Item light intensity multiplier.アイテムライト強度倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			ItemLightRangeMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "ItemLightRangeMultiplier", 1.1f, new ConfigDescription("Item light range multiplier.アイテムライト範囲倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			ItemFresnelMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "ItemFresnelMultiplier", 1.25f, new ConfigDescription("Item fresnel glow multiplier.アイテムフレネル発光倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
			ItemFresnelMaxValue = ((BaseUnityPlugin)this).Config.Bind<float>("Glow", "ItemFresnelMaxValue", 3f, new ConfigDescription("Maximum item fresnel value.アイテムフレネル最大値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			ZoomKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Zoom", "ZoomKey", (KeyCode)122, "Key used for zoom.ズームに使用するキー");
			ZoomRate = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomRate", 5f, new ConfigDescription("Zoom multiplier.ズーム倍率", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 20f), Array.Empty<object>()));
			SaveWheelZoomToConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Zoom", "SaveWheelZoomToConfig", true, "Save mouse wheel zoom changes to config.ホイールで変更したZoom倍率をConfigへ保存");
			ZoomWheelStep = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomWheelStep", 0.1f, new ConfigDescription("Zoom multiplier step for mouse wheel.ホイール操作時のZoom倍率増減値", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 5f), Array.Empty<object>()));
			ZoomSmoothInSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomSmoothInSpeed", 6f, new ConfigDescription("Zoom-in smoothing speed.ズームイン補間速度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 60f), Array.Empty<object>()));
			ZoomSmoothOutSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomSmoothOutSpeed", 5f, new ConfigDescription("Zoom-out smoothing speed.ズームアウト補間速度", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 60f), Array.Empty<object>()));
			ZoomMinimumFov = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomMinimumFov", 0.1f, new ConfigDescription("Minimum FOV allowed by the zoom unlock.ズーム下限解除時の最小FOV", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 30f), Array.Empty<object>()));
			ZoomDisplaySeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Zoom", "ZoomDisplaySeconds", 1.25f, new ConfigDescription("Seconds to show the zoom rate text after wheel adjustment.ホイール調整後にZoom倍率を表示する秒数", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
		}

		private static void CacheReflectionFields()
		{
			environmentMainCameraField = AccessTools.Field(typeof(EnvironmentDirector), "MainCamera");
			postBloomIntensityField = AccessTools.Field(typeof(PostProcessing), "bloomIntensity");
			postBloomThresholdField = AccessTools.Field(typeof(PostProcessing), "bloomThreshold");
			postLensDistortionIntensityField = AccessTools.Field(typeof(PostProcessing), "lensDistortionIntensity");
			postColorGradingSaturationField = AccessTools.Field(typeof(PostProcessing), "colorGradingSaturation");
			postColorGradingContrastField = AccessTools.Field(typeof(PostProcessing), "colorGradingContrast");
			postVignetteColorField = AccessTools.Field(typeof(PostProcessing), "vignetteColor");
			postVignetteIntensityField = AccessTools.Field(typeof(PostProcessing), "vignetteIntensity");
			postVignetteSmoothnessField = AccessTools.Field(typeof(PostProcessing), "vignetteSmoothness");
			postGrainIntensityDefaultField = AccessTools.Field(typeof(PostProcessing), "grainIntensityDefault");
			postGrainSizeDefaultField = AccessTools.Field(typeof(PostProcessing), "grainSizeDefault");
			postMotionBlurDefaultField = AccessTools.Field(typeof(PostProcessing), "motionBlurDefault");
			graphicsGlitchLoopField = AccessTools.Field(typeof(GraphicsManager), "glitchLoop");
			renderTextureWidthOriginalField = AccessTools.Field(typeof(RenderTextureMain), "textureWidthOriginal");
			renderTextureHeightOriginalField = AccessTools.Field(typeof(RenderTextureMain), "textureHeightOriginal");
			renderTextureShakeActiveField = AccessTools.Field(typeof(RenderTextureMain), "shakeActive");
			renderTextureShakeTimerField = AccessTools.Field(typeof(RenderTextureMain), "shakeTimer");
			renderTextureSizeResetTimerField = AccessTools.Field(typeof(RenderTextureMain), "sizeResetTimer");
			renderTextureOriginalSizeField = AccessTools.Field(typeof(RenderTextureMain), "originalSize");
			propLightComponentField = AccessTools.Field(typeof(PropLight), "lightComponent");
			propLightOriginalIntensityField = AccessTools.Field(typeof(PropLight), "originalIntensity");
			propEmissionMaterialField = AccessTools.Field(typeof(PropLightEmission), "material");
			propEmissionOriginalEmissionField = AccessTools.Field(typeof(PropLightEmission), "originalEmission");
			itemLightIntensityOriginalField = AccessTools.Field(typeof(ItemLight), "lightIntensityOriginal");
			itemLightRangeOriginalField = AccessTools.Field(typeof(ItemLight), "lightRangeOriginal");
			itemLightFresnelScaleOriginalField = AccessTools.Field(typeof(ItemLight), "fresnelScaleOriginal");
			levelFogStartDistanceField = AccessTools.Field(typeof(Level), "FogStartDistance");
			levelFogEndDistanceField = AccessTools.Field(typeof(Level), "FogEndDistance");
			levelFogColorField = AccessTools.Field(typeof(Level), "FogColor");
			levelAmbientColorField = AccessTools.Field(typeof(Level), "AmbientColor");
			levelAmbientColorAdaptationField = AccessTools.Field(typeof(Level), "AmbientColorAdaptation");
			levelColorTemperatureField = AccessTools.Field(typeof(Level), "ColorTemperature");
			levelColorFilterField = AccessTools.Field(typeof(Level), "ColorFilter");
			levelBloomIntensityField = AccessTools.Field(typeof(Level), "BloomIntensity");
			levelBloomThresholdField = AccessTools.Field(typeof(Level), "BloomThreshold");
			levelLensDistortionIntensityField = AccessTools.Field(typeof(Level), "LensDistortionIntensity");
			levelVignetteColorField = AccessTools.Field(typeof(Level), "VignetteColor");
			levelVignetteIntensityField = AccessTools.Field(typeof(Level), "VignetteIntensity");
			levelVignetteSmoothnessField = AccessTools.Field(typeof(Level), "VignetteSmoothness");
		}

		private static void CreateRuntimeController()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			if (!((Object)(object)runtime != (Object)null))
			{
				GameObject val = new GameObject("BetterViewRuntime");
				val.transform.parent = null;
				((Object)val).hideFlags = (HideFlags)61;
				Object.DontDestroyOnLoad((Object)(object)val);
				runtime = val.AddComponent<BetterViewRuntime>();
			}
		}

		internal static bool IsModEnabled()
		{
			return EnableMod != null && EnableMod.Value && !debugForceVanillaView;
		}

		internal static bool CanApplyNow()
		{
			try
			{
				if (!IsModEnabled())
				{
					return false;
				}
				if ((Object)(object)LevelGenerator.Instance == (Object)null || !LevelGenerator.Instance.Generated)
				{
					return false;
				}
				if (!GetBool(ApplyToSpectateCamera, fallback: true) && IsPlayerSpectating())
				{
					return false;
				}
				bool flag = false;
				bool flag2 = false;
				try
				{
					flag = SemiFunc.RunIsLevel();
				}
				catch
				{
					flag = false;
				}
				try
				{
					flag2 = SemiFunc.RunIsArena();
				}
				catch
				{
					flag2 = false;
				}
				return (flag && GetBool(ApplyToLevel, fallback: true)) || (flag2 && GetBool(ApplyToArena, fallback: true));
			}
			catch
			{
				return false;
			}
		}

		private static bool IsPlayerSpectating()
		{
			try
			{
				if ((Object)(object)PlayerAvatar.instance != (Object)null)
				{
					return PlayerAvatar.instance.spectating;
				}
				if ((Object)(object)PlayerController.instance != (Object)null && (Object)(object)PlayerController.instance.playerAvatarScript != (Object)null)
				{
					return PlayerController.instance.playerAvatarScript.spectating;
				}
			}
			catch
			{
				return false;
			}
			return false;
		}

		internal static void HandleDebugToggleKey()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!GetBool(EnableDebugToggleKey, fallback: false))
				{
					if (debugForceVanillaView)
					{
						debugForceVanillaView = false;
					}
				}
				else if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown(GetKeyCode(DebugToggleKey, (KeyCode)102)))
				{
					debugForceVanillaView = !debugForceVanillaView;
					if (debugForceVanillaView)
					{
						RestoreDistanceSettings();
						RestoreRenderTextureSettings();
						RestoreGlowSettings();
						RestorePostProcessingState(PostProcessing.Instance);
					}
					else
					{
						ApplyEverything(force: true);
					}
					if (Log != null)
					{
						Log.LogInfo((object)("Success: Debug view toggle " + (debugForceVanillaView ? "Vanilla" : "Modded")));
					}
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: HandleDebugToggleKey\n" + ex));
				}
			}
		}

		internal static void ApplyEverything(bool force)
		{
			ApplyDistanceSettings(force);
			ApplyPostProcessingSettings(PostProcessing.Instance, beforeUpdate: false);
			ApplyRenderTextureSettings(force);
			ApplyGlowSettings(force);
		}

		internal static void ApplyDistanceSettings(bool force)
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Invalid comparison between Unknown and I4
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!CanApplyNow())
				{
					RestoreDistanceSettings();
					return;
				}
				Camera mainGameplayCamera = GetMainGameplayCamera();
				if ((Object)(object)mainGameplayCamera == (Object)null || !((Behaviour)mainGameplayCamera).isActiveAndEnabled)
				{
					return;
				}
				if (!hasDistanceState || distanceCameraId != ((Object)mainGameplayCamera).GetInstanceID())
				{
					CaptureDistanceState(mainGameplayCamera);
				}
				float num = Clamp(GetFloat(FogStartDistance, 180f), 0f, 1000f);
				float num2 = Clamp(GetFloat(FogEndDistance, 300f), 1f, 1500f);
				if (num >= num2)
				{
					num = Mathf.Max(0f, num2 - 1f);
				}
				float num3 = Clamp(GetFloat(CameraFarClipDistance, 350f), 1f, 2000f);
				if (num3 <= mainGameplayCamera.nearClipPlane + 0.01f)
				{
					num3 = mainGameplayCamera.nearClipPlane + 0.01f;
				}
				bool @bool = GetBool(DisableFogCompletely, fallback: false);
				RenderSettings.fog = !@bool;
				if (!@bool)
				{
					if ((int)RenderSettings.fogMode != 1)
					{
						RenderSettings.fogMode = (FogMode)1;
					}
					RenderSettings.fogStartDistance = num;
					RenderSettings.fogEndDistance = num2;
					RenderSettings.fogColor = Color.Lerp(originalFogColor, Color.black, Clamp01(GetFloat(FogColorBlendToBlack, 0f)));
				}
				mainGameplayCamera.farClipPlane = num3;
				QualitySettings.shadowDistance = Clamp(GetFloat(ShadowDistance, 100f), 0f, 500f);
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyDistanceSettings\n" + ex));
				}
			}
		}

		private static void CaptureDistanceState(Camera targetCamera)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			hasDistanceState = true;
			distanceCameraId = ((Object)targetCamera).GetInstanceID();
			distanceOriginalFarClip = targetCamera.farClipPlane;
			originalFogStart = RenderSettings.fogStartDistance;
			originalFogEnd = RenderSettings.fogEndDistance;
			originalFogColor = RenderSettings.fogColor;
			originalFogEnabled = RenderSettings.fog;
			originalShadowDistance = QualitySettings.shadowDistance;
		}

		internal static void RestoreDistanceSettings()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (hasDistanceState)
				{
					Camera mainGameplayCamera = GetMainGameplayCamera();
					if ((Object)(object)mainGameplayCamera != (Object)null && distanceOriginalFarClip > 0f)
					{
						mainGameplayCamera.farClipPlane = distanceOriginalFarClip;
					}
					RenderSettings.fog = originalFogEnabled;
					RenderSettings.fogStartDistance = originalFogStart;
					RenderSettings.fogEndDistance = originalFogEnd;
					RenderSettings.fogColor = originalFogColor;
					if (originalShadowDistance >= 0f)
					{
						QualitySettings.shadowDistance = originalShadowDistance;
					}
					hasDistanceState = false;
					distanceCameraId = -1;
					distanceOriginalFarClip = -1f;
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: RestoreDistanceSettings\n" + ex));
				}
			}
		}

		private static Camera GetMainGameplayCamera()
		{
			try
			{
				if ((Object)(object)EnvironmentDirector.Instance != (Object)null && environmentMainCameraField != null)
				{
					object? value = environmentMainCameraField.GetValue(EnvironmentDirector.Instance);
					Camera val = (Camera)((value is Camera) ? value : null);
					if ((Object)(object)val != (Object)null)
					{
						return val;
					}
				}
				if ((Object)(object)GameDirector.instance != (Object)null && (Object)(object)GameDirector.instance.MainCamera != (Object)null)
				{
					return GameDirector.instance.MainCamera;
				}
			}
			catch
			{
			}
			return Camera.main;
		}

		internal static void CapturePostProcessingState(PostProcessing postProcessing, bool force)
		{
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)postProcessing == (Object)null))
				{
					int instanceID = ((Object)postProcessing).GetInstanceID();
					Level currentLevel = GetCurrentLevel();
					int num = ((!((Object)(object)currentLevel == (Object)null)) ? ((Object)currentLevel).GetInstanceID() : 0);
					if (force || !postProcessingStates.TryGetValue(instanceID, out var value) || value.LevelId != num)
					{
						EnsurePostProcessingComponents(postProcessing);
						PostProcessingState value2 = default(PostProcessingState);
						value2.LevelId = num;
						value2.BloomIntensity = GetLevelFloat(levelBloomIntensityField, currentLevel, GetPrivateFloat(postBloomIntensityField, postProcessing, GetBloomIntensity(postProcessing)));
						value2.BloomThreshold = GetLevelFloat(levelBloomThresholdField, currentLevel, GetPrivateFloat(postBloomThresholdField, postProcessing, GetBloomThreshold(postProcessing)));
						value2.LensDistortionIntensity = GetLevelFloat(levelLensDistortionIntensityField, currentLevel, GetPrivateFloat(postLensDistortionIntensityField, postProcessing, GetLensDistortionIntensity(postProcessing)));
						value2.VignetteColor = GetLevelColor(levelVignetteColorField, currentLevel, GetPrivateColor(postVignetteColorField, postProcessing, GetVignetteColor(postProcessing)));
						value2.VignetteIntensity = GetLevelFloat(levelVignetteIntensityField, currentLevel, GetPrivateFloat(postVignetteIntensityField, postProcessing, GetVignetteIntensity(postProcessing)));
						value2.VignetteSmoothness = GetLevelFloat(levelVignetteSmoothnessField, currentLevel, GetPrivateFloat(postVignetteSmoothnessField, postProcessing, GetVignetteSmoothness(postProcessing)));
						value2.ColorTemperature = GetLevelFloat(levelColorTemperatureField, currentLevel, GetColorTemperature(postProcessing));
						value2.ColorFilter = GetLevelColor(levelColorFilterField, currentLevel, GetColorFilter(postProcessing));
						value2.Saturation = GetPrivateFloat(postColorGradingSaturationField, postProcessing, GetSaturation(postProcessing));
						value2.Contrast = GetPrivateFloat(postColorGradingContrastField, postProcessing, GetContrast(postProcessing));
						value2.GrainIntensity = GetPrivateFloat(postGrainIntensityDefaultField, postProcessing, GetGrainIntensity(postProcessing));
						value2.GrainSize = GetPrivateFloat(postGrainSizeDefaultField, postProcessing, GetGrainSize(postProcessing));
						value2.MotionBlurShutter = GetPrivateFloat(postMotionBlurDefaultField, postProcessing, GetMotionBlurShutter(postProcessing));
						value2.ChromaticAberrationIntensity = GetChromaticAberrationIntensity(postProcessing);
						postProcessingStates[instanceID] = value2;
					}
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: CapturePostProcessingState\n" + ex));
				}
			}
		}

		internal static void ApplyPostProcessingSettings(PostProcessing postProcessing, bool beforeUpdate)
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)postProcessing == (Object)null)
				{
					return;
				}
				if (!CanApplyNow())
				{
					RestorePostProcessingState(postProcessing);
					return;
				}
				CapturePostProcessingState(postProcessing, force: false);
				if (postProcessingStates.TryGetValue(((Object)postProcessing).GetInstanceID(), out var value))
				{
					EnsurePostProcessingComponents(postProcessing);
					float num = value.BloomIntensity * Clamp(GetFloat(BloomIntensityMultiplier, 0.75f), 0f, 10f);
					float num2 = value.BloomThreshold * Clamp(GetFloat(BloomThresholdMultiplier, 1.2f), 0f, 10f);
					float num3 = value.LensDistortionIntensity * Clamp(GetFloat(LensDistortionMultiplier, 0f), 0f, 10f);
					float num4 = value.VignetteIntensity * Clamp(GetFloat(VignetteIntensityMultiplier, 0.25f), 0f, 10f);
					float num5 = value.VignetteSmoothness * Clamp(GetFloat(VignetteSmoothnessMultiplier, 1f), 0f, 10f);
					float num6 = value.Saturation + Clamp(GetFloat(SaturationOffset, 0f), -100f, 100f);
					float num7 = value.Contrast + Clamp(GetFloat(ContrastOffset, 5f), -100f, 100f);
					float value2 = value.ColorTemperature + Clamp(GetFloat(ColorTemperatureOffset, 0f), -100f, 100f);
					Color value3 = Color.Lerp(value.ColorFilter, Color.white, Clamp01(GetFloat(ColorFilterBlendToWhite, 0.08f)));
					float num8 = value.GrainIntensity * Clamp(GetFloat(GrainIntensityMultiplier, 0.25f), 0f, 10f);
					float num9 = value.GrainSize * Clamp(GetFloat(GrainSizeMultiplier, 1f), 0f, 10f);
					float num10 = value.MotionBlurShutter * Clamp(GetFloat(MotionBlurShutterMultiplier, 0f), 0f, 10f);
					float num11 = value.ChromaticAberrationIntensity * Clamp(GetFloat(ChromaticAberrationMultiplier, 0f), 0f, 10f);
					SetPrivateField(postBloomIntensityField, postProcessing, num);
					SetPrivateField(postBloomThresholdField, postProcessing, num2);
					SetPrivateField(postLensDistortionIntensityField, postProcessing, num3);
					SetPrivateField(postVignetteColorField, postProcessing, value.VignetteColor);
					SetPrivateField(postVignetteIntensityField, postProcessing, num4);
					SetPrivateField(postVignetteSmoothnessField, postProcessing, num5);
					SetPrivateField(postColorGradingSaturationField, postProcessing, num6);
					SetPrivateField(postColorGradingContrastField, postProcessing, num7);
					SetPrivateField(postGrainIntensityDefaultField, postProcessing, num8);
					SetPrivateField(postGrainSizeDefaultField, postProcessing, num9);
					SetPrivateField(postMotionBlurDefaultField, postProcessing, num10);
					if (TryGetPostSetting<ColorGrading>(postProcessing, out ColorGrading setting))
					{
						((ParameterOverride<float>)(object)setting.temperature).value = value2;
						((ParameterOverride<Color>)(object)setting.colorFilter).value = value3;
						((ParameterOverride<float>)(object)setting.saturation).value = num6;
						((ParameterOverride<float>)(object)setting.contrast).value = num7;
					}
					if (TryGetPostSetting<Bloom>(postProcessing, out Bloom setting2))
					{
						((PostProcessEffectSettings)setting2).active = num > 0.001f;
						((ParameterOverride<float>)(object)setting2.intensity).value = num;
						((ParameterOverride<float>)(object)setting2.threshold).value = num2;
					}
					if (TryGetPostSetting<LensDistortion>(postProcessing, out LensDistortion setting3))
					{
						((PostProcessEffectSettings)setting3).active = Mathf.Abs(num3) > 0.001f;
						((ParameterOverride<float>)(object)setting3.intensity).value = num3;
					}
					if (TryGetPostSetting<Vignette>(postProcessing, out Vignette setting4))
					{
						((ParameterOverride<Color>)(object)setting4.color).value = value.VignetteColor;
						((ParameterOverride<float>)(object)setting4.intensity).value = num4;
						((ParameterOverride<float>)(object)setting4.smoothness).value = Mathf.Clamp01(num5);
					}
					if (TryGetPostSetting<MotionBlur>(postProcessing, out MotionBlur setting5))
					{
						((PostProcessEffectSettings)setting5).active = num10 > 0.001f;
						((ParameterOverride<float>)(object)setting5.shutterAngle).value = num10;
					}
					if (TryGetPostSetting<ChromaticAberration>(postProcessing, out ChromaticAberration setting6))
					{
						((PostProcessEffectSettings)setting6).active = num11 > 0.001f;
						((ParameterOverride<float>)(object)setting6.intensity).value = num11;
					}
					if (TryGetPostSetting<Grain>(postProcessing, out Grain setting7))
					{
						((PostProcessEffectSettings)setting7).active = num8 > 0.001f;
						((ParameterOverride<float>)(object)setting7.intensity).value = num8;
						((ParameterOverride<float>)(object)setting7.size).value = num9;
					}
					ApplyAmbientLight(value);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyPostProcessingSettings\n" + ex));
				}
			}
		}

		private static void ApplyAmbientLight(PostProcessingState state)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Level currentLevel = GetCurrentLevel();
				Color levelColor = GetLevelColor(levelAmbientColorField, currentLevel, RenderSettings.ambientLight);
				Color levelColor2 = GetLevelColor(levelAmbientColorAdaptationField, currentLevel, levelColor);
				Color source = Color.Lerp(levelColor, levelColor2, 0.5f);
				float multiplier = Clamp(GetFloat(AmbientLightMultiplier, 1.35f), 0f, 10f);
				float maxValue = Clamp(GetFloat(AmbientLightMaxValue, 1f), 0f, 5f);
				RenderSettings.ambientLight = MultiplyColorClamped(source, multiplier, maxValue);
			}
			catch
			{
			}
		}

		internal static void RestorePostProcessingState(PostProcessing postProcessing)
		{
			//IL_0089: 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_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)postProcessing == (Object)null) && postProcessingStates.TryGetValue(((Object)postProcessing).GetInstanceID(), out var value))
				{
					EnsurePostProcessingComponents(postProcessing);
					SetPrivateField(postBloomIntensityField, postProcessing, value.BloomIntensity);
					SetPrivateField(postBloomThresholdField, postProcessing, value.BloomThreshold);
					SetPrivateField(postLensDistortionIntensityField, postProcessing, value.LensDistortionIntensity);
					SetPrivateField(postVignetteColorField, postProcessing, value.VignetteColor);
					SetPrivateField(postVignetteIntensityField, postProcessing, value.VignetteIntensity);
					SetPrivateField(postVignetteSmoothnessField, postProcessing, value.VignetteSmoothness);
					SetPrivateField(postColorGradingSaturationField, postProcessing, value.Saturation);
					SetPrivateField(postColorGradingContrastField, postProcessing, value.Contrast);
					SetPrivateField(postGrainIntensityDefaultField, postProcessing, value.GrainIntensity);
					SetPrivateField(postGrainSizeDefaultField, postProcessing, value.GrainSize);
					SetPrivateField(postMotionBlurDefaultField, postProcessing, value.MotionBlurShutter);
					if (TryGetPostSetting<ColorGrading>(postProcessing, out ColorGrading setting))
					{
						((ParameterOverride<float>)(object)setting.temperature).value = value.ColorTemperature;
						((ParameterOverride<Color>)(object)setting.colorFilter).value = value.ColorFilter;
						((ParameterOverride<float>)(object)setting.saturation).value = value.Saturation;
						((ParameterOverride<float>)(object)setting.contrast).value = value.Contrast;
					}
					if (TryGetPostSetting<Bloom>(postProcessing, out Bloom setting2))
					{
						((ParameterOverride<float>)(object)setting2.intensity).value = value.BloomIntensity;
						((ParameterOverride<float>)(object)setting2.threshold).value = value.BloomThreshold;
					}
					if (TryGetPostSetting<LensDistortion>(postProcessing, out LensDistortion setting3))
					{
						((ParameterOverride<float>)(object)setting3.intensity).value = value.LensDistortionIntensity;
					}
					if (TryGetPostSetting<Vignette>(postProcessing, out Vignette setting4))
					{
						((ParameterOverride<Color>)(object)setting4.color).value = value.VignetteColor;
						((ParameterOverride<float>)(object)setting4.intensity).value = value.VignetteIntensity;
						((ParameterOverride<float>)(object)setting4.smoothness).value = value.VignetteSmoothness;
					}
					if (TryGetPostSetting<MotionBlur>(postProcessing, out MotionBlur setting5))
					{
						((ParameterOverride<float>)(object)setting5.shutterAngle).value = value.MotionBlurShutter;
					}
					if (TryGetPostSetting<ChromaticAberration>(postProcessing, out ChromaticAberration setting6))
					{
						((ParameterOverride<float>)(object)setting6.intensity).value = value.ChromaticAberrationIntensity;
					}
					if (TryGetPostSetting<Grain>(postProcessing, out Grain setting7))
					{
						((ParameterOverride<float>)(object)setting7.intensity).value = value.GrainIntensity;
						((ParameterOverride<float>)(object)setting7.size).value = value.GrainSize;
					}
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: RestorePostProcessingState\n" + ex));
				}
			}
		}

		internal static void ApplyRenderTextureSettings(bool force)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!CanApplyNow())
				{
					RestoreRenderTextureSettings();
					return;
				}
				RenderTextureMain instance = RenderTextureMain.instance;
				if ((Object)(object)instance == (Object)null || (Object)(object)instance.renderTexture == (Object)null)
				{
					return;
				}
				if (!hasRenderTextureState)
				{
					hasRenderTextureState = true;
					originalTextureWidthOriginal = GetPrivateFloat(renderTextureWidthOriginalField, instance, instance.textureWidthLarge);
					originalTextureHeightOriginal = GetPrivateFloat(renderTextureHeightOriginalField, instance, instance.textureHeightLarge);
					originalRenderTextureSize = ((Component)instance).transform.localScale;
					if (renderTextureOriginalSizeField != null)
					{
						object value = renderTextureOriginalSizeField.GetValue(instance);
						if (value is Vector3)
						{
							originalRenderTextureSize = (Vector3)value;
						}
					}
				}
				float num = Clamp(GetFloat(RenderResolutionScale, 1f), 0.25f, 2f);
				float num2 = ((instance.textureWidthLarge > 0f) ? instance.textureWidthLarge : originalTextureWidthOriginal);
				float num3 = ((instance.textureHeightLarge > 0f) ? instance.textureHeightLarge : originalTextureHeightOriginal);
				float num4 = Mathf.Max(1f, num2 * num);
				float num5 = Mathf.Max(1f, num3 * num);
				float privateFloat = GetPrivateFloat(renderTextureWidthOriginalField, instance, originalTextureWidthOriginal);
				float privateFloat2 = GetPrivateFloat(renderTextureHeightOriginalField, instance, originalTextureHeightOriginal);
				bool flag = !NearlyEqual(privateFloat, num4) || !NearlyEqual(privateFloat2, num5) || ((Texture)instance.renderTexture).width != (int)num4 || ((Texture)instance.renderTexture).height != (int)num5;
				SetPrivateField(renderTextureWidthOriginalField, instance, num4);
				SetPrivateField(renderTextureHeightOriginalField, instance, num5);
				if (flag || force)
				{
					instance.ResetResolution();
				}
				if (GetBool(BlockRenderTextureShake, fallback: true))
				{
					SetPrivateField(renderTextureShakeActiveField, instance, false);
					SetPrivateField(renderTextureShakeTimerField, instance, 0f);
					((Component)instance).transform.localPosition = Vector3.zero;
				}
				if (GetBool(BlockRenderTextureSizeChange, fallback: true))
				{
					((Component)instance).transform.localScale = originalRenderTextureSize;
					SetPrivateField(renderTextureSizeResetTimerField, instance, 0f);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyRenderTextureSettings\n" + ex));
				}
			}
		}

		internal static void RestoreRenderTextureSettings()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (hasRenderTextureState && !((Object)(object)RenderTextureMain.instance == (Object)null))
				{
					RenderTextureMain instance = RenderTextureMain.instance;
					SetPrivateField(renderTextureWidthOriginalField, instance, originalTextureWidthOriginal);
					SetPrivateField(renderTextureHeightOriginalField, instance, originalTextureHeightOriginal);
					((Component)instance).transform.localScale = originalRenderTextureSize;
					instance.ResetResolution();
					hasRenderTextureState = false;
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: RestoreRenderTextureSettings\n" + ex));
				}
			}
		}

		internal static void ApplyGlowSettings(bool force)
		{
			try
			{
				if (!CanApplyNow())
				{
					RestoreGlowSettings();
					return;
				}
				PropLight[] array = Object.FindObjectsOfType<PropLight>();
				for (int i = 0; i < array.Length; i++)
				{
					ApplyPropLight(array[i]);
				}
				PropLightEmission[] array2 = Object.FindObjectsOfType<PropLightEmission>();
				for (int j = 0; j < array2.Length; j++)
				{
					ApplyPropEmission(array2[j]);
				}
				ItemLight[] array3 = Object.FindObjectsOfType<ItemLight>();
				for (int k = 0; k < array3.Length; k++)
				{
					ApplyItemLight(array3[k]);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyGlowSettings\n" + ex));
				}
			}
		}

		internal static void ApplyPropLight(PropLight propLight)
		{
			try
			{
				if ((Object)(object)propLight == (Object)null || !CanApplyNow())
				{
					return;
				}
				if (!GetBool(EnhancePropLights, fallback: true))
				{
					RestoreOnePropLight(propLight);
					return;
				}
				Light val = null;
				if (propLightComponentField != null)
				{
					object? value = propLightComponentField.GetValue(propLight);
					val = (Light)((value is Light) ? value : null);
				}
				if ((Object)(object)val == (Object)null)
				{
					val = ((Component)propLight).GetComponent<Light>();
				}
				if (!((Object)(object)val == (Object)null))
				{
					if (!propLightStates.TryGetValue(propLight, out var value2))
					{
						value2 = default(PropLightState);
						value2.OriginalIntensity = GetPrivateFloat(propLightOriginalIntensityField, propLight, val.intensity);
						value2.CurrentIntensity = val.intensity;
						value2.OriginalRange = val.range;
						propLightStates[propLight] = value2;
					}
					float num = Clamp(GetFloat(PropLightIntensityMultiplier, 1.25f), 0f, 10f);
					float num2 = Clamp(GetFloat(PropLightRangeMultiplier, 1.1f), 0f, 5f);
					float num3 = value2.OriginalIntensity * num;
					float range = value2.OriginalRange * num2;
					SetPrivateField(propLightOriginalIntensityField, propLight, num3);
					if (((Behaviour)val).enabled && val.intensity > 0f)
					{
						val.intensity = Mathf.Max(val.intensity, num3);
					}
					val.range = range;
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyPropLight\n" + ex));
				}
			}
		}

		internal static void ApplyPropEmission(PropLightEmission propEmission)
		{
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)propEmission == (Object)null || !CanApplyNow())
				{
					return;
				}
				if (!GetBool(EnhancePropEmissions, fallback: true))
				{
					RestoreOnePropEmission(propEmission);
					return;
				}
				Material val = null;
				if (propEmissionMaterialField != null)
				{
					object? value = propEmissionMaterialField.GetValue(propEmission);
					val = (Material)((value is Material) ? value : null);
				}
				if ((Object)(object)val == (Object)null)
				{
					Renderer component = ((Component)propEmission).GetComponent<Renderer>();
					if ((Object)(object)component != (Object)null)
					{
						val = component.material;
					}
				}
				if (!((Object)(object)val == (Object)null) && val.HasProperty("_EmissionColor"))
				{
					if (!propEmissionStates.TryGetValue(propEmission, out var value2))
					{
						value2 = default(PropEmissionState);
						value2.OriginalEmission = GetPrivateColor(propEmissionOriginalEmissionField, propEmission, val.GetColor("_EmissionColor"));
						value2.CurrentEmission = val.GetColor("_EmissionColor");
						propEmissionStates[propEmission] = value2;
					}
					float multiplier = Clamp(GetFloat(PropEmissionMultiplier, 1.25f), 0f, 10f);
					float maxValue = Clamp(GetFloat(PropEmissionMaxValue, 3f), 0f, 20f);
					Color val2 = MultiplyColorClamped(value2.OriginalEmission, multiplier, maxValue);
					SetPrivateField(propEmissionOriginalEmissionField, propEmission, val2);
					val.EnableKeyword("_EMISSION");
					val.SetColor("_EmissionColor", val2);
				}
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyPropEmission\n" + ex));
				}
			}
		}

		internal static void ApplyItemLight(ItemLight itemLight)
		{
			try
			{
				if ((Object)(object)itemLight == (Object)null || (Object)(object)itemLight.itemLight == (Object)null || !CanApplyNow())
				{
					return;
				}
				if (!GetBool(EnhanceItemLights, fallback: true))
				{
					RestoreOneItemLight(itemLight);
					return;
				}
				if (!itemLightStates.TryGetValue(itemLight, out var value))
				{
					value = default(ItemLightState);
					value.OriginalIntensity = GetPrivateFloat(itemLightIntensityOriginalField, itemLight, itemLight.itemLight.intensity);
					value.OriginalRange = GetPrivateFloat(itemLightRangeOriginalField, itemLight, itemLight.itemLight.range);
					value.OriginalFresnel = GetPrivateFloat(itemLightFresnelScaleOriginalField, itemLight, 0f);
					value.CurrentIntensity = itemLight.itemLight.intensity;
					value.CurrentRange = itemLight.itemLight.range;
					itemLightStates[itemLight] = value;
				}
				float num = Clamp(GetFloat(ItemLightIntensityMultiplier, 1.35f), 0f, 10f);
				float num2 = Clamp(GetFloat(ItemLightRangeMultiplier, 1.1f), 0f, 5f);
				float num3 = Clamp(GetFloat(ItemFresnelMultiplier, 1.25f), 0f, 10f);
				float num4 = Clamp(GetFloat(ItemFresnelMaxValue, 3f), 0f, 20f);
				float num5 = value.OriginalIntensity * num;
				float num6 = value.OriginalRange * num2;
				float num7 = Mathf.Clamp(value.OriginalFresnel * num3, 0f, num4);
				SetPrivateField(itemLightIntensityOriginalField, itemLight, num5);
				SetPrivateField(itemLightRangeOriginalField, itemLight, num6);
				SetPrivateField(itemLightFresnelScaleOriginalField, itemLight, num7);
				if (((Behaviour)itemLight.itemLight).enabled || itemLight.itemLight.intensity > 0f)
				{
					itemLight.itemLight.intensity = Mathf.Max(itemLight.itemLight.intensity, num5);
					itemLight.itemLight.range = Mathf.Max(itemLight.itemLight.range, num6);
				}
				ApplyItemFresnel(itemLight, num7);
			}
			catch (Exception ex)
			{
				if (Log != null)
				{
					Log.LogError((object)("Failure: ApplyItemLight\n" + ex));
				}
			}
		}

		private static void ApplyItemFresnel(ItemLight itemLight, float value)
		{
			if ((Object)(object)itemLight == (Object)null || itemLight.meshRenderers == null)
			{
				return;
			}
			foreach (MeshRenderer meshRenderer in itemLight.meshRenderers)
			{
				if ((Object)(object)meshRenderer != (Object)null && ((Component)meshRenderer).gameObject.activeSelf && (Object)(object)((Renderer)meshRenderer).material != (Object)null && ((Renderer)meshRenderer).material.HasProperty("_FresnelScale"))
				{
					((Renderer)meshRenderer).material.SetFloat("_FresnelScale", value);
				}
			}
		}

		internal static void RestoreGlowSettings()
		{
			foreach (KeyValuePair<PropLight, PropLightState> item in new List<KeyValuePair<PropLight, PropLightState>>(propLightStates))
			{
				RestoreOnePropLight(item.Key);
			}
			propLightStates.Clear();
			foreach (KeyValuePair<PropLightEmission, PropEmissionState> item2 in new List<KeyValuePair<PropLightEmission, PropEmissionState>>(propEmissionStates))
			{
				RestoreOnePropEmission(item2.Key);
			}
			propEmissionStates.Clear();
			foreach (KeyValuePair<ItemLight, ItemLightState> item3 in new List<KeyValuePair<ItemLight, ItemLightState>>(itemLightStates))
			{
				RestoreOneItemLight(item3.Key);
			}
			itemLightStates.Clear();
		}

		private static void RestoreOnePropLight(PropLight propLight)
		{
			try
			{
				if (!((Object)(object)propLight == (Object)null) && propLightStates.TryGetValue(propLight, out var value))
				{
					Light val = null;
					if (propLightComponentField != null)
					{
						object? value2 = propLightComponentField.GetValue(propLight);
						val = (Light)((value2 is Light) ? value2 : null);
					}
					if ((Object)(object)val == (Object)null)
					{
						val = ((Component)propLight).GetComponent<Light>();
					}
					SetPrivateField(propLightOriginalIntensityField, propLight, value.OriginalIntensity);
					if ((Object)(object)val != (Object)null)
					{
						val.intensity = value.CurrentIntensity;
						val.range = value.OriginalRange;
					}
					propLightStates.Remove(propLight);
				}
			}
			catch
			{
			}
		}

		private static void RestoreOnePropEmission(PropLightEmission propEmission)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!((Object)(object)propEmission == (Object)null) && propEmissionStates.TryGetValue(propEmission, out var value))
				{
					Material val = null;
					if (propEmissionMaterialField != null)
					{
						object? value2 = propEmissionMaterialField.GetValue(propEmission);
						val = (Material)((value2 is Material) ? value2 : null);
					}
					SetPrivateField(propEmissionOriginalEmissionField, propEmission, value.OriginalEmission);
					if ((Object)(object)val != (Object)null && val.HasProperty("_EmissionColor"))
					{
						val.SetColor("_EmissionColor", value.CurrentEmission);
					}
					propEmissionStates.Remove(propEmission);
				}
			}
			catch
			{
			}
		}

		private static void RestoreOneItemLight(ItemLight itemLight)
		{
			try
			{
				if (!((Object)(object)itemLight == (Object)null) && itemLightStates.TryGetValue(itemLight, out var value))
				{
					SetPrivateField(itemLightIntensityOriginalField, itemLight, value.OriginalIntensity);
					SetPrivateField(itemLightRangeOriginalField, itemLight, value.OriginalRange);
					SetPrivateField(itemLightFresnelScaleOriginalField, itemLight, value.OriginalFresnel);
					if ((Object)(object)itemLight.itemLight != (Object)null)
					{
						itemLight.itemLight.intensity = value.CurrentIntensity;
						itemLight.itemLight.range = value.CurrentRange;
					}
					ApplyItemFresnel(itemLight, value.OriginalFresnel);
					itemLightStates.Remove(itemLight);
				}
			}
			catch
			{
			}
		}

		private static void EnsurePostProcessingComponents(PostProcessing postProcessing)
		{
			if (!((Object)(object)postProcessing == (Object)null) && !((Object)(object)postProcessing.volume == (Object)null) && !((Object)(object)postProcessing.volume.profile == (Object)null))
			{
			}
		}

		private static bool TryGetPostSetting<T>(PostProcessing postProcessing, out T setting) where T : PostProcessEffectSettings
		{
			setting = default(T);
			if ((Object)(object)postProcessing == (Object)null || (Object)(object)postProcessing.volume == (Object)null || (Object)(object)postProcessing.volume.profile == (Object)null)
			{
				return false;
			}
			return postProcessing.volume.profile.TryGetSettings<T>(ref setting);
		}

		private static Level GetCurrentLevel()
		{
			if ((Object)(object)LevelGenerator.Instance == (Object)null)
			{
				return null;
			}
			return LevelGenerator.Instance.Level;
		}

		private static float GetBloomIntensity(PostProcessing postProcessing)
		{
			Bloom setting;
			return TryGetPostSetting<Bloom>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.intensity).value : 0f;
		}

		private static float GetBloomThreshold(PostProcessing postProcessing)
		{
			Bloom setting;
			return TryGetPostSetting<Bloom>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.threshold).value : 1f;
		}

		private static float GetLensDistortionIntensity(PostProcessing postProcessing)
		{
			LensDistortion setting;
			return TryGetPostSetting<LensDistortion>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.intensity).value : 0f;
		}

		private static Color GetVignetteColor(PostProcessing postProcessing)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Vignette setting;
			return TryGetPostSetting<Vignette>(postProcessing, out setting) ? ((ParameterOverride<Color>)(object)setting.color).value : Color.black;
		}

		private static float GetVignetteIntensity(PostProcessing postProcessing)
		{
			Vignette setting;
			return TryGetPostSetting<Vignette>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.intensity).value : 0f;
		}

		private static float GetVignetteSmoothness(PostProcessing postProcessing)
		{
			Vignette setting;
			return TryGetPostSetting<Vignette>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.smoothness).value : 0f;
		}

		private static float GetColorTemperature(PostProcessing postProcessing)
		{
			ColorGrading setting;
			return TryGetPostSetting<ColorGrading>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.temperature).value : 0f;
		}

		private static Color GetColorFilter(PostProcessing postProcessing)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			ColorGrading setting;
			return TryGetPostSetting<ColorGrading>(postProcessing, out setting) ? ((ParameterOverride<Color>)(object)setting.colorFilter).value : Color.white;
		}

		private static float GetSaturation(PostProcessing postProcessing)
		{
			ColorGrading setting;
			return TryGetPostSetting<ColorGrading>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.saturation).value : 0f;
		}

		private static float GetContrast(PostProcessing postProcessing)
		{
			ColorGrading setting;
			return TryGetPostSetting<ColorGrading>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.contrast).value : 0f;
		}

		private static float GetGrainIntensity(PostProcessing postProcessing)
		{
			Grain setting;
			return TryGetPostSetting<Grain>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.intensity).value : 0f;
		}

		private static float GetGrainSize(PostProcessing postProcessing)
		{
			Grain setting;
			return TryGetPostSetting<Grain>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.size).value : 1f;
		}

		private static float GetMotionBlurShutter(PostProcessing postProcessing)
		{
			MotionBlur setting;
			return TryGetPostSetting<MotionBlur>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.shutterAngle).value : 0f;
		}

		private static float GetChromaticAberrationIntensity(PostProcessing postProcessing)
		{
			ChromaticAberration setting;
			return TryGetPostSetting<ChromaticAberration>(postProcessing, out setting) ? ((ParameterOverride<float>)(object)setting.intensity).value : 0f;
		}

		private static float GetFloat(ConfigEntry<float> entry, float fallback)
		{
			return entry?.Value ?? fallback;
		}

		private static bool GetBool(ConfigEntry<bool> entry, bool fallback)
		{
			return entry?.Value ?? fallback;
		}

		private static KeyCode GetKeyCode(ConfigEntry<KeyCode> entry, KeyCode fallback)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			return entry?.Value ?? fallback;
		}

		private static float Clamp(float value, float min, float max)
		{
			return Mathf.Clamp(value, min, max);
		}

		private static float Clamp01(float value)
		{
			return Mathf.Clamp01(value);
		}

		private static bool NearlyEqual(float left, float right)
		{
			return Mathf.Abs(left - right) <= 0.001f;
		}

		private static float GetPrivateFloat(FieldInfo fieldInfo, object instance, float fallback)
		{
			if (fieldInfo == null || instance == null)
			{
				return fallback;
			}
			if (!(fieldInfo.GetValue(instance) is float result))
			{
				return fallback;
			}
			return result;
		}

		private static Color GetPrivateColor(FieldInfo fieldInfo, object instance, Color fallback)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (fieldInfo == null || instance == null)
			{
				return fallback;
			}
			if (!(fieldInfo.GetValue(instance) is Color result))
			{
				return fallback;
			}
			return result;
		}

		private static float GetLevelFloat(FieldInfo fieldInfo, Level level, float fallback)
		{
			if (fieldInfo == null || (Object)(object)level == (Object)null)
			{
				return fallback;
			}
			if (!(fieldInfo.GetValue(level) is float result))
			{
				return fallback;
			}
			return result;
		}

		private static Color GetLevelColor(FieldInfo fieldInfo, Level level, Color fallback)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (fieldInfo == null || (Object)(object)level == (Object)null)
			{
				return fallback;
			}
			if (!(fieldInfo.GetValue(level) is Color result))
			{
				return fallback;
			}
			return result;
		}

		private static void SetPrivateField(FieldInfo fieldInfo, object instance, object value)
		{
			if (!(fieldInfo == null) && instance != null)
			{
				fieldInfo.SetValue(instance, value);
			}
		}

		private static Color MultiplyColorClamped(Color source, float multiplier, float maxValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to