Decompiled source of Potionless Loot v0.7.0

plugins/PotionLessLoot.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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;
using PotionLessLootPlugin;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutwardModTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardModTemplate")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace PotionLessLoot
{
	[BepInPlugin("johbenji.potionlessloot", "Potionless Loot", "0.7.0")]
	public class PotionLessLootPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ItemDropper), "GenerateItem")]
		public class GenerateItemPatch
		{
			private static void Prefix(ref ItemContainer _container, BasicItemDrop _itemDrop, int _spawnAmount)
			{
				if (ConfigElements.removeImbuesRate.Value != 0f && _itemDrop != null && imbueIDs.Contains(_itemDrop.DroppedItem.ItemID))
				{
					Random random = new Random();
					if (random.NextDouble() < (double)ConfigElements.removeImbuesRate.Value)
					{
						Log.LogMessage((object)$"Removing ItemID {_itemDrop.DroppedItem.ItemID}: {_itemDrop.DroppedItem.Name}");
						_container = null;
					}
					else
					{
						Log.LogMessage((object)$"Keeping ItemID {_itemDrop.DroppedItem.ItemID}: {_itemDrop.DroppedItem.Name}");
					}
				}
				if (ConfigElements.removePotionsRate.Value != 0f && _itemDrop != null && potionIDs.Contains(_itemDrop.DroppedItem.ItemID))
				{
					Random random2 = new Random();
					if (random2.NextDouble() < (double)ConfigElements.removePotionsRate.Value)
					{
						Log.LogMessage((object)$"Removing ItemID {_itemDrop.DroppedItem.ItemID}: {_itemDrop.DroppedItem.Name}");
						_container = null;
					}
					else
					{
						Log.LogMessage((object)$"Keeping ItemID {_itemDrop.DroppedItem.ItemID}: {_itemDrop.DroppedItem.Name}");
					}
				}
			}
		}

		public const string GUID = "johbenji.potionlessloot";

		public const string NAME = "Potionless Loot";

		public const string VERSION = "0.7.0";

		internal static ManualLogSource Log;

		private static List<int> imbueIDs;

		private static List<int> potionIDs;

		internal void Awake()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			ConfigElements.Init(((BaseUnityPlugin)this).Config);
			new Harmony("johbenji.potionlessloot").PatchAll();
			imbueIDs = getImbueIDs();
			potionIDs = getPotionIDs();
		}

		private List<int> getImbueIDs()
		{
			return new List<int> { 4400030, 4400031, 4400070, 4400040, 4400041, 4400050, 4400051, 4400020, 4400021, 4400060 };
		}

		private List<int> getPotionIDs()
		{
			return new List<int>
			{
				4300350, 4300110, 4300180, 4300020, 4300430, 4300100, 4300390, 4300080, 4300060, 4300150,
				4300140, 4300030, 4300281, 4300230, 4300250, 4300260, 4300240, 4300190, 4300340, 4300330,
				4300320, 4300280, 4300010, 4300410, 4300420, 4300090, 4300370, 4300120, 4300290, 4300300,
				4300050, 4300400, 4300360, 4300170, 4300130, 4300200, 4300380, 4300220, 4300070, 4300210,
				4300160
			};
		}
	}
}
namespace PotionLessLootPlugin
{
	public static class ConfigElements
	{
		public static ConfigEntry<float> removePotionsRate;

		public static ConfigEntry<float> removeImbuesRate;

		public static void Init(ConfigFile config)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			removePotionsRate = config.Bind<float>("Potions", "Chance of removing potions", 1f, new ConfigDescription("Chance of removing the potion from the DropTables (Vanilla = 0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0]));
			removeImbuesRate = config.Bind<float>("Imbues", "Chance of removing rags/varnishes", 1f, new ConfigDescription("Chance of removing the imbues from the DropTables (Vanilla = 0)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), new object[0]));
		}
	}
}