Decompiled source of Holding Lever v1.0.1

HoldingLever.dll

Decompiled 10 hours 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.Client.Player.Input;
using CG.Client.Ship.Interactions;
using CG.Ship.Modules;
using Gameplay.Ship.VoidJump;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
using VoidManager.MPModChecks;
using VoidManager.Utilities;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HoldingLever")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Template")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("HoldingLever")]
[assembly: AssemblyTitle("While holding the lever down, when the drive hits 100%, activates the void drive.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 VoidCrew.Norealm.HoldingLever
{
	[BepInPlugin("Norealm.HoldingLever", "Holding Lever", "1.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(), "Norealm.HoldingLever");
			Configs.Load(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Norealm.HoldingLever is loaded!");
		}
	}
	internal class Configs
	{
		internal static ConfigEntry<bool> HoldingLever;

		internal static void Load(BepinPlugin plugin)
		{
			HoldingLever = ((BaseUnityPlugin)plugin).Config.Bind<bool>("HoldingLever", "HoldingLever", true, (ConfigDescription)null);
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Holding Lever";
		}

		public override void Draw()
		{
			GUILayout.Label("Settings", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Holding Lever: " + (Configs.HoldingLever.Value ? "Enabled" : "Disabled"), Array.Empty<GUILayoutOption>()))
			{
				Configs.HoldingLever.Value = !Configs.HoldingLever.Value;
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Norealm.HoldingLever";

		public const string PLUGIN_NAME = "HoldingLever";

		public const string USERS_PLUGIN_NAME = "Holding Lever";

		public const string PLUGIN_VERSION = "1.0.1";

		public const string PLUGIN_DESCRIPTION = "While holding the lever down, when the drive hits 100%, activates the void drive.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "Norealm";

		public const string PLUGIN_AUTHORS = "Gruncle Chuck, Norealm";

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

		private static VoidDriveModule _shipVoidDrive;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void Awake(VoidDriveModule __instance)
		{
			_shipVoidDrive = __instance;
		}

		[HarmonyPatch("UpdateOn")]
		[HarmonyPostfix]
		public static void UpdateOn()
		{
			if (!Configs.HoldingLever.Value)
			{
				return;
			}
			VoidDriveModule shipVoidDrive = _shipVoidDrive;
			Lever val = ((shipVoidDrive != null) ? shipVoidDrive.VoidJumpLever : null);
			if ((Object)(object)val == (Object)null || (Object)(object)VoidJumpSystemPatch.JumpSystem == (Object)null)
			{
				return;
			}
			if (_shipVoidDrive.IsFullyCharged && val.LeverPosition >= 1f)
			{
				if (VoidJumpSystemPatch.JumpSystem.IsExitVectorSet())
				{
					DebugInput.DebugImpulseJump();
				}
				else if (!_notified)
				{
					Messaging.Notification("Cannot jump without having an exit vector set.", false);
					_notified = true;
				}
			}
			if ((double)val.LeverPosition < 0.5)
			{
				_notified = false;
			}
		}
	}
	[HarmonyPatch(typeof(VoidJumpSystem))]
	public class VoidJumpSystemPatch
	{
		internal static VoidJumpSystem JumpSystem;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		internal static void Awake(VoidJumpSystem __instance)
		{
			JumpSystem = __instance;
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "Gruncle Chuck, Norealm";

		public override string Description => "While holding the lever down, when the drive hits 100%, activates the void drive.";

		public override string ThunderstoreID => "Norealm/Holding_Lever";
	}
}