Decompiled source of PeakFilter v1.1.2

plugins/PeakFilter.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Rendering.RenderGraphModule.Util;
using UnityEngine.Rendering.Universal;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("PeakFilter")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("PeakFilter")]
[assembly: AssemblyTitle("PeakFilter")]
[assembly: AssemblyVersion("1.1.1.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PeakFilter
{
	[HarmonyPatch]
	public static class CursorPatch
	{
		private static bool shouldUnlock;

		public static void SetUnlock(bool unlock)
		{
			shouldUnlock = unlock;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool PrefixLockState(ref CursorLockMode value)
		{
			if (shouldUnlock)
			{
				value = (CursorLockMode)0;
			}
			return true;
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPrefix]
		private static bool PrefixVisible(ref bool value)
		{
			if (shouldUnlock)
			{
				value = true;
			}
			return true;
		}
	}
	public static class FilterConfig
	{
		private static bool savePending;

		private static DateTime nextSaveTimeUtc;

		private static readonly TimeSpan SaveDelay = TimeSpan.FromMilliseconds(500.0);

		public static ConfigEntry<bool> ModEnabled;

		public static ConfigEntry<FilterType> ActiveFilter;

		public static ConfigEntry<float> Intensity;

		public static ConfigEntry<float> SketchEdgeStrength;

		public static ConfigEntry<float> SketchLineWidth;

		public static ConfigEntry<float> SketchPaperTexture;

		public static ConfigEntry<float> PencilDensity;

		public static ConfigEntry<float> PencilDarkness;

		public static ConfigEntry<float> PencilPaperGrain;

		public static ConfigEntry<float> CelOutlineStrength;

		public static ConfigEntry<float> CelColorSharpness;

		public static ConfigEntry<float> CelTintAmount;

		public static ConfigEntry<float> ToonRampSteps;

		public static ConfigEntry<float> ToonShadowCutoff;

		public static ConfigEntry<float> ToonInkStrength;

		public static ConfigEntry<float> HorrorFearTint;

		public static ConfigEntry<float> HorrorDarkness;

		public static ConfigEntry<float> HorrorGrain;

		public static ConfigEntry<float> PixelSize;

		public static ConfigEntry<float> PixelOutlineStrength;

		public static ConfigEntry<float> PixelDitherAmount;

		public static ConfigEntry<float> UIPanelX;

		public static ConfigEntry<float> UIPanelY;

		public static ConfigFile ConfigFile { get; private set; }

		public static long Version { get; private set; }

		public static void Initialize(ConfigFile config)
		{
			ConfigFile = config;
			ModEnabled = config.Bind<bool>("General", "Enabled", true, "Enable/disable the filter mod");
			ActiveFilter = config.Bind<FilterType>("General", "ActiveFilter", FilterType.Sketch, "Active filter type");
			Intensity = config.Bind<float>("General", "Intensity", 0.86f, "Filter intensity (0-1)");
			if (!IsAvailableFilter(ActiveFilter.Value))
			{
				ActiveFilter.Value = FilterType.Sketch;
			}
			SketchEdgeStrength = config.Bind<float>("Sketch", "EdgeStrength", 2.8f, "Edge detection strength (0-5)");
			SketchLineWidth = config.Bind<float>("Sketch", "LineWidth", 3f, "Line width (0.5-8)");
			SketchPaperTexture = config.Bind<float>("Sketch", "PaperTexture", 0.45f, "Paper texture intensity (0-1)");
			PencilDensity = config.Bind<float>("PencilSketch", "Density", 3.2f, "Pencil hatching density (0.5-8)");
			PencilDarkness = config.Bind<float>("PencilSketch", "Darkness", 1.8f, "Pencil darkness (0-3)");
			PencilPaperGrain = config.Bind<float>("PencilSketch", "PaperGrain", 0.5f, "Paper grain intensity (0-1)");
			CelOutlineStrength = config.Bind<float>("CelShade", "OutlineStrength", 3.2f, "Outline strength (0-5)");
			CelColorSharpness = config.Bind<float>("CelShade", "ColorSharpness", 10f, "Color quantization sharpness (2-20)");
			CelTintAmount = config.Bind<float>("CelShade", "TintAmount", 0.55f, "Cel shading tint amount (0-1)");
			ToonRampSteps = config.Bind<float>("ToonRamp", "RampSteps", 4f, "Cel ramp steps (2-8)");
			ToonShadowCutoff = config.Bind<float>("ToonRamp", "ShadowCutoff", 0.44f, "Shadow separation threshold (0.1-0.9)");
			ToonInkStrength = config.Bind<float>("ToonRamp", "InkStrength", 1.4f, "Ink outline strength (0-3)");
			HorrorFearTint = config.Bind<float>("Horror", "FearTint", 0.92f, "Cold green-red horror tint (0-1)");
			HorrorDarkness = config.Bind<float>("Horror", "Darkness", 0.78f, "Dark vignette and contrast (0-1)");
			HorrorGrain = config.Bind<float>("Horror", "Grain", 0.7f, "Dirty film grain amount (0-1)");
			PixelSize = config.Bind<float>("Pixelate", "PixelSize", 7f, "Pixel block size (1-30)");
			PixelOutlineStrength = config.Bind<float>("Pixelate", "OutlineStrength", 0.8f, "Pixel outline strength (0-3)");
			PixelDitherAmount = config.Bind<float>("Pixelate", "DitherAmount", 0.08f, "Pixel dithering amount (0-1)");
			UIPanelX = config.Bind<float>("UI", "PanelX", 20f, "UI panel X position");
			UIPanelY = config.Bind<float>("UI", "PanelY", 20f, "UI panel Y position");
			config.SettingChanged += delegate
			{
				Version++;
				RequestSave();
			};
		}

		public static void FlushPendingSave(bool force = false)
		{
			if (savePending && ConfigFile != null && (force || !(DateTime.UtcNow < nextSaveTimeUtc)))
			{
				ConfigFile.Save();
				savePending = false;
			}
		}

		public static void ResetDefaults()
		{
			ModEnabled.Value = true;
			ActiveFilter.Value = FilterType.Sketch;
			Intensity.Value = 0.86f;
			SketchEdgeStrength.Value = 2.8f;
			SketchLineWidth.Value = 3f;
			SketchPaperTexture.Value = 0.45f;
			PencilDensity.Value = 3.2f;
			PencilDarkness.Value = 1.8f;
			PencilPaperGrain.Value = 0.5f;
			CelOutlineStrength.Value = 3.2f;
			CelColorSharpness.Value = 10f;
			CelTintAmount.Value = 0.55f;
			ToonRampSteps.Value = 4f;
			ToonShadowCutoff.Value = 0.44f;
			ToonInkStrength.Value = 1.4f;
			HorrorFearTint.Value = 0.92f;
			HorrorDarkness.Value = 0.78f;
			HorrorGrain.Value = 0.7f;
			PixelSize.Value = 7f;
			PixelOutlineStrength.Value = 0.8f;
			PixelDitherAmount.Value = 0.08f;
		}

		public static void SavePanelPosition(float x, float y)
		{
			UIPanelX.Value = x;
			UIPanelY.Value = y;
		}

		private static void RequestSave()
		{
			savePending = true;
			nextSaveTimeUtc = DateTime.UtcNow + SaveDelay;
		}

		private static bool IsAvailableFilter(FilterType type)
		{
			if ((uint)type <= 5u || type == FilterType.Horror)
			{
				return true;
			}
			return false;
		}
	}
	public class FilterManager : MonoBehaviour
	{
		private PeakFilterFeature filterFeature;

		private Dictionary<FilterType, Material> materials = new Dictionary<FilterType, Material>();

		private AssetBundle shaderBundle;

		private bool isInitialized;

		private long lastAppliedConfigVersion = -1L;

		private static readonly Dictionary<FilterType, string> ShaderInternalNames = new Dictionary<FilterType, string>
		{
			{
				FilterType.Sketch,
				"Hidden/PeakFilter/Sketch"
			},
			{
				FilterType.PencilSketch,
				"Hidden/PeakFilter/PencilSketch"
			},
			{
				FilterType.CelShade,
				"Hidden/PeakFilter/CelShade"
			},
			{
				FilterType.ToonRamp,
				"Hidden/PeakFilter/ToonRamp"
			},
			{
				FilterType.Horror,
				"Hidden/PeakFilter/Horror"
			},
			{
				FilterType.Pixelate,
				"Hidden/PeakFilter/Pixelate"
			}
		};

		public bool IsInitialized => isInitialized;

		public void Initialize()
		{
			LoadShaders();
			InjectFeature();
			isInitialized = true;
		}

		private void LoadShaders()
		{
			LoadFromAssetBundle();
			int num = 0;
			foreach (KeyValuePair<FilterType, string> shaderInternalName in ShaderInternalNames)
			{
				if (materials.ContainsKey(shaderInternalName.Key) && (Object)(object)materials[shaderInternalName.Key] != (Object)null && (Object)(object)materials[shaderInternalName.Key].shader != (Object)null && ((Object)materials[shaderInternalName.Key].shader).name == shaderInternalName.Value)
				{
					num++;
				}
			}
			if (num < ShaderInternalNames.Count)
			{
				Debug.LogWarning((object)$"[PeakFilter] AssetBundle loaded {num}/{ShaderInternalNames.Count} shaders, trying Shader.Find fallback...");
				LoadFromShaderFind();
			}
			num = 0;
			foreach (KeyValuePair<FilterType, string> shaderInternalName2 in ShaderInternalNames)
			{
				if (materials.ContainsKey(shaderInternalName2.Key) && (Object)(object)materials[shaderInternalName2.Key] != (Object)null && (Object)(object)materials[shaderInternalName2.Key].shader != (Object)null && ((Object)materials[shaderInternalName2.Key].shader).name == shaderInternalName2.Value)
				{
					num++;
				}
			}
			if (num < ShaderInternalNames.Count)
			{
				CreateFallbackMaterials();
			}
			LogMissingShaders();
			Debug.Log((object)$"[PeakFilter] Shader loading complete: {num}/{ShaderInternalNames.Count} shaders ready.");
		}

		private void LogMissingShaders()
		{
			foreach (KeyValuePair<FilterType, string> shaderInternalName in ShaderInternalNames)
			{
				if (!materials.ContainsKey(shaderInternalName.Key) || (Object)(object)materials[shaderInternalName.Key] == (Object)null || (Object)(object)materials[shaderInternalName.Key].shader == (Object)null || ((Object)materials[shaderInternalName.Key].shader).name != shaderInternalName.Value)
				{
					Debug.LogWarning((object)$"[PeakFilter] Shader not ready: {shaderInternalName.Key} -> '{shaderInternalName.Value}'");
				}
			}
		}

		private void LoadFromAssetBundle()
		{
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Expected O, but got Unknown
			try
			{
				string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
				string text = Path.Combine(directoryName, "peakfilter_shaders");
				if (!File.Exists(text))
				{
					text = Path.Combine(directoryName, "Shaders", "peakfilter_shaders");
				}
				if (!File.Exists(text))
				{
					Debug.LogWarning((object)"[PeakFilter] AssetBundle file not found.");
					return;
				}
				shaderBundle = AssetBundle.LoadFromFile(text);
				if ((Object)(object)shaderBundle == (Object)null)
				{
					Debug.LogError((object)"[PeakFilter] Failed to load AssetBundle.");
					return;
				}
				Debug.Log((object)("[PeakFilter] AssetBundle loaded: '" + ((Object)shaderBundle).name + "'"));
				Shader[] array = shaderBundle.LoadAllAssets<Shader>();
				if (array == null || array.Length == 0)
				{
					Debug.LogError((object)"[PeakFilter] No shaders found in AssetBundle.");
					return;
				}
				Debug.Log((object)$"[PeakFilter] Found {array.Length} shaders in bundle:");
				Shader[] array2 = array;
				foreach (Shader val in array2)
				{
					Debug.Log((object)$"[PeakFilter]   - name='{((Object)val).name}' supported={val.isSupported}");
				}
				foreach (KeyValuePair<FilterType, string> shaderInternalName in ShaderInternalNames)
				{
					if (materials.ContainsKey(shaderInternalName.Key) && (Object)(object)materials[shaderInternalName.Key] != (Object)null && (Object)(object)materials[shaderInternalName.Key].shader != (Object)null && ((Object)materials[shaderInternalName.Key].shader).name == shaderInternalName.Value)
					{
						continue;
					}
					array2 = array;
					foreach (Shader val2 in array2)
					{
						if (((Object)val2).name == shaderInternalName.Value && val2.isSupported)
						{
							materials[shaderInternalName.Key] = new Material(val2)
							{
								hideFlags = (HideFlags)61
							};
							Debug.Log((object)$"[PeakFilter] Material from bundle: {shaderInternalName.Key} -> '{shaderInternalName.Value}'");
							break;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakFilter] AssetBundle error: " + ex.Message));
			}
		}

		private void LoadFromShaderFind()
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			foreach (KeyValuePair<FilterType, string> shaderInternalName in ShaderInternalNames)
			{
				if (materials.ContainsKey(shaderInternalName.Key) && (Object)(object)materials[shaderInternalName.Key] != (Object)null && (Object)(object)materials[shaderInternalName.Key].shader != (Object)null && ((Object)materials[shaderInternalName.Key].shader).name == shaderInternalName.Value)
				{
					continue;
				}
				try
				{
					Shader val = Shader.Find(shaderInternalName.Value);
					if ((Object)(object)val != (Object)null && val.isSupported)
					{
						materials[shaderInternalName.Key] = new Material(val)
						{
							hideFlags = (HideFlags)61
						};
						Debug.Log((object)$"[PeakFilter] Material from Shader.Find: {shaderInternalName.Key} -> '{shaderInternalName.Value}'");
					}
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[PeakFilter] Shader.Find failed for '" + shaderInternalName.Value + "': " + ex.Message));
				}
			}
		}

		private void CreateFallbackMaterials()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			try
			{
				Shader val = Shader.Find("Hidden/Universal Render Pipeline/Blit") ?? Shader.Find("Hidden/UniversalRenderPipeline/Blit") ?? Shader.Find("PostProcessing/Blit") ?? Shader.Find("Hidden/PostProcessing/Blit") ?? Shader.Find("Hidden/Blit") ?? Shader.Find("Blit");
				if ((Object)(object)val != (Object)null && val.isSupported)
				{
					Material value = new Material(val)
					{
						hideFlags = (HideFlags)61
					};
					foreach (FilterType key in ShaderInternalNames.Keys)
					{
						if (!materials.ContainsKey(key) || (Object)(object)materials[key] == (Object)null)
						{
							materials[key] = value;
						}
					}
					Debug.LogWarning((object)"[PeakFilter] Fallback materials created for missing shaders.");
				}
				else
				{
					Debug.LogWarning((object)"[PeakFilter] Some shaders are missing and no fallback Blit shader was found.");
				}
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakFilter] Error creating fallback materials: " + ex.Message));
			}
		}

		private void InjectFeature()
		{
			try
			{
				RenderPipelineAsset currentRenderPipeline = GraphicsSettings.currentRenderPipeline;
				UniversalRenderPipelineAsset val = (UniversalRenderPipelineAsset)(object)((currentRenderPipeline is UniversalRenderPipelineAsset) ? currentRenderPipeline : null);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogError((object)"[PeakFilter] UniversalRenderPipelineAsset not found.");
					return;
				}
				ScriptableRendererData rendererData = GetRendererData(val);
				if ((Object)(object)rendererData == (Object)null)
				{
					Debug.LogError((object)"[PeakFilter] Could not access UniversalRendererData.");
					return;
				}
				for (int i = 0; i < rendererData.rendererFeatures.Count; i++)
				{
					if (rendererData.rendererFeatures[i] is PeakFilterFeature peakFilterFeature)
					{
						filterFeature = peakFilterFeature;
						Debug.Log((object)"[PeakFilter] Found existing PeakFilterFeature.");
						return;
					}
				}
				filterFeature = ScriptableObject.CreateInstance<PeakFilterFeature>();
				((Object)filterFeature).name = "PeakFilter";
				((ScriptableRendererFeature)filterFeature).Create();
				rendererData.rendererFeatures.Add((ScriptableRendererFeature)(object)filterFeature);
				try
				{
					typeof(ScriptableRendererData).GetMethod("SetDirty", BindingFlags.Instance | BindingFlags.NonPublic)?.Invoke(rendererData, null);
				}
				catch
				{
				}
				Debug.Log((object)"[PeakFilter] Injected PeakFilterFeature into URP pipeline.");
			}
			catch (Exception ex)
			{
				Debug.LogError((object)("[PeakFilter] Error injecting renderer feature: " + ex.Message));
			}
		}

		private ScriptableRendererData GetRendererData(UniversalRenderPipelineAsset pipelineAsset)
		{
			Type type = ((object)pipelineAsset).GetType();
			FieldInfo field = type.GetField("m_RendererDataList", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field != null && field.GetValue(pipelineAsset) is ScriptableRendererData[] array && array.Length != 0)
			{
				return array[0];
			}
			PropertyInfo property = type.GetProperty("rendererDataList", BindingFlags.Instance | BindingFlags.NonPublic);
			if (property != null && property.GetValue(pipelineAsset) is ScriptableRendererData[] array2 && array2.Length != 0)
			{
				return array2[0];
			}
			return null;
		}

		public void UpdateFilter()
		{
			if ((Object)(object)filterFeature == (Object)null)
			{
				return;
			}
			long version = FilterConfig.Version;
			if (version == lastAppliedConfigVersion)
			{
				return;
			}
			FilterType value = FilterConfig.ActiveFilter.Value;
			bool value2 = FilterConfig.ModEnabled.Value;
			float value3 = FilterConfig.Intensity.Value;
			if (value == FilterType.None || !materials.ContainsKey(value) || !value2)
			{
				filterFeature.IsActive = false;
				filterFeature.CurrentMaterial = null;
				lastAppliedConfigVersion = version;
				return;
			}
			Material val = materials[value];
			if (val.HasProperty("_Intensity"))
			{
				val.SetFloat("_Intensity", value3);
			}
			switch (value)
			{
			case FilterType.Sketch:
				if (val.HasProperty("_EdgeStrength"))
				{
					val.SetFloat("_EdgeStrength", FilterConfig.SketchEdgeStrength.Value);
				}
				if (val.HasProperty("_LineWidth"))
				{
					val.SetFloat("_LineWidth", FilterConfig.SketchLineWidth.Value);
				}
				if (val.HasProperty("_PaperTexture"))
				{
					val.SetFloat("_PaperTexture", FilterConfig.SketchPaperTexture.Value);
				}
				break;
			case FilterType.PencilSketch:
				if (val.HasProperty("_PencilDensity"))
				{
					val.SetFloat("_PencilDensity", FilterConfig.PencilDensity.Value);
				}
				if (val.HasProperty("_PencilDarkness"))
				{
					val.SetFloat("_PencilDarkness", FilterConfig.PencilDarkness.Value);
				}
				if (val.HasProperty("_PaperGrain"))
				{
					val.SetFloat("_PaperGrain", FilterConfig.PencilPaperGrain.Value);
				}
				break;
			case FilterType.CelShade:
				if (val.HasProperty("_OutlineStrength"))
				{
					val.SetFloat("_OutlineStrength", FilterConfig.CelOutlineStrength.Value);
				}
				if (val.HasProperty("_ColorSharpness"))
				{
					val.SetFloat("_ColorSharpness", FilterConfig.CelColorSharpness.Value);
				}
				if (val.HasProperty("_TintAmount"))
				{
					val.SetFloat("_TintAmount", FilterConfig.CelTintAmount.Value);
				}
				break;
			case FilterType.ToonRamp:
				if (val.HasProperty("_RampSteps"))
				{
					val.SetFloat("_RampSteps", FilterConfig.ToonRampSteps.Value);
				}
				if (val.HasProperty("_ShadowCutoff"))
				{
					val.SetFloat("_ShadowCutoff", FilterConfig.ToonShadowCutoff.Value);
				}
				if (val.HasProperty("_InkStrength"))
				{
					val.SetFloat("_InkStrength", FilterConfig.ToonInkStrength.Value);
				}
				break;
			case FilterType.Horror:
				if (val.HasProperty("_FearTint"))
				{
					val.SetFloat("_FearTint", FilterConfig.HorrorFearTint.Value);
				}
				if (val.HasProperty("_Darkness"))
				{
					val.SetFloat("_Darkness", FilterConfig.HorrorDarkness.Value);
				}
				if (val.HasProperty("_Grain"))
				{
					val.SetFloat("_Grain", FilterConfig.HorrorGrain.Value);
				}
				break;
			case FilterType.Pixelate:
				if (val.HasProperty("_PixelSize"))
				{
					val.SetFloat("_PixelSize", FilterConfig.PixelSize.Value);
				}
				if (val.HasProperty("_OutlineStrength"))
				{
					val.SetFloat("_OutlineStrength", FilterConfig.PixelOutlineStrength.Value);
				}
				if (val.HasProperty("_DitherAmount"))
				{
					val.SetFloat("_DitherAmount", FilterConfig.PixelDitherAmount.Value);
				}
				break;
			}
			filterFeature.CurrentMaterial = val;
			filterFeature.IsActive = value2;
			lastAppliedConfigVersion = version;
		}

		public void SetEnabled(bool enabled)
		{
			if ((Object)(object)filterFeature != (Object)null)
			{
				filterFeature.IsActive = enabled;
			}
		}

		public void ForceUpdate()
		{
			lastAppliedConfigVersion = -1L;
			UpdateFilter();
		}

		private void OnDestroy()
		{
			if ((Object)(object)filterFeature != (Object)null)
			{
				filterFeature.IsActive = false;
				filterFeature.CurrentMaterial = null;
			}
			HashSet<Material> hashSet = new HashSet<Material>();
			foreach (Material value in materials.Values)
			{
				if ((Object)(object)value != (Object)null && hashSet.Add(value))
				{
					Object.DestroyImmediate((Object)(object)value);
				}
			}
			materials.Clear();
			if ((Object)(object)shaderBundle != (Object)null)
			{
				shaderBundle.Unload(true);
				shaderBundle = null;
			}
		}
	}
	public class PeakFilterFeature : ScriptableRendererFeature
	{
		public bool IsActive;

		public Material CurrentMaterial;

		public override void Create()
		{
		}

		public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
		{
			if (IsActive && !((Object)(object)CurrentMaterial == (Object)null))
			{
				PeakFilterPass peakFilterPass = new PeakFilterPass(CurrentMaterial);
				renderer.EnqueuePass((ScriptableRenderPass)(object)peakFilterPass);
			}
		}
	}
	public class PeakFilterPass : ScriptableRenderPass
	{
		private Material material;

		public PeakFilterPass(Material mat)
		{
			material = mat;
			((ScriptableRenderPass)this).renderPassEvent = (RenderPassEvent)550;
		}

		public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null || !material.shader.isSupported)
			{
				return;
			}
			UniversalResourceData val = frameData.Get<UniversalResourceData>();
			if (!val.isActiveTargetBackBuffer)
			{
				TextureHandle activeColorTexture = val.activeColorTexture;
				if (((TextureHandle)(ref activeColorTexture)).IsValid())
				{
					TextureHandle val2 = renderGraph.CreateTexture(activeColorTexture, "_PeakFilterDest", false);
					BlitMaterialParameters val3 = default(BlitMaterialParameters);
					((BlitMaterialParameters)(ref val3))..ctor(activeColorTexture, val2, material, 0);
					RenderGraphUtils.AddBlitPass(renderGraph, val3, "PeakFilter", "C:\\Users\\17994\\Desktop\\PeakFilter\\FilterRenderer.cs", 52);
					val.cameraColor = val2;
				}
			}
		}

		public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
		{
		}

		public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
		{
		}

		public override void OnCameraCleanup(CommandBuffer cmd)
		{
		}
	}
	public enum FilterType
	{
		None = 0,
		Sketch = 1,
		PencilSketch = 2,
		CelShade = 3,
		ToonRamp = 4,
		Pixelate = 5,
		Horror = 9,
		[Obsolete("Removed from the active filter set.")]
		Watercolor = 6,
		[Obsolete("Removed from the active filter set.")]
		OilPaint = 7,
		[Obsolete("Removed from the active filter set.")]
		ShadowBalance = 8,
		[Obsolete("Removed from the active filter set.")]
		DreamBloom = 10,
		[Obsolete("Removed from the active filter set.")]
		PosterizePop = 11,
		[Obsolete("Removed from the active filter set.")]
		FrostedGlass = 12,
		[Obsolete("Removed from the active filter set.")]
		BlackWhite = 100,
		[Obsolete("Removed from the active filter set.")]
		Sepia = 101,
		[Obsolete("Removed from the active filter set.")]
		Silhouette = 102,
		[Obsolete("Removed from the active filter set.")]
		Cyberpunk = 103,
		[Obsolete("Removed from the active filter set.")]
		Vintage = 104,
		[Obsolete("Removed from the active filter set.")]
		NeonGlow = 105
	}
	public class FilterUI : MonoBehaviour
	{
		private class FilterGroup
		{
			public string label;

			public FilterType[] filters;
		}

		private bool showPanel;

		private Rect panelRect = new Rect(20f, 20f, 540f, 560f);

		private bool isDragging;

		private Vector2 dragOffset;

		private float scale = 0.68f;

		private Vector2 scrollPos;

		private const string version = "v1.1.1";

		private const float PanelWidth = 540f;

		private const float MaxPanelHeight = 640f;

		private const float TitleHeight = 42f;

		private const float ContentPad = 16f;

		private const float CategoryWidth = 106f;

		private const float ButtonGap = 8f;

		private const float RowGap = 8f;

		private const float ButtonHeight = 34f;

		private const float SliderBlockHeight = 58f;

		private static readonly Color PanelBg = new Color(0.9f, 0.96f, 1f, 0.94f);

		private static readonly Color TitleBg = new Color(0.82f, 0.91f, 1f, 0.78f);

		private static readonly Color TextColor = new Color(0.12f, 0.14f, 0.26f, 1f);

		private static readonly Color TextDim = new Color(0.22f, 0.25f, 0.39f, 1f);

		private static readonly Color GradStart = new Color(0.13f, 0.55f, 0.98f, 1f);

		private static readonly Color GradMid = new Color(0.67f, 0.34f, 0.95f, 1f);

		private static readonly Color GradEnd = new Color(1f, 0.72f, 0.48f, 1f);

		private static readonly Color SelectedBorder = new Color(0.18f, 0.45f, 0.95f, 0.95f);

		private static readonly FilterGroup[] Groups = new FilterGroup[3]
		{
			new FilterGroup
			{
				label = "artistic",
				filters = new FilterType[2]
				{
					FilterType.Sketch,
					FilterType.PencilSketch
				}
			},
			new FilterGroup
			{
				label = "painttoon",
				filters = new FilterType[2]
				{
					FilterType.CelShade,
					FilterType.ToonRamp
				}
			},
			new FilterGroup
			{
				label = "effects",
				filters = new FilterType[2]
				{
					FilterType.Horror,
					FilterType.Pixelate
				}
			}
		};

		private static readonly Dictionary<FilterType, string> FilterKeys = new Dictionary<FilterType, string>
		{
			{
				FilterType.None,
				"none"
			},
			{
				FilterType.Sketch,
				"sketch"
			},
			{
				FilterType.PencilSketch,
				"pencilsketch"
			},
			{
				FilterType.CelShade,
				"celshade"
			},
			{
				FilterType.ToonRamp,
				"toonramp"
			},
			{
				FilterType.Horror,
				"horror"
			},
			{
				FilterType.Pixelate,
				"pixelate"
			}
		};

		private static readonly Dictionary<FilterType, Tuple<string, Func<float>, float, float>[]> FilterParams = new Dictionary<FilterType, Tuple<string, Func<float>, float, float>[]>
		{
			{
				FilterType.Sketch,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("edgeStrength", () => FilterConfig.SketchEdgeStrength.Value, 0f, 5f),
					Tuple.Create<string, Func<float>, float, float>("lineWidth", () => FilterConfig.SketchLineWidth.Value, 0.5f, 8f),
					Tuple.Create<string, Func<float>, float, float>("paperTexture", () => FilterConfig.SketchPaperTexture.Value, 0f, 1f)
				}
			},
			{
				FilterType.PencilSketch,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("pencilDensity", () => FilterConfig.PencilDensity.Value, 0.5f, 8f),
					Tuple.Create<string, Func<float>, float, float>("pencilDarkness", () => FilterConfig.PencilDarkness.Value, 0f, 3f),
					Tuple.Create<string, Func<float>, float, float>("paperGrain", () => FilterConfig.PencilPaperGrain.Value, 0f, 1f)
				}
			},
			{
				FilterType.CelShade,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("outlineStrength", () => FilterConfig.CelOutlineStrength.Value, 0f, 5f),
					Tuple.Create<string, Func<float>, float, float>("colorSharpness", () => FilterConfig.CelColorSharpness.Value, 2f, 20f),
					Tuple.Create<string, Func<float>, float, float>("celTint", () => FilterConfig.CelTintAmount.Value, 0f, 1f)
				}
			},
			{
				FilterType.ToonRamp,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("rampSteps", () => FilterConfig.ToonRampSteps.Value, 2f, 8f),
					Tuple.Create<string, Func<float>, float, float>("shadowCutoff", () => FilterConfig.ToonShadowCutoff.Value, 0.1f, 0.9f),
					Tuple.Create<string, Func<float>, float, float>("inkStrength", () => FilterConfig.ToonInkStrength.Value, 0f, 3f)
				}
			},
			{
				FilterType.Horror,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("fearTint", () => FilterConfig.HorrorFearTint.Value, 0f, 1f),
					Tuple.Create<string, Func<float>, float, float>("darkness", () => FilterConfig.HorrorDarkness.Value, 0f, 1f),
					Tuple.Create<string, Func<float>, float, float>("grain", () => FilterConfig.HorrorGrain.Value, 0f, 1f)
				}
			},
			{
				FilterType.Pixelate,
				new Tuple<string, Func<float>, float, float>[3]
				{
					Tuple.Create<string, Func<float>, float, float>("pixelSize", () => FilterConfig.PixelSize.Value, 1f, 30f),
					Tuple.Create<string, Func<float>, float, float>("pixelOutline", () => FilterConfig.PixelOutlineStrength.Value, 0f, 3f),
					Tuple.Create<string, Func<float>, float, float>("ditherAmount", () => FilterConfig.PixelDitherAmount.Value, 0f, 1f)
				}
			}
		};

		private GUIStyle titleStyle;

		private GUIStyle sectionStyle;

		private GUIStyle groupLabelStyle;

		private GUIStyle btnStyle;

		private GUIStyle selectedBtnStyle;

		private GUIStyle closeBtnStyle;

		private GUIStyle labelStyle;

		private GUIStyle valueStyle;

		private bool stylesInit;

		private Texture2D panelBgTex;

		private Texture2D titleBgTex;

		private Texture2D gradSliderBg;

		private Texture2D sliderTrackTex;

		private Texture2D buttonGradTex;

		private Texture2D buttonSelectedTex;

		private Texture2D buttonHoverTex;

		private Texture2D whiteTex;

		private bool texInit;

		private void InitStyles()
		{
			//IL_001b: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: 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_0113: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: 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_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Expected O, but got Unknown
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			if (!stylesInit)
			{
				stylesInit = true;
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 24,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				val.normal.textColor = TextColor;
				titleStyle = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				val2.normal.textColor = TextColor;
				sectionStyle = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					wordWrap = false,
					clipping = (TextClipping)1
				};
				val3.normal.textColor = TextDim;
				groupLabelStyle = val3;
				GUIStyle val4 = new GUIStyle(GUI.skin.button)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					wordWrap = false,
					clipping = (TextClipping)1
				};
				val4.normal.textColor = TextColor;
				val4.normal.background = null;
				val4.hover.textColor = TextColor;
				val4.hover.background = null;
				val4.active.textColor = TextColor;
				val4.active.background = null;
				btnStyle = val4;
				GUIStyle val5 = new GUIStyle(btnStyle);
				val5.normal.textColor = Color.white;
				val5.normal.background = null;
				val5.hover.textColor = Color.white;
				val5.hover.background = null;
				val5.active.textColor = Color.white;
				val5.active.background = null;
				selectedBtnStyle = val5;
				GUIStyle val6 = new GUIStyle(GUIStyle.none)
				{
					fontSize = 18,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				val6.normal.textColor = new Color(0.78f, 0.84f, 0.96f, 1f);
				val6.hover.textColor = Color.white;
				val6.active.textColor = Color.white;
				closeBtnStyle = val6;
				GUIStyle val7 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					alignment = (TextAnchor)3,
					wordWrap = false,
					clipping = (TextClipping)1
				};
				val7.normal.textColor = TextDim;
				labelStyle = val7;
				GUIStyle val8 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					alignment = (TextAnchor)5
				};
				val8.normal.textColor = TextColor;
				valueStyle = val8;
			}
		}

		private Texture2D MakeTex(int w, int h, Color c)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(w, h);
			for (int i = 0; i < w; i++)
			{
				for (int j = 0; j < h; j++)
				{
					val.SetPixel(i, j, c);
				}
			}
			val.Apply();
			return val;
		}

		private Texture2D MakeGradTex(int w, int h, Color from, Color to)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			Texture2D val = new Texture2D(w, h);
			for (int i = 0; i < w; i++)
			{
				float num = (float)i / (float)Mathf.Max(w - 1, 1);
				Color val2 = Color.Lerp(from, to, num);
				for (int j = 0; j < h; j++)
				{
					val.SetPixel(i, j, val2);
				}
			}
			val.Apply();
			return val;
		}

		private Texture2D MakeSliderGradTex(int w, int h)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(w, h);
			for (int i = 0; i < w; i++)
			{
				float num = (float)i / (float)Mathf.Max(w - 1, 1);
				Color val2 = ((num < 0.55f) ? Color.Lerp(GradStart, GradMid, num / 0.55f) : Color.Lerp(GradMid, GradEnd, (num - 0.55f) / 0.45f));
				for (int j = 0; j < h; j++)
				{
					val.SetPixel(i, j, val2);
				}
			}
			val.Apply();
			return val;
		}

		private void InitTextures()
		{
			//IL_0014: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			if (!texInit)
			{
				texInit = true;
				panelBgTex = MakeTex(1, 1, PanelBg);
				titleBgTex = MakeTex(1, 1, TitleBg);
				gradSliderBg = MakeSliderGradTex(256, 1);
				sliderTrackTex = MakeTex(1, 1, new Color(0.8f, 0.84f, 0.9f, 1f));
				buttonGradTex = MakeGradTex(128, 1, new Color(0.19f, 0.55f, 0.98f, 0.95f), new Color(0.55f, 0.32f, 0.88f, 0.95f));
				buttonSelectedTex = MakeGradTex(128, 1, new Color(0.1f, 0.35f, 0.82f, 1f), new Color(0.35f, 0.2f, 0.7f, 1f));
				buttonHoverTex = MakeTex(1, 1, new Color(1f, 1f, 1f, 0.18f));
				whiteTex = MakeTex(1, 1, Color.white);
			}
		}

		private void Awake()
		{
			Localization.Initialize();
			((Rect)(ref panelRect)).x = FilterConfig.UIPanelX.Value;
			((Rect)(ref panelRect)).y = FilterConfig.UIPanelY.Value;
		}

		private void Update()
		{
			if (Input.GetKeyDown((KeyCode)284))
			{
				showPanel = !showPanel;
				CursorPatch.SetUnlock(showPanel);
			}
		}

		private void OnGUI()
		{
			//IL_0015: 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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Invalid comparison between Unknown and I4
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Invalid comparison between Unknown and I4
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: 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)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			if (!showPanel)
			{
				return;
			}
			InitStyles();
			InitTextures();
			GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one * scale);
			float num = ((Rect)(ref panelRect)).x / scale;
			float num2 = ((Rect)(ref panelRect)).y / scale;
			float num3 = 540f;
			float contentHeight = GetContentHeight();
			float num4 = Mathf.Min(contentHeight + 42f + 8f, 640f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num, num2, num3, num4);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(num + num3 - 40f, num2 + 6f, 30f, 30f);
			if ((int)Event.current.type == 0 && Event.current.button == 0 && !((Rect)(ref val)).Contains(Event.current.mousePosition))
			{
				showPanel = false;
				CursorPatch.SetUnlock(unlock: false);
				Event.current.Use();
				GUI.matrix = Matrix4x4.identity;
				return;
			}
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(num, num2, num3, 42f);
			if ((int)Event.current.type == 0 && ((Rect)(ref val3)).Contains(Event.current.mousePosition) && !((Rect)(ref val2)).Contains(Event.current.mousePosition))
			{
				isDragging = true;
				dragOffset = Event.current.mousePosition - new Vector2(num, num2);
				Event.current.Use();
			}
			if (isDragging && (int)Event.current.type == 3)
			{
				Vector2 val4 = Event.current.mousePosition - dragOffset;
				((Rect)(ref panelRect)).x = val4.x * scale;
				((Rect)(ref panelRect)).y = val4.y * scale;
				Event.current.Use();
			}
			if (isDragging && (int)Event.current.type == 1)
			{
				isDragging = false;
				Event.current.Use();
			}
			GUI.DrawTexture(new Rect(num, num2, num3, num4), (Texture)(object)panelBgTex);
			DrawBorder(num, num2, num3, num4, new Color(1f, 1f, 1f, 0.95f));
			GUI.DrawTexture(new Rect(num, num2, num3, 42f), (Texture)(object)titleBgTex);
			GUI.Label(new Rect(num + 16f, num2 + 2f, num3 - 76f, 38f), Localization.Get("title") + " v1.1.1", titleStyle);
			DrawSolidRect(new Rect(num + 16f, num2 + 42f - 1f, num3 - 32f, 1f), new Color(0.34f, 0.42f, 0.58f, 0.65f));
			DrawSolidRect(val2, new Color(0.12f, 0.14f, 0.28f, 0.96f));
			if (GUI.Button(val2, "×", closeBtnStyle))
			{
				showPanel = false;
				CursorPatch.SetUnlock(unlock: false);
			}
			float num5 = num;
			float num6 = num2 + 42f + 2f;
			float num7 = num3;
			float num8 = num4 - 42f - 6f;
			scrollPos = GUI.BeginScrollView(new Rect(num5, num6, num7, num8), scrollPos, new Rect(0f, 0f, num3 - 18f, contentHeight));
			float num9 = 16f;
			float num10 = 12f;
			float num11 = num3 - 32f - 18f;
			float num12 = num9 + 106f + 8f;
			float num13 = num11 - 106f - 8f;
			FilterType value = FilterConfig.ActiveFilter.Value;
			GUI.Label(new Rect(num9, num10, num11, 22f), Localization.Get("filterSelection"), sectionStyle);
			num10 += 30f;
			bool selected = value == FilterType.None;
			GUI.Label(new Rect(num9, num10, 106f, 34f), Localization.Get("filter"), groupLabelStyle);
			if (DrawFilterButton(new Rect(num12, num10, num13, 34f), Localization.Get("none"), selected))
			{
				FilterConfig.ActiveFilter.Value = FilterType.None;
			}
			num10 += 42f;
			for (int i = 0; i < Groups.Length; i++)
			{
				FilterGroup filterGroup = Groups[i];
				GUI.Label(new Rect(num9, num10, 106f, 34f), Localization.Get(filterGroup.label), groupLabelStyle);
				int num14 = Mathf.Max(1, filterGroup.filters.Length);
				float num15 = (num13 - 8f * (float)(num14 - 1)) / (float)num14;
				for (int j = 0; j < filterGroup.filters.Length; j++)
				{
					FilterType filterType = filterGroup.filters[j];
					bool selected2 = value == filterType;
					float num16 = num12 + (float)j * (num15 + 8f);
					if (DrawFilterButton(new Rect(num16, num10, num15, 34f), Localization.Get(FilterKeys[filterType]), selected2))
					{
						FilterConfig.ActiveFilter.Value = filterType;
					}
				}
				num10 += 42f;
			}
			num10 += 8f;
			DrawSeparator(num9, num10, num11);
			num10 += 14f;
			float value2 = FilterConfig.Intensity.Value;
			DrawSliderBlock(num9, num10, num11, Localization.Get("intensity"), ref value2, 0f, 1f);
			if (!Mathf.Approximately(FilterConfig.Intensity.Value, value2))
			{
				FilterConfig.Intensity.Value = value2;
			}
			num10 += 58f;
			DrawSeparator(num9, num10, num11);
			num10 += 14f;
			if (value != 0 && FilterParams.ContainsKey(value))
			{
				GUI.Label(new Rect(num9, num10, num11, 22f), Localization.Get("filterParams"), sectionStyle);
				num10 += 30f;
				Tuple<string, Func<float>, float, float>[] array = FilterParams[value];
				foreach (Tuple<string, Func<float>, float, float> obj in array)
				{
					string item = obj.Item1;
					float value3 = obj.Item2();
					float item2 = obj.Item3;
					float item3 = obj.Item4;
					DrawSliderBlock(num9, num10, num11, Localization.Get(item), ref value3, item2, item3);
					num10 += 58f;
					ConfigEntry<float> paramEntry = GetParamEntry(value, item);
					if (paramEntry != null && !Mathf.Approximately(paramEntry.Value, value3))
					{
						paramEntry.Value = value3;
					}
				}
			}
			GUI.EndScrollView();
			GUI.matrix = Matrix4x4.identity;
		}

		private float GetContentHeight()
		{
			float num = 12f;
			num += 30f;
			num += (float)(1 + Groups.Length) * 42f;
			num += 94f;
			FilterType value = FilterConfig.ActiveFilter.Value;
			if (value != 0 && FilterParams.ContainsKey(value))
			{
				num += 30f;
				Tuple<string, Func<float>, float, float>[] array = FilterParams[value];
				for (int i = 0; i < array.Length; i++)
				{
					_ = array[i];
					num += 58f;
				}
			}
			return num + 10f;
		}

		private bool DrawFilterButton(Rect rect, string text, bool selected)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			bool num = ((Rect)(ref rect)).Contains(Event.current.mousePosition);
			GUI.DrawTexture(rect, (Texture)(object)(selected ? buttonSelectedTex : buttonGradTex));
			if (num)
			{
				GUI.DrawTexture(rect, (Texture)(object)buttonHoverTex);
			}
			DrawBorder(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, (Color)(selected ? SelectedBorder : new Color(1f, 1f, 1f, 0.55f)));
			GUI.Label(rect, text, selected ? selectedBtnStyle : btnStyle);
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private void DrawSliderBlock(float x, float y, float w, string label, ref float value, float min, float max)
		{
			//IL_000e: 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)
			GUI.Label(new Rect(x, y, w * 0.65f, 22f), label, labelStyle);
			GUI.Label(new Rect(x + w * 0.65f, y, w * 0.35f, 22f), value.ToString("F2"), valueStyle);
			DrawGradientSlider(x + 2f, y + 30f, w - 4f, ref value, min, max);
		}

		private void DrawGradientSlider(float x, float y, float w, ref float value, float min, float max)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected I4, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.InverseLerp(min, max, value);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(x - 8f, y - 8f, w + 16f, 30f);
			int controlID = GUIUtility.GetControlID("PeakFilterSlider".GetHashCode(), (FocusType)2, val);
			Event current = Event.current;
			EventType typeForControl = current.GetTypeForControl(controlID);
			switch ((int)typeForControl)
			{
			case 0:
				if (current.button == 0 && ((Rect)(ref val)).Contains(current.mousePosition))
				{
					GUIUtility.hotControl = controlID;
					value = SliderValueFromMouse(current.mousePosition.x, x, w, min, max);
					current.Use();
				}
				break;
			case 3:
				if (GUIUtility.hotControl == controlID)
				{
					value = SliderValueFromMouse(current.mousePosition.x, x, w, min, max);
					current.Use();
				}
				break;
			case 1:
				if (GUIUtility.hotControl == controlID)
				{
					GUIUtility.hotControl = 0;
					current.Use();
				}
				break;
			}
			num = Mathf.InverseLerp(min, max, value);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(x, y + 4f, w, 10f);
			GUI.DrawTexture(val2, (Texture)(object)sliderTrackTex);
			DrawBorder(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width, ((Rect)(ref val2)).height, new Color(0.2f, 0.23f, 0.34f, 0.9f));
			float num2 = num * w;
			if (num2 > 0f)
			{
				GUI.DrawTextureWithTexCoords(new Rect(x, y + 4f, num2, 10f), (Texture)(object)gradSliderBg, new Rect(0f, 0f, Mathf.Clamp01(num), 1f));
			}
			float num3 = 16f;
			float num4 = 18f;
			float num5 = x + num * w - num3 / 2f;
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(num5, y, num3, num4);
			DrawSolidRect(rect, new Color(0.92f, 0.95f, 1f, 1f));
			DrawBorder(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height, new Color(0.2f, 0.23f, 0.34f, 0.95f));
		}

		private float SliderValueFromMouse(float mouseX, float x, float w, float min, float max)
		{
			float num = Mathf.Clamp01((mouseX - x) / w);
			return Mathf.Round(Mathf.Lerp(min, max, num) * 100f) / 100f;
		}

		private void DrawSeparator(float x, float y, float w)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			DrawSolidRect(new Rect(x, y, w, 1f), new Color(0.34f, 0.42f, 0.58f, 0.55f));
		}

		private void DrawSolidRect(Rect rect, Color color)
		{
			//IL_0000: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)whiteTex);
			GUI.color = color2;
		}

		private void DrawBorder(float x, float y, float w, float h, Color color)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_002c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			DrawSolidRect(new Rect(x, y, w, 1f), color);
			DrawSolidRect(new Rect(x, y + h - 1f, w, 1f), color);
			DrawSolidRect(new Rect(x, y, 1f, h), color);
			DrawSolidRect(new Rect(x + w - 1f, y, 1f, h), color);
		}

		private ConfigEntry<float> GetParamEntry(FilterType type, string key)
		{
			switch (type)
			{
			case FilterType.Sketch:
				switch (key)
				{
				case "edgeStrength":
					return FilterConfig.SketchEdgeStrength;
				case "lineWidth":
					return FilterConfig.SketchLineWidth;
				case "paperTexture":
					return FilterConfig.SketchPaperTexture;
				}
				break;
			case FilterType.PencilSketch:
				switch (key)
				{
				case "pencilDensity":
					return FilterConfig.PencilDensity;
				case "pencilDarkness":
					return FilterConfig.PencilDarkness;
				case "paperGrain":
					return FilterConfig.PencilPaperGrain;
				}
				break;
			case FilterType.CelShade:
				switch (key)
				{
				case "outlineStrength":
					return FilterConfig.CelOutlineStrength;
				case "colorSharpness":
					return FilterConfig.CelColorSharpness;
				case "celTint":
					return FilterConfig.CelTintAmount;
				}
				break;
			case FilterType.ToonRamp:
				switch (key)
				{
				case "rampSteps":
					return FilterConfig.ToonRampSteps;
				case "shadowCutoff":
					return FilterConfig.ToonShadowCutoff;
				case "inkStrength":
					return FilterConfig.ToonInkStrength;
				}
				break;
			case FilterType.Horror:
				switch (key)
				{
				case "fearTint":
					return FilterConfig.HorrorFearTint;
				case "darkness":
					return FilterConfig.HorrorDarkness;
				case "grain":
					return FilterConfig.HorrorGrain;
				}
				break;
			case FilterType.Pixelate:
				switch (key)
				{
				case "pixelSize":
					return FilterConfig.PixelSize;
				case "pixelOutline":
					return FilterConfig.PixelOutlineStrength;
				case "ditherAmount":
					return FilterConfig.PixelDitherAmount;
				}
				break;
			}
			return null;
		}

		private void OnDisable()
		{
			FilterConfig.SavePanelPosition(((Rect)(ref panelRect)).x, ((Rect)(ref panelRect)).y);
			FilterConfig.FlushPendingSave(force: true);
		}

		private void OnDestroy()
		{
			DestroyTexture(panelBgTex);
			DestroyTexture(titleBgTex);
			DestroyTexture(gradSliderBg);
			DestroyTexture(sliderTrackTex);
			DestroyTexture(buttonGradTex);
			DestroyTexture(buttonSelectedTex);
			DestroyTexture(buttonHoverTex);
			DestroyTexture(whiteTex);
		}

		private void DestroyTexture(Texture2D tex)
		{
			if ((Object)(object)tex != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)tex);
			}
		}
	}
	public static class Localization
	{
		private static FieldInfo currentLanguageField;

		private static PropertyInfo currentLanguageProperty;

		private static bool languageMemberResolved;

		private static readonly Dictionary<string, string> EN = new Dictionary<string, string>
		{
			{ "title", "Peak Filter" },
			{ "enabled", "Enabled" },
			{ "filter", "Filter" },
			{ "filterSelection", "Filter Selection" },
			{ "filterParams", "Filter Parameters" },
			{ "intensity", "Intensity" },
			{ "reset", "Reset" },
			{ "none", "None" },
			{ "sketch", "Hand Drawn" },
			{ "pencilsketch", "Pencil Sketch" },
			{ "celshade", "Anime" },
			{ "toonramp", "Toon Ramp" },
			{ "horror", "Horror" },
			{ "pixelate", "Pixelate" },
			{ "edgeStrength", "Edge Strength" },
			{ "lineWidth", "Line Width" },
			{ "paperTexture", "Paper Texture" },
			{ "pencilDensity", "Pencil Density" },
			{ "pencilDarkness", "Pencil Darkness" },
			{ "paperGrain", "Paper Grain" },
			{ "outlineStrength", "Outline Strength" },
			{ "colorSharpness", "Color Sharpness" },
			{ "celTint", "Anime Tint" },
			{ "rampSteps", "Ramp Steps" },
			{ "shadowCutoff", "Shadow Cutoff" },
			{ "inkStrength", "Ink Strength" },
			{ "fearTint", "Fear Tint" },
			{ "darkness", "Darkness" },
			{ "grain", "Grain" },
			{ "pixelSize", "Pixel Size" },
			{ "pixelOutline", "Pixel Outline" },
			{ "ditherAmount", "Dither" },
			{ "artistic", "Artistic" },
			{ "painttoon", "Paint & Toon" },
			{ "effects", "Effects" }
		};

		private static readonly Dictionary<string, string> CN = new Dictionary<string, string>
		{
			{ "title", "PEAK 滤镜" },
			{ "enabled", "启用" },
			{ "filter", "滤镜" },
			{ "filterSelection", "滤镜选择" },
			{ "filterParams", "滤镜参数" },
			{ "intensity", "强度" },
			{ "reset", "重置" },
			{ "none", "无" },
			{ "sketch", "手绘" },
			{ "pencilsketch", "素描" },
			{ "celshade", "动漫" },
			{ "toonramp", "三渲二" },
			{ "horror", "恐怖" },
			{ "pixelate", "像素风" },
			{ "edgeStrength", "边缘强度" },
			{ "lineWidth", "线条宽度" },
			{ "paperTexture", "纸张纹理" },
			{ "pencilDensity", "铅笔密度" },
			{ "pencilDarkness", "铅笔深度" },
			{ "paperGrain", "纸张颗粒" },
			{ "outlineStrength", "轮廓强度" },
			{ "colorSharpness", "色块锐度" },
			{ "celTint", "动漫着色" },
			{ "rampSteps", "色阶层数" },
			{ "shadowCutoff", "阴影分界" },
			{ "inkStrength", "描边强度" },
			{ "fearTint", "恐怖色调" },
			{ "darkness", "压暗程度" },
			{ "grain", "颗粒噪点" },
			{ "pixelSize", "像素大小" },
			{ "pixelOutline", "像素轮廓" },
			{ "ditherAmount", "抖动量" },
			{ "artistic", "艺术绘制" },
			{ "painttoon", "绘画动漫" },
			{ "effects", "效果风格" }
		};

		public static void Initialize()
		{
			ResolveLanguageMember();
		}

		public static string Get(string key)
		{
			if (!(IsCurrentLanguageChinese() ? CN : EN).TryGetValue(key, out var value))
			{
				return key;
			}
			return value;
		}

		private static bool IsCurrentLanguageChinese()
		{
			try
			{
				object currentGameLanguage = GetCurrentGameLanguage();
				if (currentGameLanguage != null)
				{
					return currentGameLanguage.ToString().IndexOf("Chinese", StringComparison.OrdinalIgnoreCase) >= 0;
				}
			}
			catch
			{
			}
			try
			{
				return Thread.CurrentThread.CurrentUICulture.Name.StartsWith("zh", StringComparison.OrdinalIgnoreCase);
			}
			catch
			{
				return false;
			}
		}

		private static object GetCurrentGameLanguage()
		{
			ResolveLanguageMember();
			if (currentLanguageField != null)
			{
				return currentLanguageField.GetValue(null);
			}
			if (!(currentLanguageProperty != null))
			{
				return null;
			}
			return currentLanguageProperty.GetValue(null, null);
		}

		private static void ResolveLanguageMember()
		{
			if (!languageMemberResolved)
			{
				languageMemberResolved = true;
				Type type = Type.GetType("LocalizedText, Assembly-CSharp");
				if (!(type == null))
				{
					currentLanguageField = type.GetField("CURRENT_LANGUAGE", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					currentLanguageProperty = type.GetProperty("CURRENT_LANGUAGE", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				}
			}
		}
	}
	[BepInPlugin("com.peak.filter", "PeakFilter", "1.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginVersion = "1.1.1";

		private FilterManager filterManager;

		private FilterUI filterUI;

		private void Awake()
		{
			FilterConfig.Initialize(((BaseUnityPlugin)this).Config);
			Harmony.CreateAndPatchAll(typeof(CursorPatch), (string)null);
			filterManager = ((Component)this).gameObject.AddComponent<FilterManager>();
			filterUI = ((Component)this).gameObject.AddComponent<FilterUI>();
			filterManager.Initialize();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PeakFilter v1.1.1 loaded successfully.");
		}

		private void Update()
		{
			if ((Object)(object)filterManager != (Object)null && filterManager.IsInitialized)
			{
				filterManager.UpdateFilter();
			}
			FilterConfig.FlushPendingSave();
		}

		private void OnDestroy()
		{
			FilterConfig.FlushPendingSave(force: true);
			if ((Object)(object)filterManager != (Object)null)
			{
				Object.Destroy((Object)(object)filterManager);
			}
			if ((Object)(object)filterUI != (Object)null)
			{
				Object.Destroy((Object)(object)filterUI);
			}
		}
	}
}