Decompiled source of LabCam v1.0.0

Mods/LabCam.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.Elements;
using LabCam;
using LabCam.Melon;
using LabCam.Menu;
using LabCam.Resources;
using LabCam.Scripts;
using MelonLoader;
using MelonLoader.Preferences;
using SLZ.SFX;
using SLZ.VRMK;
using UnhollowerBaseLib;
using UnityEngine;
using UnityEngine.Experimental.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Take pictures with a physical camera that save to a file!")]
[assembly: AssemblyDescription("Take pictures with a physical camera that save to a file!")]
[assembly: AssemblyCompany("Weather Electric")]
[assembly: AssemblyProduct("LabCam")]
[assembly: AssemblyCopyright("Developed by SoulWithMae")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: MelonInfo(typeof(Main), "LabCam", "1.0.0", "SoulWithMae", "https://bonelab.thunderstore.io/package/SoulWithMae/LabCam/")]
[assembly: MelonColor(ConsoleColor.White)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LabCam
{
	public class Main : MelonMod
	{
		internal const string Name = "LabCam";

		internal const string Description = "Take pictures with a physical camera that save to a file!";

		internal const string Author = "SoulWithMae";

		internal const string Company = "Weather Electric";

		internal const string Version = "1.0.0";

		internal const string DownloadLink = "https://bonelab.thunderstore.io/package/SoulWithMae/LabCam/";

		internal static string CurrentMap;

		internal static Assembly CurrAsm => Assembly.GetExecutingAssembly();

		public override void OnInitializeMelon()
		{
			ModConsole.Setup(((MelonBase)this).LoggerInstance);
			Preferences.Setup();
			BoneMenu.Setup();
			UserData.Setup();
			Assets.Load();
			Hooking.OnLevelInitialized += OnLevelLoad;
		}

		private static void OnLevelLoad(LevelInfo levelInfo)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CurrentMap = levelInfo.title.Replace(" ", "");
		}
	}
}
namespace LabCam.Scripts
{
	[RegisterTypeInIl2Cpp]
	public class LabCamera : MonoBehaviour
	{
		public static LabCamera Instance;

		private Camera _camera;

		private AudioSource _captureSound;

		private MeshRenderer _previewRenderer;

		private GameObject _flashRenderer;

		private bool _flash;

		private GameObject _light;

		private PlayerAvatarArt _avatarArt;

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			AssignFields();
			SetQuality();
			SetMixers();
		}

		private void SetMixers()
		{
			ImpactSFX component = ((Component)this).GetComponent<ImpactSFX>();
			if ((Object)(object)component != (Object)null)
			{
				component.outputMixer = Audio.SFXMixer;
			}
			if ((Object)(object)_captureSound != (Object)null)
			{
				_captureSound.outputAudioMixerGroup = Audio.SFXMixer;
			}
		}

		private void AssignFields()
		{
			_camera = ((Component)((Component)this).transform.Find("Camera")).GetComponent<Camera>();
			_captureSound = ((Component)((Component)this).transform.Find("CaptureSound")).GetComponent<AudioSource>();
			_previewRenderer = ((Component)((Component)this).transform.Find("LensPreview")).GetComponent<MeshRenderer>();
			_flashRenderer = ((Component)((Component)this).transform.Find("FlashWarning")).gameObject;
			_light = ((Component)((Component)this).transform.Find("Flash")).gameObject;
			_avatarArt = ((Component)Player.rigManager).gameObject.GetComponent<PlayerAvatarArt>();
		}

		public void SetQuality()
		{
			switch (Preferences.Quality.Value)
			{
			case ImageQuality.Low:
				_camera.targetTexture = Assets.RenderTextures.LowQuality;
				((Renderer)_previewRenderer).material = Assets.Materials.LowQuality;
				break;
			case ImageQuality.Medium:
				_camera.targetTexture = Assets.RenderTextures.MediumQuality;
				((Renderer)_previewRenderer).material = Assets.Materials.MediumQuality;
				break;
			case ImageQuality.High:
				_camera.targetTexture = Assets.RenderTextures.HighQuality;
				((Renderer)_previewRenderer).material = Assets.Materials.HighQuality;
				break;
			default:
				ModConsole.Error("Invalid quality setting!");
				break;
			}
		}

		public void ToggleFlash()
		{
			_flash = !_flash;
			_flashRenderer.SetActive(_flash);
		}

		public void Capture()
		{
			if ((Object)(object)_camera == (Object)null || (Object)(object)_camera.targetTexture == (Object)null)
			{
				ModConsole.Error("Camera, render texture, or both are/is null!");
				return;
			}
			_captureSound.Play();
			SetHairMeshes(state: true);
			SetQuagmire(state: false);
			if (_flash)
			{
				_light.SetActive(true);
			}
			SaveRenderedImage(Render());
			SetHairMeshes(state: false);
			SetQuagmire(state: true);
			if (_flash)
			{
				((MonoBehaviour)this).Invoke("LightDisable", 0.3f);
			}
		}

		private static void SaveRenderedImage(Texture2D image)
		{
			string path;
			byte[] bytes;
			if (Preferences.Quality.Value == ImageQuality.Low)
			{
				path = Path.Combine(UserData.ModPath, $"BONELAB_{Main.CurrentMap}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.jpg");
				bytes = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)ImageConversion.EncodeToJPG(image));
			}
			else
			{
				path = Path.Combine(UserData.ModPath, $"BONELAB_{Main.CurrentMap}_{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
				bytes = Il2CppArrayBase<byte>.op_Implicit((Il2CppArrayBase<byte>)(object)ImageConversion.EncodeToPNG(image));
			}
			File.WriteAllBytes(path, bytes);
			Object.Destroy((Object)(object)image);
		}

		private Texture2D Render()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			RenderTexture targetTexture = _camera.targetTexture;
			Texture2D val = new Texture2D(targetTexture.width, targetTexture.height, targetTexture.graphicsFormat, ((Texture)targetTexture).mipmapCount, (TextureCreationFlags)0);
			_camera.Render();
			RenderTexture.active = targetTexture;
			val.ReadPixels(new Rect(0f, 0f, (float)targetTexture.width, (float)targetTexture.height), 0, 0);
			return val;
		}

		private void LightDisable()
		{
			_light.SetActive(false);
		}

		private void SetHairMeshes(bool state)
		{
			if (!((Object)(object)_avatarArt == (Object)null))
			{
				if (state)
				{
					_avatarArt.EnableHair();
				}
				else
				{
					_avatarArt.DisableHair();
				}
			}
		}

		private static void SetQuagmire(bool state)
		{
			if (!((Object)(object)Quagmire.Instance == (Object)null))
			{
				Quagmire.Instance.giggity.SetActive(state);
				Quagmire.Instance.giggityPreview.SetActive(state);
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}

		public LabCamera(IntPtr ptr)
			: base(ptr)
		{
		}
	}
	[RegisterTypeInIl2Cpp]
	public class Quagmire : MonoBehaviour
	{
		public static Quagmire Instance;

		public GameObject giggity;

		public GameObject giggityPreview;

		public MeshRenderer giggityRenderer;

		public AudioSource giggityAudio;

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			SetFields();
			SetQuality();
		}

		private void SetFields()
		{
			giggity = ((Component)((Component)this).transform.Find("Scale")).gameObject;
			giggityPreview = ((Component)((Component)this).transform.Find("Preview")).gameObject;
			giggityRenderer = giggityPreview.GetComponent<MeshRenderer>();
			giggityAudio = ((Component)((Component)this).transform.Find("TriggerSound")).GetComponent<AudioSource>();
		}

		public void SetQuality()
		{
			switch (Preferences.Quality.Value)
			{
			case ImageQuality.Low:
				((Renderer)giggityRenderer).material = Assets.Materials.LowQuality;
				break;
			case ImageQuality.Medium:
				((Renderer)giggityRenderer).material = Assets.Materials.MediumQuality;
				break;
			case ImageQuality.High:
				((Renderer)giggityRenderer).material = Assets.Materials.HighQuality;
				break;
			default:
				ModConsole.Error("Invalid quality setting!");
				break;
			}
		}

		public void SendCapture()
		{
			if (!((Object)(object)LabCamera.Instance == (Object)null))
			{
				giggityAudio.Play();
				LabCamera.Instance.Capture();
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}

		public Quagmire(IntPtr ptr)
			: base(ptr)
		{
		}
	}
}
namespace LabCam.Resources
{
	internal static class Assets
	{
		internal static class Prefabs
		{
			public static GameObject CameraPrefab;

			public static GameObject TriggerPrefab;

			internal static void LoadPrefabs()
			{
				if (!((Object)(object)_assetBundle == (Object)null))
				{
					if ((Object)(object)CameraPrefab == (Object)null)
					{
						CameraPrefab = HelperMethods.LoadPersistentAsset<GameObject>(_assetBundle, "Assets/LabCam/LabCam.prefab");
					}
					if ((Object)(object)TriggerPrefab == (Object)null)
					{
						TriggerPrefab = HelperMethods.LoadPersistentAsset<GameObject>(_assetBundle, "Assets/LabCam/RemoteTrigger.prefab");
					}
				}
			}
		}

		internal static class RenderTextures
		{
			public static RenderTexture HighQuality;

			public static RenderTexture MediumQuality;

			public static RenderTexture LowQuality;

			internal static void LoadRenderTextures()
			{
				if (!((Object)(object)_assetBundle == (Object)null))
				{
					if ((Object)(object)HighQuality == (Object)null)
					{
						HighQuality = HelperMethods.LoadPersistentAsset<RenderTexture>(_assetBundle, "Assets/LabCam/HighQuality.renderTexture");
					}
					if ((Object)(object)MediumQuality == (Object)null)
					{
						MediumQuality = HelperMethods.LoadPersistentAsset<RenderTexture>(_assetBundle, "Assets/LabCam/MediumQuality.renderTexture");
					}
					if ((Object)(object)LowQuality == (Object)null)
					{
						LowQuality = HelperMethods.LoadPersistentAsset<RenderTexture>(_assetBundle, "Assets/LabCam/LowQuality.renderTexture");
					}
				}
			}
		}

		internal static class Materials
		{
			public static Material HighQuality;

			public static Material MediumQuality;

			public static Material LowQuality;

			internal static void LoadMaterials()
			{
				if (!((Object)(object)_assetBundle == (Object)null))
				{
					if ((Object)(object)HighQuality == (Object)null)
					{
						HighQuality = HelperMethods.LoadPersistentAsset<Material>(_assetBundle, "Assets/LabCam/Materials/HighQualityPreview.mat");
					}
					if ((Object)(object)MediumQuality == (Object)null)
					{
						MediumQuality = HelperMethods.LoadPersistentAsset<Material>(_assetBundle, "Assets/LabCam/Materials/MediumQualityPreview.mat");
					}
					if ((Object)(object)LowQuality == (Object)null)
					{
						LowQuality = HelperMethods.LoadPersistentAsset<Material>(_assetBundle, "Assets/LabCam/Materials/LowQualityPreview.mat");
					}
				}
			}
		}

		private static AssetBundle _assetBundle;

		public static void Load()
		{
			_assetBundle = HelperMethods.LoadEmbeddedAssetBundle(Main.CurrAsm, HelperMethods.IsAndroid() ? "LabCam.Resources.Android.bundle" : "LabCam.Resources.Windows.bundle");
			if (!((Object)(object)_assetBundle == (Object)null))
			{
				Prefabs.LoadPrefabs();
				RenderTextures.LoadRenderTextures();
				Materials.LoadMaterials();
			}
		}
	}
}
namespace LabCam.Melon
{
	internal static class ModConsole
	{
		private static Instance _logger;

		public static void Setup(Instance loggerInstance)
		{
			_logger = loggerInstance;
		}

		public static void Msg(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text);
			}
		}

		public static void Msg(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text);
			}
		}

		public static void Msg(ConsoleColor txtcolor, object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text);
			}
		}

		public static void Msg(ConsoleColor txtcolor, string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text);
			}
		}

		public static void Msg(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			ConsoleColor consoleColor = ((loggingMode == 1) ? ConsoleColor.Yellow : ConsoleColor.Gray);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(consoleColor, text, args);
			}
		}

		public static void Msg(ConsoleColor txtcolor, string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Msg(txtcolor, text, args);
			}
		}

		public static void Error(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text);
			}
		}

		public static void Error(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text);
			}
		}

		public static void Error(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Error(text, args);
			}
		}

		public static void Warning(object obj, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? $"[DEBUG] {obj}" : obj.ToString());
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text);
			}
		}

		public static void Warning(string txt, int loggingMode = 0)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text);
			}
		}

		public static void Warning(string txt, int loggingMode = 0, params object[] args)
		{
			string text = ((loggingMode == 1) ? ("[DEBUG] " + txt) : txt);
			if (Preferences.LoggingMode.Value >= loggingMode)
			{
				_logger.Warning(text, args);
			}
		}
	}
	internal static class Preferences
	{
		public static readonly MelonPreferences_Category GlobalCategory = MelonPreferences.CreateCategory("Global");

		public static readonly MelonPreferences_Category OwnCategory = MelonPreferences.CreateCategory("LabCam");

		public static MelonPreferences_Entry<int> LoggingMode { get; set; }

		public static MelonPreferences_Entry<ImageQuality> Quality { get; set; }

		public static void Setup()
		{
			LoggingMode = GlobalCategory.GetEntry<int>("LoggingMode") ?? GlobalCategory.CreateEntry<int>("LoggingMode", 0, "Logging Mode", "The level of logging to use. 0 = Important Only, 1 = All", false, false, (ValueValidator)null, (string)null);
			GlobalCategory.SetFilePath(MelonUtils.UserDataDirectory + "/WeatherElectric.cfg");
			GlobalCategory.SaveToFile(false);
			Quality = OwnCategory.CreateEntry<ImageQuality>("ImageQuality", (!HelperMethods.IsAndroid()) ? ImageQuality.High : ImageQuality.Low, "Image Quality", "The quality of the images taken. Low = 480p, Medium = 720p, High = 1080p", false, false, (ValueValidator)null, (string)null);
			OwnCategory.SetFilePath(MelonUtils.UserDataDirectory + "/WeatherElectric.cfg");
			OwnCategory.SaveToFile(false);
			ModConsole.Msg("Finished preferences setup for LabCam", 1);
		}
	}
	internal enum ImageQuality
	{
		Low,
		Medium,
		High
	}
	internal static class UserData
	{
		private static readonly string WeatherElectricPath = Path.Combine(MelonUtils.UserDataDirectory, "Weather Electric");

		public static readonly string ModPath = Path.Combine(MelonUtils.UserDataDirectory, "Weather Electric/LabCam");

		public static void Setup()
		{
			if (!Directory.Exists(WeatherElectricPath))
			{
				Directory.CreateDirectory(WeatherElectricPath);
			}
			if (!Directory.Exists(ModPath))
			{
				Directory.CreateDirectory(ModPath);
			}
		}
	}
}
namespace LabCam.Menu
{
	internal static class BoneMenu
	{
		public static void Setup()
		{
			//IL_0024: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			MenuCategory obj = MenuManager.CreateCategory("Weather Electric", "#6FBDFF").CreateCategory("LabCam", "#ffad2d");
			obj.CreateEnumElement<ImageQuality>("Quality", Color.white, Preferences.Quality.Value, (Action<ImageQuality>)delegate(ImageQuality v)
			{
				Preferences.Quality.Value = v;
				Preferences.OwnCategory.SaveToFile(false);
				if ((Object)(object)LabCamera.Instance != (Object)null)
				{
					LabCamera.Instance.SetQuality();
				}
				if ((Object)(object)Quagmire.Instance != (Object)null)
				{
					Quagmire.Instance.SetQuality();
				}
			});
			obj.CreateFunctionElement("Spawn Camera", Color.green, (Action)SpawnCam);
			obj.CreateFunctionElement("Despawn Camera", Color.red, (Action)DespawnCam);
			obj.CreateFunctionElement("Spawn Trigger", Color.green, (Action)SpawnTrigger);
			obj.CreateFunctionElement("Despawn Trigger", Color.red, (Action)DespawnTrigger);
		}

		private static void SpawnCam()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)LabCamera.Instance != (Object)null))
			{
				Vector3 val = Player.playerHead.position + Player.playerHead.forward * 2f;
				Object.Instantiate<GameObject>(Assets.Prefabs.CameraPrefab, val, Quaternion.identity);
			}
		}

		private static void DespawnCam()
		{
			if (!((Object)(object)LabCamera.Instance == (Object)null))
			{
				Object.Destroy((Object)(object)((Component)LabCamera.Instance).gameObject);
			}
		}

		private static void SpawnTrigger()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Quagmire.Instance != (Object)null))
			{
				Vector3 val = Player.playerHead.position + Player.playerHead.forward * 2f;
				Object.Instantiate<GameObject>(Assets.Prefabs.TriggerPrefab, val, Quaternion.identity);
			}
		}

		private static void DespawnTrigger()
		{
			if (!((Object)(object)Quagmire.Instance == (Object)null))
			{
				Object.Destroy((Object)(object)((Component)Quagmire.Instance).gameObject);
			}
		}
	}
	internal static class BoneMenuExtensions
	{
		public static BoolElement CreateBoolPreference(this MenuCategory category, string name, Color color, MelonPreferences_Entry<bool> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateBoolElement(name, color, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static BoolElement CreateBoolPreference(this MenuCategory category, string name, string hexColor, MelonPreferences_Entry<bool> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateBoolElement(name, hexColor, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static BoolElement CreateBoolPreference(this SubPanelElement category, string name, Color color, MelonPreferences_Entry<bool> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateBoolElement(name, color, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static BoolElement CreateBoolPreference(this SubPanelElement category, string name, string hexColor, MelonPreferences_Entry<bool> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateBoolElement(name, hexColor, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this MenuCategory category, string name, Color color, float increment, float min, float max, MelonPreferences_Entry<float> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateFloatElement(name, color, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this MenuCategory category, string name, string hexColor, float increment, float min, float max, MelonPreferences_Entry<float> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateFloatElement(name, hexColor, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this SubPanelElement category, string name, Color color, float increment, float min, float max, MelonPreferences_Entry<float> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateFloatElement(name, color, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this SubPanelElement category, string name, string hexColor, float increment, float min, float max, MelonPreferences_Entry<float> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateFloatElement(name, hexColor, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this MenuCategory category, string name, Color color, int increment, int min, int max, MelonPreferences_Entry<int> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateIntElement(name, color, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this MenuCategory category, string name, string hexColor, int increment, int min, int max, MelonPreferences_Entry<int> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateIntElement(name, hexColor, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this SubPanelElement category, string name, Color color, int increment, int min, int max, MelonPreferences_Entry<int> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateIntElement(name, color, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this SubPanelElement category, string name, string hexColor, int increment, int min, int max, MelonPreferences_Entry<int> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			return category.CreateIntElement(name, hexColor, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement<TEnum> CreateEnumPreference<TEnum>(this MenuCategory category, string name, Color color, MelonPreferences_Entry<TEnum> pref, MelonPreferences_Category prefCategory, bool autoSave = true) where TEnum : Enum
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateEnumElement<TEnum>(name, color, pref.Value, (Action<TEnum>)delegate(TEnum v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement<TEnum> CreateEnumPreference<TEnum>(this MenuCategory category, string name, string hexColor, MelonPreferences_Entry<TEnum> pref, MelonPreferences_Category prefCategory, bool autoSave = true) where TEnum : Enum
		{
			return category.CreateEnumElement<TEnum>(name, hexColor, pref.Value, (Action<TEnum>)delegate(TEnum v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement<TEnum> CreateEnumPreference<TEnum>(this SubPanelElement category, string name, Color color, MelonPreferences_Entry<TEnum> pref, MelonPreferences_Category prefCategory, bool autoSave = true) where TEnum : Enum
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateEnumElement<TEnum>(name, color, pref.Value, (Action<TEnum>)delegate(TEnum v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement<TEnum> CreateEnumPreference<TEnum>(this SubPanelElement category, string name, string hexColor, MelonPreferences_Entry<TEnum> pref, MelonPreferences_Category prefCategory, bool autoSave = true) where TEnum : Enum
		{
			return category.CreateEnumElement<TEnum>(name, hexColor, pref.Value, (Action<TEnum>)delegate(TEnum v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}
	}
}