Decompiled source of CustomStorePrice v1.0.2

CustomStorePrice.dll

Decompiled 10 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CustomStorePrice")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("CustomStorePrice")]
[assembly: AssemblyCopyright("Copyright © tinymins 2023")]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
namespace CustomStorePrice
{
	[BepInPlugin("com.zhaiyiming.github.tinymins.CustomStorePrice", "CustomStorePrice", "1.0.2")]
	internal class CustomStorePrice : BaseUnityPlugin
	{
		public const string GUID = "com.zhaiyiming.github.tinymins.CustomStorePrice";

		public const string NAME = "CustomStorePrice";

		public const string VERSION = "1.0.2";

		internal static ManualLogSource Log;

		internal static ConfigEntry<string> StoreItemPrices;

		private void Awake()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			StoreItemPrices = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "StoreItemPrices", "Boombox:30,TZP-Inhalant:30,Jetpack:300,Rocket Launcher:350", "\"Please set custom prices for store items. Each price configuration should be in the format \"name:price\", separated by commas. The value for 'name' can be selected from the following: Walkie-talkie, Flashlight, Shovel, Lockpicker, Pro-flashlight, Stun grenade, Boombox, TZP-Inhalant, Zap gun, Jetpack, Extension ladder, Radar-booster, Spray paint, Rocket Launcher, Flaregun, Emergency Flare (ammo), Toy Hammer, Remote Radar, Utility Belt, Hacking Tool, Pinger, Portable Tele, Advanced Portable Tele, Night Vision Goggles, Medkit, Peeper, Helmet, Diving Kit, Wheelbarrow, Ouija Board, Shells.");
			new Harmony("com.zhaiyiming.github.tinymins.CustomStorePrice").PatchAll(Assembly.GetExecutingAssembly());
		}
	}
}
namespace CustomStorePrice.Patches
{
	[HarmonyPatch(typeof(Terminal))]
	internal class PricePatches
	{
		[HarmonyPatch("SetItemSales")]
		[HarmonyPostfix]
		private static void StorePrices(ref Item[] ___buyableItemsList)
		{
			List<string[]> list = (from i in CustomStorePrice.StoreItemPrices.Value.Split(new char[1] { ',' })
				select i.Trim().Split(new char[1] { ':' })).ToList();
			for (int j = 0; j < ___buyableItemsList.Length; j++)
			{
				Item val = ___buyableItemsList[j];
				for (int k = 0; k < list.Count; k++)
				{
					string[] array = list[k];
					if (array[0] == val.itemName && array.Length > 1)
					{
						try
						{
							int creditsWorth = int.Parse(array[1]);
							val.creditsWorth = creditsWorth;
						}
						catch
						{
						}
						break;
					}
				}
				CustomStorePrice.Log.LogInfo((object)$"{val.itemName} is now ${val.creditsWorth}.");
			}
		}
	}
}