Decompiled source of Advance GM Blocks v2.2.3

AdvanceGMBlocks.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using AdvanceGMBlocks;
using AdvanceGMBlocksPlugin.SystemMessageExtension;
using BepInEx;
using Bounce.Localization;
using Bounce.Singletons;
using Bounce.Unmanaged;
using DataModel;
using HarmonyLib;
using Newtonsoft.Json;
using PluginUtilities;
using RadialUI;
using SRF;
using TMPro;
using TaleSpire.GameMaster.Blocks;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RForRotatePlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("D20ArmyKnife")]
[assembly: AssemblyProduct("RForRotatePlugin")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace AdvanceGMBlocksPlugin.SystemMessageExtension
{
	public static class SystemMessageCallbackExtension
	{
		private static SystemMessageCallbackField _callbackField;

		public static void AddCallbackInput(SystemMessage instance, string title, string description, GMBlockData.CallbackData callbackData, Action<GMBlockData.CallbackData> onSubmit, Action onAcceptAction = null, Action onCancelAction = null)
		{
			//IL_003a: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)$"_callbackField is null = {(Object)(object)_callbackField == (Object)null}");
			if ((Object)(object)_callbackField == (Object)null)
			{
				Debug.Log((object)"Fetching original folder field and stop All Input Object");
				SystemMessageFolderField value = new Traverse((object)instance).Field("_folderField").GetValue<SystemMessageFolderField>();
				GameObject value2 = new Traverse((object)instance).Field("_stopAllInputObject").GetValue<GameObject>();
				Debug.Log((object)"cloning field");
				GameObject obj = Object.Instantiate<GameObject>(((Component)value).gameObject, value2.transform);
				((Object)obj).name = "CallbackPanel";
				Debug.Log((object)"removing original component");
				SRFGameObjectExtensions.RemoveComponentIfExists<SystemMessageFolderField>(obj);
				Debug.Log((object)"Fetching original folder field");
				_callbackField = obj.AddComponent<SystemMessageCallbackField>();
				Debug.Log((object)"Adjust Rect transform size");
				RectTransform component = obj.GetComponent<RectTransform>();
				_callbackField.collapsedHeight = component.sizeDelta.y;
				_callbackField.expandedHeight = component.sizeDelta.y + 40f;
				Debug.Log((object)"Initialize");
				_callbackField.Initialize();
			}
			Debug.Log((object)"Open");
			((object)instance).GetType().GetMethod("Open", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(instance, new object[0]);
			Debug.Log((object)"Setup Message");
			_callbackField.SetupMessage(callbackData, onSubmit, onAcceptAction, onCancelAction);
		}
	}
	public class SystemMessageCallbackField : SystemMessagePanel
	{
		[CompilerGenerated]
		private sealed class <LerpPosition>d__11 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public bool expand;

			public SystemMessageCallbackField <>4__this;

			private float <targetPosition>5__2;

			private float <fromPosition>5__3;

			private float <lerpDuration>5__4;

			private RectTransform <rectTransform>5__5;

			private float <timeElapsed>5__6;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LerpPosition>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<rectTransform>5__5 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				SystemMessageCallbackField systemMessageCallbackField = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
				}
				else
				{
					<>1__state = -1;
					<targetPosition>5__2 = (expand ? systemMessageCallbackField.expandedHeight : systemMessageCallbackField.collapsedHeight);
					<fromPosition>5__3 = (expand ? systemMessageCallbackField.collapsedHeight : systemMessageCallbackField.expandedHeight);
					<lerpDuration>5__4 = 0.2f;
					<rectTransform>5__5 = ((Component)systemMessageCallbackField).GetComponent<RectTransform>();
					float y = <rectTransform>5__5.sizeDelta.y;
					if (y == <targetPosition>5__2)
					{
						goto IL_015f;
					}
					float num2 = Mathf.InverseLerp(systemMessageCallbackField.collapsedHeight, systemMessageCallbackField.expandedHeight, y);
					if (!expand)
					{
						num2 = 1f - num2;
					}
					<timeElapsed>5__6 = num2 * <lerpDuration>5__4;
				}
				if (<timeElapsed>5__6 < <lerpDuration>5__4)
				{
					float num3 = Mathf.Lerp(<fromPosition>5__3, <targetPosition>5__2, <timeElapsed>5__6 / <lerpDuration>5__4);
					<rectTransform>5__5.sizeDelta = new Vector2(<rectTransform>5__5.sizeDelta.x, num3);
					<timeElapsed>5__6 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<rectTransform>5__5.sizeDelta = new Vector2(<rectTransform>5__5.sizeDelta.x, <targetPosition>5__2);
				goto IL_015f;
				IL_015f:
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		internal UiText Title;

		internal UiText Message;

		internal TMP_InputField _Endpoint;

		internal UiDropdown _CallbackType;

		internal TMP_InputField _Payload;

		internal Action<GMBlockData.CallbackData> _onSubmit;

		internal float collapsedHeight;

		internal float expandedHeight;

		private IEnumerator coroutine;

		private void Expand()
		{
			if (((Component)this).gameObject.activeInHierarchy)
			{
				if (coroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(coroutine);
				}
				coroutine = LerpPosition(expand: true);
				((MonoBehaviour)this).StartCoroutine(coroutine);
			}
		}

		private void Collapse()
		{
			if (((Component)this).gameObject.activeInHierarchy)
			{
				if (coroutine != null)
				{
					((MonoBehaviour)this).StopCoroutine(coroutine);
				}
				coroutine = LerpPosition(expand: false);
				((MonoBehaviour)this).StartCoroutine(coroutine);
			}
		}

		[IteratorStateMachine(typeof(<LerpPosition>d__11))]
		private IEnumerator LerpPosition(bool expand)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LerpPosition>d__11(0)
			{
				<>4__this = this,
				expand = expand
			};
		}

		public void Initialize()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			new Traverse((object)this).Field("_systemMessage").SetValue((object)SimpleSingletonBehaviour<SystemMessage>.Instance);
			Title = ((Component)((Component)this).transform.GetChild(0).GetChild(0)).GetComponent<UiText>();
			Transform child = ((Component)this).transform.GetChild(1);
			Transform child2 = ((Component)this).transform.GetChild(2);
			Message = ((Component)child.GetChild(0)).GetComponent<UiText>();
			_Endpoint = ((Component)child.GetChild(1)).GetComponent<TMP_InputField>();
			_CallbackType = ((Component)child.GetChild(2)).GetComponent<UiDropdown>();
			_Payload = Object.Instantiate<GameObject>(((Component)_Endpoint).gameObject, child).GetComponent<TMP_InputField>();
			Transform transform = ((Component)_Payload).transform;
			transform.position += new Vector3(0f, -75f, 0f);
			((TMP_Text)Message).text = "This is for 3rd party integration/callback";
			((TMP_Text)Title).text = "Set Callback Process";
			((UnityEvent)((Component)child2.GetChild(0)).GetComponent<Button>().onClick).AddListener(new UnityAction(((SystemMessagePanel)this).OnAccept));
			((UnityEvent)((Component)child2.GetChild(1)).GetComponent<Button>().onClick).AddListener(new UnityAction(((SystemMessagePanel)this).OnCancel));
		}

		public void CallbackTypeChanged(int v)
		{
			if (v == 2 || v == 3)
			{
				Expand();
			}
			else
			{
				Collapse();
			}
		}

		public void SetupMessage(GMBlockData.CallbackData callbackData, Action<GMBlockData.CallbackData> onSubmit, Action onAcceptAction = null, Action onCancelAction = null)
		{
			//IL_00a3: 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_00c1: 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)
			Debug.Log((object)"SetActive");
			((Component)this).gameObject.SetActive(true);
			((Component)this).transform.SetAsLastSibling();
			Debug.Log((object)"AddEventActions");
			base.onAccept = onAcceptAction;
			base.onCancel = onCancelAction;
			_onSubmit = onSubmit;
			Debug.Log((object)"Load string Data");
			_Endpoint.text = callbackData.Endpoint;
			_Payload.text = callbackData.Payload;
			Debug.Log((object)"Setup Drown down list");
			SetupStandardDropdownList(callbackData);
			Debug.Log((object)"Resize");
			RectTransform component = ((Component)this).GetComponent<RectTransform>();
			if (callbackData.MethodType == GMBlockData.CallbackType.Put || callbackData.MethodType == GMBlockData.CallbackType.Post)
			{
				component.sizeDelta = new Vector2(component.sizeDelta.x, expandedHeight);
			}
			else
			{
				component.sizeDelta = new Vector2(component.sizeDelta.x, collapsedHeight);
			}
			((Selectable)_Endpoint).Select();
			_Endpoint.ActivateInputField();
		}

		public override void OnAccept()
		{
			base.onAccept?.Invoke();
			_onSubmit?.Invoke(new GMBlockData.CallbackData
			{
				Endpoint = _Endpoint.text,
				Payload = _Payload.text,
				MethodType = (GMBlockData.CallbackType)((TMP_Dropdown)_CallbackType).value
			});
			CloseCallback();
		}

		public override void OnCancel()
		{
			CloseCallback();
		}

		private void CloseCallback()
		{
			_Endpoint.text = string.Empty;
			_Payload.text = string.Empty;
			((SystemMessagePanel)this).Close();
		}

		private void SetupStandardDropdownList(GMBlockData.CallbackData initialData)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			((UnityEventBase)((TMP_Dropdown)_CallbackType).onValueChanged).RemoveAllListeners();
			List<OptionData> list = new List<OptionData>
			{
				new OptionData("Desktop App"),
				new OptionData("HTTP GET"),
				new OptionData("HTTP POST"),
				new OptionData("HTTP PUT"),
				new OptionData("HTTP DELETE")
			};
			((TMP_Dropdown)_CallbackType).ClearOptions();
			((TMP_Dropdown)_CallbackType).AddOptions(list);
			((UnityEvent<int>)(object)((TMP_Dropdown)_CallbackType).onValueChanged).AddListener((UnityAction<int>)CallbackTypeChanged);
			((TMP_Dropdown)_CallbackType).value = (int)initialData.MethodType;
		}
	}
}
namespace AdvanceGMBlocks
{
	[BepInPlugin("org.hollofox.plugins.AdvanceGMBlocksPlugin", "Advance GM Blocks", "2.2.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class AdvanceGMBlocksPlugin : DependencyUnityPlugin<AdvanceGMBlocksPlugin>
	{
		public const string Guid = "org.hollofox.plugins.AdvanceGMBlocksPlugin";

		public const string Version = "2.2.3.0";

		internal static string LocalHidden;

		private static readonly Sprite AudioSprite = LoadEmbeddedSprite("file-audio.png");

		private static readonly Sprite MixerSprite = LoadEmbeddedSprite("sliders.png");

		private static readonly Sprite AtmosphereSprite = LoadEmbeddedSprite("cloud.png");

		private static readonly Sprite AmbientSprite = LoadEmbeddedSprite("volume-low.png");

		private static readonly Sprite MusicSprite = LoadEmbeddedSprite("music.png");

		private static readonly Sprite DayCycleSprite = LoadEmbeddedSprite("sun.png");

		private static readonly Sprite FogSprite = LoadEmbeddedSprite("smog.png");

		private static readonly Sprite ExposureSprite = LoadEmbeddedSprite("cloud-sun.png");

		private static readonly Sprite ImageSprite = LoadEmbeddedSprite("image.png");

		private Harmony harmony;

		private static GMBlockData _currentData;

		internal static string _currentKey;

		internal static Sprite LoadEmbeddedSprite(string path)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			path = "AdvanceGMBlocksPlugin.CustomData.Images.Icons." + path;
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
			if (manifestResourceStream == null)
			{
				Debug.LogError((object)("Embedded resource not found: " + path));
				return null;
			}
			byte[] array;
			using (MemoryStream memoryStream = new MemoryStream())
			{
				manifestResourceStream.CopyTo(memoryStream);
				array = memoryStream.ToArray();
			}
			manifestResourceStream.Dispose();
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				Debug.LogError((object)("Failed to load embedded PNG: " + path));
				return null;
			}
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}

		protected override void OnAwake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogDebug((object)"In Awake for Advance GM Blocks");
			LocalHidden = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) + "/BoardData";
			Directory.CreateDirectory(LocalHidden);
			harmony = new Harmony("org.hollofox.plugins.AdvanceGMBlocksPlugin");
			harmony.PatchAll();
			RadialUIPlugin.AddCustomButtonGMBlock("org.hollofox.plugins.AdvanceGMBlocksPlugin", new ItemArgs
			{
				CloseMenuOnActivate = false,
				Title = "Filters",
				Action = OpenFilters
			}, (Func<AtmosphereBlock, bool>)null);
		}

		protected override void OnDestroyed()
		{
			RadialUIPlugin.RemoveCustomButtonGMBlock("org.hollofox.plugins.AdvanceGMBlocksPlugin");
			LocalHidden = null;
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			((BaseUnityPlugin)this).Logger.LogDebug((object)"Advance GM Blocks unloaded");
		}

		public void OpenFilters(MapMenuItem mapmenuItem, object obj)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			MapMenu obj2 = MapMenuManager.OpenMenu(float3.op_Implicit(GMBlockInteractMenuBoardTool.block.WorldPosition), true);
			string path = Path.Join(string.op_Implicit(LocalHidden), string.op_Implicit(_currentKey));
			string text = string.Empty;
			if (File.Exists(path))
			{
				text = File.ReadAllText(path);
			}
			_currentData = (string.IsNullOrEmpty(text) ? new GMBlockData() : JsonConvert.DeserializeObject<GMBlockData>(text));
			obj2.AddMenuItem((MenuType)3, (Action<MapMenu, object>)AudioBranch, "Audio", "", "", AudioSprite, obj, true, false, 1f);
			obj2.AddMenuItem((MenuType)3, (Action<MapMenu, object>)MixerBranch, "Mixer", "", "", MixerSprite, obj, true, false, 1f);
			obj2.AddMenuItem((MenuType)3, (Action<MapMenu, object>)AtmosphereBranch, "Atmosphere", "", "", AtmosphereSprite, obj, true, false, 1f);
			obj2.AddToggleItem(!string.IsNullOrWhiteSpace(_currentData.Callback.Endpoint), (Action<MapMenuItem, object>)delegate
			{
				SystemMessageCallbackExtension.AddCallbackInput(SimpleSingletonBehaviour<SystemMessage>.Instance, "Set Callback Process", "This is for 3rd party integration/callback", _currentData.Callback, delegate(GMBlockData.CallbackData callbackData)
				{
					_currentData.Callback = callbackData;
					SaveCurrentData();
				});
			}, "Integrated Callback", "", "", "", (Sprite)null, obj, true, false, 1f);
		}

		private void AudioBranch(MapMenu map, object obj)
		{
			map.AddToggleItem(_currentData.EnabledAudio.Ambient, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAudio.Ambient = !_currentData.EnabledAudio.Ambient;
				SaveCurrentData();
			}, "Ambient", "", "", "", AmbientSprite, obj, true, false, 1f);
			map.AddToggleItem(_currentData.EnabledAudio.Music, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAudio.Music = !_currentData.EnabledAudio.Music;
				SaveCurrentData();
			}, "Music", "", "", "", MusicSprite, obj, true, false, 1f);
		}

		private void MixerBranch(MapMenu map, object obj)
		{
			map.AddToggleItem(_currentData.EnabledMixer.Ambient, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledMixer.Ambient = !_currentData.EnabledMixer.Ambient;
				SaveCurrentData();
			}, "Ambient Volume", "", "", "", AmbientSprite, obj, true, false, 1f);
			map.AddToggleItem(_currentData.EnabledMixer.Music, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledMixer.Music = !_currentData.EnabledMixer.Music;
				SaveCurrentData();
			}, "Music Volume", "", "", "", MusicSprite, obj, true, false, 1f);
		}

		private void AtmosphereBranch(MapMenu map, object obj)
		{
			map.AddToggleItem(_currentData.EnabledAtmosphere.DayCycle, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAtmosphere.DayCycle = !_currentData.EnabledAtmosphere.DayCycle;
				SaveCurrentData();
			}, "Day Cycle", "", "", "", DayCycleSprite, obj, true, false, 1f);
			map.AddToggleItem(_currentData.EnabledAtmosphere.Fog, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAtmosphere.Fog = !_currentData.EnabledAtmosphere.Fog;
				SaveCurrentData();
			}, "Fog", "", "", "", FogSprite, obj, true, false, 1f);
			map.AddToggleItem(_currentData.EnabledAtmosphere.Expose, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAtmosphere.Expose = !_currentData.EnabledAtmosphere.Expose;
				SaveCurrentData();
			}, "Exposure", "", "", "", ExposureSprite, obj, true, false, 1f);
			map.AddToggleItem(_currentData.EnabledAtmosphere.PostEffects, (Action<MapMenuItem, object>)delegate
			{
				_currentData.EnabledAtmosphere.PostEffects = !_currentData.EnabledAtmosphere.PostEffects;
				SaveCurrentData();
			}, "Post Effects", "", "", "", ImageSprite, obj, true, false, 1f);
		}

		private void SaveCurrentData()
		{
			//IL_0010: 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)
			string contents = JsonConvert.SerializeObject((object)_currentData);
			File.WriteAllText(Path.Join(string.op_Implicit(LocalHidden), string.op_Implicit(_currentKey)), contents);
		}
	}
	public sealed class GMBlockData
	{
		public enum CallbackType
		{
			Process,
			Get,
			Post,
			Put,
			Delete
		}

		public sealed class CallbackData
		{
			public string Endpoint = string.Empty;

			public CallbackType MethodType = CallbackType.Get;

			public string Payload = string.Empty;
		}

		public sealed class Audio
		{
			public bool Ambient = true;

			public bool Music = true;
		}

		public sealed class Mixer
		{
			public bool Ambient = true;

			public bool Music = true;
		}

		public sealed class Atmosphere
		{
			public bool DayCycle = true;

			public bool Fog = true;

			public bool Expose = true;

			public bool PostEffects = true;
		}

		public Audio EnabledAudio = new Audio();

		public Mixer EnabledMixer = new Mixer();

		public Atmosphere EnabledAtmosphere = new Atmosphere();

		public CallbackData Callback = new CallbackData();
	}
}
namespace AdvanceGMBlocks.GMBlockPatches
{
	[HarmonyPatch(typeof(GMBlockButtonAtmosphere), "OnOpenMenu")]
	internal sealed class GMBlockMenuPatchOpen
	{
		internal static void Prefix(ref GMDataBlockBase ____base)
		{
			AdvanceGMBlocksPlugin._currentKey = ((object)(NGuid)(ref ____base.AtmosphereBlock.Id)).ToString();
		}
	}
	[HarmonyPatch(typeof(GMBlockButtonAtmosphere), "OnApply")]
	internal sealed class GMBlockMenuPatch
	{
		internal static bool Prefix(MapMenuItem arg1, object arg2, ref GMDataBlockBase ____base)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Expected O, but got Unknown
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Expected O, but got Unknown
			AtmosphereData atmosphere = SimpleSingletonBehaviour<AtmosphereManager>.Instance.GetAtmosphere();
			GMDataBlockBase val = ____base;
			string path = Path.Join(string.op_Implicit(AdvanceGMBlocksPlugin.LocalHidden), string.op_Implicit(((object)(NGuid)(ref val.AtmosphereBlock.Id)).ToString()));
			if (!File.Exists(path))
			{
				return true;
			}
			string text = File.ReadAllText(path);
			if (string.IsNullOrWhiteSpace(text))
			{
				return true;
			}
			GMBlockData gMBlockData = JsonConvert.DeserializeObject<GMBlockData>(text);
			if (!gMBlockData.EnabledAudio.Ambient)
			{
				val.AtmosphereBlock.Data.ambientMusic = atmosphere.ambientMusic;
			}
			if (!gMBlockData.EnabledAudio.Music)
			{
				val.AtmosphereBlock.Data.music = atmosphere.music;
			}
			if (!gMBlockData.EnabledMixer.Ambient)
			{
				val.AtmosphereBlock.Data.ambientVolume = atmosphere.ambientVolume;
			}
			if (!gMBlockData.EnabledMixer.Music)
			{
				val.AtmosphereBlock.Data.musicVolume = atmosphere.musicVolume;
			}
			if (!gMBlockData.EnabledAtmosphere.DayCycle)
			{
				val.AtmosphereBlock.Data.dayCycle = atmosphere.dayCycle;
				val.AtmosphereBlock.Data.timeOfDay = atmosphere.timeOfDay;
				val.AtmosphereBlock.Data.sunDirection = atmosphere.sunDirection;
			}
			if (!gMBlockData.EnabledAtmosphere.Fog)
			{
				val.AtmosphereBlock.Data.fogMultiplier = atmosphere.fogMultiplier;
			}
			if (!gMBlockData.EnabledAtmosphere.Expose)
			{
				val.AtmosphereBlock.Data.exposure = atmosphere.exposure;
			}
			if (!gMBlockData.EnabledAtmosphere.PostEffects)
			{
				val.AtmosphereBlock.Data.posteffect = atmosphere.posteffect;
				val.AtmosphereBlock.Data.postEffectAmount = atmosphere.postEffectAmount;
			}
			SimpleSingletonBehaviour<AtmosphereManager>.Instance.SetAtmosphere(ref val.AtmosphereBlock.Data, true);
			if (!string.IsNullOrWhiteSpace(gMBlockData.Callback.Endpoint))
			{
				HttpClient val2 = new HttpClient();
				switch (gMBlockData.Callback.MethodType)
				{
				case GMBlockData.CallbackType.Get:
				{
					if (Uri.TryCreate(gMBlockData.Callback.Endpoint, UriKind.Absolute, out Uri result4))
					{
						val2.GetAsync(result4);
					}
					break;
				}
				case GMBlockData.CallbackType.Post:
				{
					if (Uri.TryCreate(gMBlockData.Callback.Endpoint, UriKind.Absolute, out Uri result2))
					{
						val2.PostAsync(result2, (HttpContent)new StringContent(gMBlockData.Callback.Payload, Encoding.UTF8, "application/json"));
					}
					break;
				}
				case GMBlockData.CallbackType.Put:
				{
					if (Uri.TryCreate(gMBlockData.Callback.Endpoint, UriKind.Absolute, out Uri result3))
					{
						val2.PutAsync(result3, (HttpContent)new StringContent(gMBlockData.Callback.Payload, Encoding.UTF8, "application/json"));
					}
					break;
				}
				case GMBlockData.CallbackType.Delete:
				{
					if (Uri.TryCreate(gMBlockData.Callback.Endpoint, UriKind.Absolute, out Uri result))
					{
						val2.DeleteAsync(result);
					}
					break;
				}
				case GMBlockData.CallbackType.Process:
					try
					{
						Process.Start(gMBlockData.Callback.Endpoint);
					}
					catch (Exception)
					{
					}
					break;
				}
			}
			return false;
		}
	}
}