Decompiled source of VoidJumpKeybind v0.0.1

VoidJumpKeybind.dll

Decompiled 4 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("Template")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VoidJumpKeybind")]
[assembly: AssemblyTitle("VoidJumpKeybind")]
[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 VoidJumpKeybind
{
	internal static class MyPluginInfo
	{
		internal const string PLUGIN_GUID = "id107.voidjumpkeybind";

		internal const string PLUGIN_NAME = "VoidJumpKeybind";

		internal const string PLUGIN_VERSION = "0.0.1";
	}
	[BepInPlugin("id107.voidjumpkeybind", "VoidJumpKeybind", "0.0.1")]
	[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(), "id107.voidjumpkeybind");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.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);
		}
	}
	[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)3;

		public override string Author => "18107";

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