Decompiled source of Change Loadout v1.0.0

ChangeLoadout.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using CG.Game.Player;
using CG.Profile;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UI.MainHUD;
using UI.Token;
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("ChangeLoadout")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ChangeLoadout")]
[assembly: AssemblyTitle("Change the gene loadout on next respawn")]
[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 ChangeLoadout
{
	[HarmonyPatch(typeof(CloneTube), "RequestOpenDoorFromInside")]
	internal class CloneTubePatch
	{
		private static void Prefix()
		{
			Common.hasLeftSarcograph = true;
		}
	}
	internal class Common
	{
		internal static int nextLoadout = -1;

		internal static bool hasLeftSarcograph = false;

		internal static void CheckChangeLoadout()
		{
			if (nextLoadout != -1)
			{
				TokenTerminal[] array = Object.FindObjectsOfType<TokenTerminal>();
				if (array.Length != 0)
				{
					array.First().TryChangeLoadout(nextLoadout);
				}
			}
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Change Loadout";
		}

		public override void Draw()
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			IPlayerPerkData perkData = PlayerProfile.PerkData;
			List<PerkLoadout> loadouts = perkData.Loadouts;
			int num = ((Common.nextLoadout != -1) ? Common.nextLoadout : perkData.ActiveLoudoutIndex);
			if ((Object)(object)LocalPlayer.Instance == (Object)null || GameSessionManager.InHub || !Common.hasLeftSarcograph)
			{
				GUILayout.Label("Switch to:", Array.Empty<GUILayoutOption>());
			}
			else
			{
				GUILayout.Label("On next respawn switch to:", Array.Empty<GUILayoutOption>());
			}
			if (GUITools.DrawButtonSelected($"A - {PlayerDataHelper.GetPlayerRole(loadouts[0].GetData())}", num == 0) && perkData.ActiveLoudoutIndex != 0)
			{
				Common.nextLoadout = 0;
			}
			if (GUITools.DrawButtonSelected($"B - {PlayerDataHelper.GetPlayerRole(loadouts[1].GetData())}", num == 1) && perkData.ActiveLoudoutIndex != 1)
			{
				Common.nextLoadout = 1;
			}
			if (GUITools.DrawButtonSelected($"C - {PlayerDataHelper.GetPlayerRole(loadouts[2].GetData())}", num == 2) && perkData.ActiveLoudoutIndex != 2)
			{
				Common.nextLoadout = 2;
			}
			if (GUITools.DrawButtonSelected($"D - {PlayerDataHelper.GetPlayerRole(loadouts[3].GetData())}", num == 3) && perkData.ActiveLoudoutIndex != 3)
			{
				Common.nextLoadout = 3;
			}
			if ((Object)(object)LocalPlayer.Instance == (Object)null || GameSessionManager.InHub || !Common.hasLeftSarcograph)
			{
				Common.CheckChangeLoadout();
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "id107.changeloadout";

		public const string PLUGIN_NAME = "ChangeLoadout";

		public const string USERS_PLUGIN_NAME = "Change Loadout";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string PLUGIN_DESCRIPTION = "Change the gene loadout on next respawn";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "";
	}
	[HarmonyPatch(typeof(Player), "Die")]
	internal class PlayerPatch
	{
		private static void Prefix()
		{
			Common.hasLeftSarcograph = false;
			Common.CheckChangeLoadout();
		}
	}
	[BepInPlugin("id107.changeloadout", "Change Loadout", "1.0.0")]
	[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(), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.changeloadout is loaded!");
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)8;

		public override string Author => "18107";

		public override string Description => "Change the gene loadout on next respawn";

		public override string ThunderstoreID => "";

		public VoidManagerPlugin()
		{
			Events.Instance.JoinedRoom += OnJoin;
			Events.Instance.HostStartSession += OnJoin;
			static void OnJoin(object o, EventArgs e)
			{
				Common.hasLeftSarcograph = false;
				Common.CheckChangeLoadout();
			}
		}
	}
	[HarmonyPatch(typeof(TokenTerminal), "TryChangeLoadout")]
	internal class TokenTerminalPatch
	{
		private static void Prefix()
		{
			Common.nextLoadout = -1;
		}
	}
}