Decompiled source of Optizoom v2.3.2

plugins/Optizoom/Optizoom.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using BepisLocaleLoader;
using Elements.Assets;
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
using Renderite.Shared;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: AssemblyDescription("Adds the ability to zoom with a keypress")]
[assembly: ComVisible(false)]
[assembly: Guid("c88ec514-5d98-4824-8c66-5ed1888c764b")]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("badhaloninja, LeCloutPanda")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.3.2.0")]
[assembly: AssemblyInformationalVersion("2.3.2+231f80dd8d41785bd38dc6608bb20280a78f145e")]
[assembly: AssemblyProduct("Optizoom")]
[assembly: AssemblyTitle("Optizoom")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LeCloutPanda/Optizoom")]
[assembly: AssemblyVersion("2.3.2.0")]
[module: RefSafetyRules(11)]
namespace Optizoom;

[ResonitePlugin("dev.lecloutpanda.Optizoom", "Optizoom", "2.3.2", "badhaloninja, LeCloutPanda", "https://github.com/LeCloutPanda/Optizoom")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Optizoom : BasePlugin
{
	[HarmonyPatch]
	private static class SpyglassUserspacePatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Userspace), "OnAttach")]
		public static void Postfix(Userspace __instance)
		{
			//IL_0037: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Expected O, but got Unknown
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Expected O, but got Unknown
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			try
			{
				Optizoom.overlayVisual = ((Worker)__instance).World.GetGloballyRegisteredComponent<OverlayManager>((Predicate<OverlayManager>)null).OverlayRoot.AddSlot("OverlayVisual - Optizoom", true);
				Optizoom.overlayVisual.PersistentSelf = false;
				Slot overlayVisual = Optizoom.overlayVisual;
				float3 forward = float3.Forward;
				overlayVisual.LocalPosition = (ref forward) * 0.1f;
				Optizoom.overlayVisual.ActiveSelf = false;
				((SyncField<string>)(object)((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<DynamicVariableSpace>(true, (Action<DynamicVariableSpace>)null).SpaceName).Value = "OverlayVisual";
				Uri val = new Uri(overlayUri.Value);
				StaticTexture2D val2 = SlotAssets.AttachTexture(Optizoom.overlayVisual, val, true, false, false, false, (TextureWrapMode)1, (int?)null);
				((SyncField<TextureFilterMode?>)(object)((StaticTextureProvider<Texture2D, Bitmap2D, BitmapMetadata, Texture2DVariantDescriptor>)(object)val2).FilterMode).Value = (TextureFilterMode)0;
				DynamicFieldExtensions.SyncWithVariable<Uri>((IField<Uri>)(object)((StaticAssetProvider<Texture2D, BitmapMetadata, Texture2DVariantDescriptor>)(object)val2).URL, "overlayUri", false, false);
				UnlitMaterial val3 = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<UnlitMaterial>(true, (Action<UnlitMaterial>)null);
				((SyncRef<IAssetProvider<ITexture2D>>)(object)val3.Texture).TrySet((IWorldElement)(object)val2);
				((SyncField<BlendMode>)(object)val3.BlendMode).Value = (BlendMode)2;
				QuadMesh val4 = SlotMeshes.AttachQuad(Optizoom.overlayVisual, overlaySize.Value, (IAssetProvider<Material>)(object)val3, false);
				DynamicFieldExtensions.SyncWithVariable<float2>((IField<float2>)(object)val4.Size, "overlaySize", false, false);
				UnlitMaterial val5 = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<UnlitMaterial>(true, (Action<UnlitMaterial>)null);
				((SyncField<colorX>)(object)val5.TintColor).Value = overlayBgColor.Value;
				DynamicFieldExtensions.SyncWithVariable<colorX>((IField<colorX>)(object)val5.TintColor, "overlayBgColor", false, false);
				FrameMesh val6 = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<FrameMesh>(true, (Action<FrameMesh>)null);
				MeshRenderer obj = SlotMeshes.AttachMesh(Optizoom.overlayVisual, (IAssetProvider<Mesh>)(object)val6, (IAssetProvider<Material>)(object)val5, 0);
				((SyncField<float>)(object)val6.Thickness).Value = 5f;
				ValueCopyExtensions.DriveFrom<float2>((IField<float2>)(object)val6.ContentSize, (IField<float2>)(object)val4.Size, false, false, true);
				DynamicFieldExtensions.SyncWithVariable<bool>((IField<bool>)(object)((ComponentBase<Component>)(object)obj).EnabledField, "overlayBg", false, false);
				StaticAudioClip zoomIn = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<StaticAudioClip>(true, (Action<StaticAudioClip>)null);
				if (!Utility.IsNullOrWhiteSpace(zoomInSound.Value))
				{
					((SyncField<Uri>)(object)((StaticAssetProvider<AudioClip, DummyMetadata, AudioClipVariantDescriptor>)(object)zoomIn).URL).Value = new Uri(zoomInSound.Value);
				}
				((ComponentBase<Component>)(object)zoomIn).RunInUpdates(3, (Action)delegate
				{
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					DynamicField<Uri> obj3 = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<DynamicField<Uri>>(true, (Action<DynamicField<Uri>>)null);
					((SyncField<string>)(object)((DynamicVariableBase<Uri>)(object)obj3).VariableName).Value = "zoomInSoundUri";
					((SyncField<RefID>)(object)obj3.TargetField).Value = ((SyncElement)((StaticAssetProvider<AudioClip, DummyMetadata, AudioClipVariantDescriptor>)(object)zoomIn).URL).ReferenceID;
				});
				StaticAudioClip zoomOut = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<StaticAudioClip>(true, (Action<StaticAudioClip>)null);
				if (!Utility.IsNullOrWhiteSpace(zoomOutSound.Value))
				{
					((SyncField<Uri>)(object)((StaticAssetProvider<AudioClip, DummyMetadata, AudioClipVariantDescriptor>)(object)zoomOut).URL).Value = new Uri(zoomOutSound.Value);
				}
				((ComponentBase<Component>)(object)zoomOut).RunInUpdates(3, (Action)delegate
				{
					//IL_002c: Unknown result type (might be due to invalid IL or missing references)
					DynamicField<Uri> obj2 = ((ContainerWorker<Component>)(object)Optizoom.overlayVisual).AttachComponent<DynamicField<Uri>>(true, (Action<DynamicField<Uri>>)null);
					((SyncField<string>)(object)((DynamicVariableBase<Uri>)(object)obj2).VariableName).Value = "zoomOutSoundUri";
					((SyncField<RefID>)(object)obj2.TargetField).Value = ((SyncElement)((StaticAssetProvider<AudioClip, DummyMetadata, AudioClipVariantDescriptor>)(object)zoomOut).URL).ReferenceID;
				});
			}
			catch (global::System.Exception ex)
			{
				Logger.LogError((object)ex);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Userspace), "OnCommonUpdate")]
		public static void Update(Userspace __instance)
		{
			//IL_0017: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (toggleZoom.Value && ((Worker)__instance).InputInterface.GetKeyDown(zoomKey.Value))
				{
					toggleState = !toggleState;
				}
				bool flag = enabled.Value && !FocusManagerExtensions.HasActiveFocus(((Worker)__instance).LocalUser) && !Userspace.HasFocus && (toggleState || ((Worker)__instance).InputInterface.GetKey(zoomKey.Value));
				if (exposeZoomedInVariable.Value)
				{
					World focusedWorld = ((Worker)__instance).Engine.WorldManager.FocusedWorld;
					object obj;
					if (focusedWorld == null)
					{
						obj = null;
					}
					else
					{
						User localUser = focusedWorld.LocalUser;
						if (localUser == null)
						{
							obj = null;
						}
						else
						{
							UserRoot root = localUser.Root;
							obj = ((root != null) ? ((Component)root).Slot : null);
						}
					}
					Slot val = (Slot)obj;
					if ((int)DynamicVariableHelper.WriteDynamicVariable<bool>(val, "User/optizoom.zoomed_in", flag) != 0)
					{
						DynamicVariableHelper.CreateVariable<bool>(val, "User/optizoom.zoomed_in", flag, false);
					}
				}
				if (flag == zoomState)
				{
					return;
				}
				zoomState = flag;
				if (enableOverlay.Value)
				{
					overlayVisual.ActiveSelf = flag;
				}
				if (enableZoomSounds.Value)
				{
					string soundUri = (flag ? zoomInSound.Value : zoomOutSound.Value);
					StaticAudioClip component = ((ContainerWorker<Component>)(object)overlayVisual).GetComponent<StaticAudioClip>((Predicate<StaticAudioClip>)((StaticAudioClip a) => ((object)((SyncField<Uri>)(object)((StaticAssetProvider<AudioClip, DummyMetadata, AudioClipVariantDescriptor>)(object)a).URL)?.Value)?.ToString() == soundUri), false);
					if (component != null)
					{
						SlotAssets.PlayOneShot(overlayVisual, (IAssetProvider<AudioClip>)(object)component, zoomVolume.Value, false, (bool?)null, 1f, false, (AudioDistanceSpace)0, false);
					}
				}
			}
			catch (global::System.Exception ex)
			{
				Logger.LogError((object)ex);
			}
		}
	}

	[HarmonyPatch]
	private class Optizoom_Patch
	{
		private static readonly Dictionary<UserRoot, UserRootFOVLerps> FOVLerps = new Dictionary<UserRoot, UserRootFOVLerps>();

		[HarmonyPostfix]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static void Postfix(UserRoot __instance, ref float __result, DesktopRenderSettings ____renderSettings)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			float num = __result;
			try
			{
				UserRootFOVLerps userRootFOVLerps = default(UserRootFOVLerps);
				if (!FOVLerps.TryGetValue(__instance, ref userRootFOVLerps))
				{
					userRootFOVLerps = new UserRootFOVLerps();
					FOVLerps.Add(__instance, userRootFOVLerps);
				}
				bool num2 = enabled.Value && !FocusManagerExtensions.HasActiveFocus(((Worker)__instance).LocalUser) && !Userspace.HasFocus && ((Worker)__instance).Engine.WorldManager.FocusedWorld == ((Worker)__instance).World && (toggleState || ((Worker)__instance).InputInterface.GetKey(zoomKey.Value));
				float num3 = ((SyncField<float>)(object)____renderSettings?.FieldOfView).Value ?? 60f;
				float num4 = (num2 ? (num3 - zoomFOV.Value) : 0f);
				if (num2 && scrollZoom.Value)
				{
					float2 value = ((Worker)__instance).InputInterface.Mouse.NormalizedScrollWheelDelta.Value;
					float num5 = 0f - ((float2)(ref value)).Y;
					userRootFOVLerps.scroll += num5 * scrollZoomSpeed.Value;
					userRootFOVLerps.scroll = MathX.Clamp(userRootFOVLerps.scroll, 0f - zoomFOV.Value, 179f - zoomFOV.Value);
					num4 -= userRootFOVLerps.scroll;
				}
				else if (scrollZoom.Value && !MathX.Approximately((double)userRootFOVLerps.scroll, 0.0, 0.001))
				{
					userRootFOVLerps.scroll = 0f;
				}
				if (lerpZoom.Value)
				{
					userRootFOVLerps.currentLerp = MathX.SmoothDamp(userRootFOVLerps.currentLerp, num4, ref userRootFOVLerps.lerpVelocity, zoomSpeed.Value, 179f, ((Worker)__instance).Time.Delta);
					__result -= userRootFOVLerps.currentLerp;
				}
				else
				{
					__result -= num4;
				}
				__result = MathX.FilterInvalid(__result, 60f);
				__result = MathX.Clamp(__result, 1f, 179f);
			}
			catch (global::System.Exception ex)
			{
				Logger.LogError((object)ex);
				__result = num;
			}
		}
	}

	private class UserRootFOVLerps
	{
		public float currentLerp;

		public float lerpVelocity;

		public float scroll;
	}

	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static EventHandler <>9__22_0;

		public static EventHandler <>9__22_1;

		public static EventHandler <>9__22_2;

		public static EventHandler <>9__22_3;

		public static EventHandler <>9__22_4;

		public static EventHandler <>9__22_5;

		public static EventHandler <>9__22_6;

		internal void <Load>b__22_0(object? _, EventArgs _)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			TryWriteDynamicValue<float2>(overlayVisual, "OverlayVisual/overlaySize", overlaySize.Value);
		}

		internal void <Load>b__22_1(object? _, EventArgs _)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/overlayUri", new Uri(overlayUri.Value));
		}

		internal void <Load>b__22_2(object? _, EventArgs _)
		{
			TryWriteDynamicValue(overlayVisual, "OverlayVisual/overlayBg", overlayBg.Value);
		}

		internal void <Load>b__22_3(object? _, EventArgs _)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			TryWriteDynamicValue<colorX>(overlayVisual, "OverlayVisual/overlayBgColor", overlayBgColor.Value);
		}

		internal void <Load>b__22_4(object? _, EventArgs _)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/zoomInSoundUri", new Uri(zoomInSound.Value));
		}

		internal void <Load>b__22_5(object? _, EventArgs _)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/zoomOutSoundUri", new Uri(zoomOutSound.Value));
		}

		internal void <Load>b__22_6(object? _, EventArgs _)
		{
			toggleState = false;
		}
	}

	private static ConfigEntry<bool> enabled;

	private static ConfigEntry<Key> zoomKey;

	private static ConfigEntry<float> zoomFOV;

	private static ConfigEntry<bool> toggleZoom;

	private static ConfigEntry<bool> lerpZoom;

	private static ConfigEntry<float> zoomSpeed;

	private static ConfigEntry<bool> scrollZoom;

	private static ConfigEntry<float> scrollZoomSpeed;

	private static ConfigEntry<bool> enableOverlay;

	private static ConfigEntry<float2> overlaySize;

	private static ConfigEntry<string> overlayUri;

	private static ConfigEntry<bool> overlayBg;

	private static ConfigEntry<colorX> overlayBgColor;

	private static ConfigEntry<bool> enableZoomSounds;

	private static ConfigEntry<string> zoomInSound;

	private static ConfigEntry<string> zoomOutSound;

	private static ConfigEntry<float> zoomVolume;

	private static ConfigEntry<bool> exposeZoomedInVariable;

	private static Slot overlayVisual;

	private static ManualLogSource Logger;

	private static bool toggleState;

	private static bool zoomState;

	public override void Load()
	{
		//IL_0029: 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_003e: Expected O, but got Unknown
		//IL_006d: 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)
		//IL_0082: Expected O, but got Unknown
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		//IL_00f7: 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_010c: Expected O, but got Unknown
		//IL_013a: 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_014f: Expected O, but got Unknown
		//IL_0181: 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_0196: Expected O, but got Unknown
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: Expected O, but got Unknown
		//IL_020b: 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_0220: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: 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_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b7: Expected O, but got Unknown
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Expected O, but got Unknown
		//IL_032c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Expected O, but got Unknown
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Expected O, but got Unknown
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Expected O, but got Unknown
		//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Expected O, but got Unknown
		//IL_0444: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Expected O, but got Unknown
		//IL_0499: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Expected O, but got Unknown
		//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f1: Expected O, but got Unknown
		//IL_0525: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0530: Expected O, but got Unknown
		//IL_054e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0553: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Expected O, but got Unknown
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_057c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Expected O, but got Unknown
		//IL_05a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ab: Expected O, but got Unknown
		//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d4: Expected O, but got Unknown
		//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fd: Expected O, but got Unknown
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0620: Unknown result type (might be due to invalid IL or missing references)
		//IL_0626: Expected O, but got Unknown
		enabled = ((BasePlugin)this).Config.Bind<bool>("Optizoom", "enabled", true, new ConfigDescription("Enable Optizoom", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.enabled.Key", "Settings.dev.lecloutpanda.optizoom.enabled.Description") }));
		zoomKey = ((BasePlugin)this).Config.Bind<Key>("Optizoom", "keyBind", (Key)9, new ConfigDescription("Zoom Key", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.keyBind.Key", "Settings.dev.lecloutpanda.optizoom.keyBind.Description") }));
		zoomFOV = ((BasePlugin)this).Config.Bind<float>("Optizoom", "zoomFOV", 7f, new ConfigDescription("Zoom FOV", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.zoomFOV.Key", "Settings.dev.lecloutpanda.optizoom.zoomFOV.Description") }));
		toggleZoom = ((BasePlugin)this).Config.Bind<bool>("Optizoom", "toggleZoom", false, new ConfigDescription("Toggle Zoom", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.toggleZoom.Key", "Settings.dev.lecloutpanda.optizoom.toggleZoom.Description") }));
		lerpZoom = ((BasePlugin)this).Config.Bind<bool>("Optizoom", "lerpZoom", true, new ConfigDescription("Lerp Zoom", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.lerpZoom.Key", "Settings.dev.lecloutpanda.optizoom.lerpZoom.Description") }));
		zoomSpeed = ((BasePlugin)this).Config.Bind<float>("Optizoom", "zoomSpeed", 50f, new ConfigDescription("Zoom Speed", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.zoomSpeed.Key", "Settings.dev.lecloutpanda.optizoom.zoomSpeed.Description") }));
		scrollZoom = ((BasePlugin)this).Config.Bind<bool>("Optizoom", "scrollZoom", true, new ConfigDescription("Zoom with scroll", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.scrollZoom.Key", "Settings.dev.lecloutpanda.optizoom.scrollZoom.Description") }));
		scrollZoomSpeed = ((BasePlugin)this).Config.Bind<float>("Optizoom", "scrollZoomSpeed", 50f, new ConfigDescription("Scroll Zoom Speed", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.scrollZoomSpeed.Key", "Settings.dev.lecloutpanda.optizoom.scrollZoomSpeed.Description") }));
		enableOverlay = ((BasePlugin)this).Config.Bind<bool>("Overlay", "enableOverlay", true, new ConfigDescription("Enable Overlay", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.enableOverlay.Key", "Settings.dev.lecloutpanda.optizoom.enableOverlay.Description") }));
		ConfigFile config = ((BasePlugin)this).Config;
		float2 one = float2.One;
		overlaySize = config.Bind<float2>("Overlay", "overlaySize", (ref one) * 1.12f, new ConfigDescription("Overlay Size", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.overlaySize.Key", "Settings.dev.lecloutpanda.optizoom.overlaySize.Description") }));
		overlayUri = ((BasePlugin)this).Config.Bind<string>("Overlay", "overlayUri", "resdb:///55b0aea6dcdce645b3f01ff83877b88f16402155f4ba54bced02aa6bdae528b9.png", new ConfigDescription("Overlay Uri", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.overlayUri.Key", "Settings.dev.lecloutpanda.optizoom.overlayUri.Description") }));
		overlayBg = ((BasePlugin)this).Config.Bind<bool>("Overlay", "overlayBg", true, new ConfigDescription("Enable Overlay Background", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.overlayBg.Key", "Settings.dev.lecloutpanda.optizoom.overlayBg.Description") }));
		overlayBgColor = ((BasePlugin)this).Config.Bind<colorX>("Overlay", "overlayBgColor", colorX.Black, new ConfigDescription("Overlay Background Color", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.overlayBgColor.Key", "Settings.dev.lecloutpanda.optizoom.overlayBgColor.Description") }));
		enableZoomSounds = ((BasePlugin)this).Config.Bind<bool>("Sound", "enableZoomSounds", true, new ConfigDescription("Enable Zoom Sounds", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.enableZoomSounds.Key", "Settings.dev.lecloutpanda.optizoom.enableZoomSounds.Description") }));
		zoomInSound = ((BasePlugin)this).Config.Bind<string>("Sound", "zoomInSound", "", new ConfigDescription("Zoom In Sound URI (null to disable)", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.zoomInSound.Key", "Settings.dev.lecloutpanda.optizoom.zoomInSound.Description") }));
		zoomOutSound = ((BasePlugin)this).Config.Bind<string>("Sound", "zoomOutSound", "", new ConfigDescription("Zoom Out Sound URI (null to disable)", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.zoomOutSound.Key", "Settings.dev.lecloutpanda.optizoom.zoomOutSound.Description") }));
		zoomVolume = ((BasePlugin)this).Config.Bind<float>("Sound", "zoomVolume", 1f, new ConfigDescription("Zoom Volume", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.zoomVolume.Key", "Settings.dev.lecloutpanda.optizoom.zoomVolume.Description") }));
		exposeZoomedInVariable = ((BasePlugin)this).Config.Bind<bool>("Optizoom", "exposeZoomedInVariable", false, new ConfigDescription("Expose zoomed-in variable on user (User/optizoom.zoomed_in)", (AcceptableValueBase)null, new object[1] { (object)new ConfigLocale("Settings.dev.lecloutpanda.optizoom.exposeZoomedInVariable.Key", "Settings.dev.lecloutpanda.optizoom.exposeZoomedInVariable.Description") }));
		Logger = ((BasePlugin)this).Log;
		((BasePlugin)this).HarmonyInstance.PatchAll();
		ConfigEntry<float2> obj = overlaySize;
		object obj2 = <>c.<>9__22_0;
		if (obj2 == null)
		{
			EventHandler val = delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				TryWriteDynamicValue<float2>(overlayVisual, "OverlayVisual/overlaySize", overlaySize.Value);
			};
			<>c.<>9__22_0 = val;
			obj2 = (object)val;
		}
		obj.SettingChanged += (EventHandler)obj2;
		ConfigEntry<string> obj3 = overlayUri;
		object obj4 = <>c.<>9__22_1;
		if (obj4 == null)
		{
			EventHandler val2 = delegate
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/overlayUri", new Uri(overlayUri.Value));
			};
			<>c.<>9__22_1 = val2;
			obj4 = (object)val2;
		}
		obj3.SettingChanged += (EventHandler)obj4;
		ConfigEntry<bool> obj5 = overlayBg;
		object obj6 = <>c.<>9__22_2;
		if (obj6 == null)
		{
			EventHandler val3 = delegate
			{
				TryWriteDynamicValue(overlayVisual, "OverlayVisual/overlayBg", overlayBg.Value);
			};
			<>c.<>9__22_2 = val3;
			obj6 = (object)val3;
		}
		obj5.SettingChanged += (EventHandler)obj6;
		ConfigEntry<colorX> obj7 = overlayBgColor;
		object obj8 = <>c.<>9__22_3;
		if (obj8 == null)
		{
			EventHandler val4 = delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				TryWriteDynamicValue<colorX>(overlayVisual, "OverlayVisual/overlayBgColor", overlayBgColor.Value);
			};
			<>c.<>9__22_3 = val4;
			obj8 = (object)val4;
		}
		obj7.SettingChanged += (EventHandler)obj8;
		ConfigEntry<string> obj9 = zoomInSound;
		object obj10 = <>c.<>9__22_4;
		if (obj10 == null)
		{
			EventHandler val5 = delegate
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/zoomInSoundUri", new Uri(zoomInSound.Value));
			};
			<>c.<>9__22_4 = val5;
			obj10 = (object)val5;
		}
		obj9.SettingChanged += (EventHandler)obj10;
		ConfigEntry<string> obj11 = zoomOutSound;
		object obj12 = <>c.<>9__22_5;
		if (obj12 == null)
		{
			EventHandler val6 = delegate
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Expected O, but got Unknown
				TryWriteDynamicValue<Uri>(overlayVisual, "OverlayVisual/zoomOutSoundUri", new Uri(zoomOutSound.Value));
			};
			<>c.<>9__22_5 = val6;
			obj12 = (object)val6;
		}
		obj11.SettingChanged += (EventHandler)obj12;
		ConfigEntry<bool> obj13 = toggleZoom;
		object obj14 = <>c.<>9__22_6;
		if (obj14 == null)
		{
			EventHandler val7 = delegate
			{
				toggleState = false;
			};
			<>c.<>9__22_6 = val7;
			obj14 = (object)val7;
		}
		obj13.SettingChanged += (EventHandler)obj14;
	}

	public static bool TryWriteDynamicValue<T>(Slot root, string name, T value)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Invalid comparison between Unknown and I4
		string text = default(string);
		string text2 = default(string);
		DynamicVariableHelper.ParsePath(name, ref text, ref text2);
		if (string.IsNullOrEmpty(text2))
		{
			return false;
		}
		DynamicVariableSpace val = DynamicVariableHelper.FindSpace(root, text);
		if (val == null)
		{
			return false;
		}
		return (int)val.TryWriteValue<T>(text2, value) == 0;
	}

	public static bool TryReadDynamicValue<T>(Slot root, string name, out T value)
	{
		value = Coder<T>.Default;
		string text = default(string);
		string text2 = default(string);
		DynamicVariableHelper.ParsePath(name, ref text, ref text2);
		if (string.IsNullOrEmpty(text2))
		{
			return false;
		}
		DynamicVariableSpace val = DynamicVariableHelper.FindSpace(root, text);
		if (val == null)
		{
			return false;
		}
		return val.TryReadValue<T>(text2, ref value);
	}
}
public static class PluginMetadata
{
	public const string GUID = "dev.lecloutpanda.Optizoom";

	public const string NAME = "Optizoom";

	public const string VERSION = "2.3.2";

	public const string AUTHORS = "badhaloninja, LeCloutPanda";

	public const string REPOSITORY_URL = "https://github.com/LeCloutPanda/Optizoom";
}