Decompiled source of LabCam v1.1.0

Mods/LabCam.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppHorizonBasedAmbientOcclusion.Universal;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Pool;
using LabFusion.Network;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using WeatherElectric.LabCam;
using WeatherElectric.LabCam.Melon;
using WeatherElectric.LabCam.Menu;
using WeatherElectric.LabCam.Resources;
using WeatherElectric.LabCam.Scripts;

[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 Mabel Amber")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: MelonInfo(typeof(Main), "LabCam", "1.1.0", "Mabel Amber", "https://bonelab.thunderstore.io/package/SoulWithMae/LabCam/")]
[assembly: MelonColor(255, 255, 173, 45)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace WeatherElectric.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 = "Mabel Amber";

		internal const string Company = "Weather Electric";

		internal const string Version = "1.1.0";

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

		internal static string CurrentMap;

		internal static bool FusionInstalled;

		internal static readonly List<HBAO> Hbao = new List<HBAO>();

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

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

		public override void OnLateInitializeMelon()
		{
			FusionInstalled = HelperMethods.CheckIfAssemblyLoaded("LabFusion");
		}

		private static void OnLevelLoad(LevelInfo levelInfo)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CurrentMap = levelInfo.title.Replace(" ", "");
			Hbao.AddRange((IEnumerable<HBAO>)Object.FindObjectsOfType<HBAO>());
			foreach (HBAO item in Hbao)
			{
				ModConsole.Msg("HBAO: " + ((Object)item).name, 1);
			}
		}
	}
}
namespace WeatherElectric.LabCam.Scripts
{
	[RegisterTypeInIl2Cpp]
	public class LabCamera : MonoBehaviour
	{
		internal 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 float _cooldownTimer;

		private const float Cooldown = 5f;

		private bool _cooldownUp;

		private bool _markedForDestruction;

		private void OnEnable()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				_markedForDestruction = true;
				((Component)this).GetComponent<Poolee>().Despawn();
				return;
			}
			Instance = this;
			_markedForDestruction = false;
			AssignFields();
			SetQuality();
			SetMixers();
		}

		private void SetMixers()
		{
			if ((Object)(object)_captureSound != (Object)null)
			{
				_captureSound.outputAudioMixerGroup = Audio.Gunshot;
			}
		}

		private void AssignFields()
		{
			_camera = ((Component)((Component)this).transform.Find("Systems/Camera")).GetComponent<Camera>();
			_captureSound = ((Component)((Component)this).transform.Find("Audio/CaptureSound")).GetComponent<AudioSource>();
			_previewRenderer = ((Component)((Component)this).transform.Find("UI/CameraScreen")).GetComponent<MeshRenderer>();
			_flashRenderer = ((Component)((Component)this).transform.Find("UI/FlashWarning")).gameObject;
			_light = ((Component)((Component)this).transform.Find("Systems/Flash")).gameObject;
		}

		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 Update()
		{
			if (!_cooldownUp)
			{
				if (_cooldownTimer < 5f)
				{
					_cooldownUp = true;
					_cooldownTimer = 0f;
				}
				else
				{
					_cooldownTimer += Time.deltaTime;
				}
			}
		}

		public void Capture()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			if (!_cooldownUp)
			{
				return;
			}
			if (Main.FusionInstalled && NetworkInfo.HasServer && NetworkInfo.IsClient)
			{
				CaptureFusionClient();
				return;
			}
			Dictionary<HBAO, ClampedFloatParameter> dictionary = new Dictionary<HBAO, ClampedFloatParameter>();
			ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f, true);
			foreach (HBAO item in Main.Hbao)
			{
				dictionary.Add(item, item.intensity);
				SetHbao(item, intensity);
			}
			if ((Object)(object)_avatarArt == (Object)null)
			{
				_avatarArt = ((Component)Player.ControllerRig).GetComponent<PlayerAvatarArt>();
			}
			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);
			}
			foreach (KeyValuePair<HBAO, ClampedFloatParameter> item2 in dictionary)
			{
				SetHbao(item2.Key, item2.Value);
			}
			_cooldownUp = false;
		}

		private void CaptureFusionClient()
		{
			_captureSound.Play();
			if (_flash)
			{
				_light.SetActive(true);
			}
			if (_flash)
			{
				((MonoBehaviour)this).Invoke("LightDisable", 0.3f);
			}
		}

		private static void SetHbao(HBAO hbao, ClampedFloatParameter intensity)
		{
			hbao.intensity = intensity;
		}

		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(((Texture)targetTexture).width, ((Texture)targetTexture).height, targetTexture.graphicsFormat, ((Texture)targetTexture).mipmapCount, (TextureCreationFlags)0);
			_camera.Render();
			RenderTexture.active = targetTexture;
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)targetTexture).width, (float)((Texture)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);
			}
		}

		public void OnDisable()
		{
			if (!_markedForDestruction)
			{
				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 bool _markedForDestruction;

		private void OnEnable()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				_markedForDestruction = true;
				((Component)this).GetComponent<Poolee>().Despawn();
				return;
			}
			_markedForDestruction = false;
			Instance = this;
			SetFields();
			SetQuality();
		}

		private void SetFields()
		{
			giggity = ((Component)((Component)this).transform.Find("Art")).gameObject;
			giggityPreview = ((Component)((Component)this).transform.Find("Systems/Preview")).gameObject;
			giggityRenderer = giggityPreview.GetComponent<MeshRenderer>();
			giggityAudio = ((Component)((Component)this).transform.Find("Audio/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();
			}
		}

		public void OnDisable()
		{
			if (!_markedForDestruction)
			{
				Instance = null;
			}
		}

		public Quagmire(IntPtr ptr)
			: base(ptr)
		{
		}
	}
}
namespace WeatherElectric.LabCam.Resources
{
	internal static class Assets
	{
		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");
					}
					ModConsole.Msg($"RenderTextures: {((Object)HighQuality).name}, {((Object)MediumQuality).name}, {((Object)LowQuality).name}", 1);
				}
			}
		}

		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/HighQualityPreview.mat");
					}
					if ((Object)(object)MediumQuality == (Object)null)
					{
						MediumQuality = HelperMethods.LoadPersistentAsset<Material>(_assetBundle, "Assets/LabCam/MediumQualityPreview.mat");
					}
					if ((Object)(object)LowQuality == (Object)null)
					{
						LowQuality = HelperMethods.LoadPersistentAsset<Material>(_assetBundle, "Assets/LabCam/LowQualityPreview.mat");
					}
					ModConsole.Msg($"Materials: {((Object)HighQuality).name}, {((Object)MediumQuality).name}, {((Object)LowQuality).name}", 1);
				}
			}
		}

		private static AssetBundle _assetBundle;

		public static void Load()
		{
			_assetBundle = HelperMethods.LoadEmbeddedAssetBundle(Main.CurrAsm, HelperMethods.IsAndroid() ? "WeatherElectric.LabCam.Resources.LabCamAndroid.bundle" : "WeatherElectric.LabCam.Resources.LabCamWindows.bundle");
			ModConsole.Msg("AssetBundle: " + ((Object)_assetBundle).name, 1);
			if (!((Object)(object)_assetBundle == (Object)null))
			{
				RenderTextures.LoadRenderTextures();
				Materials.LoadMaterials();
			}
		}
	}
}
namespace WeatherElectric.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(MelonEnvironment.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(MelonEnvironment.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(MelonEnvironment.UserDataDirectory, "Weather Electric");

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

		public static void Setup()
		{
			if (!Directory.Exists(WeatherElectricPath))
			{
				Directory.CreateDirectory(WeatherElectricPath);
			}
			if (!Directory.Exists(ModPath))
			{
				Directory.CreateDirectory(ModPath);
			}
		}
	}
}
namespace WeatherElectric.LabCam.BoneMenu
{
	internal static class Extensions
	{
		public static BoolElement CreateBoolPreference(this Page 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.CreateBool(name, color, pref.Value, (Action<bool>)delegate(bool v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static FloatElement CreateFloatPreference(this Page 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.CreateFloat(name, color, pref.Value, increment, min, max, (Action<float>)delegate(float v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static IntElement CreateIntPreference(this Page 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.CreateInt(name, color, pref.Value, increment, min, max, (Action<int>)delegate(int v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}

		public static EnumElement CreateEnumPreference(this Page category, string name, Color color, MelonPreferences_Entry<Enum> pref, MelonPreferences_Category prefCategory, bool autoSave = true)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			return category.CreateEnum(name, color, pref.Value, (Action<Enum>)delegate(Enum v)
			{
				pref.Value = v;
				if (autoSave)
				{
					prefCategory.SaveToFile(false);
				}
			});
		}
	}
}
namespace WeatherElectric.LabCam.Menu
{
	internal static class BoneMenu
	{
		public static void Setup()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Page.Root.CreatePage("<color=#6FBDFF>Weather Electric</color>", Color.white, 0, true).CreatePage("<color=#ffad2d>LabCam</color>", Color.white, 0, true).CreateEnum("Quality", Color.white, (Enum)Preferences.Quality.Value, (Action<Enum>)delegate(Enum v)
			{
				Preferences.Quality.Value = (ImageQuality)(object)v;
				Preferences.OwnCategory.SaveToFile(false);
				if (!Main.FusionInstalled || !NetworkInfo.HasServer || !NetworkInfo.IsClient)
				{
					if ((Object)(object)LabCamera.Instance != (Object)null)
					{
						LabCamera.Instance.SetQuality();
					}
					if ((Object)(object)Quagmire.Instance != (Object)null)
					{
						Quagmire.Instance.SetQuality();
					}
				}
			});
		}
	}
}