Decompiled source of Polarized v2.1.0

Mods/Polarized.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using HarmonyLib;
using Il2Cpp;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab.SaveData;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Interaction;
using MelonLoader;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.Universal;
using WeatherElectric.BONELAB.BoneMenu;
using WeatherElectric.Logging;
using WeatherElectric.Polarized;
using WeatherElectric.Polarized.Handlers;
using WeatherElectric.Polarized.Resources;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Image creation utility")]
[assembly: AssemblyDescription("Image creation utility")]
[assembly: AssemblyCompany("Weather Electric")]
[assembly: AssemblyProduct("Polarized")]
[assembly: AssemblyCopyright("Developed by Mabel Amber")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("2.1.0")]
[assembly: MelonInfo(typeof(Main), "Polarized", "2.1.0", "Mabel Amber", "https://thunderstore.io/c/bonelab/p/WeatherElectric/Polarized/")]
[assembly: MelonColor(255, 211, 137, 133)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("2.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 WeatherElectric.Polarized
{
	internal static class BoneMenu
	{
		public static void Setup()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: 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_03d1: Unknown result type (might be due to invalid IL or missing references)
			Page val = Menu.MainPage.CreatePage("Polarized", new Color(211f, 137f, 133f), 0, true);
			val.Logo = Assets.MainIcon;
			Page obj = val.CreatePage("Avatar Tools", new Color(0.4f, 0.8f, 1f), 0, true);
			obj.CreateFloat("Capture Delay", Color.white, 3f, 1f, 0f, 999f, (Action<float>)delegate(float value)
			{
				CloneHandler.Delay = value;
			});
			obj.CreateBool("Freeze Held Objects On Clone", Color.cyan, false, (Action<bool>)delegate(bool value)
			{
				CloneHandler.FreezeHeldObjs = value;
			});
			obj.CreateFunction("Clone Avatar", Color.green, (Action)CloneHandler.CreateClone);
			obj.CreateFunction("Delete Last Clone", Color.yellow, (Action)CloneHandler.DestroyLastClone);
			obj.CreateFunction("Delete All Clones", Color.red, (Action)CloneHandler.DestroyAllClones);
			obj.CreateFunction("Unfreeze Last Frozen Objects", Color.yellow, (Action)CloneHandler.UnfreezeLastFrozenObjs);
			obj.CreateFunction("Unfreeze All Frozen Objects", Color.red, (Action)CloneHandler.UnfreezeAllFrozenObjs);
			obj.CreateFloat("Nearby Radius", Color.white, 1f, 0.1f, 0.1f, 5f, (Action<float>)delegate(float value)
			{
				CloneHandler.NearbyRadius = value;
			});
			obj.CreateFunction("Delete Nearby Clone", Color.red, (Action)CloneHandler.DestroyNearbyClone);
			obj.CreateFunction("Unfreeze Nearby Objects", Color.red, (Action)CloneHandler.UnfreezeNearbyObjects);
			if (HelperMethods.IsAndroid())
			{
				val.CreateFunction("Sorry! Camera stuff don't work on Quest!", Color.red, (Action)delegate
				{
				});
				return;
			}
			Page obj2 = val.CreatePage("Camera Tools", new Color(0.75f, 0.6f, 1f), 0, true);
			obj2.CreateFloat("FOV", Color.white, 90f, 1f, 0f, 180f, (Action<float>)CameraHandler.Update);
			obj2.CreateFunction("Spawn Camera", Color.green, (Action)CameraHandler.Spawn);
			obj2.CreateFunction("Delete Camera", Color.red, (Action)CameraHandler.Destroy);
			val.CreateFunction("Toggle Screenshot Preview", new Color(1f, 0.5f, 0.8f), (Action)PreviewHandler.Toggle);
			val.CreateFloat("Capture Delay", new Color(0.3f, 0.9f, 0.85f), 3f, 1f, 0f, 999f, (Action<float>)delegate(float value)
			{
				ScreenshotHandler.Delay = value;
			});
			val.CreateFunction("Take Screenshot", new Color(0.3f, 0.9f, 0.85f), (Action)ScreenshotHandler.Screenshot);
		}
	}
	public class Main : MelonMod
	{
		internal const string Name = "Polarized";

		internal const string Description = "Image creation utility";

		internal const string Author = "Mabel Amber";

		internal const string Company = "Weather Electric";

		internal const string Version = "2.1.0";

		internal const string DownloadLink = "https://thunderstore.io/c/bonelab/p/WeatherElectric/Polarized/";

		internal static LoggerInstance Logger;

		public override void OnInitializeMelon()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			Logger = new LoggerInstance(((MelonBase)this).LoggerInstance);
			Assets.Load();
			BoneMenu.Setup();
		}
	}
}
namespace WeatherElectric.Polarized.Resources
{
	internal static class Assets
	{
		private static readonly Assembly CurrentAsm = Assembly.GetExecutingAssembly();

		public static GameObject PreviewObj { get; private set; }

		public static RenderTexture PreviewRT { get; private set; }

		public static Texture2D MainIcon { get; private set; }

		public static AudioClip TimerAudio { get; private set; }

		public static AudioClip StartAudio { get; private set; }

		public static AudioClip CaptureAudio { get; private set; }

		public static void Load()
		{
			if (HelperMethods.IsAndroid())
			{
				LoadQuest();
			}
			else
			{
				LoadPC();
			}
		}

		private static void LoadQuest()
		{
			MainIcon = HelperMethods.LoadPersistentAsset<Texture2D>(HelperMethods.LoadEmbeddedAssetBundle(CurrentAsm, "WeatherElectric.Polarized.Resources.PolarizedData.Android.pack"), "Assets/MainIcon.png");
		}

		private static void LoadPC()
		{
			AssetBundle obj = HelperMethods.LoadEmbeddedAssetBundle(CurrentAsm, "WeatherElectric.Polarized.Resources.PolarizedData.Windows.pack");
			PreviewObj = HelperMethods.LoadPersistentAsset<GameObject>(obj, "Assets/Preview.prefab");
			PreviewRT = HelperMethods.LoadPersistentAsset<RenderTexture>(obj, "Assets/PreviewRT.rendertexture");
			MainIcon = HelperMethods.LoadPersistentAsset<Texture2D>(obj, "Assets/MainIcon.png");
			TimerAudio = HelperMethods.LoadPersistentAsset<AudioClip>(obj, "Assets/TimerAudio.wav");
			StartAudio = HelperMethods.LoadPersistentAsset<AudioClip>(obj, "Assets/StartAudio.wav");
			CaptureAudio = HelperMethods.LoadPersistentAsset<AudioClip>(obj, "Assets/CaptureAudio.wav");
		}
	}
}
namespace WeatherElectric.Polarized.Handlers
{
	public static class CameraHandler
	{
		private static Camera _camera;

		private static float _camFOV = 90f;

		public static void Spawn()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0032: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)Player.Head).transform;
			if (Object.op_Implicit((Object)(object)_camera))
			{
				((Behaviour)_camera).enabled = true;
				((Component)_camera).transform.SetPositionAndRotation(((Component)transform).transform.position, ((Component)transform).transform.rotation);
				return;
			}
			GameObject val = new GameObject("Polarized_Camera");
			if (Object.op_Implicit((Object)(object)val))
			{
				val.SetActive(false);
				val.transform.SetPositionAndRotation(((Component)transform).transform.position, ((Component)transform).transform.rotation);
				Camera val2 = (_camera = val.AddComponent<Camera>());
				UniversalAdditionalCameraData val3 = val.AddComponent<UniversalAdditionalCameraData>();
				val3.allowXRRendering = false;
				val2.stereoTargetEye = (StereoTargetEyeMask)0;
				val2.depth = 100f;
				val2.depthTextureMode = (DepthTextureMode)1;
				val2.depthTextureMode = (DepthTextureMode)4;
				val2.fieldOfView = _camFOV;
				val2.farClipPlane = 10000f;
				val2.nearClipPlane = 0.01f;
				VolumetricRendering obj = val.AddComponent<VolumetricRendering>();
				obj.cam = val2;
				obj.activeCam = val2;
				obj.activeCamData = val3;
				GraphicsManager.SetVolumetricVariables(GraphicsManager.graphicsSettings._Volumetrics_k__BackingField);
				val.SetActive(true);
				((Behaviour)val2).enabled = true;
			}
		}

		public static void Destroy()
		{
			if (Object.op_Implicit((Object)(object)_camera))
			{
				((Behaviour)_camera).enabled = false;
			}
		}

		public static void Update(float fov)
		{
			_camFOV = fov;
			if (Object.op_Implicit((Object)(object)_camera))
			{
				_camera.fieldOfView = _camFOV;
			}
		}
	}
	internal static class CloneHandler
	{
		[HarmonyPatch(typeof(PlayerAvatarArt), "UpdateAvatarHead")]
		private static class PlayerArtPatch
		{
			private static void Prefix(PlayerAvatarArt __instance)
			{
				if (_captureAvatar)
				{
					__instance.EnableHair();
					CloneAvatar();
					__instance.DisableHair();
					_captureAvatar = false;
				}
			}
		}

		public static float Delay = 3f;

		public static bool FreezeHeldObjs = false;

		public static float NearbyRadius = 1f;

		private static GameObject _lastClonedAvatar;

		private static readonly List<GameObject> ClonedAvatars = new List<GameObject>();

		private static bool _captureAvatar;

		private static readonly List<Rigidbody> LastFrozenObjs = new List<Rigidbody>();

		private static readonly List<Rigidbody> FrozenObjs = new List<Rigidbody>();

		public static void CreateClone()
		{
			MelonCoroutines.Start(StartClone());
		}

		public static void DestroyLastClone()
		{
			ClonedAvatars.RemoveAll((GameObject c) => !Object.op_Implicit((Object)(object)c));
			if (Object.op_Implicit((Object)(object)_lastClonedAvatar))
			{
				Object.Destroy((Object)(object)_lastClonedAvatar);
				_lastClonedAvatar = null;
			}
		}

		public static void DestroyAllClones()
		{
			ClonedAvatars.RemoveAll((GameObject c) => !Object.op_Implicit((Object)(object)c));
			if (ClonedAvatars.Count == 0)
			{
				return;
			}
			foreach (GameObject clonedAvatar in ClonedAvatars)
			{
				Object.Destroy((Object)(object)clonedAvatar);
			}
			ClonedAvatars.Clear();
		}

		public static void DestroyNearbyClone()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			ClonedAvatars.RemoveAll((GameObject c) => !Object.op_Implicit((Object)(object)c));
			Vector3 position = ((Component)Player.RigManager).transform.position;
			GameObject val = null;
			float num = NearbyRadius * NearbyRadius;
			foreach (GameObject clonedAvatar in ClonedAvatars)
			{
				Vector3 val2 = clonedAvatar.transform.position - position;
				val2.y = 0f;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (!(sqrMagnitude >= num))
				{
					num = sqrMagnitude;
					val = clonedAvatar;
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				if ((Object)(object)val == (Object)(object)_lastClonedAvatar)
				{
					_lastClonedAvatar = null;
				}
				ClonedAvatars.Remove(val);
				Object.Destroy((Object)(object)val);
			}
		}

		private static IEnumerator StartClone()
		{
			yield return (object)new WaitForSeconds(Delay);
			_captureAvatar = true;
		}

		private static void CloneAvatar()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)Player.Avatar).gameObject;
			GameObject val = Object.Instantiate<GameObject>(gameObject);
			val.transform.SetPositionAndRotation(gameObject.transform.position, gameObject.transform.rotation);
			foreach (Grip componentsInChild in val.GetComponentsInChildren<Grip>())
			{
				Object.Destroy((Object)(object)componentsInChild);
			}
			_lastClonedAvatar = val;
			ClonedAvatars.Add(val);
			if (FreezeHeldObjs)
			{
				FreezeHeldObjects();
			}
		}

		private static void FreezeHeldObjects()
		{
			LastFrozenObjs.Clear();
			FreezeHand(Player.LeftHand);
			FreezeHand(Player.RightHand);
		}

		public static void UnfreezeLastFrozenObjs()
		{
			FrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			LastFrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			if (LastFrozenObjs.Count == 0)
			{
				return;
			}
			foreach (Rigidbody lastFrozenObj in LastFrozenObjs)
			{
				lastFrozenObj.isKinematic = false;
				FrozenObjs.Remove(lastFrozenObj);
			}
			LastFrozenObjs.Clear();
		}

		public static void UnfreezeAllFrozenObjs()
		{
			FrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			LastFrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			if (FrozenObjs.Count == 0)
			{
				return;
			}
			foreach (Rigidbody frozenObj in FrozenObjs)
			{
				frozenObj.isKinematic = false;
			}
			FrozenObjs.Clear();
		}

		public static void UnfreezeNearbyObjects()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			FrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			LastFrozenObjs.RemoveAll((Rigidbody b) => !Object.op_Implicit((Object)(object)b));
			Vector3 position = Player.Head.position;
			Transform val = null;
			float num = NearbyRadius * NearbyRadius;
			foreach (Rigidbody frozenObj in FrozenObjs)
			{
				Vector3 val2 = frozenObj.position - position;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (!(sqrMagnitude >= num))
				{
					num = sqrMagnitude;
					val = ((Component)frozenObj).transform.root;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			for (int num2 = FrozenObjs.Count - 1; num2 >= 0; num2--)
			{
				Rigidbody val3 = FrozenObjs[num2];
				if (!((Object)(object)((Component)val3).transform.root != (Object)(object)val))
				{
					val3.isKinematic = false;
					LastFrozenObjs.Remove(val3);
					FrozenObjs.RemoveAt(num2);
				}
			}
		}

		private static void FreezeHand(Hand hand)
		{
			GameObject objectInHand = Player.GetObjectInHand(hand);
			if (!Object.op_Implicit((Object)(object)objectInHand))
			{
				return;
			}
			MarrowEntity componentInChildren = ((Component)objectInHand.transform.root).GetComponentInChildren<MarrowEntity>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			foreach (MarrowBody item in (Il2CppArrayBase<MarrowBody>)(object)componentInChildren.Bodies)
			{
				item._rigidbody.isKinematic = true;
				LastFrozenObjs.Add(item._rigidbody);
				FrozenObjs.Add(item._rigidbody);
			}
		}
	}
	public static class PreviewHandler
	{
		private static GameObject _instance;

		private static object _routine;

		private static int _layer;

		private static readonly Vector3 LocalPosition = new Vector3(0f, -0.2f, 0.7f);

		private static readonly Vector3 LocalEuler = new Vector3(343.424f, 180f, 180f);

		private static readonly Vector3 LocalScale = new Vector3(-0.5f, 0.5f, 1f);

		private static readonly Dictionary<int, (Camera cam, int mask)> Original = new Dictionary<int, (Camera, int)>();

		public static void Toggle()
		{
			Transform head = Player.Head;
			if ((Object)(object)_instance != (Object)null)
			{
				Destroy();
			}
			else
			{
				Create(head);
			}
		}

		private static void Create(Transform head)
		{
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)head == (Object)null)
			{
				Main.Logger.Log("Head transform is null!", (LogLevel)2);
				return;
			}
			if ((Object)(object)Assets.PreviewObj == (Object)null || (Object)(object)Assets.PreviewRT == (Object)null)
			{
				Main.Logger.Log($"Preview assets aren't loaded! obj null = {(Object)(object)Assets.PreviewObj == (Object)null}, rt null = {(Object)(object)Assets.PreviewRT == (Object)null}", (LogLevel)2);
				return;
			}
			_layer = FindFreeLayer();
			((Texture)Assets.PreviewRT).width = Screen.width;
			((Texture)Assets.PreviewRT).height = Screen.height;
			_instance = Object.Instantiate<GameObject>(Assets.PreviewObj, head, false);
			_instance.SetActive(true);
			SetLayerRecursive(_instance, _layer);
			_instance.transform.localPosition = LocalPosition;
			_instance.transform.localRotation = Quaternion.Euler(LocalEuler);
			_instance.transform.localScale = LocalScale;
			ApplyCameraMasks();
			_routine = MelonCoroutines.Start(CaptureLoop(0.1f));
		}

		private static void Destroy()
		{
			if (_routine != null)
			{
				MelonCoroutines.Stop(_routine);
			}
			_routine = null;
			RestoreCameraMasks();
			if ((Object)(object)_instance != (Object)null)
			{
				Object.Destroy((Object)(object)_instance);
			}
			_instance = null;
			Assets.PreviewRT.Release();
		}

		private static IEnumerator CaptureLoop(float interval)
		{
			while (true)
			{
				yield return (object)new WaitForEndOfFrame();
				ApplyCameraMasks();
				ScreenCapture.CaptureScreenshotIntoRenderTexture(Assets.PreviewRT);
				yield return (object)new WaitForSeconds(interval);
			}
		}

		private static void ApplyCameraMasks()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			int num = 1 << _layer;
			foreach (Camera item in (Il2CppArrayBase<Camera>)(object)Camera.allCameras)
			{
				bool flag = (int)item.stereoTargetEye > 0;
				bool flag2 = (item.cullingMask & num) != 0;
				if (flag != flag2)
				{
					int instanceID = ((Object)item).GetInstanceID();
					if (!Original.ContainsKey(instanceID))
					{
						Original[instanceID] = (item, item.cullingMask);
					}
					if (flag)
					{
						item.cullingMask |= num;
					}
					else
					{
						item.cullingMask &= ~num;
					}
				}
			}
		}

		private static void RestoreCameraMasks()
		{
			foreach (var value in Original.Values)
			{
				if ((Object)(object)value.cam != (Object)null)
				{
					value.cam.cullingMask = value.mask;
				}
			}
			Original.Clear();
		}

		private static void SetLayerRecursive(GameObject go, int layer)
		{
			foreach (Transform componentsInChild in go.GetComponentsInChildren<Transform>(true))
			{
				((Component)componentsInChild).gameObject.layer = layer;
			}
		}

		private static int FindFreeLayer()
		{
			for (int num = 31; num >= 8; num--)
			{
				if (string.IsNullOrEmpty(LayerMask.LayerToName(num)))
				{
					return num;
				}
			}
			return 31;
		}
	}
	internal static class ScreenshotHandler
	{
		public static float Delay = 3f;

		private static int _index;

		public static void Screenshot()
		{
			string outPath = Path.Combine(MelonEnvironment.UserDataDirectory, "Screenshots");
			if (Delay == 0f)
			{
				SendScreenshotNotification(Screencap(outPath));
			}
			else
			{
				MelonCoroutines.Start(PrepareScreencap(outPath, SendScreenshotNotification));
			}
		}

		private static void SendScreenshotNotification(string savedFile)
		{
			//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)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			Notifier.Send(new Notification
			{
				Title = NotificationText.op_Implicit("Screenshot Taken"),
				Message = NotificationText.op_Implicit("Image saved to " + savedFile),
				Type = (NotificationType)3,
				PopupLength = 1f,
				ShowTitleOnPopup = true
			});
		}

		private static string Screencap(string outPath)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			int width = Screen.width;
			int height = Screen.height;
			Texture2D val = new Texture2D(width, height);
			val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0);
			val.Apply();
			byte[] bytes;
			try
			{
				bytes = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)ImageConversion.EncodeToPNG(val));
			}
			catch (Exception ex)
			{
				Main.Logger.Log("Something went wrong while encoding the image: " + ex.Message, (LogLevel)0);
				return "failed :(";
			}
			finally
			{
				Object.Destroy((Object)(object)val);
			}
			_index++;
			Directory.CreateDirectory(outPath);
			string value = CreateTimecode(DateTime.Now);
			File.WriteAllBytes(Path.Combine(outPath, $"{value} {_index}.png"), bytes);
			return $"UserData/Screenshots/{value} {_index}.png";
		}

		private static IEnumerator PrepareScreencap(string outPath, Action<string> onComplete)
		{
			Audio.Play2DOneShot(Assets.TimerAudio, Audio.UI, 1f, 1f);
			yield return (object)new WaitForSeconds(Delay);
			Audio.Play2DOneShot(Assets.StartAudio, Audio.UI, 1f, 1f);
			string obj = Screencap(outPath);
			Audio.Play2DOneShot(Assets.CaptureAudio, Audio.UI, 1f, 1f);
			onComplete?.Invoke(obj);
		}

		private static string CreateTimecode(DateTime time)
		{
			string text = time.ToString("yyyy-MM-dd");
			string text2 = time.ToString("HH.mm.ss");
			return text + " " + text2;
		}
	}
}