Decompiled source of PurpleSuitUnlocker v1.1.2

PurpleSuitUnlocker.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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PurpleSuitUnlocker")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Lets you keep some scrap on the ship after dying in singleplayer, for a more casual solo-friendly experience.")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+c4d81482628878484d495f5006ac62144ffd1789")]
[assembly: AssemblyProduct("PurpleSuitUnlocker")]
[assembly: AssemblyTitle("PurpleSuitUnlocker")]
[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 PurpleSuitUnlocker
{
	[BepInPlugin("butterystancakes.lethalcompany.purplesuitunlocker", "Purple Suit Unlocker", "1.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "butterystancakes.lethalcompany.purplesuitunlocker";

		private const string PLUGIN_NAME = "Purple Suit Unlocker";

		private const string PLUGIN_VERSION = "1.1.2";

		public static ConfigEntry<bool> configEventRequirement;

		private void Awake()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			configEventRequirement = ((BaseUnityPlugin)this).Config.Bind<bool>("Purple Suit Unlocker", "EventRequirement", true, "Require event to be completed.");
			new Harmony("butterystancakes.lethalcompany.purplesuitunlocker").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Purple Suit Unlocker v1.1.2 loaded");
		}
	}
	internal class UnlockPurpleSuit
	{
		public static void SpawnPurpleSuit()
		{
			if (((NetworkBehaviour)StartOfRound.Instance).IsServer && !StartOfRound.Instance.isChallengeFile && ES3.Load<bool>("FinishedChallenge", "LCChallengeFile", false) && Plugin.configEventRequirement.Value)
			{
				typeof(StartOfRound).GetMethod("SpawnUnlockable", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(StartOfRound.Instance, new object[1] { 24 });
			}
			else if (((NetworkBehaviour)StartOfRound.Instance).IsServer && !StartOfRound.Instance.isChallengeFile && !Plugin.configEventRequirement.Value)
			{
				typeof(StartOfRound).GetMethod("SpawnUnlockable", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(StartOfRound.Instance, new object[1] { 24 });
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PurpleSuitUnlocker";

		public const string PLUGIN_NAME = "PurpleSuitUnlocker";

		public const string PLUGIN_VERSION = "1.1.1";
	}
}
namespace PurpleSuitUnlocker.Patches
{
	[HarmonyPatch]
	internal class PurpleSuitUnlockerPatches
	{
		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		public static void PostStart()
		{
			UnlockPurpleSuit.SpawnPurpleSuit();
		}

		[HarmonyPatch(typeof(StartOfRound), "ResetShip")]
		[HarmonyPostfix]
		public static void PostResetShip()
		{
			UnlockPurpleSuit.SpawnPurpleSuit();
		}
	}
}