Decompiled source of BloodDrop v1.0.5

BloodDrop.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
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.Unity.IL2CPP;
using BloodDrop.Configuration;
using BloodDrop.Patches;
using BloodDrop.Services;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.Network;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("BloodDrop")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.5.0")]
[assembly: AssemblyInformationalVersion("1.0.5+40b36857844465928e357d96630f8efafa8d4cf8")]
[assembly: AssemblyProduct("BloodDrop")]
[assembly: AssemblyTitle("BloodDrop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 BloodDrop
{
	[BepInPlugin("BloodDrop", "BloodDrop", "1.0.5")]
	public sealed class Plugin : BasePlugin
	{
		public const string Id = "BloodDrop";

		public const string Name = "BloodDrop";

		public const string Version = "1.0.5";

		internal static Plugin Instance;

		internal DropSettings Settings;

		private Harmony? harmony;

		public override void Load()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Instance = this;
			Settings = new DropSettings(((BasePlugin)this).Config);
			harmony = new Harmony("BloodDrop");
			harmony.PatchAll(typeof(Plugin).Assembly);
		}

		public override bool Unload()
		{
			Harmony? obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			DeathEventPatch.Reset();
			return true;
		}
	}
}
namespace BloodDrop.Services
{
	public static class BloodDropService
	{
		public static readonly PrefabGUID Bottle = new PrefabGUID(828432508);

		private const int NoneBloodType = 447918373;

		private const int VBloodType = -338774148;

		public static void OnDeath(World world, DeathEvent death)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Invalid comparison between Unknown and I4
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Invalid comparison between Unknown and I4
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			DropSettings settings = Plugin.Instance.Settings;
			if (world.Name != "Server" || !settings.CanDrop)
			{
				return;
			}
			EntityManager entityManager = world.EntityManager;
			Entity died = death.Died;
			if (((EntityManager)(ref entityManager)).Exists(died) && !((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(died) && !((EntityManager)(ref entityManager)).HasComponent<VBloodUnit>(died) && !((EntityManager)(ref entityManager)).HasComponent<VBloodConsumeSource>(died) && !((EntityManager)(ref entityManager)).HasComponent<VBloodUnitTagComponent>(died) && ((EntityManager)(ref entityManager)).HasComponent<BloodConsumeSource>(died) && ((EntityManager)(ref entityManager)).HasComponent<Translation>(died))
			{
				BloodConsumeSource componentData = ((EntityManager)(ref entityManager)).GetComponentData<BloodConsumeSource>(died);
				PrefabGUID value = ((ModifiablePrefabGUID)(ref componentData.UnitBloodType)).Value;
				if (((PrefabGUID)(ref value)).GuidHash != 0 && ((PrefabGUID)(ref value)).GuidHash != 447918373 && ((PrefabGUID)(ref value)).GuidHash != -338774148 && float.IsFinite(componentData.BloodQuality) && !(componentData.BloodQuality < 0f) && !(componentData.BloodQuality > 100f) && (((int)death.StatChangeReason != 22 && (int)death.StatChangeReason != 23) || settings.Feeding.Value) && settings.ShouldDrop(componentData.BloodQuality))
				{
					float3 value2 = ((EntityManager)(ref entityManager)).GetComponentData<Translation>(died).Value;
					CreateDrop(world, value2, value, componentData.BloodQuality);
				}
			}
		}

		public static Entity CreateDrop(World world, float3 position, PrefabGUID bloodType, float quality)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			EntityManager entityManager = world.EntityManager;
			Entity val = default(Entity);
			if (!world.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabGuidToEntityMap.TryGetValue(Bottle, ref val))
			{
				throw new InvalidOperationException("Native blood bottle prefab is unavailable.");
			}
			Entity val2 = ((EntityManager)(ref entityManager)).Instantiate(val);
			Entity val3 = Entity.Null;
			try
			{
				StoredBlood val4 = new StoredBlood
				{
					BloodQuality = quality,
					PrimaryBloodType = bloodType
				};
				if (((EntityManager)(ref entityManager)).HasComponent<StoredBlood>(val2))
				{
					((EntityManager)(ref entityManager)).SetComponentData<StoredBlood>(val2, val4);
				}
				else
				{
					((EntityManager)(ref entityManager)).AddComponentData<StoredBlood>(val2, val4);
				}
				val3 = ((EntityManager)(ref entityManager)).CreateEntity();
				((EntityManager)(ref entityManager)).AddComponentData<DropItemAroundPosition>(val3, new DropItemAroundPosition
				{
					Position = position,
					ItemEntity = val2,
					ItemHash = Bottle,
					Amount = 1,
					DontMerge = true
				});
				return val2;
			}
			catch
			{
				if (((EntityManager)(ref entityManager)).Exists(val3))
				{
					((EntityManager)(ref entityManager)).DestroyEntity(val3);
				}
				if (((EntityManager)(ref entityManager)).Exists(val2))
				{
					((EntityManager)(ref entityManager)).DestroyEntity(val2);
				}
				throw;
			}
		}
	}
}
namespace BloodDrop.Patches
{
	[HarmonyPatch(typeof(ChatMessageSystem), "OnUpdate")]
	internal static class ConfigReloadPatch
	{
		[HarmonyPrefix]
		private unsafe static void Prefix(ChatMessageSystem __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> val = default(NativeArray<Entity>);
			try
			{
				if (((ComponentSystemBase)__instance).World.Name != "Server")
				{
					return;
				}
				EntityQuery chatMessageQuery = __instance._ChatMessageQuery;
				if (((EntityQuery)(ref chatMessageQuery)).IsEmpty)
				{
					return;
				}
				EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
				chatMessageQuery = __instance._ChatMessageQuery;
				val = ((EntityQuery)(ref chatMessageQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val.GetEnumerator();
				FixedString512Bytes val2 = default(FixedString512Bytes);
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					try
					{
						if (!((EntityManager)(ref entityManager)).Exists(current) || !((EntityManager)(ref entityManager)).HasComponent<ChatMessageEvent>(current))
						{
							continue;
						}
						FixedString512Bytes messageText = ((EntityManager)(ref entityManager)).GetComponentData<ChatMessageEvent>(current).MessageText;
						if (!string.Equals(((object)(*(FixedString512Bytes*)(&messageText))/*cast due to .constrained prefix*/).ToString().Trim(), "!reloadblooddropconfig", StringComparison.OrdinalIgnoreCase) || !((EntityManager)(ref entityManager)).HasComponent<FromCharacter>(current))
						{
							continue;
						}
						Entity user = ((EntityManager)(ref entityManager)).GetComponentData<FromCharacter>(current).User;
						if (!((EntityManager)(ref entityManager)).Exists(user) || !((EntityManager)(ref entityManager)).HasComponent<User>(user))
						{
							continue;
						}
						User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(user);
						((EntityManager)(ref entityManager)).DestroyEntity(current);
						string text = "BloodDrop: administrator access required.";
						if (componentData.IsAdmin)
						{
							try
							{
								((BasePlugin)Plugin.Instance).Config.Reload();
								text = "BloodDrop configuration reloaded.";
							}
							catch (Exception)
							{
								text = "BloodDrop configuration reload failed. Check BloodDrop.cfg.";
							}
						}
						((FixedString512Bytes)(ref val2))..ctor(text);
						ServerChatUtils.SendSystemMessageToClient(entityManager, componentData, ref val2);
					}
					catch (Exception)
					{
					}
				}
			}
			catch (Exception)
			{
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
		}
	}
	[HarmonyPatch(typeof(DeathEventListenerSystem), "OnUpdate")]
	internal static class DeathEventPatch
	{
		private const int MaximumRememberedDeaths = 16384;

		private static IntPtr currentWorld;

		private static readonly HashSet<Entity> seen = new HashSet<Entity>();

		private static readonly Queue<Entity> order = new Queue<Entity>();

		internal static void Reset()
		{
			currentWorld = IntPtr.Zero;
			seen.Clear();
			order.Clear();
		}

		[HarmonyPrefix]
		private static void Prefix(DeathEventListenerSystem __instance)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			NativeArray<Entity> val = default(NativeArray<Entity>);
			try
			{
				if (!Plugin.Instance.Settings.CanDrop || ((ComponentSystemBase)__instance).World.Name != "Server")
				{
					return;
				}
				if (currentWorld != ((Il2CppObjectBase)((ComponentSystemBase)__instance).World).Pointer)
				{
					Reset();
					currentWorld = ((Il2CppObjectBase)((ComponentSystemBase)__instance).World).Pointer;
				}
				EntityQuery deathEventQuery = __instance._DeathEventQuery;
				if (((EntityQuery)(ref deathEventQuery)).IsEmpty)
				{
					return;
				}
				deathEventQuery = __instance._DeathEventQuery;
				val = ((EntityQuery)(ref deathEventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
				Enumerator<Entity> enumerator = val.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Entity current = enumerator.Current;
					try
					{
						EntityManager entityManager = ((ComponentSystemBase)__instance).EntityManager;
						DeathEvent componentData = ((EntityManager)(ref entityManager)).GetComponentData<DeathEvent>(current);
						if (seen.Add(componentData.Died))
						{
							order.Enqueue(componentData.Died);
							while (order.Count > 16384)
							{
								seen.Remove(order.Dequeue());
							}
							BloodDropService.OnDeath(((ComponentSystemBase)__instance).World, componentData);
						}
					}
					catch (Exception)
					{
					}
				}
			}
			catch (Exception)
			{
			}
			finally
			{
				if (val.IsCreated)
				{
					val.Dispose();
				}
			}
		}
	}
}
namespace BloodDrop.Configuration
{
	internal static class DropPolicy
	{
		internal static bool ShouldDrop(bool enabled, float quality, bool minimumEnabled, float minimum, bool guaranteeEnabled, float guarantee, float chance, Func<double> roll)
		{
			if (!enabled || !Valid(quality) || (minimumEnabled && (!Valid(minimum) || quality < minimum)))
			{
				return false;
			}
			if (guaranteeEnabled && Valid(guarantee) && quality >= guarantee)
			{
				return true;
			}
			if (Valid(chance) && chance > 0f)
			{
				if (!(chance >= 100f))
				{
					return roll() * 100.0 < (double)chance;
				}
				return true;
			}
			return false;
		}

		private static bool Valid(float value)
		{
			if (float.IsFinite(value) && value >= 0f)
			{
				return value <= 100f;
			}
			return false;
		}
	}
	internal sealed class DropSettings
	{
		private static readonly Func<double> Roll = Random.Shared.NextDouble;

		internal ConfigEntry<bool> Enabled { get; }

		internal ConfigEntry<float> Chance { get; }

		internal ConfigEntry<bool> Feeding { get; }

		internal ConfigEntry<bool> MinimumEnabled { get; }

		internal ConfigEntry<float> MinimumQuality { get; }

		internal ConfigEntry<bool> GuaranteeEnabled { get; }

		internal ConfigEntry<float> GuaranteeQuality { get; }

		internal bool CanDrop
		{
			get
			{
				if (Enabled.Value)
				{
					if (!(Chance.Value > 0f))
					{
						return GuaranteeEnabled.Value;
					}
					return true;
				}
				return false;
			}
		}

		internal bool ShouldDrop(float quality)
		{
			return DropPolicy.ShouldDrop(Enabled.Value, quality, MinimumEnabled.Value, MinimumQuality.Value, GuaranteeEnabled.Value, GuaranteeQuality.Value, Chance.Value, Roll);
		}

		internal DropSettings(ConfigFile config)
		{
			Enabled = config.Bind<bool>("BloodDrops", "Enabled", true, "Allow ordinary NPC blood bottle drops. Players and V Bloods are always excluded.");
			Chance = Percent(config, "DropChancePercent", 100f, "Chance for eligible blood below the enabled guarantee threshold. Zero allows guaranteed drops only.");
			Feeding = config.Bind<bool>("BloodDrops", "DropOnFeedingKills", true, "Also allow bottles when feeding kills an NPC.");
			MinimumEnabled = config.Bind<bool>("BloodDrops", "EnableMinimumBloodQuality", false, "Require blood quality at or above MinimumBloodQualityPercent before any drop.");
			MinimumQuality = Percent(config, "MinimumBloodQualityPercent", 40f, "Inclusive minimum blood quality when the minimum filter is enabled.");
			GuaranteeEnabled = config.Bind<bool>("BloodDrops", "EnableGuaranteedDrops", false, "Guarantee eligible drops at or above GuaranteedDropAtOrAboveQualityPercent, bypassing chance only.");
			ConfigEntry<float> val = Percent(config, "GuaranteedBloodQualityPercent", 100f, "Legacy threshold; migrated to GuaranteedDropAtOrAboveQualityPercent.");
			GuaranteeQuality = Percent(config, "GuaranteedDropAtOrAboveQualityPercent", val.Value, "Blood quality at or above this percentage always drops when EnableGuaranteedDrops is true. Example: 90 guarantees 90% through 100%. Still respects enabled, minimum, feeding and NPC exclusions.");
			config.Remove(((ConfigEntryBase)val).Definition);
			config.Save();
		}

		private static ConfigEntry<float> Percent(ConfigFile config, string key, float value, string description)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			return config.Bind<float>("BloodDrops", key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
		}
	}
}