Decompiled source of SandsweptQuality v1.1.0

SandsweptQuality.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using ItemQualities;
using ItemQualities.ContentManagement;
using ItemQualities.Utilities.Extensions;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.EntityStates;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Orbs;
using SandsweptQuality.Effects;
using UnityEngine;
using UnityEngine.Networking;

[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("SandsweptQuality")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a320046b47b3c46c770c563d370f770bf2af806d")]
[assembly: AssemblyProduct("SandsweptQuality")]
[assembly: AssemblyTitle("SandsweptQuality")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 SandsweptQuality
{
	internal static class Buffs
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static StatHookEventHandler <0>__OnGetStatCoefficients;
		}

		public static BuffDef AmberEncased;

		public static BuffDef TimeSlowed;

		public static BuffDef Irradiated;

		public static BuffDef TimepieceRush;

		public static BuffDef PlutoniumRecharge;

		public static BuffDef FeatherFury;

		public static readonly HashSet<BuffDef> OwnBuffs = new HashSet<BuffDef>();

		public static void Register()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Expected O, but got Unknown
			AmberEncased = Make("bdSandsweptQualityAmberEncased", Color32.op_Implicit(new Color32(byte.MaxValue, (byte)170, (byte)40, byte.MaxValue)), debuff: true, stack: true);
			TimeSlowed = Make("bdSandsweptQualityTimeSlowed", Color32.op_Implicit(new Color32((byte)102, (byte)195, byte.MaxValue, byte.MaxValue)), debuff: true, stack: true);
			Irradiated = Make("bdSandsweptQualityIrradiated", Color32.op_Implicit(new Color32((byte)175, byte.MaxValue, (byte)30, byte.MaxValue)), debuff: true, stack: true);
			TimepieceRush = Make("bdSandsweptQualityTimepieceRush", Color32.op_Implicit(new Color32((byte)120, (byte)220, byte.MaxValue, byte.MaxValue)), debuff: false, stack: true);
			FeatherFury = Make("bdSandsweptQualityFeatherFury", Color32.op_Implicit(new Color32(byte.MaxValue, (byte)140, (byte)200, byte.MaxValue)), debuff: false, stack: true);
			PlutoniumRecharge = Make("bdSandsweptQualityPlutoniumRecharge", Color32.op_Implicit(new Color32((byte)110, (byte)120, (byte)110, byte.MaxValue)), debuff: false, stack: false, cooldown: true);
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				try
				{
					AmberEncased.iconSprite = Buffs.Slow80?.iconSprite;
					TimeSlowed.iconSprite = Buffs.Slow50?.iconSprite;
					Irradiated.iconSprite = Buffs.DeathMark?.iconSprite;
					TimepieceRush.iconSprite = Buffs.CloakSpeed?.iconSprite;
					FeatherFury.iconSprite = Buffs.FullCrit?.iconSprite;
					PlutoniumRecharge.iconSprite = Buffs.Immune?.iconSprite;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Could not assign buff icons: " + ex.Message));
				}
			});
			object obj = <>O.<0>__OnGetStatCoefficients;
			if (obj == null)
			{
				StatHookEventHandler val = OnGetStatCoefficients;
				<>O.<0>__OnGetStatCoefficients = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}

		private static BuffDef Make(string name, Color color, bool debuff, bool stack, bool cooldown = false)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = name;
			val.buffColor = color;
			val.isDebuff = debuff;
			val.canStack = stack;
			val.isCooldown = cooldown;
			val.isHidden = false;
			ContentAddition.AddBuffDef(val);
			OwnBuffs.Add(val);
			return val;
		}

		private static void OnGetStatCoefficients(CharacterBody body, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)body))
			{
				int buffCount = body.GetBuffCount(AmberEncased);
				int buffCount2 = body.GetBuffCount(TimeSlowed);
				float num = Mathf.Clamp01((float)Mathf.Max(buffCount, buffCount2) / 100f);
				if (num > 0f)
				{
					num = Mathf.Min(num, 0.9f);
					args.moveSpeedReductionMultAdd += num / (1f - num);
				}
				if (buffCount > 0)
				{
					float num2 = Mathf.Min((float)buffCount / 100f, 0.9f);
					args.attackSpeedReductionMultAdd += num2 / (1f - num2);
				}
				int buffCount3 = body.GetBuffCount(FeatherFury);
				if (buffCount3 > 0)
				{
					args.damageMultAdd += (float)buffCount3 / 100f;
				}
				int buffCount4 = body.GetBuffCount(TimepieceRush);
				if (buffCount4 > 0)
				{
					args.moveSpeedMultAdd += (float)buffCount4 / 100f;
				}
			}
		}

		public static void ApplyMagnitude(CharacterBody body, BuffDef buff, int value, float duration)
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)buff) && value > 0 && !(duration <= 0f))
			{
				MagnitudeBuffTracker magnitudeBuffTracker = ((Component)body).GetComponent<MagnitudeBuffTracker>();
				if (!Object.op_Implicit((Object)(object)magnitudeBuffTracker))
				{
					magnitudeBuffTracker = ((Component)body).gameObject.AddComponent<MagnitudeBuffTracker>();
				}
				magnitudeBuffTracker.Apply(body, buff, value, duration);
			}
		}
	}
	internal sealed class MagnitudeBuffTracker : MonoBehaviour
	{
		private struct Slot
		{
			public int Value;

			public float ExpiresAt;
		}

		private readonly Dictionary<BuffIndex, Slot> _slots = new Dictionary<BuffIndex, Slot>();

		private readonly List<BuffIndex> _expired = new List<BuffIndex>();

		private CharacterBody _body;

		public void Apply(CharacterBody body, BuffDef buff, int value, float duration)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			_body = body;
			float fixedTime = Time.fixedTime;
			BuffIndex buffIndex = buff.buffIndex;
			if ((int)buffIndex == -1)
			{
				return;
			}
			if (_slots.ContainsKey(buffIndex) && body.GetBuffCount(buffIndex) == 0)
			{
				_slots.Remove(buffIndex);
			}
			if (_slots.TryGetValue(buffIndex, out var value2) && value2.ExpiresAt > fixedTime)
			{
				if (value >= value2.Value)
				{
					value2.Value = value;
					value2.ExpiresAt = Mathf.Max(value2.ExpiresAt, fixedTime + duration);
				}
			}
			else
			{
				value2 = new Slot
				{
					Value = value,
					ExpiresAt = fixedTime + duration
				};
			}
			_slots[buffIndex] = value2;
			if (body.GetBuffCount(buffIndex) != value2.Value)
			{
				body.SetBuffCount(buffIndex, value2.Value);
			}
		}

		private void FixedUpdate()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0088: 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)
			if (!NetworkServer.active || _slots.Count == 0)
			{
				return;
			}
			float fixedTime = Time.fixedTime;
			foreach (KeyValuePair<BuffIndex, Slot> slot in _slots)
			{
				if (slot.Value.ExpiresAt <= fixedTime)
				{
					_expired.Add(slot.Key);
				}
			}
			foreach (BuffIndex item in _expired)
			{
				_slots.Remove(item);
				if (Object.op_Implicit((Object)(object)_body))
				{
					_body.SetBuffCount(item, 0);
				}
			}
			_expired.Clear();
		}
	}
	internal sealed class Entry
	{
		public readonly string Name;

		public readonly string NameToken;

		public readonly bool IsEquipment;

		public readonly int Phase;

		public ConfigEntry<bool> Enabled;

		public ItemQualityGroup Group;

		public EquipmentQualityGroup EquipmentGroup;

		public bool Active
		{
			get
			{
				if (!IsEquipment)
				{
					return Object.op_Implicit((Object)(object)Group);
				}
				return Object.op_Implicit((Object)(object)EquipmentGroup);
			}
		}

		public Entry(string name, string nameToken, int phase, bool isEquipment = false)
		{
			Name = name;
			NameToken = nameToken;
			Phase = phase;
			IsEquipment = isEquipment;
		}

		public ItemQualityCounts Counts(Inventory inventory)
		{
			//IL_002c: 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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Group) || !Object.op_Implicit((Object)(object)inventory))
			{
				return ItemQualityCounts.zero;
			}
			try
			{
				return InventoryExtensions.GetItemCountsEffective(inventory, Group);
			}
			catch
			{
				return ItemQualityCounts.zero;
			}
		}

		public ItemQualityCounts Counts(CharacterBody body)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body))
			{
				return ItemQualityCounts.zero;
			}
			return Counts(body.inventory);
		}

		public ItemQualityCounts Counts(CharacterMaster master)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)master))
			{
				return ItemQualityCounts.zero;
			}
			return Counts(master.inventory);
		}
	}
	internal static class Content
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static LoadContentAsyncDelegate <0>__LoadContentAsync;
		}

		public static readonly Entry AmberKnife = new Entry("Amber Knife", "ITEM_SANDSWEPT_AMBER_KNIFE_NAME", 1);

		public static readonly Entry FracturedTimepiece = new Entry("Fractured Timepiece", "ITEM_SANDSWEPT_FRACTURED_TIMEPIECE_NAME", 1);

		public static readonly Entry TemporalTransistor = new Entry("Temporal Transistor", "ITEM_SANDSWEPT_TEMPORAL_TRANSISTOR_NAME", 1);

		public static readonly Entry CrownsDiamond = new Entry("Crowns Diamond", "ITEM_SANDSWEPT_CROWNS_DIAMOND_NAME", 1);

		public static readonly Entry PocketPlutonium = new Entry("Pocket Plutonium", "ITEM_SANDSWEPT_POCKET_PLUTONIUM_NAME", 1);

		public static readonly Entry UniversalVIPPass = new Entry("Universal VIP Pass", "ITEM_SANDSWEPT_UNIVERSAL_VIP_PASS_NAME", 1);

		public static readonly Entry GlacialPlasma = new Entry("Glacial Plasma", "ITEM_SANDSWEPT_GLACIAL_PLASMA_NAME", 1);

		public static readonly Entry BleedingWitness = new Entry("Bleeding Witness", "ITEM_SANDSWEPT_BLEEDING_WITNESS_NAME", 1);

		public static readonly Entry SmoulderingDocument = new Entry("Smouldering Document", "ITEM_SANDSWEPT_SMOULDERING_DOCUMENT_NAME", 2);

		public static readonly Entry SunFragment = new Entry("Sun Fragment", "ITEM_SANDSWEPT_SUN_FRAGMENT_NAME", 2);

		public static readonly Entry RedSpringWater = new Entry("Red Spring Water", "ITEM_SANDSWEPT_RED_SPRING_WATER_NAME", 2);

		public static readonly Entry DriftingPerception = new Entry("Drifting Perception", "ITEM_SANDSWEPT_DRIFTING_PERCEPTION_NAME", 2);

		public static readonly Entry SacrificialBand = new Entry("Sacrificial Band", "ITEM_SANDSWEPT_SACRIFICIAL_BAND_NAME", 2);

		public static readonly Entry NuclearSalvo = new Entry("Nuclear Salvo", "ITEM_SANDSWEPT_NUCLEAR_SALVO_NAME", 2);

		public static readonly Entry SandSweeper = new Entry("The Sand Sweeper", "EQUIPMENT_SANDSWEPT_THE_SAND_SWEEPER_NAME", 2, isEquipment: true);

		public static readonly Entry FesteringHunger = new Entry("Festering Hunger", "ITEM_SANDSWEPT_FESTERING_HUNGER_NAME", 2);

		public static readonly Entry Millenium = new Entry("Millenium", "ITEM_SANDSWEPT_MILLENIUM_NAME", 3);

		public static readonly Entry PreservedAtoll = new Entry("Preserved Atoll", "ITEM_SANDSWEPT_PRESERVED_ATOLL_NAME", 3);

		public static readonly Entry MakeshiftPlate = new Entry("Makeshift Plate", "ITEM_SANDSWEPT_MAKESHIFT_PLATE_NAME", 3);

		public static readonly Entry CeremonialJar = new Entry("Ceremonial Jar", "ITEM_SANDSWEPT_CEREMONIAL_JAR_NAME", 3);

		public static readonly Entry TornFeather = new Entry("Torn Feather", "ITEM_SANDSWEPT_TORN_FEATHER_NAME", 3);

		public static readonly Entry GalvanicCellShield = new Entry("Galvanic Cell Shield", "EQUIPMENT_SANDSWEPT_GALVANIC_CELL_SHIELD_NAME", 3, isEquipment: true);

		public static readonly Entry[] All = new Entry[22]
		{
			AmberKnife, FracturedTimepiece, TemporalTransistor, CrownsDiamond, PocketPlutonium, UniversalVIPPass, GlacialPlasma, BleedingWitness, SmoulderingDocument, SunFragment,
			RedSpringWater, DriftingPerception, SacrificialBand, NuclearSalvo, SandSweeper, FesteringHunger, Millenium, PreservedAtoll, MakeshiftPlate, CeremonialJar,
			TornFeather, GalvanicCellShield
		};

		private const string SelfCheckToken = "ITEM_SANDSWEPT_SELF_CHECK_MISSING_NAME";

		public static void BindConfig(ConfigFile config)
		{
			Entry[] all = All;
			foreach (Entry entry in all)
			{
				string text = (entry.IsEquipment ? "Equipment" : "Items");
				entry.Enabled = config.Bind<bool>(text, entry.Name, true, "Give " + entry.Name + " quality tiers and their extra mechanic. Takes effect on the next game start.");
			}
		}

		public static void Register()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__LoadContentAsync;
			if (obj == null)
			{
				LoadContentAsyncDelegate val = LoadContentAsync;
				<>O.<0>__LoadContentAsync = val;
				obj = (object)val;
			}
			QualityContentManager.LoadContentAsync += (LoadContentAsyncDelegate)obj;
		}

		private static IEnumerator LoadContentAsync(QualityContentLoadArgs args)
		{
			try
			{
				RegisterAll(args);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Quality registration failed; Sandswept items stay without quality: " + ex));
			}
			args.ProgressReceiver?.Report(1f);
			yield break;
		}

		private static void RegisterAll(QualityContentLoadArgs args)
		{
			Dictionary<string, ItemDef> dictionary = new Dictionary<string, ItemDef>();
			ItemDef[] array = Resources.FindObjectsOfTypeAll<ItemDef>();
			foreach (ItemDef val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && !string.IsNullOrEmpty(val.nameToken) && !dictionary.ContainsKey(val.nameToken))
				{
					dictionary[val.nameToken] = val;
				}
			}
			Dictionary<string, EquipmentDef> dictionary2 = new Dictionary<string, EquipmentDef>();
			EquipmentDef[] array2 = Resources.FindObjectsOfTypeAll<EquipmentDef>();
			foreach (EquipmentDef val2 in array2)
			{
				if (Object.op_Implicit((Object)(object)val2) && !string.IsNullOrEmpty(val2.nameToken) && !dictionary2.ContainsKey(val2.nameToken))
				{
					dictionary2[val2.nameToken] = val2;
				}
			}
			int[] array3 = new int[4];
			int[] array4 = new int[4];
			Entry[] all = All;
			foreach (Entry entry in all)
			{
				if (!entry.Enabled.Value)
				{
					Plugin.Log.LogInfo((object)(entry.Name + ": disabled in config, no quality group registered."));
					continue;
				}
				try
				{
					ItemDef value2;
					if (entry.IsEquipment)
					{
						if (!dictionary2.TryGetValue(entry.NameToken, out var value))
						{
							Plugin.Log.LogWarning((object)("Sandswept equipment '" + entry.Name + "' (" + entry.NameToken + ") not found; skipped."));
						}
						else
						{
							entry.EquipmentGroup = args.CreateEquipmentQualityGroup(value);
							array4[entry.Phase]++;
						}
					}
					else if (!dictionary.TryGetValue(entry.NameToken, out value2))
					{
						Plugin.Log.LogWarning((object)("Sandswept item '" + entry.Name + "' (" + entry.NameToken + ") not found; skipped."));
					}
					else
					{
						entry.Group = args.CreateItemQualityGroup(value2);
						array3[entry.Phase]++;
					}
				}
				catch (Exception arg)
				{
					Plugin.Log.LogError((object)$"Failed to register {entry.Name} with Quality; skipped: {arg}");
				}
			}
			if (!dictionary.ContainsKey("ITEM_SANDSWEPT_SELF_CHECK_MISSING_NAME"))
			{
				Plugin.Log.LogWarning((object)"Self-check: Sandswept item 'ITEM_SANDSWEPT_SELF_CHECK_MISSING_NAME' not found; skipped (expected, the other items are unaffected).");
			}
			Plugin.Log.LogInfo((object)$"Registered {array3[1]} Sandswept items with Quality (phase 1).");
			Plugin.Log.LogInfo((object)$"Registered {array3[2]} Sandswept items and {array4[2]} equipment with Quality (phase 2).");
			Plugin.Log.LogInfo((object)$"Registered {array3[3]} Sandswept items and {array4[3]} equipment with Quality (phase 3).");
			int num = array3[1] + array3[2] + array3[3];
			int num2 = array4[1] + array4[2] + array4[3];
			Plugin.Log.LogInfo((object)$"Registered {num + num2} Sandswept entries with Quality in total ({num} items, {num2} equipment).");
		}
	}
	internal static class Q
	{
		public static float Sum(in ItemQualityCounts c, float uncommon, float rare, float epic, float legendary)
		{
			return (float)c.UncommonCount * uncommon + (float)c.RareCount * rare + (float)c.EpicCount * epic + (float)c.LegendaryCount * legendary;
		}

		public static float SumCapped(in ItemQualityCounts c, float uncommon, float rare, float epic, float legendary, float cap)
		{
			return Mathf.Min(Sum(in c, uncommon, rare, epic, legendary), cap);
		}

		public static float ByHighest(in ItemQualityCounts c, float uncommon, float rare, float epic, float legendary)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected I4, but got Unknown
			QualityTier highestQuality = ((ItemQualityCounts)(ref c)).HighestQuality;
			return (int)highestQuality switch
			{
				0 => uncommon, 
				1 => rare, 
				2 => epic, 
				3 => legendary, 
				_ => 0f, 
			};
		}

		public static float ByTier(QualityTier tier, float uncommon, float rare, float epic, float legendary)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected I4, but got Unknown
			return (int)tier switch
			{
				0 => uncommon, 
				1 => rare, 
				2 => epic, 
				3 => legendary, 
				_ => 0f, 
			};
		}
	}
	[BepInPlugin("lz.SandsweptQuality", "SandsweptQuality", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "lz.SandsweptQuality";

		public const string PluginName = "SandsweptQuality";

		public const string PluginVersion = "1.1.0";

		public const string QualityGUID = "com.Gorakh.ItemQualities";

		public const string SandsweptGUID = "com.TeamSandswept.Sandswept";

		internal static ManualLogSource Log;

		public void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Content.BindConfig(((BaseUnityPlugin)this).Config);
			string langFolder = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "lang");
			if (Directory.Exists(langFolder))
			{
				Language.collectLanguageRootFolders += delegate(List<string> folders)
				{
					folders.Add(langFolder);
				};
			}
			else
			{
				Log.LogError((object)("Language folder missing: " + langFolder));
			}
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				try
				{
					RiskOfOptionsCompat.Init(((BaseUnityPlugin)this).Info.Location);
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Risk of Options setup failed: " + ex.Message));
				}
			}
			Content.Register();
			Buffs.Register();
			NetworkingAPI.RegisterMessageType<TransistorPulseMessage>();
			Action[] array = new Action[23]
			{
				Hooks.Init,
				AmberKnife.Init,
				FracturedTimepiece.Init,
				TemporalTransistor.Init,
				CrownsDiamond.Init,
				PocketPlutonium.Init,
				UniversalVIPPass.Init,
				GlacialPlasma.Init,
				BleedingWitness.Init,
				SmoulderingDocument.Init,
				SunFragment.Init,
				RedSpringWater.Init,
				DriftingPerception.Init,
				SacrificialBand.Init,
				NuclearSalvo.Init,
				SandSweeper.Init,
				FesteringHunger.Init,
				Millenium.Init,
				PreservedAtoll.Init,
				MakeshiftPlate.Init,
				CeremonialJar.Init,
				TornFeather.Init,
				GalvanicCellShield.Init
			};
			foreach (Action action in array)
			{
				try
				{
					action();
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"Failed to set up {action.Method.DeclaringType?.Name}: {arg}");
				}
			}
		}
	}
	internal static class RiskOfOptionsCompat
	{
		internal const string GUID = "com.rune580.riskofoptions";

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void Init(string pluginLocation)
		{
			//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_0056: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Quality tiers for Sandswept items, each with one extra mechanic. Toggles apply on the next game start.", "lz.SandsweptQuality", "SandsweptQuality");
			Sprite val = LoadIcon(pluginLocation);
			if (Object.op_Implicit((Object)(object)val))
			{
				ModSettingsManager.SetModIcon(val, "lz.SandsweptQuality", "SandsweptQuality");
			}
			Entry[] all = Content.All;
			for (int i = 0; i < all.Length; i++)
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(all[i].Enabled, new CheckBoxConfig
				{
					restartRequired = true
				}), "lz.SandsweptQuality", "SandsweptQuality");
			}
		}

		private static Sprite LoadIcon(string pluginLocation)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_006e: 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)
			try
			{
				string path = Path.Combine(Path.GetDirectoryName(pluginLocation), "icon.png");
				if (!File.Exists(path))
				{
					path = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(pluginLocation)), "icon.png");
				}
				if (!File.Exists(path))
				{
					return null;
				}
				Texture2D val = new Texture2D(2, 2);
				if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
				{
					return null;
				}
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			catch
			{
				return null;
			}
		}
	}
}
namespace SandsweptQuality.Effects
{
	internal static class Hooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TakeDamage <0>__HealthComponent_TakeDamage;

			public static hook_Fire <1>__BlastAttack_Fire;
		}

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: 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_003b: Expected O, but got Unknown
			object obj = <>O.<0>__HealthComponent_TakeDamage;
			if (obj == null)
			{
				hook_TakeDamage val = HealthComponent_TakeDamage;
				<>O.<0>__HealthComponent_TakeDamage = val;
				obj = (object)val;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj;
			object obj2 = <>O.<1>__BlastAttack_Fire;
			if (obj2 == null)
			{
				hook_Fire val2 = BlastAttack_Fire;
				<>O.<1>__BlastAttack_Fire = val2;
				obj2 = (object)val2;
			}
			BlastAttack.Fire += (hook_Fire)obj2;
		}

		private static void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			bool flag = false;
			try
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)self) && damageInfo != null && !damageInfo.rejected && damageInfo.damage > 0f)
				{
					flag = self.shield > 1f;
					CharacterBody val = (Object.op_Implicit((Object)(object)damageInfo.attacker) ? damageInfo.attacker.GetComponent<CharacterBody>() : null);
					float num = 1f;
					num *= PocketPlutonium.DamageTakenMultiplier(self.body);
					if (Object.op_Implicit((Object)(object)val))
					{
						num *= GlacialPlasma.DamageMultiplier(val, self);
						num *= CrownsDiamond.DamageMultiplier(val);
					}
					if (num != 1f)
					{
						damageInfo.damage *= num;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("TakeDamage prefix: " + ex));
			}
			orig.Invoke(self, damageInfo);
			try
			{
				if (flag && NetworkServer.active)
				{
					PocketPlutonium.AfterDamage(self);
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)("TakeDamage postfix: " + ex2));
			}
		}

		private static Result BlastAttack_Fire(orig_Fire orig, BlastAttack self)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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)
			try
			{
				if (NetworkServer.active && self != null)
				{
					SunFragment.ModifyBlast(self);
					NuclearSalvo.ModifyBlast(self);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("BlastAttack prefix: " + ex));
			}
			Result result = orig.Invoke(self);
			try
			{
				if (NetworkServer.active && self != null)
				{
					Millenium.AfterBlast(self, result);
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)("BlastAttack postfix: " + ex2));
			}
			return result;
		}

		public static void ForEachEnemyInRadius(Vector3 origin, float radius, TeamIndex team, Action<CharacterBody> action, int max = int.MaxValue, GameObject exclude = null)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0034: 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_0036: 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_0048: 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)
			SphereSearch val = new SphereSearch
			{
				origin = origin,
				radius = radius
			};
			LayerIndex entityPrecise = LayerIndex.entityPrecise;
			val.mask = ((LayerIndex)(ref entityPrecise)).mask;
			val.queryTriggerInteraction = (QueryTriggerInteraction)0;
			val.RefreshCandidates();
			val.FilterCandidatesByHurtBoxTeam(TeamMask.GetEnemyTeams(team));
			val.FilterCandidatesByDistinctHurtBoxEntities();
			val.OrderCandidatesByDistance();
			HurtBox[] hurtBoxes = val.GetHurtBoxes();
			val.ClearCandidates();
			int num = 0;
			HurtBox[] array = hurtBoxes;
			foreach (HurtBox val2 in array)
			{
				if (num < max)
				{
					HealthComponent val3 = (Object.op_Implicit((Object)(object)val2) ? val2.healthComponent : null);
					if (Object.op_Implicit((Object)(object)val3) && val3.alive && Object.op_Implicit((Object)(object)val3.body) && !((Object)(object)((Component)val3).gameObject == (Object)(object)exclude))
					{
						action(val3.body);
						num++;
					}
					continue;
				}
				break;
			}
		}

		public static TeamIndex TeamOf(CharacterBody body)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent))
			{
				return (TeamIndex)(-1);
			}
			return body.teamComponent.teamIndex;
		}
	}
	internal static class AmberKnife
	{
		public static void Init()
		{
			GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
		}

		private static void OnServerDamageDealt(DamageReport report)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Content.AmberKnife.Active || (Object)(object)report?.attackerBody == (Object)null || !Object.op_Implicit((Object)(object)report.victimBody))
				{
					return;
				}
				ItemQualityCounts c = Content.AmberKnife.Counts(report.attackerBody);
				if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0)
				{
					return;
				}
				if (report.victimBody.HasBuff(Buffs.AmberEncased) && Object.op_Implicit((Object)(object)report.attackerBody.healthComponent))
				{
					float num = Q.SumCapped(in c, 0.01f, 0.02f, 0.04f, 0.08f, 0.25f);
					float num2 = report.damageDealt * num;
					if (num2 > 0f)
					{
						report.attackerBody.healthComponent.AddBarrier(num2);
					}
				}
				float num3 = ((report.damageInfo != null) ? report.damageInfo.procCoefficient : 0f);
				if (num3 > 0f && Object.op_Implicit((Object)(object)report.victim) && report.victim.alive && Util.CheckRoll(12f * num3, report.attackerMaster))
				{
					int value = Mathf.RoundToInt(Q.SumCapped(in c, 30f, 45f, 65f, 90f, 90f));
					float duration = Q.ByHighest(in c, 2f, 2.5f, 3f, 4f);
					Buffs.ApplyMagnitude(report.victimBody, Buffs.AmberEncased, value, duration);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Amber Knife: " + ex));
			}
		}
	}
	internal static class FracturedTimepiece
	{
		public static void Init()
		{
			CharacterBody.onBodyStartGlobal += delegate(CharacterBody body)
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					body.onSkillActivatedServer += delegate(GenericSkill skill)
					{
						OnSkillServer(body, skill);
					};
					body.onSkillActivatedAuthority += delegate(GenericSkill skill)
					{
						OnSkillAuthority(body, skill);
					};
				}
			};
		}

		private static bool IsUtility(CharacterBody body, GenericSkill skill)
		{
			if (Object.op_Implicit((Object)(object)skill) && Object.op_Implicit((Object)(object)body.skillLocator))
			{
				return (Object)(object)skill == (Object)(object)body.skillLocator.utility;
			}
			return false;
		}

		private static void OnSkillServer(CharacterBody body, GenericSkill skill)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Content.FracturedTimepiece.Active && Object.op_Implicit((Object)(object)body) && IsUtility(body, skill))
				{
					ItemQualityCounts c = Content.FracturedTimepiece.Counts(body);
					if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
					{
						int value = Mathf.RoundToInt(Q.SumCapped(in c, 20f, 35f, 60f, 100f, 200f));
						Buffs.ApplyMagnitude(body, Buffs.TimepieceRush, value, 3f);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Fractured Timepiece (server): " + ex));
			}
		}

		private static void OnSkillAuthority(CharacterBody body, GenericSkill skill)
		{
			//IL_0028: 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)
			try
			{
				if (!Content.FracturedTimepiece.Active || !Object.op_Implicit((Object)(object)body) || !IsUtility(body, skill))
				{
					return;
				}
				ItemQualityCounts c = Content.FracturedTimepiece.Counts(body);
				if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
				{
					GenericSkill special = body.skillLocator.special;
					if (Object.op_Implicit((Object)(object)special) && special.stock < special.maxStock)
					{
						float num = Q.SumCapped(in c, 0.05f, 0.1f, 0.2f, 0.35f, 0.6f);
						int num2 = Mathf.Max(1, (!Object.op_Implicit((Object)(object)skill.skillDef)) ? 1 : skill.skillDef.baseMaxStock);
						special.rechargeStopwatch += special.GetFinalRechargeInterval() * num / (float)num2;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Fractured Timepiece (authority): " + ex));
			}
		}
	}
	internal static class TemporalTransistor
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_ProcessJump_bool <0>__ProcessJump;
		}

		private const float Interval = 0.5f;

		private static readonly Dictionary<CharacterBody, float> _lastAuthorityJump = new Dictionary<CharacterBody, float>();

		private static readonly Dictionary<CharacterBody, float> _lastServerPulse = new Dictionary<CharacterBody, float>();

		private static readonly FieldInfo _jumpInputReceived = typeof(GenericCharacterMain).GetField("jumpInputReceived", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__ProcessJump;
			if (obj == null)
			{
				hook_ProcessJump_bool val = ProcessJump;
				<>O.<0>__ProcessJump = val;
				obj = (object)val;
			}
			GenericCharacterMain.ProcessJump_bool += (hook_ProcessJump_bool)obj;
			Stage.onStageStartGlobal += delegate
			{
				_lastAuthorityJump.Clear();
				_lastServerPulse.Clear();
			};
		}

		private static bool JumpInputReceived(GenericCharacterMain state)
		{
			if (!(_jumpInputReceived == null))
			{
				return (bool)_jumpInputReceived.GetValue(state);
			}
			return true;
		}

		private static void ProcessJump(orig_ProcessJump_bool orig, GenericCharacterMain self, bool ignoreRequirements)
		{
			//IL_006d: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = null;
			CharacterMotor val2 = null;
			bool flag = false;
			bool flag2 = false;
			int num = 0;
			try
			{
				if (Content.TemporalTransistor.Active && self != null && Object.op_Implicit((Object)(object)((EntityState)self).outer) && JumpInputReceived(self))
				{
					val = ((EntityState)self).outer.commonComponents.characterBody;
				}
				if (Object.op_Implicit((Object)(object)val) && val.hasEffectiveAuthority)
				{
					val2 = val.characterMotor;
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2))
					{
						ItemQualityCounts val3 = Content.TemporalTransistor.Counts(val);
						if (((ItemQualityCounts)(ref val3)).TotalQualityCount > 0)
						{
							flag = true;
							flag2 = val2.isGrounded;
							num = val2.jumpCount;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Temporal Transistor (pre-jump): " + ex));
			}
			orig.Invoke(self, ignoreRequirements);
			if (!flag)
			{
				return;
			}
			try
			{
				if (!Object.op_Implicit((Object)(object)val2) || val2.jumpCount <= num || flag2)
				{
					return;
				}
				float time = Time.time;
				if (_lastAuthorityJump.TryGetValue(val, out var value) && time - value < 0.5f)
				{
					return;
				}
				_lastAuthorityJump[val] = time;
				float num2 = Q.SumCapped(Content.TemporalTransistor.Counts(val), 0.25f, 0.5f, 1f, 2f, 3f);
				if (Object.op_Implicit((Object)(object)val.skillLocator))
				{
					GenericSkill[] allSkills = val.skillLocator.AllSkills;
					foreach (GenericSkill val4 in allSkills)
					{
						if (Object.op_Implicit((Object)(object)val4) && val4.stock < val4.maxStock)
						{
							val4.RunRecharge(num2);
						}
					}
				}
				if (NetworkServer.active)
				{
					ServerPulse(val);
				}
				else if (Object.op_Implicit((Object)(object)val.networkIdentity))
				{
					NetMessageExtensions.Send((INetMessage)(object)new TransistorPulseMessage(val.networkIdentity.netId), (NetworkDestination)2);
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)("Temporal Transistor (jump): " + ex2));
			}
		}

		public static void ServerPulse(CharacterBody body)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			ItemQualityCounts c = Content.TemporalTransistor.Counts(body);
			if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0)
			{
				return;
			}
			float time = Time.time;
			if (!_lastServerPulse.TryGetValue(body, out var value) || !(time - value < 0.4f))
			{
				_lastServerPulse[body] = time;
				float radius = Q.ByHighest(in c, 8f, 10f, 14f, 20f);
				Hooks.ForEachEnemyInRadius(body.corePosition, radius, Hooks.TeamOf(body), delegate(CharacterBody enemy)
				{
					Buffs.ApplyMagnitude(enemy, Buffs.TimeSlowed, 50, 2f);
				});
			}
		}
	}
	internal sealed class TransistorPulseMessage : INetMessage, ISerializableObject
	{
		private NetworkInstanceId _bodyId;

		public TransistorPulseMessage()
		{
		}

		public TransistorPulseMessage(NetworkInstanceId bodyId)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			_bodyId = bodyId;
		}

		public void Serialize(NetworkWriter writer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(_bodyId);
		}

		public void Deserialize(NetworkReader reader)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			_bodyId = reader.ReadNetworkId();
		}

		public void OnReceived()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active)
				{
					GameObject val = Util.FindNetworkObject(_bodyId);
					TemporalTransistor.ServerPulse(Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Temporal Transistor (pulse message): " + ex));
			}
		}
	}
	internal static class CrownsDiamond
	{
		internal sealed class CrownsDiamondQualityBehavior : ItemBehavior
		{
			private void FixedUpdate()
			{
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)base.body) && base.stack > 0 && !(_outOfDangerStopwatch == null))
					{
						float num = Q.SumCapped(Content.CrownsDiamond.Counts(base.body), 1f, 2f, 3.5f, 5f, 6f);
						float num2 = (float)_outOfDangerStopwatch.GetValue(base.body);
						if (num2 < 7f && num2 >= 7f - num)
						{
							_outOfDangerStopwatch.SetValue(base.body, 7f);
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Crown's Diamond (behavior): " + ex));
					((Behaviour)this).enabled = false;
				}
			}
		}

		private const float VanillaDelay = 7f;

		private static FieldInfo _outOfDangerStopwatch;

		public static void Init()
		{
			_outOfDangerStopwatch = typeof(CharacterBody).GetField("outOfDangerStopwatch", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (_outOfDangerStopwatch == null)
			{
				Plugin.Log.LogWarning((object)"Crown's Diamond: CharacterBody.outOfDangerStopwatch not found; the sooner out-of-danger part is off.");
			}
			CharacterBody.onBodyInventoryChangedGlobal += delegate(CharacterBody body)
			{
				//IL_0031: 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)
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && !(_outOfDangerStopwatch == null) && Content.CrownsDiamond.Active)
					{
						ItemQualityCounts val = Content.CrownsDiamond.Counts(body);
						body.AddItemBehavior<CrownsDiamondQualityBehavior>(((ItemQualityCounts)(ref val)).TotalQualityCount);
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Crown's Diamond: " + ex));
				}
			};
		}

		public static float DamageMultiplier(CharacterBody attacker)
		{
			//IL_0037: 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)
			if (!Content.CrownsDiamond.Active || !Object.op_Implicit((Object)(object)attacker.healthComponent) || attacker.healthComponent.barrier <= 0f)
			{
				return 1f;
			}
			ItemQualityCounts c = Content.CrownsDiamond.Counts(attacker);
			if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0)
			{
				return 1f;
			}
			return 1f + Q.SumCapped(in c, 0.05f, 0.1f, 0.2f, 0.35f, 1f);
		}
	}
	internal static class PocketPlutonium
	{
		public static void Init()
		{
		}

		public static float DamageTakenMultiplier(CharacterBody victim)
		{
			if (!Object.op_Implicit((Object)(object)victim))
			{
				return 1f;
			}
			int buffCount = victim.GetBuffCount(Buffs.Irradiated);
			if (buffCount <= 0)
			{
				return 1f;
			}
			return 1f + (float)Mathf.Min(buffCount, 150) / 100f;
		}

		public static void AfterDamage(HealthComponent hc)
		{
			//IL_0053: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!Content.PocketPlutonium.Active || !Object.op_Implicit((Object)(object)hc) || !hc.alive || hc.shield > 1f)
			{
				return;
			}
			CharacterBody body = hc.body;
			if (!Object.op_Implicit((Object)(object)body) || body.HasBuff(Buffs.PlutoniumRecharge))
			{
				return;
			}
			ItemQualityCounts c = Content.PocketPlutonium.Counts(body);
			if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
			{
				float num = Q.SumCapped(in c, 0.5f, 0.75f, 1.25f, 2f, 3f);
				body.AddTimedBuff(Buffs.Immune, num);
				body.AddTimedBuff(Buffs.PlutoniumRecharge, 20f);
				int amp = Mathf.RoundToInt(Q.SumCapped(in c, 10f, 20f, 40f, 75f, 150f));
				Hooks.ForEachEnemyInRadius(body.corePosition, 20f, Hooks.TeamOf(body), delegate(CharacterBody enemy)
				{
					Buffs.ApplyMagnitude(enemy, Buffs.Irradiated, amp, 4f);
				});
			}
		}
	}
	internal static class UniversalVIPPass
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 <0>__CreatePickupDroplet;
		}

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__CreatePickupDroplet;
			if (obj == null)
			{
				hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 val = CreatePickupDroplet;
				<>O.<0>__CreatePickupDroplet = val;
				obj = (object)val;
			}
			PickupDropletController.CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 += (hook_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3)obj;
		}

		private static void CreatePickupDroplet(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007f: 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_0093: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && Content.UniversalVIPPass.Active && Object.op_Implicit((Object)(object)pickupInfo.chest) && IsCategoryChest(((Component)pickupInfo.chest).gameObject))
				{
					float num = BestTeamChance();
					if (num > 0f && Util.CheckRoll(num * 100f, 0f, (CharacterMaster)null))
					{
						PickupIndex pickupIndex = ((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex;
						QualityTier qualityTier = QualityCatalog.GetQualityTier(pickupIndex);
						if ((int)qualityTier < 3)
						{
							PickupIndex pickupIndexOfQuality = QualityCatalog.GetPickupIndexOfQuality(pickupIndex, (QualityTier)(qualityTier + 1));
							if (pickupIndexOfQuality != pickupIndex && ((PickupIndex)(ref pickupIndexOfQuality)).isValid)
							{
								UniquePickup pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
								pickup.pickupIndex = pickupIndexOfQuality;
								((CreatePickupInfo)(ref pickupInfo)).pickup = pickup;
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Universal VIP Pass: " + ex));
			}
			orig.Invoke(pickupInfo, position, velocity);
		}

		private static bool IsCategoryChest(GameObject chest)
		{
			if (!Object.op_Implicit((Object)(object)chest))
			{
				return false;
			}
			PurchaseInteraction component = chest.GetComponent<PurchaseInteraction>();
			if (Object.op_Implicit((Object)(object)component) && ((component.displayNameToken ?? "").ToLower().Contains("category") || (component.contextToken ?? "").ToLower().Contains("category")))
			{
				return true;
			}
			GenericDisplayNameProvider component2 = chest.GetComponent<GenericDisplayNameProvider>();
			if (Object.op_Implicit((Object)(object)component2) && (component2.displayToken ?? "").ToLower().Contains("category"))
			{
				return true;
			}
			return ((Object)chest).name.ToLower().Contains("category");
		}

		private static float BestTeamChance()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterMaster val = (Object.op_Implicit((Object)(object)instance) ? instance.master : null);
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.GetBody()))
				{
					ItemQualityCounts c = Content.UniversalVIPPass.Counts(val);
					if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
					{
						num = Mathf.Max(num, Q.SumCapped(in c, 0.1f, 0.2f, 0.35f, 0.6f, 0.9f));
					}
				}
			}
			return num;
		}
	}
	internal static class GlacialPlasma
	{
		private static float _baseChance = 6f;

		private static float _freezeDuration = 3f;

		public static void Init()
		{
			try
			{
				Type type = Type.GetType("Sandswept.Items.Reds.GlacialPlasma, Sandswept");
				object obj = type?.GetField("stunToFreezeChance", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
				object obj2 = type?.GetField("stunToFreezeDuration", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
				RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
				{
					try
					{
						object obj3 = type?.GetField("stunToFreezeChance", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
						object obj4 = type?.GetField("stunToFreezeDuration", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
						if (obj3 is float baseChance2)
						{
							_baseChance = baseChance2;
						}
						if (obj4 is float num2 && num2 > 0f)
						{
							_freezeDuration = num2;
						}
					}
					catch
					{
					}
				});
				if (obj is float baseChance)
				{
					_baseChance = baseChance;
				}
				if (obj2 is float num && num > 0f)
				{
					_freezeDuration = num;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Glacial Plasma: could not read Sandswept's freeze settings, using 6% / 3 s: " + ex.Message));
			}
			GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
		}

		public static float DamageMultiplier(CharacterBody attacker, HealthComponent victim)
		{
			//IL_0028: 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)
			if (!Content.GlacialPlasma.Active || !Object.op_Implicit((Object)(object)victim) || !victim.isInFrozenState)
			{
				return 1f;
			}
			ItemQualityCounts c = Content.GlacialPlasma.Counts(attacker);
			if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0)
			{
				return 1f;
			}
			return 1f + Q.SumCapped(in c, 0.2f, 0.4f, 0.8f, 1.5f, 3f);
		}

		private static void OnServerDamageDealt(DamageReport report)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!Content.GlacialPlasma.Active || !Object.op_Implicit((Object)(object)report?.attackerBody) || !Object.op_Implicit((Object)(object)report.victimBody) || !Object.op_Implicit((Object)(object)report.victim) || !report.victim.alive)
				{
					return;
				}
				ItemQualityCounts c = Content.GlacialPlasma.Counts(report.attackerBody);
				SetStateOnHurt val = default(SetStateOnHurt);
				if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0 || !((Component)report.victimBody).TryGetComponent<SetStateOnHurt>(ref val) || !Object.op_Implicit((Object)(object)val.targetStateMachine))
				{
					return;
				}
				EntityState state = val.targetStateMachine.state;
				if (state is StunState || state is ShockState)
				{
					float num = Q.SumCapped(in c, 10f, 15f, 25f, 40f, 75f) / 100f;
					float num2 = Mathf.Clamp01(_baseChance / 100f);
					if (!(num <= num2) && Util.CheckRoll((num - num2) / (1f - num2) * 100f, report.attackerMaster))
					{
						val.SetFrozen(_freezeDuration);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Glacial Plasma: " + ex));
			}
		}
	}
	internal static class BleedingWitness
	{
		private struct Spread
		{
			public DotIndex DotIndex;

			public float Timer;

			public float Damage;

			public float Coefficient;
		}

		private const float Radius = 15f;

		private const int MaxStacksPerType = 5;

		private static FieldInfo _dotStackList;

		private static FieldInfo _dotIndex;

		private static FieldInfo _attackerObject;

		private static FieldInfo _timer;

		private static FieldInfo _damage;

		private static FieldInfo _dotDef;

		private static bool _broken;

		private static readonly Dictionary<GameObject, float> _spreadRecipients = new Dictionary<GameObject, float>();

		private const float MaxMultiplier = 3f;

		private static readonly List<GameObject> _stale = new List<GameObject>();

		public static void Init()
		{
			_dotStackList = typeof(DotController).GetField("dotStackList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			Type nestedType = typeof(DotController).GetNestedType("DotStack", BindingFlags.Public | BindingFlags.NonPublic);
			if (nestedType != null)
			{
				_dotIndex = nestedType.GetField("dotIndex", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_attackerObject = nestedType.GetField("attackerObject", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_timer = nestedType.GetField("timer", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_damage = nestedType.GetField("damage", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				_dotDef = nestedType.GetField("dotDef", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			}
			if (_dotStackList == null || _dotIndex == null || _attackerObject == null || _timer == null || _damage == null || _dotDef == null)
			{
				Plugin.Log.LogWarning((object)"Bleeding Witness: DotController layout changed; the DoT spread is off.");
				_broken = true;
				return;
			}
			GlobalEventManager.onCharacterDeathServer += OnCharacterDeath;
			Stage.onServerStageBegin += delegate
			{
				_spreadRecipients.Clear();
			};
		}

		private static void OnCharacterDeath(DamageReport report)
		{
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			if (_broken || !NetworkServer.active || !Content.BleedingWitness.Active || report == null || !Object.op_Implicit((Object)(object)report.victimBody))
			{
				return;
			}
			try
			{
				GameObject gameObject = ((Component)report.victimBody).gameObject;
				if (_spreadRecipients.TryGetValue(gameObject, out var value))
				{
					_spreadRecipients.Remove(gameObject);
					if (Time.fixedTime < value)
					{
						return;
					}
				}
				DotController val = DotController.FindDotController(gameObject);
				if (!Object.op_Implicit((Object)(object)val) || !(_dotStackList.GetValue(val) is IList { Count: not 0 } list))
				{
					return;
				}
				Dictionary<GameObject, List<Spread>> dictionary = new Dictionary<GameObject, List<Spread>>();
				foreach (object item in list)
				{
					object? value2 = _attackerObject.GetValue(item);
					GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						if (!dictionary.TryGetValue(val2, out var value3))
						{
							value3 = (dictionary[val2] = new List<Spread>());
						}
						object? value4 = _dotDef.GetValue(item);
						DotDef val3 = (DotDef)((value4 is DotDef) ? value4 : null);
						value3.Add(new Spread
						{
							DotIndex = (DotIndex)_dotIndex.GetValue(item),
							Timer = (float)_timer.GetValue(item),
							Damage = (float)_damage.GetValue(item),
							Coefficient = (val3?.damageCoefficient ?? 0f)
						});
					}
				}
				foreach (KeyValuePair<GameObject, List<Spread>> pair in dictionary)
				{
					CharacterBody attackerBody = pair.Key.GetComponent<CharacterBody>();
					ItemQualityCounts c = Content.BleedingWitness.Counts(attackerBody);
					if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0)
					{
						continue;
					}
					int max = Mathf.RoundToInt(Q.SumCapped(in c, 1f, 2f, 4f, 8f, 16f));
					List<Spread> chosen = PickStacks(pair.Value);
					if (chosen.Count == 0)
					{
						continue;
					}
					Hooks.ForEachEnemyInRadius(report.victimBody.corePosition, 15f, Hooks.TeamOf(attackerBody), delegate(CharacterBody enemy)
					{
						//IL_0038: 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_0065: 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_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_0111: Unknown result type (might be due to invalid IL or missing references)
						//IL_0113: Unknown result type (might be due to invalid IL or missing references)
						Dictionary<DotIndex, int> dictionary2 = CountStacksFrom(((Component)enemy).gameObject, pair.Key);
						float num = 0f;
						foreach (Spread item2 in chosen)
						{
							dictionary2.TryGetValue(item2.DotIndex, out var value5);
							if (value5 < 5)
							{
								dictionary2[item2.DotIndex] = value5 + 1;
								float damageMultiplier = 1f;
								if (!IsHealthBased(item2.DotIndex) && item2.Coefficient > 0f && attackerBody.damage > 0f)
								{
									damageMultiplier = Mathf.Clamp(item2.Damage / (item2.Coefficient * attackerBody.damage), 0.01f, 3f);
								}
								num = Mathf.Max(num, item2.Timer);
								InflictDotInfo val4 = new InflictDotInfo
								{
									victimObject = ((Component)enemy).gameObject,
									attackerObject = pair.Key,
									dotIndex = item2.DotIndex,
									duration = item2.Timer,
									damageMultiplier = damageMultiplier
								};
								DotController.InflictDot(ref val4);
							}
						}
						if (num > 0f)
						{
							float num2 = Time.fixedTime + num;
							if (!_spreadRecipients.TryGetValue(((Component)enemy).gameObject, out var value6) || value6 < num2)
							{
								_spreadRecipients[((Component)enemy).gameObject] = num2;
							}
						}
					}, max, gameObject);
				}
				PruneRecipients();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Bleeding Witness: " + ex));
			}
		}

		private static bool IsHealthBased(DotIndex index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			if ((int)index != 4 && (int)index != 2)
			{
				return (int)index == 3;
			}
			return true;
		}

		private static Dictionary<DotIndex, int> CountStacksFrom(GameObject victim, GameObject attacker)
		{
			//IL_0057: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<DotIndex, int> dictionary = new Dictionary<DotIndex, int>();
			DotController val = DotController.FindDotController(victim);
			if (!Object.op_Implicit((Object)(object)val) || !(_dotStackList.GetValue(val) is IList list))
			{
				return dictionary;
			}
			foreach (object item in list)
			{
				if (_attackerObject.GetValue(item) == attacker)
				{
					DotIndex key = (DotIndex)_dotIndex.GetValue(item);
					dictionary.TryGetValue(key, out var value);
					dictionary[key] = value + 1;
				}
			}
			return dictionary;
		}

		private static void PruneRecipients()
		{
			float fixedTime = Time.fixedTime;
			foreach (KeyValuePair<GameObject, float> spreadRecipient in _spreadRecipients)
			{
				if (!Object.op_Implicit((Object)(object)spreadRecipient.Key) || spreadRecipient.Value <= fixedTime)
				{
					_stale.Add(spreadRecipient.Key);
				}
			}
			foreach (GameObject item in _stale)
			{
				_spreadRecipients.Remove(item);
			}
			_stale.Clear();
		}

		private static List<Spread> PickStacks(List<Spread> all)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			List<Spread> list = new List<Spread>();
			Dictionary<DotIndex, int> dictionary = new Dictionary<DotIndex, int>();
			all.Sort((Spread a, Spread b) => b.Timer.CompareTo(a.Timer));
			foreach (Spread item in all)
			{
				if (!(item.Timer <= 0.1f))
				{
					dictionary.TryGetValue(item.DotIndex, out var value);
					if (value < 5)
					{
						dictionary[item.DotIndex] = value + 1;
						list.Add(item);
					}
				}
			}
			return list;
		}
	}
	internal static class SmoulderingDocument
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_InflictDot_refInflictDotInfo <0>__InflictDot;
		}

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__InflictDot;
			if (obj == null)
			{
				hook_InflictDot_refInflictDotInfo val = InflictDot;
				<>O.<0>__InflictDot = val;
				obj = (object)val;
			}
			DotController.InflictDot_refInflictDotInfo += (hook_InflictDot_refInflictDotInfo)obj;
		}

		private static void InflictDot(orig_InflictDot_refInflictDotInfo orig, ref InflictDotInfo info)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_004b: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			try
			{
				if (NetworkServer.active && Content.SmoulderingDocument.Active && Object.op_Implicit((Object)(object)info.attackerObject) && ((int)info.dotIndex == 1 || (int)info.dotIndex == 7))
				{
					ItemQualityCounts c = Content.SmoulderingDocument.Counts(info.attackerObject.GetComponent<CharacterBody>());
					if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
					{
						float num = 1f + Q.SumCapped(in c, 0.1f, 0.2f, 0.4f, 0.75f, 1.5f);
						info.duration *= num;
						if (info.totalDamage.HasValue)
						{
							info.totalDamage = info.totalDamage.Value * num;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Smouldering Document: " + ex));
			}
			orig.Invoke(ref info);
		}
	}
	internal static class SunFragment
	{
		private static DamageColorIndex? _flashColor;

		public static void Init()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			try
			{
				if (Type.GetType("Sandswept.Items.Greens.SunFragment, Sandswept")?.GetField("SolarFlareColour", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) is DamageColorIndex value)
				{
					_flashColor = value;
				}
				else
				{
					Plugin.Log.LogWarning((object)"Sun Fragment: flash color not found in Sandswept; the radius bonus is off.");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Sun Fragment: " + ex.Message + "; the radius bonus is off."));
			}
		}

		public static void ModifyBlast(BlastAttack blast)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			if (_flashColor.HasValue && Content.SunFragment.Active && blast.damageColorIndex == _flashColor.Value && blast.baseDamage == 0f && Object.op_Implicit((Object)(object)blast.attacker))
			{
				ItemQualityCounts c = Content.SunFragment.Counts(blast.attacker.GetComponent<CharacterBody>());
				if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
				{
					float num = Q.SumCapped(in c, 0.1f, 0.2f, 0.5f, 1f, 1f);
					blast.radius = Mathf.Min(blast.radius * (1f + num), 24f);
				}
			}
		}
	}
	internal static class RedSpringWater
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Heal <0>__Heal;
		}

		private const int MaxBuffs = 5;

		private static readonly Dictionary<CharacterBody, KeyValuePair<float, int>> _cache = new Dictionary<CharacterBody, KeyValuePair<float, int>>();

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__Heal;
			if (obj == null)
			{
				hook_Heal val = Heal;
				<>O.<0>__Heal = val;
				obj = (object)val;
			}
			HealthComponent.Heal += (hook_Heal)obj;
			Stage.onStageStartGlobal += delegate
			{
				_cache.Clear();
			};
		}

		private static float Heal(orig_Heal orig, HealthComponent self, float amount, ProcChainMask procChainMask, bool nonRegen)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && Content.RedSpringWater.Active && Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.body) && amount > 0f)
				{
					ItemQualityCounts c = Content.RedSpringWater.Counts(self.body);
					if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
					{
						int num = CountBuffs(self.body);
						if (num > 0)
						{
							amount *= 1f + Mathf.Min(Q.Sum(in c, 0.02f, 0.04f, 0.1f, 0.2f) * (float)num, 2f);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Red Spring Water: " + ex));
			}
			return orig.Invoke(self, amount, procChainMask, nonRegen);
		}

		private static int CountBuffs(CharacterBody body)
		{
			//IL_0030: 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_0084: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			float fixedTime = Time.fixedTime;
			if (_cache.TryGetValue(body, out var value) && fixedTime - value.Key < 0.25f)
			{
				return value.Value;
			}
			int num = 0;
			for (BuffIndex val = (BuffIndex)0; (int)val < BuffCatalog.buffCount; val = (BuffIndex)(val + 1))
			{
				if (num >= 5)
				{
					break;
				}
				BuffDef buffDef = BuffCatalog.GetBuffDef(val);
				if (Object.op_Implicit((Object)(object)buffDef) && !buffDef.isDebuff && !buffDef.isCooldown && !buffDef.isHidden && !Buffs.OwnBuffs.Contains(buffDef) && body.HasBuff(val))
				{
					num++;
				}
			}
			if (_cache.Count > 256)
			{
				_cache.Clear();
			}
			_cache[body] = new KeyValuePair<float, int>(fixedTime, num);
			return num;
		}
	}
	internal static class DriftingPerception
	{
		internal sealed class DriftingQualityBehavior : ItemBehavior
		{
			public float extendedThisCloak;

			private void FixedUpdate()
			{
				if (Object.op_Implicit((Object)(object)base.body) && !base.body.hasCloakBuff)
				{
					extendedThisCloak = 0f;
				}
			}
		}

		public static void Init()
		{
			GlobalEventManager.onCharacterDeathServer += OnCharacterDeath;
			CharacterBody.onBodyInventoryChangedGlobal += delegate(CharacterBody body)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Content.DriftingPerception.Active)
					{
						ItemQualityCounts val = Content.DriftingPerception.Counts(body);
						body.AddItemBehavior<DriftingQualityBehavior>(((ItemQualityCounts)(ref val)).TotalQualityCount);
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Drifting Perception: " + ex));
				}
			};
		}

		private static void OnCharacterDeath(DamageReport report)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || !Content.DriftingPerception.Active || report == null || !Object.op_Implicit((Object)(object)report.attackerBody))
				{
					return;
				}
				CharacterBody attackerBody = report.attackerBody;
				if (!attackerBody.hasCloakBuff)
				{
					return;
				}
				DriftingQualityBehavior component = ((Component)attackerBody).GetComponent<DriftingQualityBehavior>();
				ItemQualityCounts c = Content.DriftingPerception.Counts(attackerBody);
				if (Object.op_Implicit((Object)(object)component) && ((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
				{
					float num = Q.ByHighest(in c, 2f, 4f, 8f, 12f);
					float num2 = Mathf.Min(Q.Sum(in c, 0.5f, 1f, 2f, 4f), num - component.extendedThisCloak);
					if (!(num2 <= 0f))
					{
						attackerBody.ExtendTimedBuffIfPresent(Buffs.Cloak, num2);
						attackerBody.ExtendTimedBuffIfPresent(Buffs.CloakSpeed, num2);
						component.extendedThisCloak += num2;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Drifting Perception: " + ex));
			}
		}
	}
	internal static class SacrificialBand
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_AddTimedBuff_BuffDef_float <0>__AddTimedBuff;
		}

		private static BuffDef _cooldownBuff;

		public static void Init()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				try
				{
					object? obj2 = Type.GetType("Sandswept.Items.Greens.SacrificialBand, Sandswept")?.GetField("cooldownBuff", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
					_cooldownBuff = (BuffDef)((obj2 is BuffDef) ? obj2 : null);
					if (!Object.op_Implicit((Object)(object)_cooldownBuff))
					{
						Plugin.Log.LogWarning((object)"Sacrificial Band: cooldown buff not found in Sandswept; the recharge cut is off.");
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Sacrificial Band: " + ex.Message + "; the recharge cut is off."));
				}
			});
			object obj = <>O.<0>__AddTimedBuff;
			if (obj == null)
			{
				hook_AddTimedBuff_BuffDef_float val = AddTimedBuff;
				<>O.<0>__AddTimedBuff = val;
				obj = (object)val;
			}
			CharacterBody.AddTimedBuff_BuffDef_float += (hook_AddTimedBuff_BuffDef_float)obj;
		}

		private static void AddTimedBuff(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration)
		{
			//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)
			try
			{
				if (Object.op_Implicit((Object)(object)_cooldownBuff) && (Object)(object)buffDef == (Object)(object)_cooldownBuff && NetworkServer.active && Content.SacrificialBand.Active)
				{
					ItemQualityCounts c = Content.SacrificialBand.Counts(self);
					if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0)
					{
						duration *= 1f - Q.SumCapped(in c, 0.1f, 0.2f, 0.4f, 0.6f, 0.6f);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Sacrificial Band: " + ex));
			}
			orig.Invoke(self, buffDef, duration);
		}
	}
	internal static class NuclearSalvo
	{
		private delegate void orig_OnArrival(Orb self);

		private struct Pending
		{
			public float Multiplier;

			public GameObject Attacker;

			public DamageColorIndex Color;
		}

		private static Hook _hook;

		[ThreadStatic]
		private static Pending _pending;

		public static void Init()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = Type.GetType("Sandswept.Items.Greens.NuclearSalvoOrb, Sandswept")?.GetMethod("OnArrival", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (methodInfo == null)
				{
					Plugin.Log.LogWarning((object)"Nuclear Salvo: NuclearSalvoOrb.OnArrival not found in Sandswept; the damage bonus is off.");
				}
				else
				{
					_hook = new Hook((MethodBase)methodInfo, typeof(NuclearSalvo).GetMethod("OnArrival", BindingFlags.Static | BindingFlags.NonPublic));
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Nuclear Salvo: " + ex.Message + "; the damage bonus is off."));
			}
		}

		private static void OnArrival(orig_OnArrival orig, Orb self)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			Pending pending = _pending;
			try
			{
				_pending = default(Pending);
				if (NetworkServer.active && Content.NuclearSalvo.Active)
				{
					GenericDamageOrb val = (GenericDamageOrb)(object)((self is GenericDamageOrb) ? self : null);
					if (val != null && Object.op_Implicit((Object)(object)val.attacker))
					{
						CharacterMaster component = val.attacker.GetComponent<CharacterMaster>();
						CharacterMaster val2 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.minionOwnership) && Object.op_Implicit((Object)(object)component.minionOwnership.ownerMaster)) ? component.minionOwnership.ownerMaster : component);
						ItemQualityCounts c = Content.NuclearSalvo.Counts(val2);
						if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0 && (Object)(object)val2 != (Object)(object)component)
						{
							c = Content.NuclearSalvo.Counts(component);
						}
						CharacterBody val3 = (Object.op_Implicit((Object)(object)component) ? component.GetBody() : null);
						if (((ItemQualityCounts)(ref c)).TotalQualityCount > 0 && Object.op_Implicit((Object)(object)val3))
						{
							float num = 1f + Q.SumCapped(in c, 0.25f, 0.5f, 1.25f, 2.5f, 4f);
							val.damageValue *= num;
							_pending = new Pending
							{
								Multiplier = num,
								Attacker = ((Component)val3).gameObject,
								Color = val.damageColorIndex
							};
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Nuclear Salvo: " + ex));
				_pending = default(Pending);
			}
			try
			{
				orig(self);
			}
			finally
			{
				_pending = pending;
			}
		}

		public static void ModifyBlast(BlastAttack blast)
		{
			//IL_003b: 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_0052: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			if (!(_pending.Multiplier <= 1f) && Object.op_Implicit((Object)(object)_pending.Attacker) && (Object)(object)blast.attacker == (Object)(object)_pending.Attacker && blast.damageColorIndex == _pending.Color && (blast.damageType.damageType & 0x80) != 0 && (int)blast.falloffModel == 0)
			{
				blast.baseDamage *= _pending.Multiplier;
				_pending = default(Pending);
			}
		}
	}
	internal static class SandSweeper
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static EquipmentActivatedDetailedDelegate <0>__OnEquipmentActivated;
		}

		private const float Radius = 20f;

		public static void Init()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__OnEquipmentActivated;
			if (obj == null)
			{
				EquipmentActivatedDetailedDelegate val = OnEquipmentActivated;
				<>O.<0>__OnEquipmentActivated = val;
				obj = (object)val;
			}
			EquipmentSlot.onServerEquipmentActivatedDetailed += (EquipmentActivatedDetailedDelegate)obj;
		}

		private static void OnEquipmentActivated(EquipmentSlot slot, EquipmentIndex index, in EquipmentLocation location)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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)
			try
			{
				EquipmentQualityGroup equipmentGroup = Content.SandSweeper.EquipmentGroup;
				if (!Object.op_Implicit((Object)(object)equipmentGroup) || !Object.op_Implicit((Object)(object)slot) || !Object.op_Implicit((Object)(object)slot.characterBody) || !Object.op_Implicit((Object)(object)slot.characterBody.inventory) || QualityCatalog.GetEquipmentIndexOfQuality(index, (QualityTier)(-1)) != equipmentGroup.BaseEquipmentIndex)
				{
					return;
				}
				QualityTier qualityTier = QualityCatalog.GetQualityTier(index);
				if ((int)qualityTier > -1)
				{
					int enemies = 0;
					Hooks.ForEachEnemyInRadius(slot.characterBody.corePosition, 20f, Hooks.TeamOf(slot.characterBody), delegate
					{
						enemies++;
					});
					if (enemies != 0)
					{
						float num = Mathf.Min((float)enemies * Q.ByTier(qualityTier, 0.01f, 0.02f, 0.04f, 0.08f), Q.ByTier(qualityTier, 0.2f, 0.3f, 0.45f, 0.6f));
						slot.characterBody.inventory.DeductEquipmentCooldown(ref location, num);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("The Sand Sweeper: " + ex));
			}
		}
	}
	internal static class FesteringHunger
	{
		internal sealed class FesteringQualityBehavior : ItemBehavior
		{
			private float _timer;

			private void FixedUpdate()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Invalid comparison between Unknown and I4
				//IL_0088: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: 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_0117: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)base.body) || base.stack <= 0 || (int)_decay == -1)
				{
					return;
				}
				_timer -= Time.fixedDeltaTime;
				if (_timer > 0f)
				{
					return;
				}
				_timer = 0.5f;
				try
				{
					if (!Object.op_Implicit((Object)(object)base.body.healthComponent) || !base.body.healthComponent.alive)
					{
						return;
					}
					bool flag = false;
					float num = 256f;
					TeamIndex val = Hooks.TeamOf(base.body);
					foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
					{
						if (Object.op_Implicit((Object)(object)readOnlyInstances) && readOnlyInstances.HasBuff(_decay) && Hooks.TeamOf(readOnlyInstances) != val)
						{
							Vector3 val2 = readOnlyInstances.corePosition - base.body.corePosition;
							if (((Vector3)(ref val2)).sqrMagnitude <= num)
							{
								flag = true;
								break;
							}
						}
					}
					if (flag)
					{
						float num2 = Q.SumCapped(Content.FesteringHunger.Counts(base.body), 0.005f, 0.01f, 0.025f, 0.05f, 0.1f);
						base.body.healthComponent.HealFraction(num2 * 0.5f, default(ProcChainMask));
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Festering Hunger (behavior): " + ex));
					((Behaviour)this).enabled = false;
				}
			}
		}

		private const float Range = 16f;

		private const float Tick = 0.5f;

		private static BuffIndex _decay = (BuffIndex)(-1);

		public static void Init()
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Invalid comparison between Unknown and I4
				_decay = BuffCatalog.FindBuffIndex("Decay");
				if ((int)_decay == -1)
				{
					Plugin.Log.LogWarning((object)"Festering Hunger: Sandswept's Decay buff not found; the heal is off.");
				}
			});
			CharacterBody.onBodyInventoryChangedGlobal += delegate(CharacterBody body)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Content.FesteringHunger.Active)
					{
						ItemQualityCounts val = Content.FesteringHunger.Counts(body);
						body.AddItemBehavior<FesteringQualityBehavior>(((ItemQualityCounts)(ref val)).TotalQualityCount);
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Festering Hunger: " + ex));
				}
			};
		}
	}
	internal static class Sandswept
	{
		public const BindingFlags Static = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public const BindingFlags Instance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		public static Type Type(string fullName)
		{
			return System.Type.GetType(fullName + ", Sandswept");
		}

		public static object StaticValue(string typeName, string field)
		{
			return Type(typeName)?.GetField(field, BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
		}
	}
	internal static class Millenium
	{
		private const int MaxTotal = 10;

		private static ModdedProcType? _procType;

		public static void Init()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Sandswept.StaticValue("Sandswept.Items.VoidGreens.Millenium", "millenium") is ModdedProcType value)
				{
					_procType = value;
				}
				else
				{
					Plugin.Log.LogWarning((object)"Millenium: proc type not found in Sandswept; the extra Collapse is off.");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Millenium: " + ex.Message + "; the extra Collapse is off."));
			}
		}

		public static void AfterBlast(BlastAttack blast, Result result)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: 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_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			if (!_procType.HasValue || !Content.Millenium.Active || blast.baseDamage != 0f || !Object.op_Implicit((Object)(object)blast.attacker) || (blast.damageType.damageType & 0x800) == 0 || !ProcTypeAPI.HasModdedProc(blast.procChainMask, _procType.Value))
			{
				return;
			}
			CharacterBody component = blast.attacker.GetComponent<CharacterBody>();
			ItemQualityCounts c = Content.Millenium.Counts(component);
			if (((ItemQualityCounts)(ref c)).TotalQualityCount <= 0 || result.hitPoints == null)
			{
				return;
			}
			int num = Mathf.RoundToInt(Q.SumCapped(in c, 1f, 2f, 3f, 5f, 9f));
			float duration = DotController.GetDotDef((DotIndex)8)?.interval ?? 3f;
			HitPoint[] hitPoints = result.hitPoints;
			foreach (HitPoint val in hitPoints)
			{
				HealthComponent val2 = (Object.op_Implicit((Object)(object)val.hurtBox) ? val.hurtBox.healthComponent : null);
				if (Object.op_Implicit((Object)(object)val2) && val2.alive)
				{
					for (int j = 0; j < num; j++)
					{
						InflictDotInfo val3 = new InflictDotInfo
						{
							victimObject = ((Component)val2).gameObject,
							attackerObject = blast.attacker,
							dotIndex = (DotIndex)8,
							duration = duration,
							damageMultiplier = 1f,
							maxStacksFromAttacker = uint.MaxValue
						};
						DotController.InflictDot(ref val3);
					}
				}
			}
		}
	}
	internal static class PreservedAtoll
	{
		internal sealed class AtollQualityBehavior : ItemBehavior
		{
			public int pendingDecay;

			private void FixedUpdate()
			{
				if (pendingDecay <= 0)
				{
					return;
				}
				int num = pendingDecay;
				pendingDecay = 0;
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)base.body) && Object.op_Implicit((Object)(object)_readyBuff) && base.body.HasBuff(_readyBuff))
					{
						Component component = ((Component)base.body).GetComponent(_controllerType);
						if (Object.op_Implicit((Object)(object)component))
						{
							_applyDecay.Invoke(component, new object[1] { num });
						}
					}
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Preserved Atoll (implode): " + ex));
					((Behaviour)this).enabled = false;
				}
			}
		}

		private static Type _controllerType;

		private static MethodInfo _applyDecay;

		private static BuffDef _readyBuff;

		private static float _baseDivisor = -1f;

		private static float _stackDivisor = -1f;

		private static float _radius = -1f;

		public static void Init()
		{
			try
			{
				_controllerType = Sandswept.Type("Sandswept.Items.VoidGreens.PreservedAtollController");
				_applyDecay = _controllerType?.GetMethod("ApplyDecay", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(int) }, null);
				if (_applyDecay == null)
				{
					Plugin.Log.LogWarning((object)"Preserved Atoll: ApplyDecay not found in Sandswept; the light-hit implosion is off.");
					return;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Preserved Atoll: " + ex.Message + "; the light-hit implosion is off."));
				return;
			}
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				try
				{
					object obj = Sandswept.StaticValue("Sandswept.Items.VoidGreens.PreservedAtoll", "readyBuff");
					_readyBuff = (BuffDef)((obj is BuffDef) ? obj : null);
					if (Sandswept.StaticValue("Sandswept.Items.VoidGreens.PreservedAtoll", "baseHealthDivisor") is float baseDivisor)
					{
						_baseDivisor = baseDivisor;
					}
					if (Sandswept.StaticValue("Sandswept.Items.VoidGreens.PreservedAtoll", "stackHealthDivisor") is float stackDivisor)
					{
						_stackDivisor = stackDivisor;
					}
					if (Sandswept.StaticValue("Sandswept.Items.VoidGreens.PreservedAtoll", "radius") is float radius)
					{
						_radius = radius;
					}
					if (!Object.op_Implicit((Object)(object)_readyBuff) || _baseDivisor <= 0f || _radius <= 0f)
					{
						Plugin.Log.LogWarning((object)"Preserved Atoll: settings not found in Sandswept; the light-hit implosion is off.");
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogWarning((object)("Preserved Atoll: " + ex2.Message + "; the light-hit implosion is off."));
				}
			});
			GlobalEventManager.onServerDamageDealt += OnServerDamageDealt;
			CharacterBody.onBodyInventoryChangedGlobal += delegate(CharacterBody body)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Content.PreservedAtoll.Active)
					{
						ItemQualityCounts val = Content.PreservedAtoll.Counts(body);
						body.AddItemBehavior<AtollQualityBehavior>(((ItemQualityCounts)(ref val)).TotalQualityCount);
					}
				}
				catch (Exception ex2)
				{
					Plugin.Log.LogError((object)("Preserved Atoll: " + ex2));
				}
			};
		}

		private static void OnServerDamageDealt(DamageReport report)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (_applyDecay == null || !Object.op_Implicit((Object)(object)_readyBuff) || _baseDivisor <= 0f || _radius <= 0f || report == null || !Object.op_Implicit((Object)(object)report.victimBody) || !Object.op_Implicit((Object)(object)report.victim) || report.damageInfo == null || !Object.op_Implicit((Object)(object)report.damageInfo.attacker))
				{
					return;
				}
				CharacterBody victimBody = report.victimBody;
				if (!victimBody.HasBuff(_readyBuff))
				{
					return;
				}
				AtollQualityBehavior component = ((Component)victimBody).GetComponent<AtollQualityBehavior>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				int num = (Object.op_Implicit((Object)(object)victimBody.inventory) ? victimBody.inventory.GetItemCountEffective(Content.PreservedAtoll.Group.BaseItemIndex) : 0);
				if (num <= 0)
				{
					return;
				}
				float num2 = _baseDivisor + Mathf.Max(0f, _stackDivisor) * (float)(num - 1);
				float num3 = 100f / num2;
				if (Mathf.RoundToInt(Mathf.Min(report.damageInfo.damage / Mathf.Max(1f, report.victim.fullCombinedHealth) * 100f / num3, 100f / num3)) <= 0)
				{
					bool enemyNear = false;
					Hooks.ForEachEnemyInRadius(victimBody.corePosition, _radius, Hooks.TeamOf(victimBody), delegate
					{
						enemyNear = true;
					}, 1);
					if (enemyNear)
					{
						int num4 = Mathf.RoundToInt(Q.Sum(Content.PreservedAtoll.Counts(victimBody), 1f, 2f, 3f, 5f));
						component.pendingDecay = Mathf.Max(component.pendingDecay, Mathf.Min(num4, Mathf.RoundToInt(num2)));
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("Preserved Atoll: " + ex));
			}
		}
	}
	internal static class MakeshiftPlate
	{
		internal sealed class PlateQualityBehavior : ItemBehavior
		{
			private float _last;

			private bool _armed;

			private void FixedUpdate()
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)base.body) || base.stack <= 0 || _currentPlating == null)
				{
					return;
				}
				try
				{
					Component component = ((Component)base.body).GetComponent(_managerType);
					float num = (Object.op_Implicit((Object)(object)component) ? ((float)_currentPlating.GetValue(component)) : 0f);
					if (num > _last && num > 0f)
					{
						_armed = true;
					}
					if (_armed && _last > 0f && num <= 0f)
					{
						_armed = false;
						Detonate();
					}
					_last = num;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogError((object)("Makeshift Plate (behavior): " + ex));
					((Behaviour)this).enabled = false;
				}
			}

			private void Detonate()
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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_0051: 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_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: 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_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0084: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result