Decompiled source of DoubleJump v1.1.0

Mods/DoubleJump.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.BoneMenu.Elements;
using DoubleJump;
using DoubleJump.Melon;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Reenables the double jump feature in BONELAB.")]
[assembly: AssemblyDescription("Reenables the double jump feature in BONELAB.")]
[assembly: AssemblyCompany("Weather Electric")]
[assembly: AssemblyProduct("Double Jump")]
[assembly: AssemblyCopyright("Developed by SoulWithMae")]
[assembly: AssemblyTrademark("Weather Electric")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: MelonInfo(typeof(Main), "Double Jump", "1.1.0", "SoulWithMae", "https://bonelab.thunderstore.io/package/SoulWithMae/DoubleJump/")]
[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.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 DoubleJump
{
	public class Main : MelonMod
	{
		[HarmonyPatch(typeof(Player_Health), "MakeVignette")]
		public static class VignettePatch
		{
			public static void Postfix(Player_Health __instance)
			{
				if (Preferences.AutoEnable.Value)
				{
					ModConsole.Msg("Enabling double jump automatically", 1);
					Player.remapRig.doubleJump = true;
				}
			}
		}

		internal const string Name = "Double Jump";

		internal const string Description = "Reenables the double jump feature in BONELAB.";

		internal const string Author = "SoulWithMae";

		internal const string Company = "Weather Electric";

		internal const string Version = "1.1.0";

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

		public override void OnInitializeMelon()
		{
			ModConsole.Setup(((MelonBase)this).LoggerInstance);
			Preferences.Setup();
			BoneMenu.Setup();
		}
	}
}
namespace DoubleJump.Melon
{
	internal static class BoneMenu
	{
		public static void Setup()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			MenuCategory obj = MenuManager.CreateCategory("Weather Electric", "#6FBDFF").CreateCategory("Double Jump", "#fe9500");
			obj.CreateFunctionElement("Enable", Color.green, (Action)Enable);
			obj.CreateFunctionElement("Disable", Color.red, (Action)Disable);
			obj.CreateSubPanel("Settings", Color.white).CreateBoolPreference("Auto Enable", Color.white, Preferences.AutoEnable, Preferences.OwnCategory);
		}

		private static void Enable()
		{
			ModConsole.Msg("Enabling double jump", 1);
			Player.remapRig.doubleJump = true;
		}

		private static void Disable()
		{
			ModConsole.Msg("Disabling double jump", 1);
			Player.remapRig.doubleJump = false;
		}
	}
	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);
				}
			});
		}
	}
	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("Double Jump");

		public static MelonPreferences_Entry<bool> AutoEnable { get; set; }

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

		public static void Setup()
		{
			AutoEnable = OwnCategory.CreateEntry<bool>("AutoEnable", true, "Auto Enable", "Automatically enables double jump when you load into a level", false, false, (ValueValidator)null, (string)null);
			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);
			OwnCategory.SetFilePath(MelonUtils.UserDataDirectory + "/WeatherElectric.cfg");
			OwnCategory.SaveToFile(false);
			ModConsole.Msg("Finished preferences setup for Double Jump", 1);
		}
	}
}