Decompiled source of OneLastLibPt2 v1.0.0

Mods/OneLastLibPt2.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib.BoneMenu;
using MelonLoader;
using MelonLoader.Logging;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WeatherElectric;
using WeatherElectric.BONELAB.BoneMenu;
using WeatherElectric.Logging;
using WeatherElectric.MelonPrefs;
using WeatherElectric.MelonUserData;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("But in our lies, there's a truth to find. | Core mod for my mods.")]
[assembly: AssemblyDescription("But in our lies, there's a truth to find. | Core mod for my mods.")]
[assembly: AssemblyCompany("Weather Electric")]
[assembly: AssemblyProduct("One Last Lib Pt.2")]
[assembly: AssemblyCopyright("Developed by Mabel Amber")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: MelonInfo(typeof(Core), "One Last Lib Pt.2", "1.0.0", "Mabel Amber", "https://thunderstore.io/c/bonelab/p/WeatherElectric/OneLastLibPt2/")]
[assembly: MelonColor(255, 255, 255, 255)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonOptionalDependencies(new string[] { "BoneLib" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.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
{
	public class Core : MelonMod
	{
		internal const string Name = "One Last Lib Pt.2";

		internal const string Description = "But in our lies, there's a truth to find. | Core mod for my mods.";

		internal const string Author = "Mabel Amber";

		internal const string Company = "Weather Electric";

		internal const string Version = "1.0.0";

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

		internal static LoggerInstance Logger;

		public override void OnInitializeMelon()
		{
			Logger = new LoggerInstance(((MelonBase)this).LoggerInstance);
			Preferences.Init();
			UserDataCore.Init();
			if (Helpers.CheckGame("BONELAB", "Stress Level Zero") && Helpers.IsAssemblyLoaded("BoneLib"))
			{
				Menu.Init();
			}
			Logger.Log("Finished initialization for One Last Lib Pt. 2", LogLevel.Debug);
		}
	}
	public static class Helpers
	{
		public static bool IsAssemblyLoaded(string assemblyName)
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				if (assemblies[i].GetName().Name?.ToLower() == assemblyName.ToLower())
				{
					return true;
				}
			}
			return false;
		}

		public static bool CheckGame(string gameName, string gameAuthor)
		{
			string text = Application.productName.ToLower();
			string text2 = Application.companyName.ToLower();
			if (text == gameName.ToLower())
			{
				return text2 == gameAuthor.ToLower();
			}
			return false;
		}
	}
}
namespace WeatherElectric.MelonUserData
{
	public class UserData
	{
		public readonly string Path = UserDataCore.CreateSubfolder(modName);

		public UserData(string modName)
		{
		}

		public string GetFile(string fileName)
		{
			return System.IO.Path.Combine(Path, fileName);
		}

		public string[] GetFiles(bool recursive = false)
		{
			if (!recursive)
			{
				return Directory.GetFiles(Path);
			}
			return Directory.GetFiles(Path, "*", SearchOption.AllDirectories);
		}

		public string GetFolder(string folderName, bool recursive = false, bool createIfMissing = false)
		{
			if (recursive)
			{
				string[] directories = Directory.GetDirectories(Path, folderName, SearchOption.AllDirectories);
				if (directories.Length != 0)
				{
					return directories[0];
				}
			}
			else
			{
				string text = System.IO.Path.Combine(Path, folderName);
				if (Directory.Exists(text))
				{
					return text;
				}
			}
			if (!createIfMissing || recursive)
			{
				return null;
			}
			string text2 = System.IO.Path.Combine(Path, folderName);
			Directory.CreateDirectory(text2);
			return text2;
		}

		public string[] GetFolders()
		{
			return Directory.GetDirectories(Path);
		}
	}
	public static class UserDataCore
	{
		private static readonly string MainPath = Path.Combine(MelonEnvironment.UserDataDirectory, "Weather Electric");

		internal static void Init()
		{
			if (!Directory.Exists(MainPath))
			{
				Directory.CreateDirectory(MainPath);
			}
		}

		public static string CreateSubfolder(string folderName)
		{
			string text = Path.Combine(MainPath, folderName);
			if (!Directory.Exists(text))
			{
				Directory.CreateDirectory(text);
			}
			return text;
		}

		public static string[] GetSubfolders()
		{
			return Directory.GetDirectories(MainPath);
		}

		public static string[] GetFilesIn(string subfolder)
		{
			string path = Path.Combine(MainPath, subfolder);
			if (!Directory.Exists(path))
			{
				return Array.Empty<string>();
			}
			return Directory.GetFiles(path);
		}
	}
}
namespace WeatherElectric.MelonPrefs
{
	public static class Preferences
	{
		internal static readonly MelonPreferences_Category GlobalCategory = MelonPreferences.CreateCategory("Global");

		internal static MelonPreferences_Entry<bool> DebugMode;

		public static string FilePath => Path.Combine(MelonEnvironment.UserDataDirectory, "WeatherElectric.cfg");

		internal static void Init()
		{
			DebugMode = GlobalCategory.CreateEntry<bool>("DebugMode", false, "Debug Mode", "Enables debug logging.", false, false, (ValueValidator)null, (string)null);
			GlobalCategory.SetFilePath(FilePath);
			GlobalCategory.SaveToFile(false);
			Core.Logger.Log("Finished preferences setup for One Last Lib Pt. 2", LogLevel.Debug);
		}
	}
}
namespace WeatherElectric.Logging
{
	public class LoggerInstance
	{
		[CompilerGenerated]
		private Instance <melonLoggerInstance>P;

		public LoggerInstance(Instance melonLoggerInstance)
		{
			<melonLoggerInstance>P = melonLoggerInstance;
			base..ctor();
		}

		public void Log(string message, LogLevel level = LogLevel.Info)
		{
			if (level != LogLevel.Debug || Preferences.DebugMode.Value)
			{
				switch (level)
				{
				case LogLevel.Info:
					<melonLoggerInstance>P.Msg(message);
					break;
				case LogLevel.Warning:
					<melonLoggerInstance>P.Warning(message);
					break;
				case LogLevel.Error:
					<melonLoggerInstance>P.Error(message);
					break;
				case LogLevel.BigError:
					<melonLoggerInstance>P.BigError(message);
					break;
				case LogLevel.Debug:
					<melonLoggerInstance>P.Msg(ConsoleColor.Cyan, "[DEBUG] " + message);
					break;
				default:
					throw new ArgumentOutOfRangeException("level", level, null);
				}
			}
		}

		public void Log(object message, LogLevel level = LogLevel.Info)
		{
			if (level != LogLevel.Debug || Preferences.DebugMode.Value)
			{
				switch (level)
				{
				case LogLevel.Info:
					<melonLoggerInstance>P.Msg(message);
					break;
				case LogLevel.Warning:
					<melonLoggerInstance>P.Warning(message);
					break;
				case LogLevel.Error:
					<melonLoggerInstance>P.Error(message);
					break;
				case LogLevel.BigError:
					<melonLoggerInstance>P.BigError(message.ToString());
					break;
				case LogLevel.Debug:
					<melonLoggerInstance>P.Msg(ConsoleColor.Cyan, $"[DEBUG] {message}");
					break;
				default:
					throw new ArgumentOutOfRangeException("level", level, null);
				}
			}
		}

		public void WriteLines(ColorARGB color, int count = 30)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			<melonLoggerInstance>P.WriteLine(color, count);
		}

		public void WriteLines(int count = 30)
		{
			<melonLoggerInstance>P.WriteLine(count);
		}

		public void WriteSpacer()
		{
			<melonLoggerInstance>P.WriteSpacer();
		}
	}
	public enum LogLevel
	{
		Info,
		Warning,
		Error,
		BigError,
		Debug
	}
}
namespace WeatherElectric.BONELAB.BoneMenu
{
	public 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);
				}
			});
		}
	}
	public static class Menu
	{
		public static Page MainPage;

		internal static void Init()
		{
			//IL_000a: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			MainPage = Page.Root.CreatePage("<color=#6FBDFF>Weather Electric</color>", Color.white, 0, true);
			MainPage.CreatePage("Global Settings", Color.gray, 0, true).CreateBoolPreference("Debug Mode", Color.white, Preferences.DebugMode, Preferences.GlobalCategory);
		}
	}
}