Decompiled source of BuyableDramaMask v1.0.0

BuyableDramaMask.dll

Decompiled a month 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[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.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("BuyableDramaMask")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCopyright("Copyright © 2023 MegaPiggy")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+de03bd2735d14ec5e61f253b6602806c4ce89ece")]
[assembly: AssemblyProduct("BuyableDramaMask")]
[assembly: AssemblyTitle("BuyableDramaMask")]
[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 BuyableDramaMask
{
	[BepInDependency("evaisa.lethallib", "0.13.0")]
	[BepInDependency("DramaMask", "1.0.0")]
	[BepInPlugin("MegaPiggy.BuyableDramaMask", "Buyable Drama Mask", "1.0.0")]
	public class BuyableDramaMask : BaseUnityPlugin
	{
		private const string modGUID = "MegaPiggy.BuyableDramaMask";

		private const string modName = "Buyable Drama Mask";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("MegaPiggy.BuyableDramaMask");

		private static BuyableDramaMask Instance;

		private ConfigEntry<int> DramaMaskPriceConfig;

		private static ManualLogSource LoggerInstance => ((BaseUnityPlugin)Instance).Logger;

		public List<Item> AllItems => Resources.FindObjectsOfTypeAll<Item>().Concat(Object.FindObjectsByType<Item>((FindObjectsInactive)1, (FindObjectsSortMode)1)).ToList();

		public Item Drama => ((IEnumerable<Item>)AllItems).FirstOrDefault((Func<Item, bool>)((Item item) => ((Object)item).name.Equals("DramaMask")));

		public int DramaMaskPrice => DramaMaskPriceConfig.Value;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll();
			DramaMaskPriceConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", "DramaMaskPrice", 30, "Credits needed to buy drama mask");
			Item obj = MakeNonScrap(Drama, DramaMaskPrice);
			int dramaMaskPrice = DramaMaskPrice;
			Items.RegisterShopItem(obj, (TerminalNode)null, (TerminalNode)null, CreateInfoNode("DramaMask", "A mask that is not haunted unlike its Tragedy and Comedy counterparts. Wearing it will make other Masked enemies ignore you!"), dramaMaskPrice);
			LoggerInstance.LogInfo((object)$"Drama Mask added to Shop for {DramaMaskPrice} credits");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Buyable Drama Mask is loaded with version 1.0.0!");
		}

		private static Item MakeNonScrap(Item original, int price)
		{
			Item val = Object.Instantiate<Item>(original);
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).name = "Buyable" + ((Object)original).name;
			val.isScrap = false;
			val.creditsWorth = price;
			return val;
		}

		private static TerminalNode CreateInfoNode(string name, string description)
		{
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			((Object)val).name = name + "InfoNode";
			val.displayText = description + "\n\n";
			return val;
		}
	}
}