Decompiled source of DropYourGems v1.0.0

BepInEx/plugins/MoSadie-DropYourGems/com.mosadie.dropyourgems.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MoCore;
using Subpixel;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.mosadie.dropyourgems")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Push button. Drop gems.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f55b6a9a1596ae198806612f0320d8f58c1e00e2")]
[assembly: AssemblyProduct("DropYourGems")]
[assembly: AssemblyTitle("com.mosadie.dropyourgems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 DropYourGems
{
	[BepInPlugin("com.mosadie.dropyourgems", "DropYourGems", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("Slipstream_Win.exe")]
	public class DropYourGems : BaseUnityPlugin, IMoPlugin
	{
		private static ConfigEntry<bool> debugLogs;

		private static ConfigEntry<KeyboardShortcut> DropGemKeyBind;

		internal static ManualLogSource Log;

		public static readonly string COMPATIBLE_GAME_VERSION = "4.1595";

		public static readonly string GAME_VERSION_URL = "https://raw.githubusercontent.com/MoSadie/DropYourGems/refs/heads/main/versions.json";

		private void Awake()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Log = ((BaseUnityPlugin)this).Logger;
				if (!MoCore.RegisterPlugin((IMoPlugin)(object)this))
				{
					Log.LogError((object)"Failed to register plugin with MoCore. Please check the logs for more information.");
					return;
				}
				debugLogs = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugLogs", false, "Enable additional logging for debugging");
				DropGemKeyBind = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "DropGemKeyBind", new KeyboardShortcut((KeyCode)114, Array.Empty<KeyCode>()), "Keybind to drop all gems from your inventory.");
				Log.LogInfo((object)"Plugin com.mosadie.dropyourgems is loaded!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)"An error occurred while starting the plugin.");
				Log.LogError((object)ex.Message);
			}
		}

		private void Update()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Invalid comparison between Unknown and I4
			KeyboardShortcut value = DropGemKeyBind.Value;
			if (!((KeyboardShortcut)(ref value)).IsDown())
			{
				return;
			}
			LocalCrewSelectionManager main = Mainstay<LocalCrewSelectionManager>.Main;
			if ((Object)(object)main == (Object)null)
			{
				DebugLogWarn("Attempted to check if on helm, but LocalCrewSelectionManager is null!");
				return;
			}
			LocalCrewmate selectedLocalCrewmate = main.GetSelectedLocalCrewmate();
			if ((Object)(object)selectedLocalCrewmate == (Object)null)
			{
				DebugLogWarn("Attempted to check if on helm, but no local crewmate is found!");
			}
			else if ((Object)(object)selectedLocalCrewmate.Crewmate == (Object)null || (Object)(object)selectedLocalCrewmate.Crewmate.EmoteController == (Object)null)
			{
				DebugLogWarn("Attempted to check if on helm, but no crewmate or emote controller is found!");
			}
			else if ((Object)(object)selectedLocalCrewmate.Crewmate.CurrentStation != (Object)null && (int)selectedLocalCrewmate.Crewmate.CurrentStation.StationType == 3)
			{
				DebugLogInfo("On helm, skipping gem drop.");
			}
			else if (selectedLocalCrewmate.Inventory.Gems.IsEmpty())
			{
				DebugLogInfo("No gems to drop.");
			}
			else
			{
				dropGems();
			}
		}

		internal static void dropGems()
		{
			try
			{
				GameObject val = GameObject.Find("GemInventoryHud");
				if ((Object)(object)val == (Object)null)
				{
					DebugLogError("Gem HUD is null!");
					return;
				}
				GemInventoryHud component = val.GetComponent<GemInventoryHud>();
				if ((Object)(object)component == (Object)null)
				{
					DebugLogError("GemInventoryHud is null!");
					return;
				}
				component.HideIfEmpty();
				((BaseInventoryHud)component).DropItems();
				Log.LogInfo((object)"Dropped gems!");
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		internal static void DebugLogInfo(string message)
		{
			if (debugLogs.Value)
			{
				Log.LogInfo((object)message);
			}
		}

		internal static void DebugLogWarn(string message)
		{
			if (debugLogs.Value)
			{
				Log.LogWarning((object)message);
			}
		}

		internal static void DebugLogError(string message)
		{
			if (debugLogs.Value)
			{
				Log.LogError((object)message);
			}
		}

		internal static void DebugLogDebug(string message)
		{
			if (debugLogs.Value)
			{
				Log.LogDebug((object)message);
			}
		}

		public string GetCompatibleGameVersion()
		{
			return COMPATIBLE_GAME_VERSION;
		}

		public string GetVersionCheckUrl()
		{
			return GAME_VERSION_URL;
		}

		public BaseUnityPlugin GetPluginObject()
		{
			return (BaseUnityPlugin)(object)this;
		}

		public IMoHttpHandler GetHttpHandler()
		{
			return null;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.mosadie.dropyourgems";

		public const string PLUGIN_NAME = "DropYourGems";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}