Decompiled source of firearmlicense v1.1.0

firearmlicense.dll

Decompiled a year 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 LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("firearmlicense")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Allows you to purchase Nutcracker shotguns from the store")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("firearmlicense")]
[assembly: AssemblyTitle("firearmlicense")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 firearmlicense
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "firearmlicense";

		public const string PLUGIN_NAME = "firearmlicense";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace enemyalert
{
	[BepInPlugin("firearmlicense", "firearmlicense", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInProcess("Lethal Company.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public static ManualLogSource Log;

		private static ConfigEntry<int> gunPrice;

		private static ConfigEntry<bool> gunEnabled;

		private static ConfigEntry<int> shellPrice;

		private static ConfigEntry<bool> shellEnabled;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"firearmlicense v. 1.1.0");
			Log.LogInfo((object)"Allows you to purchase Nutcracker shotguns from the store");
			gunPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Shotgun", "StorePrice", 1000, "Store price for the Nutcracker shotgun");
			gunEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "Enabled", true, "If true, the shotgun will be available in store");
			shellPrice = ((BaseUnityPlugin)this).Config.Bind<int>("Shotgun", "ShellStorePrice", 200, "Store price for the shotgun shells");
			shellEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "ShellEnabled", true, "If true, the shotgun shells will be available in store");
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (gunEnabled.Value)
			{
				Item obj = Object.Instantiate<Item>(getItem("Shotgun"));
				((Object)obj).name = "PurchasableShotgun";
				obj.isScrap = false;
				obj.creditsWorth = gunPrice.Value;
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val).name = "ShotgunInfoNode";
				val.displayText = "The Company takes no liability for casualties inflicted by this item. Remember the 5 firearm handling rules: [INFORMATION EXPUNGED]\n\n";
				val.clearPreviousText = true;
				val.maxCharactersToType = 25;
				Items.RegisterShopItem(obj, (TerminalNode)null, (TerminalNode)null, val, gunPrice.Value);
				Log.LogInfo((object)$"shotgun added to the store with price {gunPrice.Value}");
			}
			if (shellEnabled.Value)
			{
				Item obj2 = Object.Instantiate<Item>(getItem("GunAmmo"));
				((Object)obj2).name = "PurchasableShells";
				obj2.isScrap = false;
				obj2.creditsWorth = shellPrice.Value;
				TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
				((Object)val2).name = "ShellInfoNode";
				val2.displayText = "Ammo required for the shotgun to remain a practical weapon.\n\n";
				val2.clearPreviousText = true;
				val2.maxCharactersToType = 25;
				Items.RegisterShopItem(obj2, (TerminalNode)null, (TerminalNode)null, val2, shellPrice.Value);
				Log.LogInfo((object)$"shells added to the store with price {shellPrice.Value}");
			}
		}

		private static Item getItem(string v)
		{
			Item[] array = Resources.FindObjectsOfTypeAll<Item>();
			foreach (Item val in array)
			{
				if (((Object)val).name == v)
				{
					return val;
				}
			}
			return null;
		}
	}
}