Decompiled source of Void Jump Keybind v0.0.3

VoidJumpKeybind.dll

Decompiled 3 months 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 CG;
using CG.Client.Ship.Interactions;
using CG.Game;
using CG.Input;
using CG.Ship.Modules;
using CG.Space;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("VoidJumpKeybind")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Adds a keybind for the pilot to activate the void jump lever, Client Side")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+8c01aa72cb23c60a57220ca72f73034968b06126")]
[assembly: AssemblyProduct("VoidJumpKeybind")]
[assembly: AssemblyTitle("Adds a keybind for the pilot to activate the void jump lever, Client Side")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.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 VoidJumpKeybind
{
	[BepInPlugin("18107.VoidJumpKeybind", "VoidJumpKeybind", "0.0.3")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.VoidJumpKeybind");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.VoidJumpKeybind is loaded!");
		}
	}
	internal class Configs
	{
		internal static ConfigEntry<KeyCode> LeverPullConfig;

		internal static void Load(BepinPlugin plugin)
		{
			LeverPullConfig = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("VoidJumpKeybind", "PullLever", (KeyCode)121, (ConfigDescription)null);
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Void Jump Keybind";
		}

		public override void Draw()
		{
			GUITools.DrawChangeKeybindButton("Change Void Jump Keybind", ref Configs.LeverPullConfig);
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.VoidJumpKeybind";

		public const string PLUGIN_NAME = "VoidJumpKeybind";

		public const string USERS_PLUGIN_NAME = "Void Jump Keybind";

		public const string PLUGIN_VERSION = "0.0.3";

		public const string PLUGIN_DESCRIPTION = "Adds a keybind for the pilot to activate the void jump lever, Client Side";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "";
	}
	[HarmonyPatch(typeof(VoidDriveModule))]
	internal class VoidDriveModulePatch
	{
		private static bool isKeyPressed;

		[HarmonyPostfix]
		[HarmonyPatch("FixedUpdate")]
		private static void FixedUpdate(VoidDriveModule __instance)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			AbstractPlayerControlledShip playerShip = ClientGame.Current.PlayerShip;
			object obj;
			if (playerShip == null)
			{
				obj = null;
			}
			else
			{
				Helm module = playerShip.GetModule<Helm>();
				obj = ((module != null) ? module.Chair : null);
			}
			TakeoverChair val = (TakeoverChair)((obj is TakeoverChair) ? obj : null);
			if ((Object)(object)val == (Object)null || val.IsAvailable || PhotonNetwork.LocalPlayer != ((MonoBehaviourPun)val).photonView.Owner || ServiceBase<InputService>.Instance.CursorVisibilityControl.IsCursorShown)
			{
				if (isKeyPressed)
				{
					isKeyPressed = false;
					((ClickerInteractable)__instance.VoidJumpLever).EndClick();
				}
			}
			else if ((int)Configs.LeverPullConfig.Value != 0 && isKeyPressed != UnityInput.Current.GetKey(Configs.LeverPullConfig.Value))
			{
				isKeyPressed = !isKeyPressed;
				if (isKeyPressed)
				{
					((ClickerInteractable)__instance.VoidJumpLever).StartClick();
				}
				else
				{
					((ClickerInteractable)__instance.VoidJumpLever).EndClick();
				}
			}
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107";

		public override string Description => "Adds a keybind for the pilot to activate the void jump lever";
	}
}