Decompiled source of Retrigger Gun from Seat v1.1.1

RetriggerGunFromSeat.dll

Decompiled 4 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.Quests.SectorTwists;
using CG.Game.Player;
using CG.Ship.Modules;
using Gameplay.CompositeWeapons;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("RetriggerGunFromSeat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1")]
[assembly: AssemblyProduct("RetriggerGunFromSeat")]
[assembly: AssemblyTitle("Allows you to turn on/off the gun that you are sitting on.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 RetriggerGunFromSeat
{
	internal class Configs
	{
		internal static ConfigEntry<KeyCode> retriggerKey;

		internal static ConfigEntry<KeyCode> switchGunOnKey;

		internal static ConfigEntry<KeyCode> switchGunOffKey;

		internal static void Load(Plugin plugin)
		{
			retriggerKey = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("RetriggerGunFromSeat", "retriggerGunKey", (KeyCode)0, (ConfigDescription)null);
			switchGunOffKey = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("RetriggerGunFromSeat", "retriggerGunOffKey", (KeyCode)0, (ConfigDescription)null);
			switchGunOnKey = ((BaseUnityPlugin)plugin).Config.Bind<KeyCode>("RetriggerGunFromSeat", "retriggerGunOnKey", (KeyCode)0, (ConfigDescription)null);
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Retrigger Gun from Seat";
		}

		public override void Draw()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("Retrigger Gun From Seat Settings:", Array.Empty<GUILayoutOption>());
			KeyCode value = Configs.retriggerKey.Value;
			if (GUITools.DrawChangeKeybindButton("Retrigger On/Off: ", ref value) && Configs.retriggerKey.Value != value)
			{
				Configs.retriggerKey.Value = value;
			}
			KeyCode value2 = Configs.switchGunOnKey.Value;
			if (GUITools.DrawChangeKeybindButton("Trigger Gun On: ", ref value2) && Configs.switchGunOnKey.Value != value2)
			{
				Configs.switchGunOnKey.Value = value2;
			}
			KeyCode value3 = Configs.switchGunOffKey.Value;
			if (GUITools.DrawChangeKeybindButton("Trigger Gun Off: ", ref value3) && Configs.switchGunOffKey.Value != value3)
			{
				Configs.switchGunOffKey.Value = value3;
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Gruncle_Chuck.RetriggerGunFromSeat";

		public const string PLUGIN_NAME = "RetriggerGunFromSeat";

		public const string USERS_PLUGIN_NAME = "Retrigger Gun from Seat";

		public const string PLUGIN_VERSION = "1.1.1";

		public const string PLUGIN_DESCRIPTION = "Allows you to turn on/off the gun that you are sitting on.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "Gruncle_Chuck";

		public const string PLUGIN_AUTHORS = "Gruncle Chuck";

		public const string PLUGIN_THUNDERSTORE_ID = "";
	}
	[BepInPlugin("Gruncle_Chuck.RetriggerGunFromSeat", "Retrigger Gun from Seat", "1.1.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource log;

		private void Awake()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			Configs.Load(this);
			log = ((BaseUnityPlugin)this).Logger;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Gruncle_Chuck.RetriggerGunFromSeat is loaded!");
		}
	}
	[HarmonyPatch(typeof(CompositeWeaponModule))]
	internal class RetriggerPlugin
	{
		internal static CompositeWeaponModule playerChair;

		internal static bool weaponIsOccupied;

		internal static bool malfunctionActive;

		[HarmonyPostfix]
		[HarmonyPatch("PlayerTakeoverLocal")]
		private static void PlayerTakesChair(CompositeWeaponModule __instance)
		{
			playerChair = __instance;
			weaponIsOccupied = true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("PlayerFreeLocal")]
		private static void PlayerLeavesChair(CompositeWeaponModule __instance)
		{
			weaponIsOccupied = false;
		}
	}
	[HarmonyPatch(typeof(LocalPlayer))]
	internal class RetriggerUpdate
	{
		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		private static void Update()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			if (!VoidManagerPlugin.sessionFeaturesEnabled)
			{
				return;
			}
			bool flag = false;
			if (GameSessionManager.ActiveSector != (GameSessionSector)null)
			{
				flag = GameSessionManager.ActiveSector.Twists.Exists((SectorTwist thing) => ((object)thing).GetType() == typeof(Interference));
			}
			if (!RetriggerPlugin.weaponIsOccupied)
			{
				return;
			}
			if (ButtonPressed(Configs.retriggerKey.Value))
			{
				if (flag)
				{
					Messaging.Notification("Cannot Retrigger Gun while malfunction surge is active.", false);
				}
				else if (((CellModule)RetriggerPlugin.playerChair).IsPowered)
				{
					((CellModule)RetriggerPlugin.playerChair).TurnOff();
				}
				else
				{
					((CellModule)RetriggerPlugin.playerChair).TurnOn();
				}
			}
			else if (ButtonPressed(Configs.switchGunOnKey.Value) && !((CellModule)RetriggerPlugin.playerChair).IsPowered)
			{
				if (flag)
				{
					Messaging.Notification("Cannot Retrigger Gun while malfunction surge is active.", false);
				}
				else
				{
					((CellModule)RetriggerPlugin.playerChair).TurnOn();
				}
			}
			else if (ButtonPressed(Configs.switchGunOffKey.Value) && ((CellModule)RetriggerPlugin.playerChair).IsPowered)
			{
				if (flag)
				{
					Messaging.Notification("Cannot Retrigger Gun while malfunction surge is active.", false);
				}
				else
				{
					((CellModule)RetriggerPlugin.playerChair).TurnOff();
				}
			}
		}

		public static bool ButtonPressed(KeyCode button)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if ((int)button == 0)
			{
				return false;
			}
			return UnityInput.Current.GetKeyDown(button);
		}
	}
	internal class VoidManagerPlugin : VoidPlugin
	{
		internal static bool sessionFeaturesEnabled;

		public override string Author => "Gruncle Chuck";

		public override string Description => "Allows you to turn on/off the gun that you are sitting on.";

		public override MultiplayerType MPType => (MultiplayerType)8;

		public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0024: Expected I4, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			CallType callType = input.CallType;
			CallType val = callType;
			switch ((int)val)
			{
			case 2:
				if (input.IsMod_Session)
				{
					sessionFeaturesEnabled = true;
				}
				else
				{
					sessionFeaturesEnabled = false;
				}
				break;
			case 3:
				if (input.IsHost)
				{
					sessionFeaturesEnabled = true;
				}
				break;
			case 0:
			case 1:
				sessionFeaturesEnabled = true;
				break;
			case 4:
				sessionFeaturesEnabled = true;
				break;
			}
			SessionChangedReturn result = default(SessionChangedReturn);
			result.SetMod_Session = true;
			return result;
		}
	}
}