Decompiled source of AllBossRoute v1.7.3

20 Minute Ping.dll

Decompiled 7 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using On.RoR2.UI;
using R2API.Utils;
using RoR2.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("20 Minute Ping")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("20 Minute Ping")]
[assembly: AssemblyTitle("20 Minute Ping")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TwentyMinutePing;

[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("com.TeaBoneJones.TwentyMinutePing", "20 Minute Ping", "1.0.0")]
public class TwentyMinutePing : BaseUnityPlugin
{
	private static ConfigWrapper<int> minutes;

	public void Awake()
	{
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		minutes = ((BaseUnityPlugin)this).Config.Wrap<int>("Ping Indicator", "Minutes", "Set how long you want the ping to be enabled for, in minutes. Default = 20", 20);
		float seconds = minutes.Value * 60;
		PingIndicator.RebuildPing += (hook_RebuildPing)delegate(orig_RebuildPing orig, PingIndicator self)
		{
			orig.Invoke(self);
			Reflection.SetFieldValue<float>((object)self, "fixedTimer", seconds);
		};
	}
}

AchievementLoadFix.dll

Decompiled 7 hours ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using RoR2.Achievements.Artifacts;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace AchievementLoadFix
{
	[BepInPlugin("custom.AchievementLoadFix", "AchievementLoadFix", "1.0.0")]
	public class AchievementLoadFixPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("custom.AchievementLoadFix");
			HarmonyMethod val2 = new HarmonyMethod(typeof(AchievementLoadFixPlugin), "Finalizer", (Type[])null);
			string[] array = new string[2] { "OnInstall", "OnUninstall" };
			foreach (string text in array)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(BaseObtainArtifactAchievement), text, (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					MethodInfo methodInfo2 = methodInfo;
					HarmonyMethod val3 = val2;
					val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, val3, (HarmonyMethod)null);
				}
			}
		}

		private static Exception Finalizer(object __instance, Exception __exception)
		{
			if (__exception != null)
			{
				Log.LogWarning((object)("Skipped broken achievement " + ((__instance == null) ? "?" : __instance.GetType().FullName) + ": " + __exception.Message));
			}
			return null;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

AcolyteInstantSacrifice.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Acolyte.Weapon;
using HarmonyLib;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AcolyteInstantSacrifice")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("AcolyteInstantSacrifice")]
[assembly: AssemblyTitle("AcolyteInstantSacrifice")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("AcolyteInstantSacrifice", "AcolyteInstantSacrifice", "1.0.0")]
public class AcolyteInstantSacrifice : BaseUnityPlugin
{
	[HarmonyPatch(typeof(AimSacrifice), "OnEnter")]
	public static class OnEnter
	{
		[HarmonyPostfix]
		private static void Postfix(AimSacrifice __instance)
		{
			AimSacrifice.minDuration = 0f;
			GenericSkill special = ((Component)((EntityState)__instance).outer).GetComponent<CharacterBody>().skillLocator.special;
			special.skillDef.mustKeyPress = false;
		}
	}

	[HarmonyPatch(typeof(AimSacrifice), "FixedUpdateAuthority")]
	public static class FixedUpdateAuthority
	{
		[HarmonyPrefix]
		private static bool Prefix(AimSacrifice __instance)
		{
			//IL_0042: 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_005e: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (KeyDown((BaseSkillState)(object)__instance))
			{
				if ((Object)(object)Target.Invoke(__instance) != (Object)null)
				{
					Stopwatch.Invoke(__instance) = 0f;
					((EntityState)__instance).outer.SetNextState((EntityState)new Sacrifice
					{
						target = Target.Invoke(__instance)
					});
				}
				else
				{
					Stopwatch.Invoke(__instance) -= Time.fixedDeltaTime;
					if (Stopwatch.Invoke(__instance) <= 0f)
					{
						Stopwatch.Invoke(__instance) += 1f / AimSacrifice.trackerUpdateFrequency;
						InputBankTest component = ((Component)((EntityState)__instance).outer).GetComponent<InputBankTest>();
						Ray val = default(Ray);
						((Ray)(ref val))..ctor(component.aimOrigin, component.aimDirection);
						__instance.SearchForTarget(val);
					}
				}
			}
			else
			{
				Stopwatch.Invoke(__instance) = 0f;
				((EntityState)__instance).outer.SetNextStateToMain();
			}
			return false;
		}
	}

	internal static ManualLogSource Log;

	internal static readonly FieldRef<AimSacrifice, HurtBox> Target = AccessTools.FieldRefAccess<AimSacrifice, HurtBox>("trackingTarget");

	internal static readonly Func<BaseSkillState, bool> KeyDown = AccessTools.MethodDelegate<Func<BaseSkillState, bool>>(AccessTools.Method(typeof(BaseSkillState), "IsKeyDownAuthority", (Type[])null, (Type[])null), (object)null, true);

	internal static readonly FieldRef<AimSacrifice, float> Stopwatch = AccessTools.FieldRefAccess<AimSacrifice, float>("trackerUpdateStopwatch");

	private void Awake()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
		val.PatchAll(typeof(AcolyteInstantSacrifice).Assembly);
	}
}

AlloyEncounters.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace AlloyEncounters
{
	public class AlloyMarker : MonoBehaviour
	{
		public enum Kind
		{
			Stage2Hunter,
			SirenHunter,
			ConduitHunter,
			WorshipUnit
		}

		public Kind kind;

		public bool invulnerable;

		public bool statsApplied;

		public bool dropsGiven;

		public float damageMult = 1f;
	}
	[BepInPlugin("custom.AlloyEncounters", "AlloyEncounters", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AlloyEncountersPlugin : BaseUnityPlugin
	{
		public const string QualityGUID = "com.Gorakh.ItemQualities";

		private const string SirenScene = "shipgraveyard";

		private const string ConduitScene = "conduitcanyon";

		internal static AlloyEncountersPlugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Stage2Hunter;

		internal static ConfigEntry<bool> Stage2ApplyOnLoops;

		internal static ConfigEntry<bool> SirenForceTeleporter;

		internal static ConfigEntry<bool> SirenWorshipRequired;

		internal static ConfigEntry<bool> SirenForceSolusBoss;

		internal static ConfigEntry<bool> SirenHunter;

		internal static ConfigEntry<bool> SirenChat;

		internal static ConfigEntry<bool> SirenDisableDescent;

		internal static ConfigEntry<float> SirenHunterFallbackSeconds;

		internal static ConfigEntry<bool> SirenHunterInvulnerable;

		internal static ConfigEntry<string> DescentCardNames;

		internal static ConfigEntry<float> WorshipDamageMult;

		internal static ConfigEntry<float> ConduitHunterHpMult;

		internal static ConfigEntry<float> SirenHunterHpMult;

		internal static ConfigEntry<float> Stage2HunterDamageMult;

		internal static ConfigEntry<float> ConduitHunterDamageMult;

		internal static ConfigEntry<float> SirenHunterDamageMult;

		internal static ConfigEntry<bool> Stage2Chat;

		internal static ConfigEntry<string> Stage2ChatText;

		private static Action<CharacterBody, float> setDamage;

		internal static ConfigEntry<bool> ConduitDrops;

		internal static ConfigEntry<bool> SirenDrops;

		internal static ConfigEntry<bool> WorshipDrops;

		internal static ConfigEntry<bool> WorshipLegendaryReds;

		internal static ConfigEntry<float> RedConversionWindow;

		internal static ConfigEntry<int> RedConversionCount;

		private static CharacterSpawnCard hunterCard;

		private static CharacterSpawnCard solusControlCard;

		private static BodyIndex hunterBody = (BodyIndex)(-1);

		private static BodyIndex worshipBody = (BodyIndex)(-1);

		private static BodyIndex solusControlBody = (BodyIndex)(-1);

		private static float redWindowEnd = -1f;

		private static int redConversionsLeft;

		private static readonly FieldInfo monstersClearedField = AccessTools.Field(typeof(TeleporterInteraction), "monstersCleared");

		private static readonly FieldInfo defeatedServerField = AccessTools.Field(typeof(CombatSquad), "defeatedServer");

		private static bool QualityInstalled
		{
			[CompilerGenerated]
			get
			{
				return Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities");
			}
		}

		private void Awake()
		{
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_0398: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Expected O, but got Unknown
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Expected O, but got Unknown
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Expected O, but got Unknown
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Expected O, but got Unknown
			//IL_0527: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Expected O, but got Unknown
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Expected O, but got Unknown
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			Stage2Hunter = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage2", "InvincibleOverloadingHunter", true, "Spawn one unkillable Overloading Alloy Hunter when any stage 2 teleporter starts. It is despawned once the teleporter finishes and its boss is dead.");
			Stage2ApplyOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage2", "ApplyOnLoops", true, "Also apply on stage 2 of later loops (stage 7, 12, ...).");
			SirenForceTeleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "WorshipUnitActivatesTeleporter", true, "Spawning the Alloy Worship Unit forces the teleporter to activate.");
			SirenWorshipRequired = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "WorshipUnitRequiredForTeleporter", true, "The Alloy Worship Unit must be killed before the teleporter can finish.");
			SirenForceSolusBoss = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "ForceSolusControlUnitBoss", true, "The teleporter boss is always Solus Control Units, even during family events.");
			SirenHunter = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "OverloadingHunterBoss", true, "Spawn an Overloading Alloy Hunter as an extra teleporter boss. It is unkillable until all Solus Control Units are dead.");
			SirenHunterInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "HunterInvulnerableUntilSolusDead", false, "If true, the Siren's Call hunter cannot be damaged until all Solus Control Units are dead. If false, it is a normal teleporter boss from the start.");
			SirenHunterFallbackSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("SirensCall", "HunterVulnerableFallbackSeconds", 60f, "If no Solus Control Unit has spawned after this many seconds, the hunter becomes vulnerable anyway.");
			SirenChat = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "SirenChatMessage", true, "Broadcast 'Siren: Awoooooooooo' when the teleporter activates.");
			SirenDisableDescent = ((BaseUnityPlugin)this).Config.Bind<bool>("SirensCall", "DisableShrineOfDescent", true, "Prevent the Shrine of Descent from spawning on Siren's Call.");
			DescentCardNames = ((BaseUnityPlugin)this).Config.Bind<string>("SirensCall", "DescentSpawnCardNames", "Descent,Descend", "Comma-separated name fragments of spawn cards blocked on Siren's Call when DisableShrineOfDescent is on.");
			WorshipDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "WorshipUnitDamageMultiplier", 2f, "Damage multiplier for the Alloy Worship Unit.");
			ConduitHunterHpMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "ConduitCanyonHunterHealthMultiplier", 2f, "Health multiplier for the Alloy Hunter in Conduit Canyon.");
			SirenHunterHpMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "SirensCallHunterHealthMultiplier", 2f, "Health multiplier for the Overloading Alloy Hunter on Siren's Call.");
			Stage2HunterDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Stage2AmbushHunterDamageMultiplier", 5f, "Damage multiplier for the stage 2 ambush Overloading Alloy Hunter (1 = unchanged).");
			ConduitHunterDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "ConduitCanyonHunterDamageMultiplier", 1f, "Damage multiplier for the Alloy Hunter in Conduit Canyon (1 = unchanged).");
			SirenHunterDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "SirensCallHunterDamageMultiplier", 2f, "Damage multiplier for the Overloading Alloy Hunter on Siren's Call (1 = unchanged).");
			Stage2Chat = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage2", "AmbushChatMessage", true, "Broadcast a chat message in Mithrix's dialogue style when the stage 2 ambush hunter spawns.");
			Stage2ChatText = ((BaseUnityPlugin)this).Config.Bind<string>("Stage2", "AmbushChatText", "Awooooo", "Text of the stage 2 ambush message (shown as 'Siren: <text>').");
			ConduitDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Drops", "ConduitCanyonHunterDrops", true, "Conduit Canyon Alloy Hunter drops Faulty Conductor (Epic with Quality) + Polylute.");
			SirenDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Drops", "SirensCallHunterDrops", true, "Siren's Call Overloading Alloy Hunter drops Faulty Conductor (Legendary with Quality) + Polylute + Unstable Tesla Coil + Silence Between Two Strikes.");
			WorshipDrops = ((BaseUnityPlugin)this).Config.Bind<bool>("Drops", "WorshipUnitDropsEmpathyCores", true, "Alloy Worship Unit drops Empathy Cores (Legendary with Quality).");
			WorshipLegendaryReds = ((BaseUnityPlugin)this).Config.Bind<bool>("Drops", "WorshipUnitRedsLegendary", true, "With Quality installed, red items dropped when the Alloy Worship Unit dies become Legendary.");
			RedConversionWindow = ((BaseUnityPlugin)this).Config.Bind<float>("Drops", "RedConversionWindowSeconds", 30f, "How long after the Worship Unit dies its red reward drops are converted.");
			RedConversionCount = ((BaseUnityPlugin)this).Config.Bind<int>("Drops", "RedConversionCount", 0, "How many red drops to convert. 0 = one per player (matches the vanilla reward count).");
			AsyncOperationHandle<CharacterSpawnCard> val = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/VultureHunter/cscVultureHunter.asset");
			val.Completed += delegate(AsyncOperationHandle<CharacterSpawnCard> h)
			{
				hunterCard = h.Result;
			};
			AsyncOperationHandle<CharacterSpawnCard> val2 = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset");
			val2.Completed += delegate(AsyncOperationHandle<CharacterSpawnCard> h)
			{
				solusControlCard = h.Result;
			};
			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_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_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)
				hunterBody = BodyCatalog.FindBodyIndex("VultureHunterBody");
				worshipBody = BodyCatalog.FindBodyIndex("SuperRoboBallBossBody");
				solusControlBody = BodyCatalog.FindBodyIndex("RoboBallBossBody");
			});
			Harmony val3 = new Harmony("custom.AlloyEncounters");
			MethodInfo dmgSetter = AccessTools.PropertySetter(typeof(CharacterBody), "damage");
			if (dmgSetter != null)
			{
				try
				{
					setDamage = (Action<CharacterBody, float>)Delegate.CreateDelegate(typeof(Action<CharacterBody, float>), dmgSetter);
				}
				catch
				{
					setDamage = delegate(CharacterBody b, float v)
					{
						dmgSetter.Invoke(b, new object[1] { v });
					};
				}
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null);
			HarmonyMethod val4 = new HarmonyMethod(typeof(AlloyEncountersPlugin), "RecalculateStatsPostfix", (Type[])null);
			val3.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			PatchPrefix(val3, typeof(HealthComponent), "TakeDamage", "BlockDamagePrefix");
			PatchPrefix(val3, typeof(HealthComponent), "TakeDamageProcess", "BlockDamagePrefix");
			PatchPrefix(val3, typeof(HealthComponent), "Suicide", "BlockDamagePrefix");
			MethodInfo[] methods = typeof(CharacterMaster).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo2 in methods)
			{
				if (methodInfo2.Name == "TrueKill")
				{
					val3.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(AlloyEncountersPlugin), "BlockTrueKillPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			methodInfo = AccessTools.Method(typeof(CombatDirector), "SetNextSpawnAsBoss", (Type[])null, (Type[])null);
			val4 = new HarmonyMethod(typeof(AlloyEncountersPlugin), "SetNextSpawnAsBossPostfix", (Type[])null);
			val3.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val3.Patch((MethodBase)AccessTools.Method(typeof(GenericPickupController), "CreatePickup", (Type[])null, (Type[])null), new HarmonyMethod(typeof(AlloyEncountersPlugin), "CreatePickupPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(DLC4SacrificeZoneSpawner), "OnPrePopulateSceneServer", (Type[])null, (Type[])null);
			if (methodInfo3 != null)
			{
				val3.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(AlloyEncountersPlugin), "SacrificeZonePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			val3.Patch((MethodBase)AccessTools.Method(typeof(DirectorCore), "TrySpawnObject", (Type[])null, (Type[])null), new HarmonyMethod(typeof(AlloyEncountersPlugin), "TrySpawnObjectPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			TeleporterInteraction.onTeleporterBeginChargingGlobal += OnTeleporterBeginCharging;
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			GlobalEventManager.onCharacterDeathServer += OnCharacterDeath;
		}

		private static void PatchPrefix(Harmony h, Type t, string name, string prefix)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			MethodInfo[] methods = t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				if (methodInfo.Name == name)
				{
					h.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(AlloyEncountersPlugin), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
		}

		private static string SceneName()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			return (!Object.op_Implicit((Object)(object)mostRecentSceneDef)) ? string.Empty : mostRecentSceneDef.cachedName;
		}

		private static PickupIndex ToQuality(PickupIndex idx, int tier)
		{
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_000b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			if (!QualityInstalled || idx == PickupIndex.none)
			{
				return idx;
			}
			try
			{
				Type type = Type.GetType("ItemQualities.QualityCatalog, ItemQualities");
				Type type2 = Type.GetType("ItemQualities.QualityTier, ItemQualities");
				if (type == null || type2 == null)
				{
					return idx;
				}
				MethodInfo method = type.GetMethod("GetPickupIndexOfQuality", new Type[2]
				{
					typeof(PickupIndex),
					type2
				});
				if (method == null)
				{
					return idx;
				}
				return (PickupIndex)method.Invoke(null, new object[2]
				{
					idx,
					Enum.ToObject(type2, tier)
				});
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return idx;
			}
		}

		private static PickupIndex ItemPickup(string itemName)
		{
			//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_0009: Invalid comparison between Unknown and I4
			//IL_0018: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex val = ItemCatalog.FindItemIndex(itemName);
			return ((int)val != -1) ? PickupCatalog.FindPickupIndex(val) : PickupIndex.none;
		}

		private static PickupIndex EquipmentPickup(string name)
		{
			//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_0009: Invalid comparison between Unknown and I4
			//IL_0018: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(name);
			return ((int)val != -1) ? PickupCatalog.FindPickupIndex(val) : PickupIndex.none;
		}

		private static void DropAll(List<PickupIndex> pickups, Vector3 pos)
		{
			//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)
			//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_005d: 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_0065: 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_0075: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			pickups.RemoveAll((PickupIndex p) => p == PickupIndex.none);
			if (pickups.Count != 0)
			{
				float num = 360f / (float)pickups.Count;
				for (int num2 = 0; num2 < pickups.Count; num2++)
				{
					Vector3 val = Quaternion.AngleAxis(num * (float)num2, Vector3.up) * Vector3.forward;
					PickupDropletController.CreatePickupDroplet(new UniquePickup(pickups[num2]), pos + Vector3.up * 2f, Vector3.up * 20f + val * 8f, false, false);
				}
			}
		}

		private static void MultiplyStat(Inventory inv, ItemDef boostItem, float mult)
		{
			if (Object.op_Implicit((Object)(object)inv) && Object.op_Implicit((Object)(object)boostItem) && !(mult <= 1f))
			{
				int itemCountPermanent = inv.GetItemCountPermanent(boostItem);
				float num = 1f + 0.1f * (float)itemCountPermanent;
				int num2 = Mathf.RoundToInt((num * mult - num) * 10f);
				if (num2 > 0)
				{
					inv.GiveItemPermanent(boostItem, num2);
				}
			}
		}

		private static void RecalculateStatsPostfix(CharacterBody __instance)
		{
			if (setDamage != null && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.master))
			{
				AlloyMarker component = ((Component)__instance.master).GetComponent<AlloyMarker>();
				if (Object.op_Implicit((Object)(object)component) && component.damageMult > 0f && Mathf.Abs(component.damageMult - 1f) > 0.0001f)
				{
					setDamage(__instance, __instance.damage * component.damageMult);
				}
			}
		}

		private static void SetDamageMult(CharacterMaster master, AlloyMarker marker, float mult)
		{
			if (Object.op_Implicit((Object)(object)marker))
			{
				marker.damageMult = Mathf.Max(0f, mult);
				CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody());
				if (Object.op_Implicit((Object)(object)val))
				{
					val.RecalculateStats();
				}
			}
		}

		private static void ApplyOverloading(Inventory inv)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			EliteDef lightning = Elites.Lightning;
			if (Object.op_Implicit((Object)(object)inv) && Object.op_Implicit((Object)(object)lightning) && Object.op_Implicit((Object)(object)lightning.eliteEquipmentDef))
			{
				inv.SetEquipmentIndex(lightning.eliteEquipmentDef.equipmentIndex);
				int num = Mathf.RoundToInt((lightning.healthBoostCoefficient - 1f) * 10f);
				int num2 = Mathf.RoundToInt((lightning.damageBoostCoefficient - 1f) * 10f);
				if (num > 0)
				{
					inv.GiveItemPermanent(Items.BoostHp, num);
				}
				if (num2 > 0)
				{
					inv.GiveItemPermanent(Items.BoostDamage, num2);
				}
			}
		}

		private static AlloyMarker MarkerOf(CharacterMaster master)
		{
			return (!Object.op_Implicit((Object)(object)master)) ? null : ((Component)master).GetComponent<AlloyMarker>();
		}

		private static AlloyMarker MarkerOfBodyObject(GameObject bodyObj)
		{
			if (!Object.op_Implicit((Object)(object)bodyObj))
			{
				return null;
			}
			CharacterBody component = bodyObj.GetComponent<CharacterBody>();
			return (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.master)) ? null : ((Component)component.master).GetComponent<AlloyMarker>();
		}

		private static void Despawn(CharacterMaster master)
		{
			if (!Object.op_Implicit((Object)(object)master))
			{
				return;
			}
			try
			{
				master.DestroyBody();
				NetworkServer.Destroy(((Component)master).gameObject);
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static bool BlockDamagePrefix(HealthComponent __instance)
		{
			if (!Object.op_Implicit((Object)(object)__instance))
			{
				return true;
			}
			AlloyMarker alloyMarker = MarkerOfBodyObject(((Component)__instance).gameObject);
			return !Object.op_Implicit((Object)(object)alloyMarker) || !alloyMarker.invulnerable;
		}

		private static bool BlockTrueKillPrefix(CharacterMaster __instance)
		{
			AlloyMarker alloyMarker = MarkerOf(__instance);
			return !Object.op_Implicit((Object)(object)alloyMarker) || !alloyMarker.invulnerable;
		}

		private static void ProtectBody(CharacterBody body)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			if (Object.op_Implicit((Object)(object)body))
			{
				body.bodyFlags = (BodyFlags)(body.bodyFlags | 0x810);
			}
		}

		private static void SpawnHunter(TeleporterInteraction tp, AlloyMarker.Kind kind, Action<CharacterMaster> onReady)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)hunterCard) || !Object.op_Implicit((Object)(object)DirectorCore.instance))
			{
				Log.LogError((object)"Alloy Hunter spawn card not loaded.");
				return;
			}
			CharacterSpawnCard obj = hunterCard;
			DirectorPlacementRule val = new DirectorPlacementRule();
			val.placementMode = (PlacementMode)1;
			val.spawnOnTarget = ((Component)tp).transform;
			val.position = ((Component)tp).transform.position;
			val.minDistance = 15f;
			val.maxDistance = 60f;
			DirectorSpawnRequest val2 = new DirectorSpawnRequest((SpawnCard)(object)obj, val, new Xoroshiro128Plus(Run.instance.stageRng.nextUlong));
			val2.teamIndexOverride = (TeamIndex)2;
			val2.ignoreTeamMemberLimit = true;
			DirectorSpawnRequest val3 = val2;
			val3.onSpawnedServer = delegate(SpawnResult result)
			{
				if (result.success && Object.op_Implicit((Object)(object)result.spawnedInstance))
				{
					CharacterMaster component = result.spawnedInstance.GetComponent<CharacterMaster>();
					if (Object.op_Implicit((Object)(object)component))
					{
						AlloyMarker alloyMarker = ((Component)component).gameObject.AddComponent<AlloyMarker>();
						alloyMarker.kind = kind;
						alloyMarker.invulnerable = kind == AlloyMarker.Kind.Stage2Hunter || SirenHunterInvulnerable.Value;
						ApplyOverloading(component.inventory);
						if (kind == AlloyMarker.Kind.SirenHunter)
						{
							MultiplyStat(component.inventory, Items.BoostHp, SirenHunterHpMult.Value);
						}
						SetDamageMult(component, alloyMarker, (kind != AlloyMarker.Kind.SirenHunter) ? Stage2HunterDamageMult.Value : SirenHunterDamageMult.Value);
						alloyMarker.statsApplied = true;
						CharacterBody body = component.GetBody();
						if (Object.op_Implicit((Object)(object)body))
						{
							ProtectBody(body);
						}
						component.onBodyStart += ProtectBody;
						onReady?.Invoke(component);
					}
				}
			};
			GameObject val4 = DirectorCore.instance.TrySpawnObject(val3);
			if (!Object.op_Implicit((Object)(object)val4))
			{
				Log.LogWarning((object)string.Concat("Failed to place Alloy Hunter (", kind, ")."));
			}
		}

		private void OnTeleporterBeginCharging(TeleporterInteraction tp)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)tp) || !Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			try
			{
				int stageClearCount = Run.instance.stageClearCount;
				bool flag = stageClearCount % 5 == 1 && (stageClearCount == 1 || Stage2ApplyOnLoops.Value);
				string text = SceneName();
				if (Stage2Hunter.Value && flag && text != "shipgraveyard")
				{
					SpawnHunter(tp, AlloyMarker.Kind.Stage2Hunter, delegate(CharacterMaster master)
					{
						if (Stage2Chat.Value)
						{
							BroadcastSiren(Stage2ChatText.Value);
						}
						((MonoBehaviour)this).StartCoroutine(Stage2Watcher(tp, master));
					});
				}
				if (!(text == "shipgraveyard"))
				{
					return;
				}
				if (SirenChat.Value)
				{
					BroadcastSiren("Awoooooooooo");
				}
				if (SirenHunter.Value)
				{
					SpawnHunter(tp, AlloyMarker.Kind.SirenHunter, delegate(CharacterMaster master)
					{
						master.isBoss = true;
						((MonoBehaviour)this).StartCoroutine(SirenHunterWatcher(tp, master));
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private IEnumerator Stage2Watcher(TeleporterInteraction tp, CharacterMaster master)
		{
			WaitForSeconds wait = new WaitForSeconds(0.5f);
			while (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)tp))
			{
				CombatSquad squad = ((!Object.op_Implicit((Object)(object)tp.bossGroup)) ? null : tp.bossGroup.combatSquad);
				bool bossDead = !Object.op_Implicit((Object)(object)squad) || squad.memberCount == 0;
				if (tp.isCharged && bossDead)
				{
					break;
				}
				yield return wait;
			}
			Despawn(master);
		}

		private static void SetMonstersCleared(TeleporterInteraction tp, bool value)
		{
			try
			{
				if (Object.op_Implicit((Object)(object)tp) && monstersClearedField != null)
				{
					monstersClearedField.SetValue(tp, value);
				}
			}
			catch
			{
			}
		}

		private static bool SquadDefeated(CombatSquad squad)
		{
			try
			{
				return Object.op_Implicit((Object)(object)squad) && defeatedServerField != null && (bool)defeatedServerField.GetValue(squad);
			}
			catch
			{
				return false;
			}
		}

		private static CombatSquad TeleporterSquad(TeleporterInteraction tp)
		{
			if (!Object.op_Implicit((Object)(object)tp))
			{
				return null;
			}
			CombatSquad val = null;
			try
			{
				if (Object.op_Implicit((Object)(object)tp.bossGroup))
				{
					val = tp.bossGroup.combatSquad;
				}
			}
			catch
			{
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				try
				{
					if (Object.op_Implicit((Object)(object)tp.bossDirector))
					{
						val = tp.bossDirector.combatSquad;
					}
				}
				catch
				{
				}
			}
			if (!Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)tp.bossGroup))
			{
				val = ((Component)tp.bossGroup).GetComponent<CombatSquad>();
			}
			return val;
		}

		private static int CountAliveSolusControlUnits()
		{
			//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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			int num = 0;
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && readOnlyInstances.bodyIndex == solusControlBody && Object.op_Implicit((Object)(object)readOnlyInstances.healthComponent) && readOnlyInstances.healthComponent.alive && Object.op_Implicit((Object)(object)readOnlyInstances.teamComponent) && (int)readOnlyInstances.teamComponent.teamIndex != 1)
				{
					num++;
				}
			}
			return num;
		}

		private IEnumerator SirenHunterWatcher(TeleporterInteraction tp, CharacterMaster master)
		{
			WaitForSeconds wait = new WaitForSeconds(0.25f);
			float start = Time.time;
			bool seenSolus = false;
			bool added = false;
			while (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)tp))
			{
				CharacterBody body = master.GetBody();
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && !body.healthComponent.alive)
				{
					break;
				}
				AlloyMarker marker = MarkerOf(master);
				if (!added)
				{
					CombatSquad val = TeleporterSquad(tp);
					if (Object.op_Implicit((Object)(object)val) && val.memberCount > 0 && !SquadDefeated(val))
					{
						try
						{
							val.AddMember(master);
							added = true;
							Log.LogInfo((object)"Siren hunter added to teleporter boss group.");
						}
						catch (Exception ex)
						{
							Log.LogError((object)ex);
							added = true;
						}
					}
				}
				if (Object.op_Implicit((Object)(object)marker) && marker.invulnerable)
				{
					int num = CountAliveSolusControlUnits();
					if (num > 0)
					{
						seenSolus = true;
					}
					if ((seenSolus && num == 0) || (!seenSolus && Time.time - start > SirenHunterFallbackSeconds.Value))
					{
						marker.invulnerable = false;
						Log.LogInfo((object)"Siren hunter is now vulnerable.");
					}
				}
				SetMonstersCleared(tp, value: false);
				yield return wait;
			}
			if (Object.op_Implicit((Object)(object)tp))
			{
				CombatSquad val2 = TeleporterSquad(tp);
				SetMonstersCleared(tp, !Object.op_Implicit((Object)(object)val2) || SquadDefeated(val2) || val2.memberCount == 0);
			}
		}

		private IEnumerator RequireBossManually(TeleporterInteraction tp, CharacterMaster master)
		{
			WaitForSeconds wait = new WaitForSeconds(0.1f);
			while (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)tp))
			{
				CharacterBody b = master.GetBody();
				if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)b.healthComponent) && !b.healthComponent.alive)
				{
					break;
				}
				SetMonstersCleared(tp, value: false);
				yield return wait;
			}
			if (Object.op_Implicit((Object)(object)tp))
			{
				CombatSquad val = ((!Object.op_Implicit((Object)(object)tp.bossGroup)) ? null : tp.bossGroup.combatSquad);
				SetMonstersCleared(tp, !Object.op_Implicit((Object)(object)val) || SquadDefeated(val) || val.memberCount == 0);
			}
		}

		private static void BroadcastSiren(string text)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			string text2 = null;
			try
			{
				string text3 = Language.GetString("BROTHER_DIALOGUE_FORMAT");
				if (!string.IsNullOrEmpty(text3) && text3.Contains("{0}") && text3.Contains("Mithrix"))
				{
					text2 = string.Format(text3.Replace("Mithrix", "Siren"), text);
				}
			}
			catch
			{
			}
			if (text2 == null)
			{
				text2 = "<color=#c6d5ff><size=120%>Siren: " + text + "</color></size>";
			}
			SimpleChatMessage val = new SimpleChatMessage();
			val.baseToken = text2;
			Chat.SendBroadcastChat((ChatMessageBase)(object)val);
		}

		private void OnBodyStart(CharacterBody body)
		{
			//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_00b4: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master))
			{
				return;
			}
			try
			{
				CharacterMaster master = body.master;
				string text = SceneName();
				if (body.bodyIndex == worshipBody && (int)worshipBody != -1)
				{
					AlloyMarker alloyMarker = MarkerOf(master);
					if (!Object.op_Implicit((Object)(object)alloyMarker))
					{
						alloyMarker = ((Component)master).gameObject.AddComponent<AlloyMarker>();
						alloyMarker.kind = AlloyMarker.Kind.WorshipUnit;
						SetDamageMult(master, alloyMarker, WorshipDamageMult.Value);
						alloyMarker.statsApplied = true;
						if (text == "shipgraveyard")
						{
							((MonoBehaviour)this).StartCoroutine(HandleWorshipOnSiren(master));
						}
					}
				}
				else if (body.bodyIndex == hunterBody && (int)hunterBody != -1 && text == "conduitcanyon" && !Object.op_Implicit((Object)(object)MarkerOf(master)))
				{
					AlloyMarker alloyMarker2 = ((Component)master).gameObject.AddComponent<AlloyMarker>();
					alloyMarker2.kind = AlloyMarker.Kind.ConduitHunter;
					MultiplyStat(master.inventory, Items.BoostHp, ConduitHunterHpMult.Value);
					SetDamageMult(master, alloyMarker2, ConduitHunterDamageMult.Value);
					alloyMarker2.statsApplied = true;
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private IEnumerator HandleWorshipOnSiren(CharacterMaster worship)
		{
			yield return null;
			TeleporterInteraction tp = TeleporterInteraction.instance;
			if (!Object.op_Implicit((Object)(object)tp) || !Object.op_Implicit((Object)(object)worship))
			{
				yield break;
			}
			if (SirenForceTeleporter.Value && tp.isIdle)
			{
				Interactor val = null;
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					CharacterBody val2 = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody());
					if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)(val = ((Component)val2).GetComponent<Interactor>())))
					{
						break;
					}
				}
				try
				{
					tp.OnInteractionBegin(val);
				}
				catch (Exception ex)
				{
					Log.LogError((object)ex);
				}
			}
			if (SirenWorshipRequired.Value && !tp.isCharged)
			{
				((MonoBehaviour)this).StartCoroutine(RequireBossManually(tp, worship));
			}
		}

		private static void SetNextSpawnAsBossPostfix(CombatDirector __instance)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			try
			{
				if (SirenForceSolusBoss.Value && NetworkServer.active && Object.op_Implicit((Object)(object)solusControlCard) && !(SceneName() != "shipgraveyard"))
				{
					TeleporterInteraction instance = TeleporterInteraction.instance;
					if (Object.op_Implicit((Object)(object)instance) && !((Object)(object)instance.bossDirector != (Object)(object)__instance))
					{
						DirectorCard val = new DirectorCard();
						val.spawnCard = (SpawnCard)(object)solusControlCard;
						val.selectionWeight = 1;
						__instance.OverrideCurrentMonsterCard(val);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private void OnCharacterDeath(DamageReport report)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || report == null || !Object.op_Implicit((Object)(object)report.victimMaster))
			{
				return;
			}
			try
			{
				AlloyMarker alloyMarker = MarkerOf(report.victimMaster);
				if (!Object.op_Implicit((Object)(object)alloyMarker) || alloyMarker.dropsGiven)
				{
					return;
				}
				Vector3 pos = ((!Object.op_Implicit((Object)(object)report.victimBody)) ? ((Component)report.victimMaster).transform.position : report.victimBody.corePosition);
				List<PickupIndex> list = new List<PickupIndex>();
				switch (alloyMarker.kind)
				{
				default:
					return;
				case AlloyMarker.Kind.ConduitHunter:
					if (!ConduitDrops.Value)
					{
						return;
					}
					list.Add(ToQuality(ItemPickup("ShockDamageAura"), 2));
					list.Add(ItemPickup("ChainLightningVoid"));
					break;
				case AlloyMarker.Kind.SirenHunter:
					if (!SirenDrops.Value)
					{
						return;
					}
					list.Add(ToQuality(ItemPickup("ShockDamageAura"), 3));
					list.Add(ItemPickup("ChainLightningVoid"));
					list.Add(ItemPickup("ShockNearby"));
					list.Add(EquipmentPickup("AffixBlue"));
					break;
				case AlloyMarker.Kind.WorshipUnit:
					if (WorshipLegendaryReds.Value && QualityInstalled)
					{
						redWindowEnd = Time.time + RedConversionWindow.Value;
						redConversionsLeft = ((RedConversionCount.Value <= 0) ? Math.Max(1, PlayerCharacterMasterController.instances.Count) : RedConversionCount.Value);
					}
					if (!WorshipDrops.Value)
					{
						return;
					}
					list.Add(ToQuality(ItemPickup("RoboBallBuddy"), 3));
					break;
				}
				alloyMarker.dropsGiven = true;
				DropAll(list, pos);
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void CreatePickupPrefix(ref CreatePickupInfo createPickupInfo)
		{
			//IL_0043: 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_005b: Invalid comparison between Unknown and I4
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			//IL_0073: 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)
			try
			{
				if (Time.time > redWindowEnd || redConversionsLeft <= 0 || !NetworkServer.active || SceneName() != "shipgraveyard")
				{
					return;
				}
				PickupDef pickupDef = PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref createPickupInfo)).pickupIndex);
				if (pickupDef != null && (int)pickupDef.itemIndex != -1 && (int)pickupDef.itemTier == 2)
				{
					((CreatePickupInfo)(ref createPickupInfo)).pickupIndex = ToQuality(((CreatePickupInfo)(ref createPickupInfo)).pickupIndex, 3);
					if (--redConversionsLeft <= 0)
					{
						redWindowEnd = -1f;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static bool SacrificeZonePrefix()
		{
			return !SirenDisableDescent.Value || !(SceneName() == "shipgraveyard");
		}

		private static bool TrySpawnObjectPrefix(DirectorSpawnRequest directorSpawnRequest, ref GameObject __result)
		{
			if (!SirenDisableDescent.Value || directorSpawnRequest == null || !Object.op_Implicit((Object)(object)directorSpawnRequest.spawnCard))
			{
				return true;
			}
			if (SceneName() != "shipgraveyard")
			{
				return true;
			}
			string name = ((Object)directorSpawnRequest.spawnCard).name;
			string[] array = DescentCardNames.Value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				string text2 = text.Trim();
				if (text2.Length > 0 && name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					__result = null;
					return false;
				}
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

AurelioniteRework.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Missions.BrotherEncounter;
using EntityStates.Missions.Goldshores;
using EntityStates.Missions.ProvidenceBossEncounter;
using HG;
using HarmonyLib;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ExpansionManagement;
using RoR2.Items;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace AurelioniteRework
{
	[BepInPlugin("custom.AurelioniteRework", "AurelioniteRework", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AurelioniteReworkPlugin : BaseUnityPlugin
	{
		private enum Context
		{
			Teleporter,
			Mithrix,
			Providence,
			Voidling,
			FalseSon,
			Other
		}

		private class Phase4Record
		{
			public EntityState state;

			public bool providence;

			public float startTime;

			public bool done;
		}

		internal static ManualLogSource Log;

		private static ConfigEntry<bool> teleporterInvulnerable;

		private static ConfigEntry<bool> bossPhaseInvulnerable;

		private static ConfigEntry<bool> bossPhasePlayersInvulnerable;

		private static ConfigEntry<bool> voidlingUltimateSpawn;

		private static ConfigEntry<float> fallbackSpawnDelay;

		private static ConfigEntry<bool> falseSonInvulnerable;

		private static ConfigEntry<bool> teleporterPlayersInvulnerable;

		private static ConfigEntry<float> falseSonHealthMultiplier;

		private static ConfigEntry<bool> eyeNeedsAurelionite;

		private static PickupIndex eyePickup = PickupIndex.none;

		private static bool falseSonFoughtWithAurelionite;

		private static readonly HashSet<CharacterMaster> boostedFalseSons = new HashSet<CharacterMaster>();

		private static ConfigEntry<bool> seedCannotBeRemoved;

		private static ConfigEntry<string> goldshoresSubtitle;

		private static ConfigEntry<bool> singleSeedDrop;

		private static ConfigEntry<bool> portalsOnSpawn;

		private static ConfigEntry<string> seerStages;

		private static ConfigEntry<bool> noShrineOfGold;

		private static ConfigEntry<bool> goldPortalOnlyGildedCoast;

		private static ConfigEntry<string> seedText;

		private static ConfigEntry<string> falseSonObjective;

		private static ConfigEntry<bool> voidlingStays;

		private static ConfigEntry<bool> voidlingPassive;

		private static ConfigEntry<bool> noQualitySeed;

		private static ConfigEntry<bool> tricornIgnoresAurelionite;

		private static object voidlingChanneler;

		private static SpawnCard goldPortalCard;

		private static string goldPortalPrefabName = "PortalGoldshores";

		private static float nextPortalSweep;

		private static readonly HashSet<ItemIndex> seedVariants = new HashSet<ItemIndex>();

		private static PickupIndex seedPickup = PickupIndex.none;

		private static Type defeatBossTrackerType;

		private static float goddessCheckTime = -100f;

		private static bool goddessAgainstYou;

		private static readonly Dictionary<CharacterMaster, Context> titans = new Dictionary<CharacterMaster, Context>();

		private static readonly List<Phase4Record> phase4States = new List<Phase4Record>();

		private static Context? nextContext;

		private static bool allowTitanKill;

		private static bool allowSeedRemoval;

		private static bool blessingActive;

		private static ItemIndex seedIndex = (ItemIndex)(-1);

		private static FieldInfo stealOwnerField;

		private static bool portalsSpawnedThisStage;

		private static BossGroup goldshoresBossGroup;

		private static float lastBlockLog = -100f;

		private static readonly HashSet<int> seerStageSet = new HashSet<int>();

		private static string seedDescToken = "ITEM_TITANGOLDDURINGTP_DESC";

		private static string seedPickupToken = "ITEM_TITANGOLDDURINGTP_PICKUP";

		private static string seedDescExtra = "";

		private static string seedPickupExtra = "";

		private static int installed;

		private static int failed;

		private static float fightOverSince = -1f;

		private static readonly Dictionary<SpawnCard, bool> shrineOfGoldCards = new Dictionary<SpawnCard, bool>();

		private void Awake()
		{
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			teleporterInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter Aurelionite", "Invulnerable", true, "The Aurelionite the Halcyon Seed summons during a teleporter event can't be hurt or killed by anything (void implosions included) until the teleporter is charged, when she leaves and the seeds are handed back.");
			teleporterPlayersInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter Aurelionite", "PlayersInvulnerable", true, "While that Aurelionite is out, every player takes no damage of any kind.");
			bossPhaseInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Phase Aurelionite", "Invulnerable", true, "The Aurelionite summoned in Mithrix's phase 4, Echo of Providence's phase 4 and Voidling's final battle can't be hurt or killed by anything.");
			bossPhasePlayersInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Phase Aurelionite", "PlayersInvulnerable", true, "While that Aurelionite is out, every player takes no damage of any kind.");
			voidlingUltimateSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Phase Aurelionite", "SpawnInVoidlingFinalBattle", true, "Aurelionite is also summoned (using the seeds) when Voidling's final battle (VoidlingRework's phase 12) drops to half health. With a seed, that battle has twice the health (needs VoidlingRework).");
			voidlingPassive = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Phase Aurelionite", "PassiveInVoidlingFinalBattle", true, "The Aurelionite summoned in Voidling's final battle never attacks: she only protects the players.");
			fallbackSpawnDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Boss Phase Aurelionite", "FallbackSpawnDelay", 6f, "If Aurelionite hasn't appeared this many seconds into Mithrix's or Echo of Providence's phase 4 (e.g. another mod changed the fight), summon her anyway. 0 = never.");
			falseSonInvulnerable = ((BaseUnityPlugin)this).Config.Bind<bool>("False Son Aurelionite", "Invulnerable", true, "The Aurelionite that fights for False Son in phase 3 can't be hurt by players (or anything else). She leaves as soon as False Son is defeated and the seeds are handed back.");
			falseSonHealthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("False Son Aurelionite", "FalseSonHealthMultiplier", 3f, "False Son's phase 3 health is multiplied by this when Aurelionite joins him (his current health is scaled to match). 1 = unchanged.");
			eyeNeedsAurelionite = ((BaseUnityPlugin)this).Config.Bind<bool>("False Son Aurelionite", "EyeOfTheStormNeedsAurelionite", true, "StormboundFalseSon's Eye of the Storm only drops if Aurelionite was fighting alongside False Son when he was defeated. His other rewards are unchanged.");
			seedCannotBeRemoved = ((BaseUnityPlugin)this).Config.Bind<bool>("Halcyon Seed", "CannotBeRemoved", true, "The Halcyon Seed can't be scrapped, printed away, corrupted, turned by Egocentrism, stolen, cooked or removed in any other way. Only Aurelionite borrows it while she is out, and it always comes back.");
			goldshoresSubtitle = ((BaseUnityPlugin)this).Config.Bind<string>("Gilded Coast", "AurelioniteSubtitle", "Goddess of Light", "Aurelionite's subtitle in the Gilded Coast (overrides other mods). Empty = unchanged.");
			singleSeedDrop = ((BaseUnityPlugin)this).Config.Bind<bool>("Gilded Coast", "SingleSeedDrop", true, "Defeating Aurelionite in the Gilded Coast drops exactly one Halcyon Seed, whatever the number of players.");
			portalsOnSpawn = ((BaseUnityPlugin)this).Config.Bind<bool>("Gilded Coast", "PortalsWhenAurelioniteSpawns", true, "The gold portal (next stage) and the green portal (Path of the Colossus, if it would normally appear) open when Aurelionite spawns instead of when she dies.");
			seerStages = ((BaseUnityPlugin)this).Config.Bind<string>("Bazaar", "GildedCoastSeerAfterStages", "1,2,3", "One of the two Lunar Seers always shows the Gilded Coast in the Bazaar visited after these stages' teleporters (stages cleared). Every other Bazaar never shows it. Empty = vanilla seers.");
			noShrineOfGold = ((BaseUnityPlugin)this).Config.Bind<bool>("Bazaar", "NoShrineOfGold", true, "Shrines of Gold never spawn.");
			goldPortalOnlyGildedCoast = ((BaseUnityPlugin)this).Config.Bind<bool>("Gilded Coast", "GoldPortalOnlyInGildedCoast", true, "The gold portal (to the Gilded Coast) never appears anywhere except in the Gilded Coast itself, whatever creates it (Shrine of Gold, teleporter, other mods).");
			seedText = ((BaseUnityPlugin)this).Config.Bind<string>("Halcyon Seed", "Description", "The Goddess is on your side...", "The Halcyon Seed's whole pickup text and description (also what LookingGlass shows). Empty = the game's text plus this mod's notes.");
			falseSonObjective = ((BaseUnityPlugin)this).Config.Bind<string>("False Son Aurelionite", "ObjectiveText", "The Goddess is not on your side...", "Objective shown in False Son's phase 3 while Aurelionite fights for him (instead of \"Defeat the Boss!\"). Empty = unchanged.");
			voidlingStays = ((BaseUnityPlugin)this).Config.Bind<bool>("Boss Phase Aurelionite", "StayAfterVoidlingDefeated", true, "The Aurelionite summoned in Voidling's final battle stays (and keeps protecting the players) after Voidling is defeated.");
			tricornIgnoresAurelionite = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "TrophyHunterTricornIgnoresAurelionite", true, "Trophy Hunter's Tricorn can never target any Aurelionite (it picks another boss, or nothing).");
			noQualitySeed = ((BaseUnityPlugin)this).Config.Bind<bool>("Halcyon Seed", "NoQualityVersions", true, "ItemQualities: the Halcyon Seed never comes in a quality version (any that would be created or picked up become the normal seed).");
			string[] array = seerStages.Value.Split(',');
			for (int i = 0; i < array.Length; i++)
			{
				if (int.TryParse(array[i].Trim(), out var result))
				{
					seerStageSet.Add(result);
				}
			}
			Harmony harmony = new Harmony("custom.AurelioniteRework");
			Type typeFromHandle = typeof(GoldTitanManager);
			TryPatch(harmony, Find(typeFromHandle, "TryStartChannelingTitansServer", typeof(object), typeof(Vector3), typeof(Vector3?), typeof(Action)), null, "ChannelPostfix");
			TryPatch(harmony, Find(typeFromHandle, "TryStartChannelingAgainstCombatSquadServer", typeof(CombatSquad)), "ChannelSquadPrefix", null);
			TryPatch(harmony, Find(typeFromHandle, "KillTitansInList", typeof(List<CharacterMaster>)), "KillTitansPrefix", null, "KillTitansFinalizer");
			MethodBase target = Find(typeof(HealthComponent), "TakeDamageProcess", typeof(DamageInfo)) ?? Find(typeof(HealthComponent), "TakeDamage", typeof(DamageInfo));
			TryPatch(harmony, target, "GuardPrefix", null, null, 800);
			TryPatch(harmony, target, "GuardPrefixLate", null, null, 0);
			TryPatch(harmony, Find(typeof(HealthComponent), "Suicide", typeof(GameObject), typeof(GameObject), typeof(DamageTypeCombo)), "SuicidePrefix", null);
			TryPatch(harmony, Find(typeof(BrotherEncounterPhaseBaseState), "OnEnter", Type.EmptyTypes), null, "Phase4EnterPostfix");
			TryPatch(harmony, Find(typeof(ProvidenceBossEncounterPhaseBaseState), "OnEnter", Type.EmptyTypes), null, "Phase4EnterPostfix");
			TryPatch(harmony, Find(typeof(Inventory), "GiveItemPermanent", typeof(ItemIndex), typeof(int)), "SeedRemovalPrefix", null);
			TryPatch(harmony, Find(typeof(ItemTransformation), "CanTake", typeof(Inventory), typeof(CanTakeResult).MakeByRefType()), null, "CanTakePostfix");
			TryPatch(harmony, Find(typeof(ContagiousItemManager), "StepInventoryInfection", typeof(Inventory), typeof(ItemIndex), typeof(int), typeof(bool)), "InfectionPrefix", null);
			Type type = null;
			try
			{
				type = AccessTools.Inner(typeof(ItemStealController), "StolenInventoryInfo");
			}
			catch (Exception)
			{
			}
			if (type != null)
			{
				stealOwnerField = AccessTools.Field(type, "owner");
				TryPatch(harmony, Find(type, "StealItem", typeof(ItemIndex), typeof(int), typeof(bool?)), "StealItemPrefix", null, "StealItemFinalizer");
			}
			else
			{
				Log.LogWarning((object)"ItemStealController.StolenInventoryInfo not found; item steals aren't filtered for the Halcyon Seed.");
			}
			TryPatch(harmony, Find(typeof(CharacterBody), "GetSubtitle", Type.EmptyTypes), null, "SubtitlePostfix", null, 0);
			TryPatch(harmony, Find(typeof(Language), "GetLocalizedStringByToken", typeof(string)), null, "LanguagePostfix", null, 0);
			TryPatch(harmony, Find(typeof(BossGroup), "UpdateObservations", typeof(BossMemory).MakeByRefType()), null, "BossBarPostfix", null, 0);
			TryPatch(harmony, Find(typeof(TeleporterInteraction), "AttemptToSpawnGoldshoresPortal"), "TeleporterGoldPortalPrefix", null);
			TryPatch(harmony, Find(typeFromHandle, "EndChannelingTitansServer", typeof(object)), "EndChannelPrefix", null);
			TryPatch(harmony, Find(typeof(EquipmentSlot), "UpdateTargets", typeof(EquipmentIndex), typeof(bool)), null, "TricornTargetPostfix");
			try
			{
				defeatBossTrackerType = AccessTools.Inner(typeof(BossGroup), "DefeatBossObjectiveTracker");
			}
			catch (Exception)
			{
			}
			TryPatch(harmony, Find(typeof(ObjectiveTracker), "IsDirty"), null, "ObjectiveDirtyPostfix");
			TryPatch(harmony, Find(typeof(ObjectiveTracker), "GenerateString"), null, "ObjectiveStringPostfix");
			TryPatch(harmony, Find(typeof(GoldshoresBossfight), "SpawnBoss", Type.EmptyTypes), null, "SpawnBossPostfix");
			TryPatch(harmony, Find(typeof(Exit), "OnEnter", Type.EmptyTypes), "ExitPrefix", null);
			TryPatch(harmony, Find(typeof(BossGroup), "DropRewards", Type.EmptyTypes), "DropRewardsPrefix", null);
			TryPatch(harmony, Find(typeof(BazaarController), "SetUpSeerStations", Type.EmptyTypes), null, "SeerPostfix");
			TryPatch(harmony, Find(typeof(DirectorCore), "TrySpawnObject", typeof(DirectorSpawnRequest)), "TrySpawnPrefix", null);
			TryPatch(harmony, Find(typeof(PickupDropletController), "CreatePickupDroplet", typeof(CreatePickupInfo), typeof(Vector3), typeof(Vector3)), "PickupDropPrefix", null);
			Log.LogInfo((object)("Installed " + installed + " hooks" + ((failed > 0) ? (" (" + failed + " failed, see above).") : ".")));
			SceneDirector.onGenerateInteractableCardSelection += OnGenerateInteractables;
			Stage.onServerStageBegin += OnServerStageBegin;
			RoR2Application.onFixedUpdate += Tick;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded));
		}

		private static MethodBase Find(Type type, string name, params Type[] args)
		{
			if (type == null)
			{
				return null;
			}
			try
			{
				return AccessTools.Method(type, name, args ?? Type.EmptyTypes, (Type[])null);
			}
			catch (Exception ex)
			{
				try
				{
					MethodInfo methodInfo = (from m in AccessTools.GetDeclaredMethods(type)
						where m.Name == name
						orderby m.GetParameters().Length descending
						select m).FirstOrDefault();
					Log.LogWarning((object)("Looking up " + type.Name + "." + name + " failed (" + ex.GetType().Name + "); using " + ((methodInfo != null) ? methodInfo.ToString() : "nothing") + "."));
					return methodInfo;
				}
				catch (Exception)
				{
					return null;
				}
			}
		}

		private static void TryPatch(Harmony harmony, MethodBase target, string prefix, string postfix, string finalizer = null, int priority = -1)
		{
			if (target == null)
			{
				failed++;
				Log.LogError((object)("Patch target missing for " + (prefix ?? postfix ?? finalizer) + "; that change is disabled."));
				return;
			}
			try
			{
				harmony.Patch(target, Method(prefix, priority), Method(postfix, priority), (HarmonyMethod)null, Method(finalizer, priority), (HarmonyMethod)null);
				installed++;
			}
			catch (Exception ex)
			{
				failed++;
				Log.LogError((object)("Could not hook " + target.DeclaringType?.Name + "." + target.Name + ": " + ex));
			}
		}

		private static HarmonyMethod Method(string name, int priority)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (name == null)
			{
				return null;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(AurelioniteReworkPlugin), name, (Type[])null);
			if (priority >= 0)
			{
				val.priority = priority;
			}
			return val;
		}

		private void OnGameLoaded()
		{
			//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)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			try
			{
				ItemDef titanGoldDuringTP = Items.TitanGoldDuringTP;
				if (!Object.op_Implicit((Object)(object)titanGoldDuringTP))
				{
					Log.LogWarning((object)"Halcyon Seed not found.");
					return;
				}
				seedIndex = titanGoldDuringTP.itemIndex;
				seedPickup = PickupCatalog.FindPickupIndex(seedIndex);
				if (noQualitySeed.Value)
				{
					((MonoBehaviour)this).StartCoroutine(RemoveQualitySeed());
				}
				seedDescToken = titanGoldDuringTP.descriptionToken;
				seedPickupToken = titanGoldDuringTP.pickupToken;
				try
				{
					ItemIndex val = ItemCatalog.FindItemIndex("EyeOfTheStorm_Stormbound");
					eyePickup = (((int)val != -1) ? PickupCatalog.FindPickupIndex(val) : PickupIndex.none);
					Log.LogInfo((object)((!(eyePickup != PickupIndex.none)) ? "StormboundFalseSon's Eye of the Storm not found." : (eyeNeedsAurelionite.Value ? "Eye of the Storm only drops when False Son is beaten with Aurelionite on his side." : "Eye of the Storm drops normally.")));
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Eye of the Storm lookup: " + ex.Message));
				}
				try
				{
					goldPortalCard = LegacyResourcesAPI.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscGoldshoresPortal");
					if (Object.op_Implicit((Object)(object)goldPortalCard) && Object.op_Implicit((Object)(object)goldPortalCard.prefab))
					{
						goldPortalPrefabName = ((Object)goldPortalCard.prefab).name;
					}
				}
				catch (Exception ex2)
				{
					Log.LogWarning((object)("Gold portal lookup: " + ex2.Message));
				}
				BuildSeedText();
				if (seedCannotBeRemoved.Value)
				{
					titanGoldDuringTP.canRemove = false;
					if (titanGoldDuringTP.tags != null && titanGoldDuringTP.tags.Contains((ItemTag)30))
					{
						titanGoldDuringTP.tags = titanGoldDuringTP.tags.Where((ItemTag t) => (int)t != 30).ToArray();
					}
					Log.LogInfo((object)"Halcyon Seed can no longer be removed.");
				}
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Halcyon Seed setup: " + ex3));
			}
			if (!voidlingUltimateSpawn.Value)
			{
				return;
			}
			try
			{
				Type type = AccessTools.TypeByName("VoidlingRework.VLController");
				MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "SeedAurelionite", (Type[])null, (Type[])null));
				if (methodInfo != null)
				{
					new Harmony("custom.AurelioniteRework.voidling").Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(AurelioniteReworkPlugin), "VoidlingUltimatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					Log.LogInfo((object)"Aurelionite will answer the seed in Voidling's final battle.");
				}
				else
				{
					Log.LogWarning((object)"VoidlingRework's final battle hook not found; Aurelionite won't appear in it.");
				}
			}
			catch (Exception ex4)
			{
				Log.LogError((object)("Voidling hook: " + ex4));
			}
		}

		private static bool MasterNamed(CharacterMaster master, string name)
		{
			if (!Object.op_Implicit((Object)(object)master))
			{
				return false;
			}
			string name2 = ((Object)master).name;
			if (!(name2 == name))
			{
				return name2.StartsWith(name + "(", StringComparison.Ordinal);
			}
			return true;
		}

		private static Context Classify(object channeler)
		{
			if (nextContext.HasValue)
			{
				return nextContext.Value;
			}
			if (channeler is TeleporterInteraction)
			{
				return Context.Teleporter;
			}
			CombatSquad val = (CombatSquad)((channeler is CombatSquad) ? channeler : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				foreach (Phase4Record phase4State in phase4States)
				{
					if (phase4State.state != null)
					{
						CombatSquad val2 = SquadOf(phase4State.state);
						if (Object.op_Implicit((Object)(object)val2) && (Object)(object)val2 == (Object)(object)val)
						{
							return (!phase4State.providence) ? Context.Mithrix : Context.Providence;
						}
					}
				}
				foreach (CharacterMaster readOnlyMembers in val.readOnlyMembersList)
				{
					if (MasterNamed(readOnlyMembers, "FalseSonBossLunarShardBrokenMaster"))
					{
						return Context.FalseSon;
					}
					if (MasterNamed(readOnlyMembers, "BrotherHurtMaster"))
					{
						return Context.Mithrix;
					}
					if (MasterNamed(readOnlyMembers, "ProvidenceFinalMaster"))
					{
						return Context.Providence;
					}
					if (Object.op_Implicit((Object)(object)readOnlyMembers) && ((Object)readOnlyMembers).name.StartsWith("MiniVoidRaidCrabMaster", StringComparison.Ordinal))
					{
						return Context.Voidling;
					}
				}
				SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
				if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && mostRecentSceneDef.cachedName == "meridian")
				{
					return Context.FalseSon;
				}
			}
			return Context.Other;
		}

		private static void ChannelPostfix(object channeler, bool __result)
		{
			try
			{
				if (!__result || GoldTitanManager.currentChanneler != channeler)
				{
					return;
				}
				Context context = Classify(channeler);
				if (context == Context.Voidling)
				{
					voidlingChanneler = channeler;
				}
				if (context == Context.FalseSon && GoldTitanManager.currentTitans.Count > 0)
				{
					falseSonFoughtWithAurelionite = true;
				}
				if (context == Context.FalseSon)
				{
					CombatSquad val = (CombatSquad)((channeler is CombatSquad) ? channeler : null);
					if (val != null)
					{
						BoostFalseSon(val);
					}
				}
				foreach (CharacterMaster currentTitan in GoldTitanManager.currentTitans)
				{
					if (Object.op_Implicit((Object)(object)currentTitan) && !titans.ContainsKey(currentTitan))
					{
						titans[currentTitan] = context;
						if (context == Context.Voidling && voidlingPassive.Value)
						{
							MakePassive(currentTitan);
						}
						Log.LogInfo((object)("Aurelionite summoned (" + context.ToString() + ")" + (IsInvulnerable(context) ? ", invulnerable" : "") + (IsBlessing(context) ? ", protecting the players" : "") + "."));
					}
				}
				UpdateBlessing();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Channel: " + ex.Message));
			}
		}

		private static void MakePassive(CharacterMaster titan)
		{
			try
			{
				HoldPassive(titan);
				Log.LogInfo((object)"Voidling's final battle: Aurelionite is passive.");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Passive Aurelionite: " + ex.Message));
			}
		}

		private static void HoldPassive(CharacterMaster titan)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			BaseAI[] components = ((Component)titan).GetComponents<BaseAI>();
			foreach (BaseAI val in components)
			{
				if (Object.op_Implicit((Object)(object)val) && (((Behaviour)val).enabled || (Object.op_Implicit((Object)(object)val.stateMachine) && ((Behaviour)val.stateMachine).enabled)))
				{
					Target currentEnemy = val.currentEnemy;
					if (currentEnemy != null)
					{
						currentEnemy.Reset();
					}
					((Behaviour)val).enabled = false;
					if (Object.op_Implicit((Object)(object)val.stateMachine))
					{
						((Behaviour)val.stateMachine).enabled = false;
					}
				}
			}
			CharacterBody body = titan.GetBody();
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inputBank))
			{
				((ButtonState)(ref body.inputBank.skill1)).PushState(false);
				((ButtonState)(ref body.inputBank.skill2)).PushState(false);
				((ButtonState)(ref body.inputBank.skill3)).PushState(false);
				((ButtonState)(ref body.inputBank.skill4)).PushState(false);
				body.inputBank.moveVector = Vector3.zero;
			}
		}

		private static bool IsPassiveTitan(CharacterMaster master)
		{
			if (Object.op_Implicit((Object)(object)master) && voidlingPassive.Value && titans.TryGetValue(master, out var value))
			{
				return value == Context.Voidling;
			}
			return false;
		}

		private static bool FromPassiveTitan(DamageInfo damageInfo)
		{
			if (titans.Count == 0 || damageInfo == null || !Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				return false;
			}
			CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				return IsPassiveTitan(component.master);
			}
			return false;
		}

		private static void BoostFalseSon(CombatSquad squad)
		{
			float value = falseSonHealthMultiplier.Value;
			if (value <= 0f || Mathf.Abs(value - 1f) < 0.001f)
			{
				return;
			}
			foreach (CharacterMaster readOnlyMembers in squad.readOnlyMembersList)
			{
				if (!MasterNamed(readOnlyMembers, "FalseSonBossLunarShardBrokenMaster") || !Object.op_Implicit((Object)(object)readOnlyMembers.inventory) || boostedFalseSons.Contains(readOnlyMembers))
				{
					continue;
				}
				try
				{
					boostedFalseSons.Add(readOnlyMembers);
					ItemDef percentMaxHealth = Items.PercentMaxHealth;
					int itemCountEffective = readOnlyMembers.inventory.GetItemCountEffective(percentMaxHealth);
					int num = Mathf.RoundToInt((float)((itemCountEffective > 0) ? itemCountEffective : 100) * value) - ((itemCountEffective > 0) ? itemCountEffective : 0);
					if (num <= 0)
					{
						continue;
					}
					CharacterBody body = readOnlyMembers.GetBody();
					HealthComponent val = (Object.op_Implicit((Object)(object)body) ? body.healthComponent : null);
					float num2 = ((Object.op_Implicit((Object)(object)val) && val.fullHealth > 0f) ? Mathf.Clamp01(val.health / val.fullHealth) : 1f);
					readOnlyMembers.inventory.GiveItemPermanent(percentMaxHealth, num);
					if (Object.op_Implicit((Object)(object)body))
					{
						body.RecalculateStats();
						if (Object.op_Implicit((Object)(object)val) && val.alive)
						{
							val.Networkhealth = Mathf.Max(1f, num2 * val.fullHealth);
						}
						Log.LogInfo((object)("False Son's phase 3 health x" + value + " now that Aurelionite fights for him (" + Mathf.RoundToInt(Object.op_Implicit((Object)(object)val) ? val.fullHealth : 0f) + " HP)."));
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("False Son health: " + ex.Message));
				}
			}
		}

		private static bool ChannelSquadPrefix(CombatSquad combatSquad, ref bool __result)
		{
			if (Object.op_Implicit((Object)(object)combatSquad) && (GoldTitanManager.currentChanneler == combatSquad || combatSquad.defeatedServer || combatSquad.memberCount == 0))
			{
				__result = false;
				return false;
			}
			return true;
		}

		private static void KillTitansPrefix()
		{
			allowTitanKill = true;
		}

		private static Exception KillTitansFinalizer(Exception __exception)
		{
			allowTitanKill = false;
			return __exception;
		}

		private static bool IsInvulnerable(Context context)
		{
			switch (context)
			{
			case Context.Mithrix:
			case Context.Providence:
			case Context.Voidling:
				return bossPhaseInvulnerable.Value;
			case Context.FalseSon:
				return falseSonInvulnerable.Value;
			default:
				return teleporterInvulnerable.Value;
			}
		}

		private static bool IsBlessing(Context context)
		{
			if (context == Context.Teleporter)
			{
				return teleporterPlayersInvulnerable.Value;
			}
			if (bossPhasePlayersInvulnerable.Value)
			{
				if (context != Context.Mithrix && context != Context.Providence)
				{
					return context == Context.Voidling;
				}
				return true;
			}
			return false;
		}

		private static bool IsProtectedTitan(CharacterBody body)
		{
			if (titans.Count == 0 || !Object.op_Implicit((Object)(object)body))
			{
				return false;
			}
			CharacterMaster master = body.master;
			if (Object.op_Implicit((Object)(object)master) && titans.TryGetValue(master, out var value))
			{
				return IsInvulnerable(value);
			}
			return false;
		}

		private static void UpdateBlessing()
		{
			bool flag = false;
			foreach (KeyValuePair<CharacterMaster, Context> titan in titans)
			{
				if (IsBlessing(titan.Value) && Object.op_Implicit((Object)(object)titan.Key))
				{
					CharacterBody body = titan.Key.GetBody();
					if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
					{
						flag = true;
						break;
					}
				}
			}
			if (!flag && bossPhasePlayersInvulnerable.Value && phase4States.Count > 0)
			{
				foreach (Phase4Record phase4State in phase4States)
				{
					if (IsCurrent(phase4State) && PlayersHaveSeeds())
					{
						flag = true;
						break;
					}
				}
			}
			if (flag != blessingActive)
			{
				blessingActive = flag;
				Log.LogInfo((object)(flag ? "Aurelionite is protecting the players: they can't take damage." : "Aurelionite's protection has ended."));
			}
		}

		private static bool ShouldReject(HealthComponent victim)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)victim))
			{
				return false;
			}
			CharacterBody body = victim.body;
			if (!Object.op_Implicit((Object)(object)body))
			{
				return false;
			}
			if (IsProtectedTitan(body))
			{
				return true;
			}
			if (blessingActive)
			{
				return body.isPlayerControlled;
			}
			return false;
		}

		private static bool GuardPrefix(HealthComponent __instance, DamageInfo damageInfo)
		{
			if (damageInfo != null && (ShouldReject(__instance) || (NetworkServer.active && FromPassiveTitan(damageInfo))))
			{
				damageInfo.rejected = true;
				return false;
			}
			return true;
		}

		private static bool GuardPrefixLate(HealthComponent __instance, DamageInfo damageInfo)
		{
			if (damageInfo != null && (ShouldReject(__instance) || (NetworkServer.active && FromPassiveTitan(damageInfo))))
			{
				damageInfo.rejected = true;
				return false;
			}
			return true;
		}

		private static bool SuicidePrefix(HealthComponent __instance, DamageTypeCombo damageType)
		{
			//IL_0027: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (allowTitanKill || !NetworkServer.active || !Object.op_Implicit((Object)(object)__instance) || !ShouldReject(__instance))
			{
				return true;
			}
			CharacterBody body = __instance.body;
			try
			{
				if ((damageType.damageType & int.MinValue) != 0 && Object.op_Implicit((Object)(object)Run.instance))
				{
					TeleportHelper.TeleportBody(body, Run.instance.FindSafeTeleportPosition(body, (Transform)null, 0f, 0f));
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Rescue teleport: " + ex.Message));
			}
			if (Time.time - lastBlockLog > 5f)
			{
				lastBlockLog = Time.time;
				Log.LogInfo((object)("Blocked an instant kill on " + (IsProtectedTitan(body) ? "the protected Aurelionite." : "a protected player.")));
			}
			return false;
		}

		private static void Phase4EnterPostfix(EntityState __instance)
		{
			if (!NetworkServer.active)
			{
				return;
			}
			bool num = __instance is Phase4;
			bool flag = __instance is Phase4;
			if (num || flag)
			{
				phase4States.RemoveAll((Phase4Record r) => r.done || r.state == null || (Object)(object)r.state.outer == (Object)null || r.state.outer.state != r.state);
				phase4States.Add(new Phase4Record
				{
					state = __instance,
					providence = flag,
					startTime = Time.time
				});
			}
		}

		private static bool IsCurrent(Phase4Record record)
		{
			if (record.state != null && (Object)(object)record.state.outer != (Object)null)
			{
				return record.state.outer.state == record.state;
			}
			return false;
		}

		private static CombatSquad SquadOf(EntityState state)
		{
			ScriptedCombatEncounter val = null;
			BrotherEncounterPhaseBaseState val2 = (BrotherEncounterPhaseBaseState)(object)((state is BrotherEncounterPhaseBaseState) ? state : null);
			if (val2 != null)
			{
				val = val2.phaseScriptedCombatEncounter;
			}
			else
			{
				ProvidenceBossEncounterPhaseBaseState val3 = (ProvidenceBossEncounterPhaseBaseState)(object)((state is ProvidenceBossEncounterPhaseBaseState) ? state : null);
				if (val3 != null)
				{
					val = val3.phaseScriptedCombatEncounter;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return val.combatSquad;
		}

		private static bool PlayersHaveSeeds()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_000c: 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)
			if ((int)seedIndex == -1)
			{
				return false;
			}
			GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
			((GetTotalItemCountFromTeamArgs)(ref val))..ctor(seedIndex);
			val.requiredTeam = (TeamIndex)1;
			val.requiresAlive = true;
			val.requiresConnected = true;
			return Util.GetTotalItemCountFromTeam(val) > 0;
		}

		private static void Summon(CombatSquad squad, Context context)
		{
			nextContext = context;
			try
			{
				if (GoldTitanManager.TryStartChannelingAgainstCombatSquadServer(squad))
				{
					Log.LogInfo((object)("Summoned Aurelionite for " + context.ToString() + "."));
				}
			}
			finally
			{
				nextContext = null;
			}
		}

		private static void VoidlingUltimatePostfix(MonoBehaviour __instance)
		{
			try
			{
				if (!NetworkServer.active || !voidlingUltimateSpawn.Value || !Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				CharacterBody component = ((Component)__instance).GetComponent<CharacterBody>();
				CharacterMaster val = (Object.op_Implicit((Object)(object)component) ? component.master : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				CombatSquad[] array = Object.FindObjectsOfType<CombatSquad>();
				foreach (CombatSquad val2 in array)
				{
					if (Object.op_Implicit((Object)(object)val2) && val2.ContainsMember(val))
					{
						if (PlayersHaveSeeds())
						{
							Summon(val2, Context.Voidling);
						}
						return;
					}
				}
				Log.LogWarning((object)"Voidling's combat squad not found; Aurelionite can't join the final battle.");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Voidling ultimate: " + ex.Message));
			}
		}

		private static void CheckFinishedFight()
		{
			object currentChanneler = GoldTitanManager.currentChanneler;
			CombatSquad val = (CombatSquad)((currentChanneler is CombatSquad) ? currentChanneler : null);
			if (val == null || (voidlingStays.Value && currentChanneler == voidlingChanneler))
			{
				fightOverSince = -1f;
			}
			else if (Object.op_Implicit((Object)(object)val) && !val.defeatedServer)
			{
				fightOverSince = -1f;
			}
			else if (fightOverSince < 0f)
			{
				fightOverSince = Time.time;
			}
			else if (!(Time.time - fightOverSince < 0.5f))
			{
				fightOverSince = -1f;
				Log.LogInfo((object)"The fight is over but Aurelionite was still out (another mod's error interrupted the game's cleanup); sending her away and returning the seeds.");
				GoldTitanManager.EndChannelingTitansServer(currentChanneler);
			}
		}

		private static void Tick()
		{
			if (!NetworkServer.active)
			{
				if (titans.Count > 0)
				{
					titans.Clear();
				}
				blessingActive = false;
				return;
			}
			try
			{
				if (titans.Count > 0)
				{
					List<CharacterMaster> list = null;
					foreach (KeyValuePair<CharacterMaster, Context> titan in titans)
					{
						if (!Object.op_Implicit((Object)(object)titan.Key))
						{
							(list ?? (list = new List<CharacterMaster>())).Add(titan.Key);
						}
					}
					if (list != null)
					{
						foreach (CharacterMaster item in list)
						{
							titans.Remove(item);
						}
					}
					foreach (KeyValuePair<CharacterMaster, Context> titan2 in titans)
					{
						if (IsPassiveTitan(titan2.Key))
						{
							HoldPassive(titan2.Key);
						}
					}
				}
				CheckFinishedFight();
				SweepGoldPortals();
				UpdateBlessing();
				if (phase4States.Count == 0 || fallbackSpawnDelay.Value <= 0f)
				{
					return;
				}
				foreach (Phase4Record phase4State in phase4States)
				{
					if (phase4State.done)
					{
						continue;
					}
					if (phase4State.state == null || (Object)(object)phase4State.state.outer == (Object)null || phase4State.state.outer.state != phase4State.state)
					{
						phase4State.done = true;
					}
					else
					{
						if (Time.time - phase4State.startTime < fallbackSpawnDelay.Value)
						{
							continue;
						}
						CombatSquad val = SquadOf(phase4State.state);
						if (Object.op_Implicit((Object)(object)val) && val.memberCount != 0)
						{
							if (GoldTitanManager.currentChanneler == val)
							{
								phase4State.done = true;
							}
							else if (PlayersHaveSeeds())
							{
								phase4State.done = true;
								Summon(val, (!phase4State.providence) ? Context.Mithrix : Context.Providence);
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Tick: " + ex.Message));
			}
		}

		private static bool SeedRemovalPrefix(Inventory __instance, ref ItemIndex itemIndex, int countToAdd)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Invalid comparison between I4 and Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected I4, but got Unknown
			if (countToAdd > 0 && seedVariants.Count > 0 && seedVariants.Contains(itemIndex) && noQualitySeed.Value)
			{
				itemIndex = (ItemIndex)(int)seedIndex;
				return true;
			}
			if (countToAdd >= 0 || (int)itemIndex != (int)seedIndex || (int)seedIndex == -1 || allowSeedRemoval || !seedCannotBeRemoved.Value)
			{
				return true;
			}
			if (Time.time - lastBlockLog > 5f)
			{
				lastBlockLog = Time.time;
				CharacterMaster val = (Object.op_Implicit((Object)(object)__instance) ? ((Component)__instance).GetComponent<CharacterMaster>() : null);
				Log.LogInfo((object)("Blocked removing a Halcyon Seed" + (Object.op_Implicit((Object)(object)val) ? (" from " + ((Object)val).name) : "") + "."));
			}
			return false;
		}

		private static void CanTakePostfix(ref ItemTransformation __instance, ref bool __result)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (__result && (int)seedIndex != -1 && ((ItemTransformation)(ref __instance)).originalItemIndex == seedIndex && seedCannotBeRemoved.Value)
			{
				__result = false;
			}
		}

		private static bool InfectionPrefix(ItemIndex originalItem, ref bool __result)
		{
			//IL_0000: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			if ((int)seedIndex != -1 && originalItem == seedIndex && seedCannotBeRemoved.Value)
			{
				__result = false;
				return false;
			}
			return true;
		}

		private static bool IsGoldTitanStealer(ItemStealController owner)
		{
			if (Object.op_Implicit((Object)(object)owner) && owner.itemStealFilter != null)
			{
				return owner.itemStealFilter.Method.Name == "GoldTitanItemFilter";
			}
			return false;
		}

		private static bool StealItemPrefix(object __instance, ItemIndex itemIndex, ref int __result)
		{
			//IL_0000: 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_0009: Unknown result type (might be due to invalid IL or missing references)
			if ((int)seedIndex == -1 || itemIndex != seedIndex || !seedCannotBeRemoved.Value)
			{
				return true;
			}
			if (IsGoldTitanStealer((ItemStealController)((stealOwnerField != null) ? /*isinst with value type is only supported in some contexts*/: null)))
			{
				allowSeedRemoval = true;
				return true;
			}
			__result = 0;
			return false;
		}

		private static Exception StealItemFinalizer(Exception __exception)
		{
			allowSeedRemoval = false;
			return __exception;
		}

		private static bool InGoldshores()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef))
			{
				return mostRecentSceneDef.cachedName == "goldshores";
			}
			return false;
		}

		private static bool IsTitanGold(CharacterBody body)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)body))
			{
				return false;
			}
			string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
			if (bodyName != null)
			{
				return bodyName.IndexOf("TitanGold", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}

		private static void SubtitlePostfix(CharacterBody __instance, ref string __result)
		{
			if (!string.IsNullOrEmpty(goldshoresSubtitle.Value) && InGoldshores() && IsTitanGold(__instance))
			{
				__result = goldshoresSubtitle.Value;
			}
		}

		private static void LanguagePostfix(string token, ref string __result)
		{
			if (token == null || __result == null)
			{
				return;
			}
			if (token == "TITANGOLD_BODY_SUBTITLE")
			{
				if (!string.IsNullOrEmpty(goldshoresSubtitle.Value) && InGoldshores())
				{
					__result = goldshoresSubtitle.Value;
				}
			}
			else if (token == seedDescToken)
			{
				if (!string.IsNullOrEmpty(seedText.Value))
				{
					__result = seedText.Value;
				}
				else if (seedDescExtra.Length > 0 && !__result.EndsWith(seedDescExtra))
				{
					__result += seedDescExtra;
				}
			}
			else if (token == seedPickupToken)
			{
				if (!string.IsNullOrEmpty(seedText.Value))
				{
					__result = seedText.Value;
				}
				else if (seedPickupExtra.Length > 0 && !__result.EndsWith(seedPickupExtra))
				{
					__result += seedPickupExtra;
				}
			}
		}

		private static void BossBarPostfix(BossGroup __instance)
		{
			try
			{
				if (string.IsNullOrEmpty(goldshoresSubtitle.Value) || string.IsNullOrEmpty(__instance.bestObservedSubtitle) || !InGoldshores() || !Object.op_Implicit((Object)(object)__instance.combatSquad))
				{
					return;
				}
				foreach (CharacterMaster readOnlyMembers in __instance.combatSquad.readOnlyMembersList)
				{
					if (Object.op_Implicit((Object)(object)readOnlyMembers) && IsTitanGold(readOnlyMembers.GetBody()))
					{
						string text = "<sprite name=\"CloudLeft\" tint=1> " + goldshoresSubtitle.Value + "<sprite name=\"CloudRight\" tint=1>";
						if (__instance.bestObservedSubtitle != text)
						{
							__instance.bestObservedSubtitle = text;
						}
						break;
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private static bool PickupDropPrefix(ref CreatePickupInfo pickupInfo)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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)
			try
			{
				if (seedVariants.Count > 0 && seedPickup != PickupIndex.none && noQualitySeed.Value)
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex);
					if (pickupDef != null && seedVariants.Contains(pickupDef.itemIndex))
					{
						((CreatePickupInfo)(ref pickupInfo)).pickupIndex = seedPickup;
					}
				}
				if (!eyeNeedsAurelionite.Value || eyePickup == PickupIndex.none || !NetworkServer.active || ((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex != eyePickup || falseSonFoughtWithAurelionite)
				{
					return true;
				}
				SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
				if (!Object.op_Implicit((Object)(object)mostRecentSceneDef) || mostRecentSceneDef.cachedName != "meridian")
				{
					return true;
				}
				Log.LogInfo((object)"False Son was beaten without Aurelionite on his side: no Eye of the Storm.");
				return false;
			}
			catch (Exception)
			{
				return true;
			}
		}

		private static void BuildSeedText()
		{
			//IL_011a: 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)
			string text = "";
			if (teleporterInvulnerable.Value || teleporterPlayersInvulnerable.Value)
			{
				text = text + " Aurelionite is " + (teleporterInvulnerable.Value ? "<style=cIsUtility>invulnerable</style>" : "") + ((teleporterInvulnerable.Value && teleporterPlayersInvulnerable.Value) ? " and " : "") + (teleporterPlayersInvulnerable.Value ? "makes every player <style=cIsHealing>invulnerable</style> while she is out" : "") + ".";
			}
			text = text + " She also answers in <style=cIsUtility>Mithrix's</style> and <style=cIsUtility>Echo of Providence's</style> final phase" + (voidlingUltimateSpawn.Value ? " and at half of <style=cIsUtility>Voidling's</style> final battle (which a seed makes twice as long)" : "") + (bossPhasePlayersInvulnerable.Value ? ", making every player <style=cIsHealing>invulnerable</style>" : "") + ".";
			bool flag = Mathf.Abs(falseSonHealthMultiplier.Value - 1f) > 0.001f;
			bool flag2 = eyeNeedsAurelionite.Value && eyePickup != PickupIndex.none;
			if (flag || flag2)
			{
				text = text + " In False Son's final phase she sides with him" + (flag ? (", and he gains <style=cIsHealth>" + falseSonHealthMultiplier.Value.ToString("0.##", CultureInfo.InvariantCulture) + "x health</style>") : "") + (flag2 ? "; only then does he drop the <style=cIsUtility>Eye of the Storm</style>" : "") + ".";
			}
			if (seedCannotBeRemoved.Value)
			{
				text += " <style=cIsUtility>Can never be lost</style>: Aurelionite only borrows the seed.";
			}
			seedDescExtra = text;
			seedPickupExtra = (seedCannotBeRemoved.Value ? " Can never be lost." : "");
		}

		private static void OnServerStageBegin(Stage stage)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			portalsSpawnedThisStage = false;
			goldshoresBossGroup = null;
			phase4States.Clear();
			boostedFalseSons.Clear();
			falseSonFoughtWithAurelionite = false;
			voidlingChanneler = null;
			nextPortalSweep = 0f;
			if (!noShrineOfGold.Value)
			{
				return;
			}
			try
			{
				PortalStatueBehavior[] array = Object.FindObjectsOfType<PortalStatueBehavior>();
				foreach (PortalStatueBehavior val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && (int)val.portalType == 1)
					{
						NetworkServer.Destroy(((Component)val).gameObject);
						Log.LogInfo((object)"Removed a Shrine of Gold.");
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Shrine of Gold cleanup: " + ex.Message));
			}
		}

		private static void SpawnBossPostfix(GoldshoresBossfight __instance)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && __instance.hasSpawnedBoss)
				{
					if (Object.op_Implicit((Object)(object)__instance.scriptedCombatEncounter))
					{
						goldshoresBossGroup = ((Component)__instance.scriptedCombatEncounter).GetComponent<BossGroup>();
					}
					if (portalsOnSpawn.Value && !portalsSpawnedThisStage)
					{
						portalsSpawnedThisStage = true;
						SpawnPortals(((EntityState)__instance).transform.position);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Gilded Coast portals: " + ex.Message));
			}
		}

		private static void SpawnPortals(Vector3 origin)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0064: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			GoldshoresMissionController instance = GoldshoresMissionController.instance;
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(LegacyResourcesAPI.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscGoldshoresPortal"), new DirectorPlacementRule
			{
				maxDistance = float.PositiveInfinity,
				minDistance = 10f,
				placementMode = (PlacementMode)3,
				position = origin,
				spawnOnTarget = (Object.op_Implicit((Object)(object)instance) ? instance.bossSpawnPosition : null)
			}, Run.instance.stageRng));
			if (Object.op_Implicit((Object)(object)val))
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "PORTAL_GOLDSHORES_OPEN"
				});
				SceneExitController component = val.GetComponent<SceneExitController>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.useRunNextStageScene = true;
				}
				Log.LogInfo((object)"Gold portal opened as Aurelionite spawned.");
			}
			if (!Run.instance.GetEventFlag("FalseSonBossComplete") && IsValidStormTier(instance) && Object.op_Implicit((Object)(object)DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(LegacyResourcesAPI.Load<SpawnCard>("SpawnCards/InteractableSpawnCard/iscColossusPortal"), new DirectorPlacementRule
			{
				maxDistance = 30f,
				minDistance = 10f,
				placementMode = (PlacementMode)3,
				position = origin
			}, Run.instance.stageRng))))
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "PORTAL_STORM_OPEN"
				});
				Log.LogInfo((object)"Green portal opened as Aurelionite spawned.");
			}
		}

		private static bool IsValidStormTier(GoldshoresMissionController mission)
		{
			Run instance = Run.instance;
			if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.nextStageScene))
			{
				return false;
			}
			int stageOrder = instance.nextStageScene.stageOrder;
			ExpansionDef val = (Object.op_Implicit((Object)(object)mission) ? mission.requiredExpansion : null);
			if (!Object.op_Implicit((Object)(object)val) || instance.IsExpansionEnabled(val))
			{
				if (stageOrder != 2 && stageOrder != 3)
				{
					return stageOrder == 4;
				}
				return true;
			}
			return false;
		}

		private static bool ExitPrefix(Exit __instance)
		{
			if (!NetworkServer.active || !portalsSpawnedThisStage)
			{
				return true;
			}
			if (!Run.instance.GetEventFlag("TitanGoldBossComplete"))
			{
				Run.instance.SetEventFlag("TitanGoldBossComplete");
			}
			for (int num = CombatDirector.instancesList.Count - 1; num >= 0; num--)
			{
				((Behaviour)CombatDirector.instancesList[num]).enabled = false;
			}
			return false;
		}

		private static bool IsGoldshoresBossGroup(BossGroup group)
		{
			if ((Object)(object)group == (Object)(object)goldshoresBossGroup)
			{
				return true;
			}
			if (!InGoldshores())
			{
				return false;
			}
			GoldshoresMissionController instance = GoldshoresMissionController.instance;
			if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.bossSpawnPosition))
			{
				return (Object)(object)group.dropPosition == (Object)(object)instance.bossSpawnPosition;
			}
			return false;
		}

		private static bool DropRewardsPrefix(BossGroup __instance)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_004b: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!singleSeedDrop.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)__instance) || (int)seedIndex == -1 || !IsGoldshoresBossGroup(__instance))
			{
				return true;
			}
			try
			{
				Transform dropPosition = __instance.dropPosition;
				Vector3 val = (Object.op_Implicit((Object)(object)dropPosition) ? dropPosition.position : ((Component)__instance).transform.position);
				Vector3 val2 = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
				PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(seedIndex)), val, val2);
				Log.LogInfo((object)"Aurelionite dropped a single Halcyon Seed.");
				return false;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Gilded Coast drop: " + ex.Message));
				return true;
			}
		}

		private static void SeerPostfix(BazaarController __instance)
		{
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Invalid comparison between I4 and Unknown
			try
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || seerStageSet.Count == 0 || __instance.seerStations == null)
				{
					return;
				}
				SceneDef goldshores = SceneCatalog.FindSceneDef("goldshores");
				if (!Object.op_Implicit((Object)(object)goldshores))
				{
					return;
				}
				SeerStationController[] array = __instance.seerStations.Where((SeerStationController s) => Object.op_Implicit((Object)(object)s)).ToArray();
				if (array.Length == 0)
				{
					return;
				}
				int stageClearCount = Run.instance.stageClearCount;
				if (seerStageSet.Contains(stageClearCount))
				{
					if (!array.Any((SeerStationController s) => s.ReturnTargetSceneDefIndex() == (int)goldshores.sceneDefIndex))
					{
						SeerStationController obj = array[^1];
						obj.SetTargetScene(goldshores);
						PurchaseInteraction component = ((Component)obj).GetComponent<PurchaseInteraction>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.SetAvailable(true);
						}
						if (!Object.op_Implicit((Object)(object)goldshores.portalMaterial))
						{
							Log.LogWarning((object)"The Gilded Coast has no seer preview picture; that seer will look blank.");
						}
						Log.LogInfo((object)("Lunar Seer now shows the Gilded Coast (stages cleared: " + stageClearCount + ")."));
					}
					return;
				}
				SeerStationController[] array2 = array;
				foreach (SeerStationController val in array2)
				{
					if (val.ReturnTargetSceneDefIndex() != (int)goldshores.sceneDefIndex)
					{
						continue;
					}
					SceneDef val2 = PickReplacementScene(array);
					if (Object.op_Implicit((Object)(object)val2))
					{
						val.SetTargetScene(val2);
						Log.LogInfo((object)("Lunar Seer showed the Gilded Coast after stage " + stageClearCount + "; replaced with " + val2.cachedName + "."));
					}
					else
					{
						PurchaseInteraction component2 = ((Component)val).GetComponent<PurchaseInteraction>();
						if (Object.op_Implicit((Object)(object)component2))
						{
							component2.SetAvailable(false);
						}
						Log.LogInfo((object)("Lunar Seer showed the Gilded Coast after stage " + stageClearCount + "; turned it off."));
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Lunar Seers: " + ex.Message));
			}
		}

		private static SceneDef PickReplacementScene(SeerStationController[] seers)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Invalid comparison between Unknown and I4
			SceneDef nextStageScene = Run.instance.nextStageScene;
			if (!Object.op_Implicit((Object)(object)nextStageScene))
			{
				return null;
			}
			List<SceneDef> list = new List<SceneDef>();
			Enumerator<SceneDef> enumerator = SceneCatalog.allSceneDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					SceneDef scene = enumerator.Current;
					if (Object.op_Implicit((Object)(object)scene) && !scene.filterOutOfBazaar && (int)scene.sceneType != 6 && scene.stageOrder == nextStageScene.stageOrder && scene.cachedName != "goldshores" && (Run.instance.stageClearCount >= 4 || !scene.isLockedBeforeLooping) && (!Object.op_Implicit((Object)(object)scene.requiredExpansion) || Run.instance.IsExpansionEnabled(scene.requiredExpansion)) && !seers.Any((SeerStationController s) => s.ReturnTargetSceneDefIndex() == (int)scene.sceneDefIndex))
					{
						list.Add(scene);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			if (list.Count == 0)
			{
				return null;
			}
			return list[Random.Range(0, list.Count)];
		}

		private static bool IsShrineOfGold(SpawnCard card)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)card))
			{
				return false;
			}
			if (shrineOfGoldCards.TryGetValue(card, out var value))
			{
				return value;
			}
			bool flag = false;
			if (Object.op_Implicit((Object)(object)card.prefab))
			{
				PortalStatueBehavior component = card.prefab.GetComponent<PortalStatueBehavior>();
				flag = Object.op_Implicit((Object)(object)component) && (int)component.portalType == 1;
			}
			shrineOfGoldCards[card] = flag;
			return flag;
		}

		private static void OnGenerateInteractables(SceneDirector director, DirectorCardCategorySelection selection)
		{
			if (noShrineOfGold.Value && Object.op_Implicit((Object)(object)selection))
			{
				selection.RemoveCardsThatFailFilter((Predicate<DirectorCard>)((DirectorCard card) => card == null || !IsShrineOfGold(card.spawnCard)));
			}
		}

		private static bool TrySpawnPrefix(DirectorSpawnRequest directorSpawnRequest, ref GameObject __result)
		{
			if (directorSpawnRequest == null)
			{
				return true;
			}
			if (noShrineOfGold.Value && IsShrineOfGold(directorSpawnRequest.spawnCard))
			{
				__result = null;
				return false;
			}
			if (goldPortalOnlyGildedCoast.Value && IsGoldPortalCard(directorSpawnRequest.spawnCard) && !InGoldshores())
			{
				Log.LogInfo((object)"Blocked a gold portal outside the Gilded Coast.");
				__result = null;
				return false;
			}
			return true;
		}

		private static bool IsGoldPortalCard(SpawnCard card)
		{
			if (!Object.op_Implicit((Object)(object)card))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)goldPortalCard) && (Object)(object)card == (Object)(object)goldPortalCard)
			{
				return true;
			}
			if (Object.op_Implicit((Object)(object)card.prefab))
			{
				return ((Object)card.prefab).name == goldPortalPrefabName;
			}
			return false;
		}

		private static bool TeleporterGoldPortalPrefix(TeleporterInteraction __instance)
		{
			if (!goldPortalOnlyGildedCoast.Value || InGoldshores())
			{
				return true;
			}
			try
			{
				__instance.shouldAttemptToSpawnGoldshoresPortal = false;
			}
			catch (Exception)
			{
			}
			Log.LogInfo((object)"Blocked the teleporter's gold portal.");
			return false;
		}

		private static void SweepGoldPortals()
		{
			if (!goldPortalOnlyGildedCoast.Value || Time.time < nextPortalSweep)
			{
				return;
			}
			nextPortalSweep = Time.time + 1f;
			if (InGoldshores())
			{
				return;
			}
			try
			{
				List<SceneExitController> instancesList = InstanceTracker.GetInstancesList<SceneExitController>();
				for (int num = instancesList.Count - 1; num >= 0; num--)
				{
					SceneExitController val = instancesList[num];
					if (Object.op_Implicit((Object)(object)val) && ((Object)((Component)val).gameObject).name.StartsWith(goldPortalPrefabName, StringComparison.Ordinal))
					{
						Log.LogInfo((object)"Removed a gold portal outside the Gilded Coast.");
						NetworkServer.Destroy(((Component)val).gameObject);
					}
				}
				if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal)
				{
					TeleporterInteraction.instance.shouldAttemptToSpawnGoldshoresPortal = false;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Gold portal sweep: " + ex.Message));
			}
		}

		private static void TricornTargetPostfix(EquipmentSlot __instance, EquipmentIndex targetingEquipmentIndex)
		{
			//IL_0018: 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_011a: 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)
			try
			{
				if (!tricornIgnoresAurelionite.Value || !Object.op_Implicit((Object)(object)Equipment.BossHunter) || targetingEquipmentIndex != Equipment.BossHunter.equipmentIndex)
				{
					return;
				}
				HurtBox hurtBox = __instance.currentTarget.hurtBox;
				if (!Object.op_Implicit((Object)(object)hurtBox) || !Object.op_Implicit((Object)(object)hurtBox.healthComponent) || !IsTitanGold(hurtBox.healthComponent.body))
				{
					return;
				}
				HurtBox val = null;
				if (__instance.targetFinder != null)
				{
					foreach (HurtBox result in __instance.targetFinder.GetResults())
					{
						if (!Object.op_Implicit((Object)(object)result) || !Object.op_Implicit((Object)(object)result.healthComponent) || !Object.op_Implicit((Object)(object)result.healthComponent.body))
						{
							continue;
						}
						CharacterBody body = result.healthComponent.body;
						if (!IsTitanGold(body) && !body.HasBuff(Buffs.Immune))
						{
							DeathRewards component = ((Component)body).GetComponent<DeathRewards>();
							if ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.bossDropTable)) || BrotherKarmaUtils.IsBrother(body))
							{
								val = result;
								break;
							}
						}
					}
				}
				__instance.currentTarget = new UserTargetInfo(val);
				if (__instance.targetIndicator != null)
				{
					__instance.targetIndicator.active = Object.op_Implicit((Object)(object)val);
					__instance.targetIndicator.targetTransform = (Object.op_Implicit((Object)(object)val) ? ((Component)val).transform : null);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Tricorn target: " + ex.Message));
			}
		}

		private static bool EndChannelPrefix(object channeler)
		{
			if (voidlingStays.Value && channeler != null && channeler == voidlingChanneler && NetworkServer.active)
			{
				return false;
			}
			return true;
		}

		private static bool InMeridian()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef))
			{
				return mostRecentSceneDef.cachedName == "meridian";
			}
			return false;
		}

		private static bool GoddessAgainstYou()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			if (Time.unscaledTime - goddessCheckTime < 0.25f)
			{
				return goddessAgainstYou;
			}
			goddessCheckTime = Time.unscaledTime;
			goddessAgainstYou = false;
			if (!InMeridian())
			{
				return false;
			}
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances) && Object.op_Implicit((Object)(object)readOnlyInstances.teamComponent) && (int)readOnlyInstances.teamComponent.teamIndex != 1 && Object.op_Implicit((Object)(object)readOnlyInstances.healthComponent) && readOnlyInstances.healthComponent.alive && IsTitanGold(readOnlyInstances))
				{
					goddessAgainstYou = true;
					break;
				}
			}
			return goddessAgainstYou;
		}

		private static bool IsBossObjective(object tracker)
		{
			if (defeatBossTrackerType != null && tracker != null)
			{
				return tracker.GetType() == defeatBossTrackerType;
			}
			return false;
		}

		private static void ObjectiveDirtyPostfix(ObjectiveTracker __instance, ref bool __result)
		{
			if (!__result && !string.IsNullOrEmpty(falseSonObjective.Value) && IsBossObjective(__instance) && InMeridian())
			{
				__result = true;
			}
		}

		private static void ObjectiveStringPostfix(ObjectiveTracker __instance, ref string __result)
		{
			if (!string.IsNullOrEmpty(falseSonObjective.Value) && IsBossObjective(__instance) && GoddessAgainstYou())
			{
				__result = falseSonObjective.Value;
			}
		}

		private IEnumerator RemoveQualitySeed()
		{
			Type type = AccessTools.TypeByName("ItemQualities.QualityCatalog");
			if (type == null)
			{
				yield break;
			}
			FieldInfo availabilityField = AccessTools.Field(type, "Availability");
			FieldInfo groupsField = AccessTools.Field(type, "_itemIndexToQualityGroupIndex");
			if (availabilityField == null || groupsField == null)
			{
				Log.LogWarning((object)"ItemQualities changed; quality Halcyon Seeds can't be removed.");
				yield break;
			}
			float waited = 0f;
			while (true)
			{
				bool flag = false;
				try
				{
					object value = availabilityField.GetValue(null);
					PropertyInfo propertyInfo = AccessTools.Property(value.GetType(), "available");
					flag = propertyInfo != null && (bool)propertyInfo.GetValue(value, null);
				}
				catch (Exception)
				{
				}
				if (flag)
				{
					break;
				}
				if (waited > 300f)
				{
					Log.LogWarning((object)"ItemQualities never finished loading; quality Halcyon Seeds were not removed.");
					yield break;
				}
				waited += 0.5f;
				yield return (object)new WaitForSecondsRealtime(0.5f);
			}
			try
			{
				if (!(groupsField.GetValue(null) is Array array) || (int)seedIndex < 0 || (int)seedIndex >= array.Length)
				{
					yield break;
				}
				int num = Convert.ToInt32(array.GetValue((int)seedIndex));
				if (num < 0)
				{
					Log.LogInfo((object)"The Halcyon Seed has no quality versions.");
					yield break;
				}
				object value2 = Enum.ToObject(array.GetType().GetElementType(), -1);
				for (int i = 0; i < array.Length; i++)
				{
					if (Convert.ToInt32(array.GetValue(i)) == num)
					{
						if (i != (int)seedIndex)
						{
							seedVariants.Add((ItemIndex)i);
						}
						array.SetValue(value2, i);
					}
				}
				Log.LogInfo((object)("Removed " + seedVariants.Count + " quality versions of the Halcyon Seed."));
			}
			catch (Exception ex2)
			{
				Log.LogWarning((object)("Quality Halcyon Seed: " + ex2.Message));
			}
		}
	}
}

BazaarOverhaul.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.NewtMonster;
using EntityStates.SolusVendor;
using HarmonyLib;
using RoR2;
using RoR2.CharacterSpeech;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace BazaarOverhaul
{
	[BepInPlugin("custom.BazaarOverhaul", "BazaarOverhaul", "1.2.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BazaarOverhaulPlugin : BaseUnityPlugin
	{
		public const string QualityGUID = "com.Gorakh.ItemQualities";

		internal static BazaarOverhaulPlugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> GuaranteeBluePortal;

		internal static ConfigEntry<bool> FreeLunar;

		internal static ConfigEntry<bool> DisableLunarRecycler;

		internal static ConfigEntry<int> PrinterCount;

		internal static ConfigEntry<float> PrinterWhite;

		internal static ConfigEntry<float> PrinterGreen;

		internal static ConfigEntry<float> PrinterRed;

		internal static ConfigEntry<float> PrinterBoss;

		internal static ConfigEntry<int> QualityPrinterCount;

		internal static ConfigEntry<float> QualityWhite;

		internal static ConfigEntry<float> QualityGreen;

		internal static ConfigEntry<float> QualityRed;

		internal static ConfigEntry<float> QualityBoss;

		internal static ConfigEntry<int> ScrapperCount;

		internal static ConfigEntry<string> PrinterSpots;

		internal static ConfigEntry<string> QualityPrinterSpots;

		internal static ConfigEntry<string> ScrapperSpots;

		internal static ConfigEntry<bool> BazaarQualityScrapper;

		internal static ConfigEntry<string> QualityScrapperSpot;

		internal static ConfigEntry<bool> MoonScrapper;

		internal static ConfigEntry<bool> EssenceEnabled;

		internal static ConfigEntry<bool> EssenceOnLoops;

		internal static ConfigEntry<string> EssenceTiers;

		internal static ConfigEntry<string> EssenceFallbackPosition;

		internal static ConfigEntry<float> EssenceDistance;

		private static GameObject commandCubePrefab;

		internal static ConfigEntry<bool> NoKickOut;

		internal static ConfigEntry<float> NewtHealthMult;

		internal static ConfigEntry<float> NewtArmor;

		internal static ConfigEntry<bool> CompExchangeNoKickOut;

		private static BodyIndex newtIndex = (BodyIndex)(-1);

		private static bool suppressCompKick;

		private static Transform hiddenKickObject;

		private static bool compKickLogged;

		private static readonly string[] DuplicatorPaths = new string[4] { "RoR2/Base/Duplicator/iscDuplicator.asset", "RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset", "RoR2/Base/DuplicatorMilitary/iscDuplicatorMilitary.asset", "RoR2/Base/DuplicatorWild/iscDuplicatorWild.asset" };

		private const string ScrapperPath = "RoR2/Base/Scrapper/iscScrapper.asset";

		private static readonly string[] QualityFields = new string[4] { "QualityDuplicator", "QualityDuplicatorLarge", "QualityDuplicatorMilitary", "QualityDuplicatorWild" };

		private static readonly InteractableSpawnCard[] duplicatorCards = (InteractableSpawnCard[])(object)new InteractableSpawnCard[4];

		private static InteractableSpawnCard scrapperCard;

		private static readonly Vector3 MoonQualityScrapperSpot = new Vector3(-208.6049f, -144.4923f, -335.8936f);

		private void Awake()
		{
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0443: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Expected O, but got Unknown
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Expected O, but got Unknown
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Expected O, but got Unknown
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Expected O, but got Unknown
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Expected O, but got Unknown
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Expected O, but got Unknown
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Expected O, but got Unknown
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Expected O, but got Unknown
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Expected O, but got Unknown
			//IL_06fe: Expected O, but got Unknown
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_0734: Expected O, but got Unknown
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Expected O, but got Unknown
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			GuaranteeBluePortal = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "GuaranteeBluePortal", true, "Always spawn the Bazaar (blue) portal after every teleporter event.");
			FreeLunar = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FreeLunarContent", true, "All Lunar Coin purchases cost 0 (lunar pods, bazaar shop, seers, newt altars, etc.).");
			DisableLunarRecycler = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableLunarRecycler", true, "Block the Bazaar lunar shop reroll (Lunar Recycler).");
			PrinterCount = ((BaseUnityPlugin)this).Config.Bind<int>("Printers", "Count", 4, "Regular printers added to the Bazaar (0-4).");
			PrinterWhite = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "WhiteWeight", 60f, "Relative chance of a white printer.");
			PrinterGreen = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "GreenWeight", 30f, "Relative chance of a green printer.");
			PrinterRed = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "RedWeight", 5f, "Relative chance of a red printer.");
			PrinterBoss = ((BaseUnityPlugin)this).Config.Bind<float>("Printers", "BossWeight", 5f, "Relative chance of a boss (yellow) printer.");
			QualityPrinterCount = ((BaseUnityPlugin)this).Config.Bind<int>("QualityPrinters", "Count", 2, "Quality printers added to the Bazaar when the Quality mod is installed (0-2).");
			QualityWhite = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "WhiteWeight", 60f, "Relative chance of a white quality printer.");
			QualityGreen = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "GreenWeight", 30f, "Relative chance of a green quality printer.");
			QualityRed = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "RedWeight", 5f, "Relative chance of a red quality printer.");
			QualityBoss = ((BaseUnityPlugin)this).Config.Bind<float>("QualityPrinters", "BossWeight", 5f, "Relative chance of a boss quality printer.");
			ScrapperCount = ((BaseUnityPlugin)this).Config.Bind<int>("Scrappers", "Count", 4, "Scrappers added to the Bazaar (0-4).");
			PrinterSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "PrinterPositions", "-133.3,-25.7,-17.9,72.6; -143.8,-24.7,-23.6,61; -110.7,-26.7,-46.4,32.2; -132,-25,-29.7,60", "Positions for regular printers as x,y,z,yaw separated by ';'. The y value is snapped to the floor.");
			QualityPrinterSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "QualityPrinterPositions", "-138.5,-25.2,-20.7,66; -121.4,-25.8,-38,45", "Positions for quality printers as x,y,z,yaw separated by ';'.");
			ScrapperSpots = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "ScrapperPositions", "-87.1,-24,-7.2,72.6; -65.7,-23.5,-18.9,72.6; -82.1,-23.7,-5.2,72.6; -71.3,-24.7,-29.2,291", "Positions for scrappers as x,y,z,yaw separated by ';'.");
			BazaarQualityScrapper = ((BaseUnityPlugin)this).Config.Bind<bool>("Scrappers", "QualityScrapper", true, "Also add the Quality mod's Quality Scrapper (turns Quality Scrap into normal scrap) to the Bazaar, next to the other scrappers. Needs the Quality mod.");
			QualityScrapperSpot = ((BaseUnityPlugin)this).Config.Bind<string>("Placement", "QualityScrapperPosition", "-84.6,-23.9,-6.2", "Where to look for a spot for the Quality Scrapper in the Bazaar (x,y,z). The nearest clear, level floor within 10 m that isn't on top of another interactable is used, so it ends up beside the scrappers.");
			MoonScrapper = ((BaseUnityPlugin)this).Config.Bind<bool>("Moon", "NormalScrapper", true, "Add a normal scrapper on Commencement, beside the Quality mod's Quality Scrapper (which only takes Quality Scrap). Placed at the same spot without the Quality mod.");
			EssenceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CommandEssence", "Enabled", true, "Spawn one Command Essence in front of the Newt when entering the Bazaar.");
			EssenceTiers = ((BaseUnityPlugin)this).Config.Bind<string>("CommandEssence", "TiersAfterStage", "white,green,green,red", "Tier of the essence when entering the Bazaar after stage 1,2,3,4 (white/green/red/boss/none). Stages beyond the list get nothing.");
			EssenceOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("CommandEssence", "ApplyOnLoops", false, "If true, the list repeats every loop (after stage 6-9 etc.). If false, only after the first 4 stages.");
			EssenceDistance = ((BaseUnityPlugin)this).Config.Bind<float>("CommandEssence", "ForwardDistanceFromCauldrons", 15f, "How far in front of the midpoint between the two Bazaar cauldrons the essence appears. Use a negative value to place it behind instead.");
			EssenceFallbackPosition = ((BaseUnityPlugin)this).Config.Bind<string>("CommandEssence", "FallbackPosition", "-81.5,-23.6,-46.3", "Used if the cauldrons cannot be found (x,y,z).");
			NoKickOut = ((BaseUnityPlugin)this).Config.Bind<bool>("Newt", "DisableKickOut", true, "The Newt never kicks players out of the Bazaar.");
			NewtHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Newt", "HealthMultiplier", 10f, "Multiplier for the Newt's max health (1 = vanilla).");
			NewtArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Newt", "Armor", 0f, "The Newt's armor. Vanilla is 100. Armor-reducing debuffs still lower it further.");
			CompExchangeNoKickOut = ((BaseUnityPlugin)this).Config.Bind<bool>("Computational Exchange", "DisableKickOut", true, "The Solus vendor's Extractor never kicks players out of the Computational Exchange after stealing (and no Karma is gained for it, same as the Bazaar no-kick).");
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Command/CommandCube.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> h)
			{
				commandCubePrefab = h.Result;
			};
			for (int num = 0; num < 4; num++)
			{
				int idx = num;
				AsyncOperationHandle<InteractableSpawnCard> val2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)DuplicatorPaths[num]);
				val2.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> h)
				{
					duplicatorCards[idx] = h.Result;
				};
			}
			AsyncOperationHandle<InteractableSpawnCard> val3 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Scrapper/iscScrapper.asset");
			val3.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> h)
			{
				scrapperCard = h.Result;
			};
			Harmony val4 = new Harmony("custom.BazaarOverhaul");
			MethodInfo methodInfo = AccessTools.Method(typeof(TeleporterInteraction), "Start", (Type[])null, (Type[])null);
			HarmonyMethod val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "TeleporterStartPostfix", (Type[])null);
			val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			methodInfo = AccessTools.Method(typeof(PurchaseInteraction), "Awake", (Type[])null, (Type[])null);
			val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "PurchaseCostPostfix", (Type[])null);
			val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			methodInfo = AccessTools.Method(typeof(PurchaseInteraction), "Start", (Type[])null, (Type[])null);
			val5 = new HarmonyMethod(typeof(BazaarOverhaulPlugin), "PurchaseStartPostfix", (Type[])null);
			val4.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val5, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val4.Patch((MethodBase)AccessTools.Method(typeof(PurchaseInteraction), "GetInteractability", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "InteractabilityPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Type typeFromHandle = typeof(KickFromShop);
			val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnEnter", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickOnEnterPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "FixedUpdate", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickSkipPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val4.Patch((MethodBase)AccessTools.Method(typeFromHandle, "OnExit", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KickSkipPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(SetNewtArmor));
			try
			{
				val4.Patch((MethodBase)AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(BazaarOverhaulPlugin), "NewtArmorPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Newt armor hook failed: " + ex));
			}
			try
			{
				val4.Patch((MethodBase)AccessTools.Method(typeof(StealItem), "OnExit", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "StealExitPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(BazaarOverhaulPlugin), "StealExitFinalizer", (Type[])null), (HarmonyMethod)null);
				val4.Patch((MethodBase)AccessTools.Method(typeof(Util), "KarmaEventTrigger", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "KarmaPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val4.Patch((MethodBase)AccessTools.Method(typeof(SolusVendorShrineSpeechDriver), "SayGetOut", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BazaarOverhaulPlugin), "SayGetOutPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Computational Exchange no-kick hook failed: " + ex2));
			}
			TeleporterInteraction.onTeleporterBeginChargingGlobal += delegate(TeleporterInteraction tp)
			{
				ForceShopPortal(tp);
			};
			Stage.onServerStageBegin += OnServerStageBegin;
		}

		private static void TeleporterStartPostfix(TeleporterInteraction __instance)
		{
			ForceShopPortal(__instance);
		}

		private static void ForceShopPortal(TeleporterInteraction tp)
		{
			if (!GuaranteeBluePortal.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)tp))
			{
				return;
			}
			try
			{
				tp.shouldAttemptToSpawnShopPortal = true;
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void PurchaseCostPostfix(PurchaseInteraction __instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			if (FreeLunar.Value && Object.op_Implicit((Object)(object)__instance) && (int)__instance.costType == 3)
			{
				__instance.cost = 0;
			}
		}

		private static void PurchaseStartPostfix(PurchaseInteraction __instance)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if (FreeLunar.Value && NetworkServer.active && Object.op_Implicit((Object)(object)__instance))
			{
				if ((int)__instance.costType == 3 && __instance.cost != 0)
				{
					__instance.Networkcost = 0;
				}
				if (DisableLunarRecycler.Value && IsRecycler(__instance))
				{
					__instance.SetAvailable(false);
				}
			}
		}

		private static bool IsRecycler(PurchaseInteraction pi)
		{
			if (Object.op_Implicit((Object)(object)pi))
			{
				return ((Object)((Component)pi).gameObject).name.StartsWith("LunarRecycler", StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}

		private static bool InteractabilityPrefix(PurchaseInteraction __instance, ref Interactability __result)
		{
			if (DisableLunarRecycler.Value && IsRecycler(__instance))
			{
				__result = (Interactability)0;
				return false;
			}
			return true;
		}

		private static void OnServerStageBegin(Stage stage)
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && !(mostRecentSceneDef.cachedName != "bazaar"))
			{
				((MonoBehaviour)Instance).StartCoroutine(SetUpBazaar());
			}
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && mostRecentSceneDef.cachedName == "moon2" && MoonScrapper.Value)
			{
				((MonoBehaviour)Instance).StartCoroutine(SetUpMoonScrapper());
			}
		}

		private unsafe static IEnumerator SetUpMoonScrapper()
		{
			yield return (object)new WaitForSeconds(1f);
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance))
			{
				yield break;
			}
			for (int w = 0; w < 10; w++)
			{
				if (Object.op_Implicit((Object)(object)scrapperCard))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
			if (!Object.op_Implicit((Object)(object)scrapperCard))
			{
				Log.LogWarning((object)"Moon scrapper: scrapper spawn card not loaded.");
				yield break;
			}
			try
			{
				Vector3 val = MoonQualityScrapperSpot;
				GameObject val2 = FindQualityScrapper();
				if (Object.op_Implicit((Object)(object)val2))
				{
					val = val2.transform.position;
				}
				List<Vector3> list = InteractablePositions();
				list.Add(val);
				if (!FindClearSpot(val, 4.5f, 16f, 3f, list, out var spot))
				{
					ManualLogSource log = Log;
					Vector3 val3 = val;
					log.LogWarning((object)("Moon scrapper: no clear floor near " + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString() + "; not spawned."));
					yield break;
				}
				Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.seed ^ 0x5C4A99E5);
				if (Object.op_Implicit((Object)(object)Spawn(scrapperCard, spot, 0f, rng)))
				{
					ManualLogSource log2 = Log;
					Vector3 val3 = spot;
					log2.LogInfo((object)("Moon: spawned a normal scrapper at " + ((object)(*(Vector3*)(&val3))/*cast due to .constrained prefix*/).ToString() + (Object.op_Implicit((Object)(object)val2) ? " beside the Quality Scrapper." : ".")));
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static GameObject FindQualityScrapper()
		{
			Type type = Type.GetType("ItemQualities.QualityScrapperController, ItemQualities");
			if (type == null)
			{
				return null;
			}
			Object obj = Object.FindObjectOfType(type);
			Component val = (Component)(object)((obj is Component) ? obj : null);
			if (val == null)
			{
				return null;
			}
			return val.gameObject;
		}

		private static InteractableSpawnCard GetQualityScrapperCard()
		{
			try
			{
				Type type = Type.GetType("ItemQualities.ItemQualitiesContent+SpawnCards, ItemQualities");
				PropertyInfo propertyInfo = ((type == null) ? null : type.GetProperty("AllSpawnCards", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
				if (propertyInfo != null && propertyInfo.GetValue(null) is IEnumerable enumerable)
				{
					foreach (object item in enumerable)
					{
						InteractableSpawnCard val = (InteractableSpawnCard)((item is InteractableSpawnCard) ? item : null);
						if (val != null && Object.op_Implicit((Object)(object)val) && ((Object)val).name == "iscQualityScrapper")
						{
							return val;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return null;
		}

		private static GameObject GetQualityScrapperPrefab()
		{
			try
			{
				Type type = Type.GetType("ItemQualities.ItemQualitiesContent+NetworkedPrefabs, ItemQualities");
				object? obj = ((type == null) ? null : type.GetField("QualityScrapper", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null);
				return (GameObject)((obj is GameObject) ? obj : null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return null;
			}
		}

		private unsafe static void SpawnBazaarQualityScrapper(Xoroshiro128Plus rng, List<GameObject> spawned)
		{
			//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_0023: 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)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ParseVector(QualityScrapperSpot.Value, new Vector3(-84.6f, -23.9f, -6.2f));
			List<Vector3> list = InteractablePositions();
			foreach (GameObject item in spawned)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					list.Add(item.transform.position);
				}
			}
			if (!FindClearSpot(val, 0f, 10f, 2f, list, out var spot))
			{
				ManualLogSource log = Log;
				Vector3 val2 = val;
				log.LogWarning((object)("Quality Scrapper: no clear floor near " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString() + "; not spawned."));
				return;
			}
			InteractableSpawnCard qualityScrapperCard = GetQualityScrapperCard();
			GameObject val3 = null;
			if (Object.op_Implicit((Object)(object)qualityScrapperCard))
			{
				val3 = Spawn(qualityScrapperCard, spot, 0f, rng);
			}
			else
			{
				GameObject qualityScrapperPrefab = GetQualityScrapperPrefab();
				if (!Object.op_Implicit((Object)(object)qualityScrapperPrefab))
				{
					Log.LogWarning((object)"Quality Scrapper not found in the Quality mod; not spawned.");
					return;
				}
				val3 = Object.Instantiate<GameObject>(qualityScrapperPrefab, spot, Quaternion.Euler(0f, rng.RangeFloat(0f, 360f), 0f));
				NetworkServer.Spawn(val3);
			}
			if (Object.op_Implicit((Object)(object)val3))
			{
				spawned.Add(val3);
				ManualLogSource log2 = Log;
				Vector3 val2 = spot;
				log2.LogInfo((object)("Spawned the Quality Scrapper at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString()));
			}
		}

		private static List<Vector3> InteractablePositions()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			MonoBehaviour[] array = Object.FindObjectsOfType<MonoBehaviour>();
			foreach (MonoBehaviour val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && val is IInteractable)
				{
					list.Add(((Component)val).transform.position);
				}
			}
			return list;
		}

		private static bool FindClearSpot(Vector3 centre, float minRadius, float maxRadius, float maxRise, List<Vector3> avoid, out Vector3 spot)
		{
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_0054: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: 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_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val2 = default(RaycastHit);
			for (float num = minRadius; num <= maxRadius + 0.01f; num += 1.5f)
			{
				int num2 = ((num < 0.5f) ? 1 : Mathf.Max(8, Mathf.RoundToInt((float)Math.PI * 2f * num / 1.5f)));
				for (int i = 0; i < num2; i++)
				{
					float num3 = (float)i * ((float)Math.PI * 2f) / (float)num2;
					Vector3 val = centre + new Vector3(Mathf.Cos(num3) * num, 0f, Mathf.Sin(num3) * num) + Vector3.up * 5f;
					Vector3 down = Vector3.down;
					LayerIndex world = LayerIndex.world;
					if (!Physics.Raycast(val, down, ref val2, 10f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) || ((RaycastHit)(ref val2)).normal.y < 0.93f || Mathf.Abs(((RaycastHit)(ref val2)).point.y - centre.y) > maxRise)
					{
						continue;
					}
					Vector3 point = ((RaycastHit)(ref val2)).point;
					Vector3 val3 = point + Vector3.up * 2f;
					Vector3 val4 = point + Vector3.up * 3f;
					world = LayerIndex.world;
					if (Physics.CheckCapsule(val3, val4, 1.4f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
					{
						continue;
					}
					bool flag = false;
					foreach (Vector3 item in avoid)
					{
						Vector3 val5 = item - point;
						if (Mathf.Abs(val5.y) < 4f && val5.x * val5.x + val5.z * val5.z < 12.25f)
						{
							flag = true;
							break;
						}
					}
					if (!flag)
					{
						spot = point;
						return true;
					}
				}
			}
			spot = centre;
			return false;
		}

		private static IEnumerator SetUpBazaar()
		{
			yield return (object)new WaitForSeconds(0.5f);
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance))
			{
				yield break;
			}
			if (DisableLunarRecycler.Value)
			{
				PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>();
				foreach (PurchaseInteraction val in array)
				{
					if (IsRecycler(val))
					{
						val.SetAvailable(false);
					}
				}
			}
			Xoroshiro128Plus rng = new Xoroshiro128Plus(Run.instance.stageRng.nextUlong);
			for (int w = 0; w < 10; w++)
			{
				if (FindCauldrons().Count >= 2)
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.5f);
			}
			try
			{
				SpawnCommandEssence(rng);
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			List<GameObject> spawned = new List<GameObject>();
			List<Vector4> list = ParseSpots(PrinterSpots.Value);
			int num = Mathf.Min(Mathf.Max(0, PrinterCount.Value), list.Count);
			for (int j = 0; j < num; j++)
			{
				SpawnAt(duplicatorCards[PickTier(rng, PrinterWhite.Value, PrinterGreen.Value, PrinterRed.Value, PrinterBoss.Value)], list[j], rng, spawned);
			}
			List<Vector4> list2 = ParseSpots(QualityPrinterSpots.Value);
			int num2 = Mathf.Min(Mathf.Max(0, QualityPrinterCount.Value), list2.Count);
			if (num2 > 0 && Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities"))
			{
				InteractableSpawnCard[] qualityCards = GetQualityCards();
				for (int k = 0; k < num2; k++)
				{
					InteractableSpawnCard val2 = qualityCards[PickTier(rng, QualityWhite.Value, QualityGreen.Value, QualityRed.Value, QualityBoss.Value)];
					if (!Object.op_Implicit((Object)(object)val2))
					{
						Log.LogWarning((object)"Quality printer spawn card not found.");
					}
					else
					{
						SpawnAt(val2, list2[k], rng, spawned);
					}
				}
			}
			List<Vector4> list3 = ParseSpots(ScrapperSpots.Value);
			int num3 = Mathf.Min(Mathf.Max(0, ScrapperCount.Value), list3.Count);
			for (int l = 0; l < num3; l++)
			{
				SpawnAt(scrapperCard, list3[l], rng, spawned);
			}
			if (BazaarQualityScrapper.Value && Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities"))
			{
				try
				{
					SpawnBazaarQualityScrapper(rng, spawned);
				}
				catch (Exception ex2)
				{
					Log.LogError((object)ex2);
				}
			}
			yield return (object)new WaitForSeconds(1f);
			foreach (GameObject item in spawned)
			{
				if (!Object.op_Implicit((Object)(object)item))
				{
					continue;
				}
				ShopTerminalBehavior component = item.GetComponent<ShopTerminalBehavior>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					continue;
				}
				try
				{
					if (component.CurrentPickupIndex() == PickupIndex.none)
					{
						component.GenerateNewPickupServer();
					}
				}
				catch (Exception ex3)
				{
					Log.LogError((object)ex3);
				}
			}
			Log.LogInfo((object)("Bazaar: spawned " + spawned.Count + " interactables."));
		}

		private static bool KickOnEnterPrefix(KickFromShop __instance)
		{
			if (!NoKickOut.Value)
			{
				return true;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)((EntityState)__instance).outer))
				{
					((EntityState)__instance).outer.SetNextStateToMain();
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return false;
		}

		private static bool KickSkipPrefix()
		{
			return !NoKickOut.Value;
		}

		private static void SetNewtArmor()
		{
			//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)
			try
			{
				newtIndex = BodyCatalog.FindBodyIndex("ShopkeeperBody");
				GameObject val = BodyCatalog.FindBodyPrefab("ShopkeeperBody");
				CharacterBody val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					Log.LogInfo((object)("Newt armor " + val2.baseArmor + " (+" + val2.levelArmor + "/level) -> " + NewtArmor.Value));
					val2.baseArmor = NewtArmor.Value;
					val2.levelArmor = 0f;
				}
				else
				{
					Log.LogWarning((object)"Newt body not found; its armor is unchanged.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void NewtArmorPostfix(CharacterBody __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((int)newtIndex != -1 && Object.op_Implicit((Object)(object)__instance) && __instance.bodyIndex == newtIndex && __instance.armor > NewtArmor.Value)
			{
				__instance.armor = NewtArmor.Value;
			}
		}

		private static void StealExitPrefix()
		{
			if (!CompExchangeNoKickOut.Value)
			{
				return;
			}
			suppressCompKick = true;
			try
			{
				Transform val = (Object.op_Implicit((Object)(object)SceneInfo.instance) ? ((Component)SceneInfo.instance).transform.Find("KickOutOfShop") : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					((Object)val).name = "KickOutOfShop (blocked by BazaarOverhaul)";
					hiddenKickObject = val;
				}
				if (!compKickLogged)
				{
					compKickLogged = true;
					Log.LogInfo((object)"Computational Exchange: kick-out blocked.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static Exception StealExitFinalizer(Exception __exception)
		{
			if (Object.op_Implicit((Object)(object)hiddenKickObject))
			{
				((Object)hiddenKickObject).name = "KickOutOfShop";
			}
			hiddenKickObject = null;
			suppressCompKick = false;
			return __exception;
		}

		private static bool KarmaPrefix(string identifier, ref bool __result)
		{
			if (suppressCompKick && identifier == "KickedOutOfCompExchange")
			{
				__result = false;
				return false;
			}
			return true;
		}

		private static bool SayGetOutPrefix()
		{
			return !suppressCompKick;
		}

		private static void OnBodyStart(CharacterBody body)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.master) || NewtHealthMult.Value <= 1f || body.bodyIndex != BodyCatalog.FindBodyIndex("ShopkeeperBody") || Object.op_Implicit((Object)(object)((Component)body.master).GetComponent<NewtBuffed>()))
				{
					return;
				}
				((Component)body.master).gameObject.AddComponent<NewtBuffed>();
				Inventory inventory = body.master.inventory;
				if (Object.op_Implicit((Object)(object)inventory))
				{
					int itemCountPermanent = inventory.GetItemCountPermanent(Items.BoostHp);
					float num = 1f + 0.1f * (float)itemCountPermanent;
					int num2 = Mathf.RoundToInt((num * NewtHealthMult.Value - num) * 10f);
					if (num2 > 0)
					{
						inventory.GiveItemPermanent(Items.BoostHp, num2);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private unsafe static void SpawnCommandEssence(Xoroshiro128Plus rng)
		{
			//IL_00ee: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_011a: 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_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			if (!EssenceEnabled.Value)
			{
				return;
			}
			int stageClearCount = Run.instance.stageClearCount;
			if (stageClearCount < 1)
			{
				return;
			}
			string[] array = EssenceTiers.Value.Split(new char[1] { ',' });
			int num = stageClearCount - 1;
			if (EssenceOnLoops.Value)
			{
				num %= 5;
			}
			if (num < array.Length)
			{
				List<PickupIndex> list;
				switch (array[num].Trim().ToLowerInvariant())
				{
				default:
					return;
				case "white":
					list = Run.instance.availableTier1DropList;
					break;
				case "green":
					list = Run.instance.availableTier2DropList;
					break;
				case "red":
					list = Run.instance.availableTier3DropList;
					break;
				case "boss":
					list = Run.instance.availableBossDropList;
					break;
				}
				if (list != null && list.Count != 0)
				{
					PickupIndex pickupIndex = list[rng.RangeInt(0, list.Count)];
					GetEssencePosition(out var pos, out var _);
					CreatePickupInfo val = default(CreatePickupInfo);
					((CreatePickupInfo)(ref val)).pickupIndex = pickupIndex;
					val.position = pos;
					val.rotation = Quaternion.identity;
					val.artifactFlag = (PickupArtifactFlag)1;
					PickupDropletController.CreatePickupDroplet(val, pos, Vector3.up * 10f);
					ManualLogSource log = Log;
					string text = array[num].Trim();
					Vector3 val2 = pos;
					log.LogInfo((object)("Spawned " + text + " Command Essence at " + ((object)(*(Vector3*)(&val2))/*cast due to .constrained prefix*/).ToString()));
				}
			}
		}

		private static List<Transform> FindCauldrons()
		{
			List<Transform> list = new List<Transform>();
			PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>();
			foreach (PurchaseInteraction val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Object)((Component)val).gameObject).name.IndexOf("LunarCauldron", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					list.Add(((Component)val).gameObject.transform);
				}
			}
			return list;
		}

		private static void GetEssencePosition(out Vector3 pos, out Quaternion rot)
		{
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = FindCauldrons();
			if (list.Count >= 2)
			{
				Transform val = list[0];
				Transform val2 = list[1];
				float num = float.MaxValue;
				for (int i = 0; i < list.Count; i++)
				{
					for (int j = i + 1; j < list.Count; j++)
					{
						Vector3 val3 = list[i].position - list[j].position;
						float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
						if (sqrMagnitude < num)
						{
							num = sqrMagnitude;
							val = list[i];
							val2 = list[j];
						}
					}
				}
				Vector3 val4 = (val.position + val2.position) * 0.5f;
				Vector3 val5 = val.forward + val2.forward;
				val5.y = 0f;
				if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
				{
					Vector3 val6 = val2.position - val.position;
					val6.y = 0f;
					val5 = Vector3.Cross(Vector3.up, val6);
				}
				((Vector3)(ref val5)).Normalize();
				Vector3 val7 = val4 + val5 * EssenceDistance.Value + Vector3.up * 5f;
				Vector3 val8 = val7;
				Vector3 down = Vector3.down;
				LayerIndex world = LayerIndex.world;
				RaycastHit val9 = default(RaycastHit);
				if (Physics.Raycast(val8, down, ref val9, 20f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
				{
					val7 = ((RaycastHit)(ref val9)).point;
				}
				pos = val7 + Vector3.up * 1f;
				rot = Quaternion.LookRotation(-val5);
				Log.LogInfo((object)("Command Essence placed between cauldrons " + ((Object)((Component)val).gameObject).name + " and " + ((Object)((Component)val2).gameObject).name));
			}
			else
			{
				Log.LogWarning((object)"Bazaar cauldrons not found; using fallback position.");
				pos = ParseVector(EssenceFallbackPosition.Value, new Vector3(-81.5f, -23.6f, -46.3f));
				rot = Quaternion.identity;
			}
		}

		private static Vector3 ParseVector(string s, Vector3 fallback)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string[] array = s.Split(new char[1] { ',' });
				CultureInfo invariantCulture = CultureInfo.InvariantCulture;
				return new Vector3(float.Parse(array[0], invariantCulture), float.Parse(array[1], invariantCulture), float.Parse(array[2], invariantCulture));
			}
			catch
			{
				return fallback;
			}
		}

		private static GameObject Spawn(InteractableSpawnCard card, Vector3 pos, float yaw, Xoroshiro128Plus rng)
		{
			//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_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_001a: Expected O, but got Unknown
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_001c: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				DirectorSpawnRequest val = new DirectorSpawnRequest((SpawnCard)(object)card, new DirectorPlacementRule
				{
					placementMode = (PlacementMode)0,
					position = pos
				}, rng);
				return ((SpawnCard)card).DoSpawn(pos, Quaternion.Euler(0f, yaw, 0f), val).spawnedInstance;
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return null;
			}
		}

		private unsafe static void SpawnAt(InteractableSpawnCard card, Vector4 spot, Xoroshiro128Plus rng, List<GameObject> spawned)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_0076: 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_00d7: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)card))
			{
				Log.LogWarning((object)"Spawn card not loaded; skipped.");
				return;
			}
			Vector3 point = default(Vector3);
			((Vector3)(ref point))..ctor(spot.x, spot.y, spot.z);
			Vector3 val = point + Vector3.up * 6f;
			Vector3 down = Vector3.down;
			LayerIndex world = LayerIndex.world;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, down, ref val2, 15f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
			{
				point = ((RaycastHit)(ref val2)).point;
			}
			GameObject val3 = Spawn(card, point, spot.w, rng);
			if (Object.op_Implicit((Object)(object)val3))
			{
				spawned.Add(val3);
				ManualLogSource log = Log;
				string name = ((Object)card).name;
				Vector3 val4 = point;
				log.LogInfo((object)("Spawned " + name + " at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString()));
			}
			else
			{
				ManualLogSource log2 = Log;
				string name2 = ((Object)card).name;
				Vector3 val4 = point;
				log2.LogWarning((object)("Failed to spawn " + name2 + " at " + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString()));
			}
		}

		private static List<Vector4> ParseSpots(string value)
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			List<Vector4> list = new List<Vector4>();
			CultureInfo invariantCulture = CultureInfo.InvariantCulture;
			string[] array = value.Split(new char[1] { ';' });
			foreach (string text in array)
			{
				string[] array2 = text.Split(new char[1] { ',' });
				if (array2.Length >= 3)
				{
					try
					{
						list.Add(new Vector4(float.Parse(array2[0].Trim(), invariantCulture), float.Parse(array2[1].Trim(), invariantCulture), float.Parse(array2[2].Trim(), invariantCulture), (array2.Length <= 3) ? 0f : float.Parse(array2[3].Trim(), invariantCulture)));
					}
					catch
					{
						Log.LogWarning((object)("Bad position entry: " + text));
					}
				}
			}
			return list;
		}

		private static int PickTier(Xoroshiro128Plus rng, float w, float g, float r, float b)
		{
			float num = Mathf.Max(0f, w) + Mathf.Max(0f, g) + Mathf.Max(0f, r) + Mathf.Max(0f, b);
			if (num <= 0f)
			{
				return 0;
			}
			float num2 = rng.nextNormalizedFloat * num;
			if ((num2 -= Mathf.Max(0f, w)) < 0f)
			{
				return 0;
			}
			if ((num2 -= Mathf.Max(0f, g)) < 0f)
			{
				return 1;
			}
			if ((num2 -= Mathf.Max(0f, r)) < 0f)
			{
				return 2;
			}
			return 3;
		}

		private static InteractableSpawnCard[] GetQualityCards()
		{
			InteractableSpawnCard[] array = (InteractableSpawnCard[])(object)new InteractableSpawnCard[4];
			try
			{
				Type type = Type.GetType("ItemQualities.ItemQualitiesContent+SpawnCards, ItemQualities");
				if (type == null)
				{
					return array;
				}
				for (int i = 0; i < 4; i++)
				{
					FieldInfo field = type.GetField(QualityFields[i], BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						ref InteractableSpawnCard reference = ref array[i];
						object? value = field.GetValue(null);
						reference = (InteractableSpawnCard)((value is InteractableSpawnCard) ? value : null);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return array;
		}
	}
	public class NewtBuffed : MonoBehaviour
	{
	}
}

BetterReincarnation.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace BetterReincarnation
{
	[BepInPlugin("com.Bloonjitsu7.BetterReincarnation", "BetterReincarnation", "1.2.0")]
	public class BetterReincarnation : BaseUnityPlugin
	{
		public static int trialCount;

		private static readonly Dictionary<string, Vector3> PagePositions = new Dictionary<string, Vector3>
		{
			{
				"sad1",
				new Vector3(-4768.42f, 70.14f, -5173.27f)
			},
			{
				"soul1",
				new Vector3(4420.31f, -2410.97f, 1230.51f)
			},
			{
				"surv2",
				new Vector3(3295.17f, -976.83f, -2154.03f)
			}
		};

		public static ConfigEntry<int> trialRequirement { get; set; }

		public static ConfigEntry<bool> everyTrial { get; set; }

		public void Awake()
		{
			trialRequirement = ((BaseUnityPlugin)this).Config.Bind<int>("Better Reincarnation", "Trial Requirement", 1, "Number of trials that must be entered in a run before pages start spawning. 1 = from the first trial.");
			everyTrial = ((BaseUnityPlugin)this).Config.Bind<bool>("Better Reincarnation", "Every Trial", true, "If true, a page spawns in every trial from the requirement onward. If false, only once (original behaviour).");
			Stage.onStageStartGlobal += OnStageStart;
			Run.onRunStartGlobal += OnRunStart;
		}

		private void OnStageStart(Stage stage)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: 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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)stage) || !Object.op_Implicit((Object)(object)stage.sceneDef) || !PagePositions.TryGetValue(stage.sceneDef.cachedName, out var value))
			{
				return;
			}
			trialCount++;
			if (!((!everyTrial.Value) ? (trialCount == trialRequirement.Value) : (trialCount >= trialRequirement.Value)))
			{
				return;
			}
			try
			{
				CreatePickupInfo val = default(CreatePickupInfo);
				((CreatePickupInfo)(ref val)).pickupIndex = PickupCatalog.FindPickupIndex(Items.PageDie.itemIndex);
				val.rotation = Quaternion.identity;
				PickupDropletController.CreatePickupDroplet(val, value, Vector3.zero);
				((BaseUnityPlugin)this).Logger.LogMessage((object)("Page Spawned! (trial " + trialCount + ")"));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)ex);
			}
		}

		private void OnRunStart(Run run)
		{
			trialCount = 0;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

BossSuperArmor.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HarmonyLib;
using RoR2;
using RoR2.SolusWing;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace BossSuperArmor
{
	[BepInPlugin("custom.BossSuperArmor", "BossSuperArmor", "1.7.2")]
	public class BossSuperArmorPlugin : BaseUnityPlugin
	{
		private class ArmorRule
		{
			public string name;

			public ConfigEntry<bool> enabled;

			public ConfigEntry<float> thresholdPercent;

			public ConfigEntry<float> duration;

			public float Threshold => Mathf.Max(0.001f, thresholdPercent.Value / 100f);
		}

		private struct HitState
		{
			public bool tracked;

			public bool addedNonLethal;

			public float preHealth;

			public float preShield;

			public float preBarrier;

			public float allowed;

			public float duration;
		}

		internal class BossPhaseClock : MonoBehaviour
		{
			public int phase;

			public FixedTimeStamp start;
		}

		public const string GUID = "custom.BossSuperArmor";

		public const string NAME = "BossSuperArmor";

		public const string VERSION = "1.7.1";

		private const string BrotherBodyPath = "RoR2/Base/Brother/BrotherBody.prefab";

		internal static ManualLogSource Log;

		internal static BossSuperArmorPlugin Instance;

		internal static BuffDef ArmorBuff;

		internal static int RequiredKarma = 1;

		internal static GameObject ApplicationEffect;

		private ConfigEntry<bool> requireKarma;

		private ConfigEntry<string> extraBodies;

		private readonly Dictionary<string, ArmorRule> bodyNameToRule = new Dictionary<string, ArmorRule>(StringComparer.OrdinalIgnoreCase);

		private readonly Dictionary<BodyIndex, ArmorRule> bodyRules = new Dictionary<BodyIndex, ArmorRule>();

		private readonly HashSet<BodyIndex> providenceBodies = new HashSet<BodyIndex>();

		private readonly HashSet<BodyIndex> wurmBodies = new HashSet<BodyIndex>();

		private ArmorRule provP1;

		private ArmorRule provP2;

		private ArmorRule provP3;

		private ArmorRule provP4;

		private ArmorRule[] falseSonRules;

		private ArmorRule[] mithrixRules;

		private ArmorRule[] voidlingRules;

		private readonly HashSet<BodyIndex> falseSonIdx = new HashSet<BodyIndex>();

		private readonly HashSet<BodyIndex> mithrixIdx = new HashSet<BodyIndex>();

		private readonly HashSet<BodyIndex> voidlingIdx = new HashSet<BodyIndex>();

		internal static int falseSonPhase = 0;

		internal static int mithrixPhase = 0;

		private static PropertyInfo fathomlessInstance;

		private static MethodInfo fathomlessGetPhase;

		internal static int providencePhase = 0;

		internal static FixedTimeStamp mithrixPhaseStart;

		internal static FixedTimeStamp falseSonPhaseStart;

		internal static FixedTimeStamp providencePhaseStart;

		private static readonly string[] FalseSonBodies = new string[3] { "FalseSonBossBody", "FalseSonBossBodyLunarShard", "FalseSonBossBodyBrokenLunarShard" };

		private static readonly string[] SolusWingBodies = new string[1] { "SolusWingBody" };

		private static readonly string[] SolusHeartBodies = new string[2] { "SolusHeartBody", "SolusHeartBody_Offering" };

		private static readonly string[] AnimaHarvesterBodies = new string[3] { "ReaperBossBody", "ReaperBossMalachiteBody", "ReaperBossSoulBody" };

		private static readonly string[] MithrixBodies = new string[3] { "BrotherBody", "BrotherHurtBody", "BrotherHurtBodyP3" };

		private static readonly string[] VoidlingBodies = new string[6] { "MiniVoidRaidCrabBodyBase", "MiniVoidRaidCrabBodyPhase1", "MiniVoidRaidCrabBodyPhase2", "MiniVoidRaidCrabBodyPhase3", "VoidRaidCrabBody", "VoidRaidCrabJointBody" };

		private static readonly string[] ProvidenceBodyNames = new string[4] { "ProvBody", "ProvDesperationBody", "ProvFinalBody", "ProvStationaryBody" };

		private static readonly string[] WurmBodyNames = new string[2] { "GildedWurmLaserBody", "GildedWurmOrbBody" };

		private static readonly string[] AurelioniteBodies = new string[1] { "TitanGoldBody" };

		internal static readonly string[] HalcyoniteBodies = new string[1] { "HalcyoniteBody" };

		private readonly HashSet<BodyIndex> aurelioniteIdx = new HashSet<BodyIndex>();

		private readonly HashSet<BodyIndex> lateChecked = new HashSet<BodyIndex>();

		private ArmorRule voidlingAddsRule;

		private ArmorRule voidlingFinalRule;

		internal bool IsProvidenceBody(CharacterBody b)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)b))
			{
				return providenceBodies.Contains(b.bodyIndex);
			}
			return false;
		}

		private static string[] JoinNames(string[] a, string[] b)
		{
			string[] array = new string[a.Length + b.Length];
			a.CopyTo(array, 0);
			b.CopyTo(array, a.Length);
			return array;
		}

		private void Awake()
		{
			//IL_0539: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Expected O, but got Unknown
			//IL_0767: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Expected O, but got Unknown
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e7: Expected O, but got Unknown
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Expected O, but got Unknown
			//IL_0673: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			requireKarma = ((BaseUnityPlugin)this).Config.Bind<bool>("Super Armor", "RequireKarma", true, "Super armor only applies when the run's Karma meets Mithrix's requirement (Karma 1). Off = always.");
			falseSonRules = new ArmorRule[3]
			{
				Rule("False Son Phase 1", string.Empty, 20f, 1f),
				Rule("False Son Phase 2", string.Empty, 20f, 1f),
				Rule("False Son Phase 3", string.Empty, 20f, 1f)
			};
			ArmorRule rule = Rule("Solus Wing", string.Empty, 20f, 1f);
			ArmorRule rule2 = Rule("Solus Heart", string.Empty, 20f, 1f);
			ArmorRule rule3 = Rule("Anima Harvester", "both phases", 20f, 1f);
			ArmorRule rule4 = Rule("Aurelionite", "hostile Aurelionite: Gilded Coast boss and Aurelionite on False Son's side", 20f, 1f);
			ArmorRule rule5 = Rule("Halcyonite", "only the Halcyonites a Halcyon Shrine spawns, not normal ones", 20f, 1f);
			voidlingAddsRule = Rule("Voidling Adds", "the Voidtouched Halcyon Knights and Alloy Hunters of VoidlingRework's phases 4 and 10", 20f, 1f);
			provP1 = Rule("Echo of Providence Phase 1", string.Empty, 20f, 1f);
			provP2 = Rule("Echo of Providence Phase 2", "both worms", 20f, 1f);
			provP3 = Rule("Echo of Providence Phase 3", string.Empty, 20f, 1f);
			provP4 = Rule("Echo of Providence Phase 4", string.Empty, 10f, 1f);
			mithrixRules = new ArmorRule[4]
			{
				Rule("Mithrix Phase 1", "replaces Mithrix's vanilla super armor values", 20f, 1f),
				Rule("Mithrix Phase 2", "replaces Mithrix's vanilla super armor values", 20f, 1f),
				Rule("Mithrix Phase 3", "replaces Mithrix's vanilla super armor values", 10f, 1f),
				Rule("Mithrix Phase 4", "replaces Mithrix's vanilla super armor values", 10f, 5f, enabledByDefault: false)
			};
			voidlingRules = new ArmorRule[3]
			{
				Rule("Voidling Phase 1", "vanilla, OldFathomlessVoidling, Nuxlar FathomlessVoidling; VoidlingRework's phase 1", 20f, 1f),
				Rule("Voidling Phase 2", "vanilla, OldFathomlessVoidling, Nuxlar FathomlessVoidling; VoidlingRework's phases 2 to 5", 20f, 1f),
				Rule("Voidling Phase 3", "vanilla, OldFathomlessVoidling, Nuxlar FathomlessVoidling; VoidlingRework's phases 6 to 11", 20f, 1f)
			};
			voidlingFinalRule = Rule("Voidling Final Battle", "VoidlingRework's phase 12", 10f, 1f);
			Type type = AccessTools.TypeByName("FathomlessVoidling.Controllers.FathomlessMissionController");
			if (type != null)
			{
				fathomlessInstance = AccessTools.Property(type, "instance");
				fathomlessGetPhase = AccessTools.Method(type, "GetCurrentPhase", (Type[])null, (Type[])null);
			}
			extraBodies = ((BaseUnityPlugin)this).Config.Bind<string>("Super Armor - Extra Bodies", "BodyNames", string.Empty, "Comma-separated extra body names (e.g. BeetleQueen2Body) that also get super armor.");
			ArmorRule value = Rule("Extra Bodies", "the bodies listed in BodyNames", 10f, 1f);
			Map(falseSonRules[0], FalseSonBodies);
			Map(rule, SolusWingBodies);
			Map(rule2, SolusHeartBodies);
			Map(rule3, AnimaHarvesterBodies);
			Map(rule4, AurelioniteBodies);
			Map(rule5, HalcyoniteBodies);
			Map(mithrixRules[0], MithrixBodies);
			Map(voidlingRules[0], VoidlingBodies);
			Map(provP1, ProvidenceBodyNames);
			Map(provP2, WurmBodyNames);
			string[] array = extraBodies.Value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (!string.IsNullOrWhiteSpace(text) && !bodyNameToRule.ContainsKey(text.Trim()))
				{
					bodyNameToRule[text.Trim()] = value;
				}
			}
			Stormbound.Setup(((BaseUnityPlugin)this).Config, new KeyValuePair<string, string[]>[9]
			{
				new KeyValuePair<string, string[]>("Voidling Adds", new string[0]),
				new KeyValuePair<string, string[]>("Aurelionite", AurelioniteBodies),
				new KeyValuePair<string, string[]>("Halcyonite", HalcyoniteBodies),
				new KeyValuePair<string, string[]>("Solus Wing", SolusWingBodies),
				new KeyValuePair<string, string[]>("Solus Heart", SolusHeartBodies),
				new KeyValuePair<string, string[]>("Anima Harvester", AnimaHarvesterBodies),
				new KeyValuePair<string, string[]>("Echo of Providence", JoinNames(ProvidenceBodyNames, WurmBodyNames)),
				new KeyValuePair<string, string[]>("Mithrix", MithrixBodies),
				new KeyValuePair<string, string[]>("Voidling", VoidlingBodies)
			});
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherBody.prefab");
			val.Completed += delegate(AsyncOperationHandle<GameObject> handle)
			{
				ReadMithrixArmor(handle.Result);
			};
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ResolveBodyIndices));
			Stage.onStageStartGlobal += delegate
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: 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_002b: Unknown result type (might be due to invalid IL or missing references)
				providencePhase = 0;
				falseSonPhase = 0;
				mithrixPhase = 0;
				providencePhaseStart = FixedTimeStamp.zero;
				falseSonPhaseStart = FixedTimeStamp.zero;
				mithrixPhaseStart = FixedTimeStamp.zero;
			};
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(FixStormboundPhases));
			RoR2Application.onFixedUpdate += AllBossesTick;
			Harmony val2 = new Harmony("custom.BossSuperArmor");
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
				val2.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(BossSuperArmorPlugin), "TakeDamagePrefix", (Type[])null), new HarmonyMethod(typeof(BossSuperArmorPlugin), "TakeDamagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not hook damage: " + ex));
			}
			try
			{
				Stormbound.Hook(val2);
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Could not hook Stormbound defenses: " + ex2));
			}
			try
			{
				val2.Patch((MethodBase)AccessTools.Method(typeof(BrotherSuperArmorController), "OnDamageDealtServer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(BossSuperArmorPlugin), "VanillaArmorPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Could not hook vanilla super armor: " + ex3));
			}
			try
			{
				MethodInfo methodInfo2 = AccessTools.Method(typeof(EntityStateMachine), "SetState", new Type[1] { typeof(EntityState) }, (Type[])null);
				HarmonyMethod val3 = new HarmonyMethod(typeof(BossSuperArmorPlugin), "SetStatePostfix", (Type[])null);
				val2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex4)
			{
				Log.LogError((object)("Could not hook state machine: " + ex4));
			}
		}

		private ArmorRule Rule(string section, string note, float threshold, float duration, bool enabledByDefault = true)
		{
			string text = ((!string.IsNullOrEmpty(note)) ? (" (" + note + ")") : string.Empty);
			ArmorRule obj = new ArmorRule
			{
				name = section
			};
			string text2 = "Super Armor - " + section;
			obj.enabled = ((BaseUnityPlugin)this).Config.Bind<bool>(text2, "Enabled", enabledByDefault, "Give " + section + text + " super armor.");
			obj.thresholdPercent = ((BaseUnityPlugin)this).Config.Bind<float>(text2, "HealthThresholdPercent", threshold, "Super armor starts every time this percent of max HP is lost (VoidlingRework's phases 2 to 8: of the current part's third of the bar, counted again from zero each part).");
			obj.duration = ((BaseUnityPlugin)this).Config.Bind<float>(text2, "Duration", duration, "Super armor duration in seconds.");
			return obj;
		}

		private void Map(ArmorRule rule, string[] names)
		{
			foreach (string key in names)
			{
				bodyNameToRule[key] = rule;
			}
		}

		private void ResolveBodyIndices()
		{
			//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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			bodyRules.Clear();
			providenceBodies.Clear();
			wurmBodies.Clear();
			falseSonIdx.Clear();
			mithrixIdx.Clear();
			voidlingIdx.Clear();
			aurelioniteIdx.Clear();
			foreach (KeyValuePair<string, ArmorRule> item in bodyNameToRule)
			{
				BodyIndex val = BodyCatalog.FindBodyIndex(item.Key);
				if ((int)val == -1)
				{
					Log.LogInfo((object)("Body not found (DLC/mod not installed?): " + item.Key));
					continue;
				}
				bodyRules[val] = item.Value;
				if (Array.IndexOf(ProvidenceBodyNames, item.Key) >= 0)
				{
					providenceBodies.Add(val);
				}
				if (Array.IndexOf(WurmBodyNames, item.Key) >= 0)
				{
					wurmBodies.Add(val);
				}
				if (Array.IndexOf(FalseSonBodies, item.Key) >= 0)
				{
					falseSonIdx.Add(val);
				}
				if (Array.IndexOf(MithrixBodies, item.Key) >= 0)
				{
					mithrixIdx.Add(val);
				}
				if (Array.IndexOf(VoidlingBodies, item.Key) >= 0)
				{
					voidlingIdx.Add(val);
				}
				if (Array.IndexOf(AurelioniteBodies, item.Key) >= 0)
				{
					aurelioniteIdx.Add(val);
				}
			}
			Log.LogInfo((object)("Super armor targets resolved: " + bodyRules.Count));
		}

		private static void ReadMithrixArmor(GameObject brotherPrefab)
		{
			try
			{
				BrotherSuperArmorController val = ((!Object.op_Implicit((Object)(object)brotherPrefab)) ? null : brotherPrefab.GetComponentInChildren<BrotherSuperArmorController>(true));
				if ((Object)(object)val != (Object)null)
				{
					Traverse obj = Traverse.Create((object)val);
					BuffDef value = obj.Field("buffToApply").GetValue<BuffDef>();
					if (Object.op_Implicit((Object)(object)value))
					{
						ArmorBuff = value;
					}
					RequiredKarma = obj.Field("requiredKarma").GetValue<int>();
					ApplicationEffect = obj.Field("applicationEffectPrefab").GetValue<GameObject>();
					Log.LogInfo((object)("Using Mithrix super armor buff=" + ((!Object.op_Implicit((Object)(object)ArmorBuff)) ? "null" : ((Object)ArmorBuff).name) + " karma=" + RequiredKarma));
				}
				else
				{
					Log.LogWarning((object)"BrotherSuperArmorController not found on Mithrix; using defaults.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			if (!Object.op_Implicit((Object)(object)ArmorBuff))
			{
				ArmorBuff = Buffs.DamageReduction;
				Log.LogWarning((object)"Falling back to DLC4 DamageReduction buff.");
			}
		}

		private static void SetStatePostfix(EntityState newState)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (newState == null)
			{
				return;
			}
			string fullName = ((object)newState).GetType().FullName;
			if (fullName == null)
			{
				return;
			}
			int result;
			if (fullName.StartsWith("EntityStates.Missions.ProvidenceBossEncounter.Phase", StringComparison.Ordinal))
			{
				if (int.TryParse(fullName.Substring(fullName.Length - 1), out result))
				{
					if (result != providencePhase)
					{
						providencePhaseStart = FixedTimeStamp.now;
					}
					providencePhase = result;
				}
			}
			else if (fullName.StartsWith("EntityStates.MeridianEvent.Phase", StringComparison.Ordinal))
			{
				if (int.TryParse(fullName.Substring(fullName.Length - 1), out result))
				{
					if (result != falseSonPhase)
					{
						falseSonPhaseStart = FixedTimeStamp.now;
					}
					falseSonPhase = result;
				}
			}
			else if (fullName.StartsWith("EntityStates.Missions.BrotherEncounter.Phase", StringComparison.Ordinal) && int.TryParse(fullName.Substring(fullName.Length - 1), out result))
			{
				if (result != mithrixPhase)
				{
					mithrixPhaseStart = FixedTimeStamp.now;
				}
				mithrixPhase = result;
			}
		}

		private void AllBossesTick()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Invalid comparison between Unknown and I4
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || Stormbound.RemoveAfter == null)
			{
				return;
			}
			float value = Stormbound.RemoveAfter.Value;
			if (value <= 0f)
			{
				return;
			}
			try
			{
				ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
				for (int num = readOnlyInstancesList.Count - 1; num >= 0; num--)
				{
					CharacterBody val = readOnlyInstancesList[num];
					if (!Object.op_Implicit((Object)(object)val) || !val.hasStarted || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive || (Object.op_Implicit((Object)(object)val.teamComponent) && (int)val.teamComponent.teamIndex == 1) || (!val.isBoss && !Stormbound.Applies(val) && !TryGetRule(val, out var _)))
					{
						continue;
					}
					int num2 = PhaseKey(val);
					BossPhaseClock bossPhaseClock = ((Component)val).GetComponent<BossPhaseClock>();
					if (!Object.op_Implicit((Object)(object)bossPhaseClock))
					{
						bossPhaseClock = ((Component)val).gameObject.AddComponent<BossPhaseClock>();
						bossPhaseClock.phase = num2;
						bossPhaseClock.start = PhaseStart(val, num2, val.localStartTime);
					}
					else if (bossPhaseClock.phase != num2)
					{
						bossPhaseClock.phase = num2;
						bossPhaseClock.start = PhaseStart(val, num2, FixedTimeStamp.now);
						if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<Stormbound.AdaptiveStripped>()))
						{
							Stormbound.Restore(val);
						}
						continue;
					}
					if (!(((FixedTimeStamp)(ref bossPhaseClock.start)).timeSince + 0.0001f < value))
					{
						if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<Stormbound.AdaptiveStripped>()))
						{
							Stormbound.StripAdaptive(val);
						}
						else
						{
							Stormbound.KeepStripped(val);
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Removing boss adaptive armor: " + ex.Message));
			}
		}

		private int PhaseKey(CharacterBody b)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			BodyIndex bodyIndex = b.bodyIndex;
			if (mithrixIdx.Contains(bodyIndex))
			{
				return mithrixPhase;
			}
			if (falseSonIdx.Contains(bodyIndex) || (aurelioniteIdx.Contains(bodyIndex) && falseSonPhase > 0))
			{
				return falseSonPhase;
			}
			if (providenceBodies.Contains(bodyIndex) || wurmBodies.Contains(bodyIndex))
			{
				return providencePhase;
			}
			if (voidlingIdx.Contains(bodyIndex))
			{
				int num = Stormbound.VoidlingStage(b);
				if (num <= 0)
				{
					return VoidlingPhase(b);
				}
				return num;
			}
			if (Stormbound.IsAnima(b))
			{
				if (!Stormbound.harvesterPhase2)
				{
					return 1;
				}
				return 2;
			}
			return 0;
		}

		private FixedTimeStamp PhaseStart(CharacterBody b, int phase, FixedTimeStamp fallback)
		{
			//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_0004: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			if (phase <= 0)
			{
				return fallback;
			}
			BodyIndex bodyIndex = b.bodyIndex;
			FixedTimeStamp harvesterPhaseStart;
			if (mithrixIdx.Contains(bodyIndex))
			{
				harvesterPhaseStart = mithrixPhaseStart;
			}
			else if (falseSonIdx.Contains(bodyIndex) || aurelioniteIdx.Contains(bodyIndex))
			{
				harvesterPhaseStart = falseSonPhaseStart;
			}
			else if (providenceBodies.Contains(bodyIndex) || wurmBodies.Contains(bodyIndex))
			{
				harvesterPhaseStart = providencePhaseStart;
			}
			else
			{
				if (!Stormbound.IsAnima(b))
				{
					return fallback;
				}
				harvesterPhaseStart = Stormbound.harvesterPhaseStart;
			}
			if (!(harvesterPhaseStart.t > 0f) || !(harvesterPhaseStart.t <= FixedTimeStamp.now.t))
			{
				return fallback;
			}
			return harvesterPhaseStart;
		}

		private static void FixStormboundPhases()
		{
			try
			{
				if (!Stormbound.FixStormboundPhase3.Value)
				{
					return;
				}
				Type configs = AccessTools.TypeByName("StormboundFalseSon.Configs");
				if (configs == null)
				{
					return;
				}
				Func<string, float> obj = delegate(string field)
				{
					FieldInfo fieldInfo = AccessTools.Field(configs, field);
					return (!(fieldInfo == null)) ? Convert.ToSingle(fieldInfo.GetValue(null)) : float.NaN;
				};
				float num = obj("fsBaseHP2");
				float num2 = obj("fsLevelHP2");
				float num3 = obj("fsBaseHP3");
				float num4 = obj("fsLevelHP3");
				float num5 = obj("fsBaseArmor");
				float num6 = obj("fsLevelArmor");
				if (float.IsNaN(num) || float.IsNaN(num2) || float.IsNaN(num3) || float.IsNaN(num4) || float.IsNaN(num5) || float.IsNaN(num6))
				{
					Log.LogWarning((object)"Stormbound False Son phase fix: its settings weren't found, nothing changed.");
					return;
				}
				GameObject val = BodyCatalog.FindBodyPrefab("FalseSonBossBodyLunarShard");
				GameObject val2 = BodyCatalog.FindBodyPrefab("FalseSonBossBodyBrokenLunarShard");
				CharacterBody val3 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<CharacterBody>() : null);
				CharacterBody val4 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent<CharacterBody>() : null);
				if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val4))
				{
					return;
				}
				if (val4.baseMaxHealth == num3 && val4.levelMaxHealth == num4 && val4.baseArmor == num5 && val4.levelArmor == num6)
				{
					Log.LogInfo((object)"Stormbound False Son already sets up phase 3 correctly; nothing changed.");
					return;
				}
				if (val3.baseMaxHealth == num3 && val3.levelMaxHealth == num4)
				{
					val3.baseMaxHealth = num;
					val3.levelMaxHealth = num2;
					val3.baseMoveSpeed /= 1.15f;
				}
				val4.baseMaxHealth = num3;
				val4.levelMaxHealth = num4;
				val4.baseArmor = num5;
				val4.levelArmor = num6;
				val4.baseMoveSpeed *= 1.15f;
				Log.LogInfo((object)("Stormbound False Son phases fixed: phase 2 " + num + " HP (+" + num2 + "/level), phase 3 " + num3 + " HP (+" + num4 + "/level), " + num5 + " armor, x1.15 speed each."));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stormbound False Son phase fix failed: " + ex.Message));
			}
		}

		private static bool VanillaArmorPrefix(BrotherSuperArmorController __instance)
		{
			try
			{
				if ((Object)(object)Instance == (Object)null || (Object)(object)__instance == (Object)null)
				{
					return true;
				}
				CharacterBody val = Traverse.Create((object)__instance).Field("body").GetValue<CharacterBody>();
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = ((Component)__instance).GetComponent<CharacterBody>();
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					return true;
				}
				if (Instance.TryGetRule(val, out var rule) && Instance.ResolveRule(val, rule).enabled.Value)
				{
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private ArmorRule ResolveRule(CharacterBody body, ArmorRule rule)
		{
			//IL_0007: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (wurmBodies.Contains(body.bodyIndex))
			{
				return provP2;
			}
			if (falseSonIdx.Contains(body.bodyIndex))
			{
				return Pick(falseSonRules, (falseSonPhase <= 0) ? FalseSonPhaseFromBody(body) : falseSonPhase);
			}
			if (mithrixIdx.Contains(body.bodyIndex))
			{
				return Pick(mithrixRules, (mithrixPhase <= 0) ? MithrixPhaseFromBody(body) : mithrixPhase);
			}
			if (voidlingIdx.Contains(body.bodyIndex))
			{
				int num = Stormbound.VoidlingStage(body);
				if ((num == 45 || num == 46) && voidlingFinalRule != null)
				{
					return voidlingFinalRule;
				}
				return Pick(voidlingRules, VoidlingPhase(body));
			}
			if (!providenceBodies.Contains(body.bodyIndex))
			{
				return rule;
			}
			switch (providencePhase)
			{
			case 1:
				return provP1;
			case 2:
				return provP2;
			case 3:
				return provP3;
			case 4:
				return provP4;
			default:
			{
				string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
				if (bodyName == "ProvDesperationBody")
				{
					return provP3;
				}
				if (bodyName == "ProvFinalBody")
				{
					return provP4;
				}
				return provP1;
			}
			}
		}

		private static ArmorRule Pick(ArmorRule[] rules, int phase)
		{
			return rules[Mathf.Clamp(phase, 1, rules.Length) - 1];
		}

		private static int MithrixPhaseFromBody(CharacterBody body)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
			if (bodyName == "BrotherHurtBodyP3")
			{
				return 3;
			}
			if (bodyName == "BrotherHurtBody")
			{
				return 4;
			}
			return 1;
		}

		private bool TryGetRule(CharacterBody body, out ArmorRule rule)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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_0131: 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)
			if (Stormbound.IsOrdinaryHalcyonite(body))
			{
				rule = null;
				return false;
			}
			if (Stormbound.IsVoidlingAdd(body))
			{
				rule = voidlingAddsRule;
				return rule != null;
			}
			if (bodyRules.TryGetValue(body.bodyIndex, out rule))
			{
				return true;
			}
			if ((int)body.bodyIndex == -1 || lateChecked.Contains(body.bodyIndex))
			{
				return false;
			}
			lateChecked.Add(body.bodyIndex);
			string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
			if (bodyName == null || !bodyNameToRule.TryGetValue(bodyName, out rule))
			{
				return false;
			}
			bodyRules[body.bodyIndex] = rule;
			if (Array.IndexOf(MithrixBodies, bodyName) >= 0)
			{
				mithrixIdx.Add(body.bodyIndex);
			}
			if (Array.IndexOf(FalseSonBodies, bodyName) >= 0)
			{
				falseSonIdx.Add(body.bodyIndex);
			}
			if (Array.IndexOf(VoidlingBodies, bodyName) >= 0)
			{
				voidlingIdx.Add(body.bodyIndex);
			}
			if (Array.IndexOf(ProvidenceBodyNames, bodyName) >= 0)
			{
				providenceBodies.Add(body.bodyIndex);
			}
			if (Array.IndexOf(WurmBodyNames, bodyName) >= 0)
			{
				wurmBodies.Add(body.bodyIndex);
			}
			if (Array.IndexOf(AurelioniteBodies, bodyName) >= 0)
			{
				aurelioniteIdx.Add(body.bodyIndex);
			}
			Log.LogInfo((object)("Late-resolved super armor target: " + bodyName));
			return true;
		}

		private static int FalseSonPhaseFromBody(CharacterBody body)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
			if (bodyName == "FalseSonBossBodyBrokenLunarShard")
			{
				return 3;
			}
			if (bodyName == "FalseSonBossBodyLunarShard")
			{
				return 2;
			}
			return 1;
		}

		private static int VoidlingPhase(CharacterBody body)
		{
			//IL_0001: 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_0074: Expected O, but got Unknown
			string bodyName = BodyCatalog.GetBodyName(body.bodyIndex);
			if (bodyName.EndsWith("Phase1"))
			{
				return 1;
			}
			if (bodyName.EndsWith("Phase2"))
			{
				return 2;
			}
			if (bodyName.EndsWith("Phase3"))
			{
				return 3;
			}
			try
			{
				if (fathomlessInstance != null && fathomlessGetPhase != null)
				{
					object value = fathomlessInstance.GetValue(null, null);
					if (value is Object && Object.op_Implicit((Object)value))
					{
						int num = Convert.ToInt32(fathomlessGetPhase.Invoke(value, null));
						if (num >= 0)
						{
							return num + 1;
						}
					}
				}
			}
			catch
			{
			}
			return 1;
		}

		private bool KarmaAllows()
		{
			if (!requireKarma.Value)
			{
				return true;
			}
			KarmaManager instance = KarmaManager.instance;
			if (!Object.op_Implicit((Object)(object)instance) || !instance.IsKarmaEnabled())
			{
				return false;
			}
			return instance.GetEffectiveKarma() >= RequiredKarma;
		}

		private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo, out HitState __state)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			__state = default(HitState);
			try
			{
				if (!NetworkServer.active || (Object)(object)Instance == (Object)null || damageInfo == null || !Object.op_Implicit((Object)(object)__instance) || !__instance.alive)
				{
					return;
				}
				CharacterBody body = __instance.body;
				if (!Object.op_Implicit((Object)(object)body) || (Object.op_Implicit((Object)(object)body.teamComponent) && (int)body.teamComponent.teamIndex == 1) || !Instance.TryGetRule(body, out var rule))
				{
					return;
				}
				rule = Instance.ResolveRule(body, rule);
				if (rule.enabled.Value && Object.op_Implicit((Object)(object)ArmorBuff) && Instance.KarmaAllows() && !body.HasBuff(ArmorBuff))
				{
					SuperArmorTracker superArmorTracker = ((Component)body).GetComponent<SuperArmorTracker>();
					if (!Object.op_Implicit((Object)(object)superArmorTracker))
					{
						superArmorTracker = ((Component)body).gameObject.AddComponent<SuperArmorTracker>();
					}
					int num = Stormbound.VoidlingStage(body);
					if (num != superArmorTracker.part)
					{
						superArmorTracker.part = num;
						superArmorTracker.damageAccumulated = 0f;
					}
					float num2 = rule.Threshold * Stormbound.PartHealth(__instance);
					__state.tracked = true;
					__state.allowed = Mathf.Max(0f, num2 - superArmorTracker.damageAccumulated);
					__state.duration = Mathf.Max(0.05f, rule.duration.Value);
					__state.preHealth = __instance.health;
					__state.preShield = __instance.shield;
					__state.preBarrier = __instance.barrier;
					float num3 = __state.preHealth + __state.preShield + __state.preBarrier;
					if (__state.allowed < num3 && (damageInfo.damageType.damageType & 1) == 0)
					{
						ref DamageType damageType = ref damageInfo.damageType.damageType;
						damageType = (DamageType)((uint)damageType | 1u);
						__state.addedNonLethal = true;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void TakeDamagePostfix(HealthComponent __instance, DamageInfo damageInfo, HitState __state)
		{
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			if (!__state.tracked)
			{
				return;
			}
			try
			{
				if (__state.addedNonLethal)
				{
					ref DamageType damageType = ref damageInfo.damageType.damageType;
					damageType = (DamageType)((uint)damageType & 0xFFFFFFFEu);
				}
				if (!Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				CharacterBody body = __instance.body;
				SuperArmorTracker superArmorTracker = ((!Object.op_Implicit((Object)(object)body)) ? null : ((Component)body).GetComponent<SuperArmorTracker>());
				if (!Object.op_Implicit((Object)(object)superArmorTracker))
				{
					return;
				}
				float num = Mathf.Max(0f, __state.preHealth - __instance.health);
				float num2 = Mathf.Max(0f, __state.preShield - __instance.shield);
				float num3 = Mathf.Max(0f, __state.preBarrier - __instance.barrier);
				float num4 = num + num2 + num3;
				if (num4 <= 0f)
				{
					return;
				}
				if (num4 < __state.allowed)
				{
					superArmorTracker.damageAccumulated += num4;
					return;
				}
				float num5 = num4 - __state.allowed;
				if (__instance.alive && num5 > 0f)
				{
					float num6 = Mathf.Min(num5, num);
					num5 -= num6;
					float num7 = Mathf.Min(num5, num2);
					num5 -= num7;
					float num8 = Mathf.Min(num5, num3);
					if (num6 > 0f)
					{
						__instance.Networkhealth = __instance.health + num6;
					}
					if (num7 > 0f)
					{
						__instance.Networkshield = __instance.shield + num7;
					}
					if (num8 > 0f)
					{
						__instance.Networkbarrier = __instance.barrier + num8;
					}
				}
				superArmorTracker.damageAccumulated = 0f;
				if (__instance.alive && Object.op_Implicit((Object)(object)body))
				{
					body.AddTimedBuff(ArmorBuff, __state.duration);
					if (Object.op_Implicit((Object)(object)ApplicationEffect))
					{
						EffectManager.SpawnEffect(ApplicationEffect, new EffectData
						{
							origin = body.corePosition,
							rootObject = ((Component)body).gameObject,
							scale = body.radius
						}, true);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}
	public class SuperArmorTracker : MonoBehaviour
	{
		public float damageAccumulated;

		public int part = -1;
	}
	internal static class Stormbound
	{
		private class AnimaP2 : MonoBehaviour
		{
			public bool noHeal;
		}

		private class EchoHpGiven : MonoBehaviour
		{
		}

		private struct HitState
		{
			public float hp;

			public float adaptive;
		}

		internal class AdaptiveStripped : MonoBehaviour
		{
			public int removedItems;
		}

		internal class ShrineSpawned : MonoBehaviour
		{
		}

		private class ShrineDirectorHooked : MonoBehaviour
		{
		}

		internal static ConfigEntry<bool> AdaptiveEnabled;

		internal static ConfigEntry<int> AdaptiveStacks;

		internal static ConfigEntry<float> AdaptiveCap;

		internal static ConfigEntry<float> RemoveAfter;

		internal static ConfigEntry<bool> WeakPointAdaptive;

		internal static ConfigEntry<bool> SoftCap;

		internal static ConfigEntry<float> CapPercent;

		internal static ConfigEntry<float> ExcessMult;

		internal static ConfigEntry<bool> WeakPointSoftCap;

		internal static ConfigEntry<float> EchoHpMult;

		internal static ConfigEntry<float> AnimaP2HpMult;

		internal static ConfigEntry<bool> AnimaP2NoHeal;

		internal static ConfigEntry<bool> FixSharedSuffering;

		internal static ConfigEntry<bool> FixStormboundPhase3;

		internal static FixedTimeStamp harvesterPhaseStart;

		private static bool sharedSufferingErrorLogged;

		private static readonly HashSet<BodyIndex> weakPointIdx = new HashSet<BodyIndex>();

		internal static bool harvesterPhase2;

		private static readonly string[] AnimaBodies = new string[3] { "ReaperBossBody", "ReaperBossMalachiteBody", "ReaperBossSoulBody" };

		private static readonly string[] EchoHpBodies = new string[6] { "ProvBody", "ProvDesperationBody", "ProvFinalBody", "ProvStationaryBody", "GildedWurmLaserBody", "GildedWurmOrbBody" };

		private static readonly Dictionary<string, ConfigEntry<bool>> nameToToggle = new Dictionary<string, ConfigEntry<bool>>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<BodyIndex, ConfigEntry<bool>> idx = new Dictionary<BodyIndex, ConfigEntry<bool>>();

		private static readonly HashSet<BodyIndex> checkedIdx = new HashSet<BodyIndex>();

		private static BodyIndex halcyoniteIndex = (BodyIndex)(-1);

		private static bool halcyoniteResolved;

		internal static ConfigEntry<bool> VoidlingAddsToggle;

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

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

		private static bool markersResolved;

		internal static void Restore(CharacterBody b)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			AdaptiveStripped adaptiveStripped = (Object.op_Implicit((Object)(object)b) ? ((Component)b).GetComponent<AdaptiveStripped>() : null);
			if (!Object.op_Implicit((Object)(object)adaptiveStripped))
			{
				return;
			}
			int num = adaptiveStripped.removedItems;
			Object.DestroyImmediate((Object)(object)adaptiveStripped);
			if (Object.op_Implicit((Object)(object)b.inventory) && Object.op_Implicit((Object)(object)Items.AdaptiveArmor) && b.inventory.GetItemCountPermanent(Items.AdaptiveArmor) <= 0)
			{
				if (Applies(b) && AdaptiveEnabled.Value)
				{
					num = Mathf.Max(num, AdaptiveStacks.Value);
				}
				if (num > 0)
				{
					b.inventory.GiveItemPermanent(Items.AdaptiveArmor, num);
				}
			}
			b.RecalculateStats();
			BossSuperArmorPlugin.Log.LogInfo((object)("New phase: adaptive armor given back to " + BodyCatalog.GetBodyName(b.bodyIndex) + "."));
		}

		internal static void KeepStripped(CharacterBody b)
		{
			if (!Object.op_Implicit((Object)(object)b))
			{
				return;
			}
			bool flag = false;
			if (Object.op_Implicit((Object)(object)b.inventory) && Object.op_Implicit((Object)(object)Items.AdaptiveArmor))
			{
				int itemCountPermanent = b.inventory.GetItemCountPermanent(Items.AdaptiveArmor);
				if (itemCountPermanent > 0)
				{
					b.inventory.RemoveItemPermanent(Items.AdaptiveArmor, itemCountPermanent);
					flag = true;
					AdaptiveStripped component = ((Component)b).GetComponent<AdaptiveStripped>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.removedItems = Mathf.Max(component.removedItems, itemCountPermanent);
					}
				}
			}
			if (Object.op_Implicit((Object)(object)b.healthComponent) && b.healthComponent.adaptiveArmorValue != 0f)
			{
				b.healthComponent.adaptiveArmorValue = 0f;
				flag = true;
			}
			if (flag)
			{
				b.RecalculateStats();
			}
		}

		internal static void Setup(ConfigFile cfg, KeyValuePair<string, string[]>[] groups)
		{
			AdaptiveEnabled = cfg.Bind<bool>("Adaptive Armor", "Enabled", true, "Give the bosses in [Bosses] Stormbound False Son's adaptive armor (vanilla Adaptive Armor with extra stacks and a higher cap).");
			AdaptiveStacks = cfg.Bind<int>("Adaptive Armor", "Stacks", 2, "Adaptive Armor stacks each boss has. Every stack gives +30 armor per 1% of max HP lost (VoidlingRework's phases 2 to 8: 1% of the current part's third of the bar); it all decays at 40 armor per second. Stormbound False Son gives him 2.");
			AdaptiveCap = cfg.Bind<float>("Adaptive Armor", "Cap", 500f, "Maximum adaptive armor. Vanilla is 400; Stormbound False Son raises it to 400 x (1 + 0.25 per extra stack) = 500 with 2 stacks.");
			RemoveAfter = cfg.Bind<float>("Adaptive Armor", "RemovedAfterSeconds", 200f, "Every boss (all of them, including False Son and teleporter bosses) loses all adaptive armor once the current phase of its fight has lasted this many seconds. Every phase starts again with its armor (Echo of Providence phase 4 counts from when its music starts). Paused time doesn't count. 0 = never.");
			WeakPointAdaptive = cfg.Bind<bool>("Adaptive Armor", "SolusWingWeakPoints", false, "Give Solus Wing's weak points adaptive armor: damage to any weak point builds one shared pool (measured against the weak points' combined HP) that protects all of them. Off = weak points have none. Solus Wing's core always has its own.");
			SoftCap = cfg.Bind<bool>("Soft Damage Cap", "Enabled", true, "Damage from a single hit above CapPercent of the boss's max HP is reduced, for the bosses in [Bosses]. Checked after armor.");
			CapPercent = cfg.Bind<float>("Soft Damage Cap", "CapPercent", 5f, "Soft cap threshold, percent of max HP (Stormbound False Son uses 15).");
			ExcessMult = cfg.Bind<float>("Soft Damage Cap", "ExcessMultiplier", 0.5f, "Multiplier for the part of a hit above the cap (0.5 = halved).");
			WeakPointSoftCap = cfg.Bind<bool>("Soft Damage Cap", "SolusWingWeakPoints", true, "Also cap hits on Solus Wing's weak points, measured against the weak points' combined HP (so CapPercent 5 = 20% of one weak point when there are four).");
			EchoHpMult = cfg.Bind<float>("Boss Health", "EchoOfProvidenceMultiplier", 8f, "Max HP multiplier for every phase of the Echo of Providence fight (Providence and both worms; not the phase 3 shadow clones). 1 = vanilla.");
			AnimaP2HpMult = cfg.Bind<float>("Boss Health", "AnimaHarvesterPhase2Multiplier", 8f, "Max HP multiplier for the Anima Harvester's second phase. 1 = vanilla.");
			AnimaP2NoHeal = cfg.Bind<bool>("Boss Health", "AnimaHarvesterPhase2NoHealing", true, "The Anima Harvester's second phase can't recover HP by any means (healing, regen, lifesteal...).");
			FixSharedSuffering = cfg.Bind<bool>("Fixes", "SharedSufferingPool", true, "Fixes a vanilla Shared Suffering bug: when its pooled damage kills an enemy mid-tick, the game errors out and never empties the pool, so it keeps growing and is dealt again (ignoring armor) every few seconds. With this on, each tick deals the pool once and then resets it.");
			FixStormboundPhase3 = cfg.Bind<bool>("Fixes", "StormboundFalseSonPhase3", true, "Stormbound False Son puts its phase 3 HP, armor and speed on the phase 2 body by mistake (phase 2 also gets its speed boost twice) and leaves phase 3 vanilla. This gives each phase its intended values. Needs a restart.");
			for (int i = 0; i < groups.Length; i++)
			{
				KeyValuePair<string, string[]> keyValuePair = groups[i];
				string text = ((keyValuePair.Key == "Halcyonite") ? "the Halcyonites a Halcyon Shrine spawns (not normal ones)" : ((keyValuePair.Key == "Voidling Adds") ? "the Voidtouched Halcyon Knights and Alloy Hunters of VoidlingRework's phases 4 and 10" : keyValuePair.Key));
				ConfigEntry<bool> val = cfg.Bind<bool>("Bosses", keyValuePair.Key.Replace(" ", string.Empty), true, "Give " + text + " the adaptive armor and the soft damage cap (False Son has Stormbound False Son's own).");
				if (keyValuePair.Key == "Voidling Adds")
				{
					VoidlingAddsToggle = val;
				}
				string[] value = keyValuePair.Value;
				foreach (string key in value)
				{
					nameToToggle[key] = val;
				}
			}
		}

		internal static bool IsHalcyonite(CharacterBody b)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//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_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 (!halcyoniteResolved && BodyCatalog.bodyCount > 0)
			{
				halcyoniteResolved = true;
				halcyoniteIndex = BodyCatalog.FindBodyIndex(BossSuperArmorPlugin.HalcyoniteBodies[0]);
			}
			if (Object.op_Implicit((Object)(object)b) && (int)halcyoniteIndex != -1)
			{
				return b.bodyIndex == halcyoniteIndex;
			}
			return false;
		}

		internal static bool IsShrineHalcyonite(CharacterBody b)
		{
			if (IsHalcyonite(b) && Object.op_Implicit((Object)(object)b.master))
			{
				return Object.op_Implicit((Object)(object)((Component)b.master).GetComponent<ShrineSpawned>());
			}
			return false;
		}

		internal static bool IsOrdinaryHalcyonite(CharacterBody b)
		{
			if (IsHalcyonite(b) && !IsShrineHalcyonite(b))
			{
				return !IsVoidlingAdd(b);
			}
			return false;
		}

		private static void ResolveMarkers()
		{
			//IL_001a: 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)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (!markersResolved && BuffCatalog.buffCount > 0)
			{
				markersResolved = true;
				addMarker = BuffCatalog.FindBuffIndex("bdVoidlingReworkAdd");
				stageMarker = BuffCatalog.FindBuffIndex("bdVoidlingReworkStage");
			}
		}

		internal static bool IsVoidlingAdd(CharacterBody b)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			ResolveMarkers();
			if (Object.op_Implicit((Object)(object)b) && (int)addMarker != -1)
			{
				return b.HasBuff(addMarker);
			}
			return false;
		}

		internal static float PartHealth(HealthComponent hc)
		{
			float fullCombinedHealth = hc.fullCombinedHealth;
			int num = VoidlingStage(hc.body);
			if ((uint)(num - 20) <= 1u || num == 23 || (uint)(num - 30) <= 2u)
			{
				return Mathf.Max(1f, fullCombinedHealth / 3f);
			}
			return Mathf.Max(1f, fullCombinedHealth);
		}

		internal static int VoidlingStage(CharacterBody b)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			ResolveMarkers();
			if (!Object.op_Implicit((Object)(object)b) || (int)stageMarker == -1)
			{
				return 0;
			}
			return b.GetBuffCount(stageMarker);
		}

		private static void ShrineActivationPostfix(CombatDirector __instance)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			try
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ShrineDirectorHooked>()))
				{
					((Component)__instance).gameObject.AddComponent<ShrineDirectorHooked>();
					if (__instance.onSpawnedServer == null)
					{
						__instance.onSpawnedServer = new OnSpawnedServer();
					}
					((UnityEvent<GameObject>)(object)__instance.onSpawnedServer).AddListener((UnityAction<GameObject>)OnShrineSpawned);
				}
			}
			catch (Exception ex)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Halcyon Shrine hook: " + ex.Message));
			}
		}

		private static void OnShrineSpawned(GameObject spawned)
		{
			try
			{
				CharacterMaster val = (Object.op_Implicit((Object)(object)spawned) ? spawned.GetComponent<CharacterMaster>() : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)((Component)val).GetComponent<ShrineSpawned>()))
				{
					((Component)val).gameObject.AddComponent<ShrineSpawned>();
				}
				CharacterBody body = val.GetBody();
				if (IsHalcyonite(body))
				{
					BossSuperArmorPlugin.Log.LogInfo((object)"Halcyon Shrine Halcyonite spawned: gets the boss defenses.");
					if (body.hasStarted)
					{
						SetupAdaptive(body);
					}
				}
			}
			catch (Exception ex)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Halcyon Shrine spawn: " + ex.Message));
			}
		}

		internal static void Hook(Harmony h)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0140: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Expected O, but got Unknown
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Expected O, but got Unknown
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(CombatDirector), "HalcyoniteShrineActivation", new Type[4]
				{
					typeof(float),
					typeof(DirectorCard),
					typeof(int),
					typeof(Transform)
				}, (Type[])null);
				if (methodInfo != null)
				{
					h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Stormbound), "ShrineActivationPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					BossSuperArmorPlugin.Log.LogWarning((object)"Halcyon Shrine spawns not found; Halcyonites get no boss defenses.");
				}
			}
			catch (Exception ex)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Halcyon Shrine hook failed: " + ex.Message));
			}
			MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			h.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(Stormbound), "Prefix", (Type[])null)
			{
				priority = 800
			}, new HarmonyMethod(typeof(Stormbound), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo3 = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null);
			HarmonyMethod val = new HarmonyMethod(typeof(Stormbound), "RecalcPostfix", (Type[])null);
			h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			methodInfo3 = AccessTools.Method(typeof(EntityStateMachine), "SetState", new Type[1] { typeof(EntityState) }, (Type[])null);
			val = new HarmonyMethod(typeof(Stormbound), "PhasePostfix", (Type[])null);
			h.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			h.Patch((MethodBase)AccessTools.Method(typeof(HealthComponent), "Heal", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stormbound), "HealPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			try
			{
				MethodInfo methodInfo4 = AccessTools.Method(typeof(SharedSufferingManager), "DealDamage", (Type[])null, (Type[])null);
				if (methodInfo4 != null)
				{
					h.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(Stormbound), "SharedSufferingDealDamagePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					BossSuperArmorPlugin.Log.LogWarning((object)"Shared Suffering fix: DealDamage not found, fix not applied.");
				}
			}
			catch (Exception ex2)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Shared Suffering fix not applied: " + ex2.Message));
			}
			Stage.onStageStartGlobal += delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				harvesterPhase2 = false;
				harvesterPhaseStart = FixedTimeStamp.zero;
			};
		}

		internal static bool IsAnima(CharacterBody b)
		{
			//IL_000e: 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
			if (Object.op_Implicit((Object)(object)b) && Array.IndexOf(AnimaBodies, BodyCatalog.GetBodyName(b.bodyIndex)) >= 0)
			{
				if (Object.op_Implicit((Object)(object)b.teamComponent))
				{
					return (int)b.teamComponent.teamIndex != 1;
				}
				return true;
			}
			return false;
		}

		private static void PhasePostfix(EntityState newState)
		{
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (newState == null || !NetworkServer.active)
			{
				return;
			}
			string fullName = ((object)newState).GetType().FullName;
			if (fullName == null)
			{
				return;
			}
			switch (fullName.Length)
			{
			case 54:
				switch (fullName[38])
				{
				default:
					return;
				case 'S':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperSpawnSecondPhase"))
					{
						return;
					}
					break;
				case 'F':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperFightSecondPhase"))
					{
						return;
					}
					break;
				case 's':
					if (!(fullName == "EntityStates.ChampRushReaper.PhaseTransitionSpawnState"))
					{
						return;
					}
					break;
				}
				goto IL_0108;
			case 43:
				switch (fullName[38])
				{
				default:
					return;
				case 'S':
					if (fullName == "EntityStates.Missions.ChampRush.ReaperSpawn")
					{
						harvesterPhase2 = false;
						harvesterPhaseStart = FixedTimeStamp.now;
					}
					return;
				case 'F':
					break;
				}
				if (!(fullName == "EntityStates.Missions.ChampRush.ReaperFight"))
				{
					return;
				}
				break;
			case 61:
				if (!(fullName == "EntityStates.ChampRushReaper.ReaperSecondPhaseSpawnTransition"))
				{
					return;
				}
				goto IL_0108;
			case 46:
				if (!(fullName == "EntityStates.Missions.ChampRush.StartChampRush"))
				{
					return;
				}
				break;
			case 40:
				if (!(fullName == "EntityStates.Missions.ChampRush.Finished"))
				{
					return;
				}
				break;
			case 45:
				if (!(fullName == "EntityStates.Missions.ChampRush.FailChampRush"))
				{
					return;
				}
				break;
			default:
				return;
				IL_0108:
				if (harvesterPhase2)
				{
					return;
				}
				harvesterPhase2 = true;
				harvesterPhaseStart = FixedTimeStamp.now;
				BossSuperArmorPlugin.Log.LogInfo((object)"Anima Harvester phase 2 started.");
				foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
				{
					if (IsAnima(readOnlyInstances))
					{
						ApplyAnimaP2(readOnlyInstances);
					}
				}
				return;
			}
			harvesterPhase2 = false;
		}

		private static void ApplyAnimaP2(CharacterBody b)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)b) || !Object.op_Implicit((Object)(object)b.master) || !Object.op_Implicit((Object)(object)b.inventory))
			{
				return;
			}
			AnimaP2 component = ((Component)b.master).GetComponent<AnimaP2>();
			if (Object.op_Implicit((Object)(object)component))
			{
				if (!Object.op_Implicit((Object)(object)((Component)b).GetComponent<AnimaP2>()))
				{
					((Component)b).gameObject.AddComponent<AnimaP2>().noHeal = component.noHeal;
				}
				return;
			}
			component = ((Component)b.master).gameObject.AddComponent<AnimaP2>();
			int num = Mathf.RoundToInt((AnimaP2HpMult.Value - 1f) * 10f);
			if (num > 0)
			{
				b.inventory.GiveItem(Items.BoostHp, num);
			}
			BossSuperArmorPlugin.Log.LogInfo((object)("Anima Harvester phase 2: HP x" + AnimaP2HpMult.Value + " on " + BodyCatalog.GetBodyName(b.bodyIndex)));
			if (Object.op_Implicit((Object)(object)BossSuperArmorPlugin.Instance))
			{
				((MonoBehaviour)BossSuperArmorPlugin.Instance).StartCoroutine(LockHealing(b, component));
			}
		}

		private static IEnumerator LockHealing(CharacterBody b, AnimaP2 m)
		{
			yield return (object)new WaitForSeconds(1f);
			if (Object.op_Implicit((Object)(object)m))
			{
				m.noHeal = true;
				if (Object.op_Implicit((Object)(object)b) && !Object.op_Implicit((Object)(object)((Component)b).GetComponent<AnimaP2>()))
				{
					((Component)b).gameObject.AddComponent<AnimaP2>().noHeal = true;
				}
				else if (Object.op_Implicit((Object)(object)b))
				{
					((Component)b).GetComponent<AnimaP2>().noHeal = true;
				}
			}
		}

		private static bool HealPrefix(HealthComponent __instance, ref float __result)
		{
			if (!AnimaP2NoHeal.Value || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.body))
			{
				return true;
			}
			AnimaP2 component = ((Component)__instance.body).GetComponent<AnimaP2>();
			if (!Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)__instance.body.master))
			{
				component = ((Component)__instance.body.master).GetComponent<AnimaP2>();
			}
			if (Object.op_Implicit((Object)(object)component) && component.noHeal)
			{
				__result = 0f;
				return false;
			}
			return true;
		}

		internal static bool Applies(CharacterBody b)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_005f: 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_0087: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Invalid comparison between Unknown and I4
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)b) || (int)b.bodyIndex == -1 || IsOrdinaryHalcyonite(b))
			{
				return false;
			}
			if (IsVoidlingAdd(b))
			{
				if (VoidlingAddsToggle == null || VoidlingAddsToggle.Value)
				{
					if (Object.op_Implicit((Object)(object)b.teamComponent))
					{
						return (int)b.teamComponent.teamIndex != 1;
					}
					return true;
				}
				return false;
			}
			if (!idx.TryGetValue(b.bodyIndex, out var value))
			{
				if (checkedIdx.Contains(b.bodyIndex))
				{
					return false;
				}
				checkedIdx.Add(b.bodyIndex);
				string bodyName = BodyCatalog.GetBodyName(b.bodyIndex);
				if (bodyName == null || !nameToToggle.TryGetValue(bodyName, out value))
				{
					return false;
				}
				idx[b.bodyIndex] = value;
			}
			if (value.Value)
			{
				if (Object.op_Implicit((Object)(object)b.teamComponent))
				{
					return (int)b.teamComponent.teamIndex != 1;
				}
				return true;
			}
			return false;
		}

		private static bool SharedSufferingDealDamagePrefix(SharedSufferingManager __instance)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			if (FixSharedSuffering == null || !FixSharedSuffering.Value || !Object.op_Implicit((Object)(object)__instance))
			{
				return true;
			}
			ProcChainMask procChainMask = default(ProcChainMask);
			((ProcChainMask)(ref procChainMask)).AddProc((ProcType)24);
			float[] damagePools = __instance.damagePools;
			List<CharacterBody>[] afflictedBodyPools = __instance.afflictedBodyPools;
			for (int i = 0; i < damagePools.Length && i < afflictedBodyPools.Length; i++)
			{
				float num = damagePools[i];
				if (num <= 0f || afflictedBodyPools[i] == null || afflictedBodyPools[i].Count == 0)
				{
					continue;
				}
				CharacterBody[] array = afflictedBodyPools[i].ToArray();
				foreach (CharacterBody val in array)
				{
					try
					{
						if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
						{
							if (Object.op_Implicit((Object)(object)__instance.damageEffectPrefab))
							{
								EffectManager.SpawnEffect(__instance.damageEffectPrefab, new EffectData
								{
									origin = val.corePosition,
									start = val.corePosition,
									rotation = Quaternion.identity,
									scale = val.radius
								}, true);
							}
							val.healthComponent.TakeDamage(new DamageInfo
							{
								attacker = null,
								damage = num,
								procChainMask = procChainMask,
								damageColorIndex = (DamageColorIndex)16,
								damageType = DamageTypeCombo.op_Implicit((DamageType)2),
								procCoefficient = 0f,
								position = val.corePosition
							});
						}
					}
					catch (Exception ex)
					{
						if (!sharedSufferingErrorLogged)
						{
							sharedSufferingErrorLogged = true;
							BossSuperArmorPlugin.Log.LogWarning((object)("Shared Suffering tick on one enemy failed (others still hit): " + ex.Message));
						}
					}
				}
			}
			__instance.onDamageDealt?.Invoke();
			return false;
		}

		internal static void StripAdaptive(CharacterBody b)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)b) || Object.op_Implicit((Object)(object)((Component)b).GetComponent<AdaptiveStripped>()))
			{
				return;
			}
			AdaptiveStripped adaptiveStripped = ((Component)b).gameObject.AddComponent<AdaptiveStripped>();
			if (Object.op_Implicit((Object)(object)b.inventory) && Object.op_Implicit((Object)(object)Items.AdaptiveArmor))
			{
				int itemCountPermanent = b.inventory.GetItemCountPermanent(Items.AdaptiveArmor);
				if (itemCountPermanent > 0)
				{
					b.inventory.RemoveItemPermanent(Items.AdaptiveArmor, itemCountPermanent);
					adaptiveStripped.removedItems = itemCountPermanent;
				}
			}
			if (Object.op_Implicit((Object)(object)b.healthComponent))
			{
				b.healthComponent.adaptiveArmorValue = 0f;
			}
			b.RecalculateStats();
			BossSuperArmorPlugin.Log.LogInfo((object)("Adaptive armor removed from " + BodyCatalog.GetBodyName(b.bodyIndex) + "."));
		}

		internal static WeakPointArmorPool PoolFor(CharacterBody wp)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)wp) || WeakPointAdaptive == null || (!WeakPointAdaptive.Value && !WeakPointSoftCap.Value) || !weakPointIdx.Contains(wp.bodyIndex))
			{
				return null;
			}
			WeakPointLink component = ((Component)wp).GetComponent<WeakPointLink>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.dwp))
			{
				return null;
			}
			CharacterBody referencedBody = component.dwp.referencedBody;
			if (!Object.op_Implicit((Object)(object)referencedBody) || !Applies(referencedBody))
			{
				return null;
			}
			if (Object.op_Implicit((Object)(object)component.pool) && (Object)(object)((Component)component.pool).gameObject == (Object)(object)((Component)referencedBody).gameObject)
			{
				return component.pool;
			}
			if (!Object.op_Implicit((Object)(object)((Component)referencedBody).GetComponent<SolusWingWeakPointsController>()))
			{
				return null;
			}
			WeakPointArmorPool weakPointArmorPool = ((Component)referencedBody).GetComponent<WeakPointArmorPool>();
			if (!Object.op_Implicit((Object)(object)weakPointArmorPool))
			{
				weakPointArmorPool = ((Component)referencedBody).gameObject.AddComponent<WeakPointArmorPool>();
				BossSuperArmorPlugin.Log.LogInfo((object)(BodyCatalog.GetBodyName(referencedBody.bodyIndex) + " weak points: adaptive armor " + (WeakPointAdaptive.Value ? "on (shared)" : "off") + ", soft damage cap " + ((SoftCap.Value && WeakPointSoftCap.Value) ? "on (combined HP)" : "off") + "."));
			}
			component.pool = weakPointArmorPool;
			return weakPointArmorPool;
		}

		private static void OnBodyStart(CharacterBody b)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Invalid comparison between Unknown and I4
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)b))
				{
					DestructibleWeakPoint component = ((Component)b).GetComponent<DestructibleWeakPoint>();
					if (Object.op_Implicit((Object)(object)component))
					{
						weakPointIdx.Add(b.bodyIndex);
						if (!Object.op_Implicit((Object)(object)((Component)b).GetComponent<WeakPointLink>()))
						{
							((Component)b).gameObject.AddComponent<WeakPointLink>().dwp = component;
						}
					}
				}
			}
			catch (Exception ex)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Weak point setup: " + ex.Message));
			}
			try
			{
				if (NetworkServer.active && harvesterPhase2 && IsAnima(b))
				{
					ApplyAnimaP2(b);
				}
			}
			catch (Exception ex2)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Anima P2: " + ex2.Message));
			}
			try
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)b.master) && Object.op_Implicit((Object)(object)b.inventory) && Array.IndexOf(EchoHpBodies, BodyCatalog.GetBodyName(b.bodyIndex)) >= 0 && (!Object.op_Implicit((Object)(object)b.teamComponent) || (int)b.teamComponent.teamIndex != 1) && !Object.op_Implicit((Object)(object)((Component)b.master).GetComponent<EchoHpGiven>()))
				{
					int num = Mathf.RoundToInt((EchoHpMult.Value - 1f) * 10f);
					if (num > 0)
					{
						((Component)b.master).gameObject.AddComponent<EchoHpGiven>();
						b.inventory.GiveItem(Items.BoostHp, num);
						BossSuperArmorPlugin.Log.LogInfo((object)("Echo of Providence HP x" + EchoHpMult.Value + " for " + BodyCatalog.GetBodyName(b.bodyIndex)));
					}
				}
			}
			catch (Exception ex3)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Echo HP: " + ex3.Message));
			}
			SetupAdaptive(b);
		}

		internal static void SetupAdaptive(CharacterBody b)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && Applies(b) && AdaptiveEnabled.Value && Object.op_Implicit((Object)(object)b.inventory) && Object.op_Implicit((Object)(object)Items.AdaptiveArmor) && !Object.op_Implicit((Object)(object)((Component)b).GetComponent<AdaptiveStripped>()))
				{
					int itemCountPermanent = b.inventory.GetItemCountPermanent(Items.AdaptiveArmor);
					int num = Mathf.Max(0, AdaptiveStacks.Value);
					if (itemCountPermanent < num)
					{
						b.inventory.GiveItemPermanent(Items.AdaptiveArmor, num - itemCountPermanent);
					}
					BossSuperArmorPlugin.Log.LogInfo((object)("Adaptive armor on " + BodyCatalog.GetBodyName(b.bodyIndex) + ": " + Mathf.Max(itemCountPermanent, num) + " stacks, cap " + AdaptiveCap.Value + "."));
				}
			}
			catch (Exception ex)
			{
				BossSuperArmorPlugin.Log.LogWarning((object)("Adaptive armor setup: " + ex.Message));
			}
		}

		private static void Prefix(HealthComponent __instance, DamageInfo damageInfo, out HitState __state)
		{
			//IL_0065: 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_0161: 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)
			__state = new HitState
			{
				hp = -1f,
				adaptive = 0f
			};
			try
			{
				if (!NetworkServer.active || damageInfo == null || damageInfo.rejected || !Object.op_Implicit((Object)(object)__instance) || !__instance.alive)
				{
					return;
				}
				CharacterBody body = __instance.body;
				bool flag = false;
				float num;
				if (Applies(body))
				{
					if ((damageInfo.damageType.damageTypeExtended & 0x40000) != 0 && (Object)(object)damageInfo.attacker == (Object)null && Object.op_Implicit((Object)(object)((Component)body).GetComponent<SolusWingWeakPointsController>()))
					{
						if (!WeakPointAdaptive.Value)
						{
							__state.hp = __instance.health + __instance.shield + __instance.barrier;
							__state.adaptive = __instance.adaptiveArmorValue;
						}
						return;
					}
					num = __instance.fullCombinedHealth;
				}
				else
				{
					WeakPointArmorPool weakPointArmorPool = PoolFor(body);
					if (!Object.op_Implicit((Object)(object)weakPointArmorPool))
					{
						return;
					}
					num = weakPointArmorPool.GroupMaxHealth(__instance);
					flag = true;
				}
				if (!flag || WeakPointAdaptive.Value)
				{
					__state.hp = __instance.health + __instance.shield + __instance.barrier;
					__state.adaptive = __instance.adaptiveArmorValue;
				}
				if (SoftCap.Value && (!flag || WeakPointSoftCap.Value) && !(damageInfo.damage <= 0f))
				{
					float num2 = 1f;
					if ((damageInfo.damageType.damageType & 2) == 0)
					{
						float num3 = body.armor + __instance.adaptiveArmorValue;
						num2 = ((!(num3 >= 0f)) ? (2f - 100f / (100f - num3)) : (100f / (100f + num3)));
					}
					float num4 = damageInfo.damage * num2;
					float num5 = num * Mathf.Max(0f, CapPercent.Value) / 100f;
					if (!(num5 <= 0f) && !(num4 <= num5) && !(num2 <= 0f))
					{
						float num6 = num5 + (num4 - num5) * Mathf.Clamp01(ExcessMult.Value);
						damageInfo.damage = num6 / num2;
					}
				}
			}
			catch
			{
			}
		}

		private static void Postfix(HealthComponent __instance, HitState __state)
		{
			if (__state.hp < 0f || !Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			try
			{
				float num = __state.hp - (__instance.health + __instance.shield + __instance.barrier);
				CharacterBody body = __instance.body;
				if (!Applies(body))
				{
					WeakPointArmorPool weakPointArmorPool = ((num > 0f) ? PoolFor(body) : null);
					if (Object.op_Implicit((Object)(object)weakPointArmorPool) && WeakPointAdaptive.Value)
					{
						float num2 = weakPointArmorPool.GroupMaxHealth(__instance);
						if (num2 > 0f)
						{
							weakPointArmorPool.Add(num / num2 * 100f);
						}
					}
				}
				else
				{
					if (!AdaptiveEnabled.Value || !Object.op_Implicit((Object)(object)body.inventory) || !Object.op_Implicit((Object)(object)Items.AdaptiveArmor) || __instance.fullCombinedHealth <= 0f || Object.op_Implicit((Object)(object)((Component)body).GetComponent<AdaptiveStripped>()))
					{
						return;
					}
					int itemCountEffective = body.inventory.GetItemCountEffective(Items.AdaptiveArmor);
					if (itemCountEffective > 0)
					{
						float num3 = __instance.adaptiveArmorValue;
						if (num > 0f)
						{
							num3 = Mathf.Max(num3, __state.adaptive + num / PartHealth(__instance) * 100f * 30f * (float)itemCountEffective);
						}
						num3 = Mathf.Min(num3, Mathf.Max(0f, AdaptiveCap.Value));
						if (num3 != __instance.adaptiveArmorValue)
						{
							__instance.adaptiveArmorValue = num3;
						}
					}
				}
			}
			catch
			{
			}
		}

		private static void RecalcPostfix(CharacterBody __instance)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance) && NetworkServer.active && WeakPointAdaptive.Value && weakPointIdx.Contains(__instance.bodyIndex))
			{
				WeakPointArmorPool weakPointArmorPool = PoolFor(__instance);
				if (Object.op_Implicit((Object)(object)weakPointArmorPool) && weakPointArmorPool.Total > 0f)
				{
					__instance.armor += weakPointArmorPool.Total;
				}
			}
		}
	}
	public class WeakPointLink : MonoBehaviour
	{
		public DestructibleWeakPoint dwp;

		public WeakPointArmorPool pool;
	}
	public class WeakPointArmorPool : MonoBehaviour
	{
		public float value;

		private float applied;

		private SolusWingWeakPointsController controller;

		public float Total => value;

		private void Awake()
		{
			controller = ((Component)this).GetComponent<SolusWingWeakPointsController>();
		}

		public float GroupMaxHealth(HealthComponent fallback)
		{
			float num = 0f;
			int num2 = 0;
			if (Object.op_Implicit((Object)(object)controller))
			{
				List<CharacterBody> weakpointBodies = controller.WeakpointBodies;
				for (int i = 0; i < weakpointBodies.Count; i++)
				{
					CharacterBody val = weakpointBodies[i];
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent))
					{
						num += val.healthComponent.fullCombinedHealth;
						num2++;
					}
				}
				if (num2 > 0 && controller.totalWeakPoints > num2)
				{
					num *= (float)controller.totalWeakPoints / (float)num2;
				}
			}
			if (num <= 0f && Object.op_Implicit((Object)(object)fallback))
			{
				num = fallback.fullCombinedHealth;
			}
			return num;
		}

		public void Add(float percentLost)
		{
			if (!(percentLost <= 0f))
			{
				value = Mathf.Min(Mathf.Max(0f, Stormbound.AdaptiveCap.Value), value + percentLost * 30f * (float)Mathf.Max(0, Stormbound.AdaptiveStacks.Value));
				Refresh();
			}
		}

		private void FixedUpdate()
		{
			if (value <= 0f)
			{
				if (applied != 0f)
				{
					Refresh();
				}
				return;
			}
			value = Mathf.Max(0f, value - 40f * Time.fixedDeltaTime);
			if (Mathf.Abs(value - applied) >= 4f || value == 0f)
			{
				Refresh();
			}
		}

		private void Refresh()
		{
			applied = value;
			if (!Object.op_Implicit((Object)(object)controller))
			{
				return;
			}
			List<CharacterBody> weakpointBodies = controller.WeakpointBodies;
			for (int i = 0; i < weakpointBodies.Count; i++)
			{
				CharacterBody val = weakpointBodies[i];
				if (Object.op_Implicit((Object)(object)val))
				{
					val.RecalculateStats();
				}
			}
		}
	}
}

EnemyCap20.dll

Decompiled 7 hours ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using RoR2;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace EnemyCap20
{
	[BepInPlugin("custom.EnemyCap20", "EnemyCap20", "1.0.1")]
	public class EnemyCapPlugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			ConfigEntry<int> val = ((BaseUnityPlugin)this).Config.Bind<int>("General", "EnemyCap", 15, "Max enemies alive per enemy team (vanilla: 40). Applies to Monster, Lunar and Void teams.");
			TeamIndex[] array = new TeamIndex[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			TeamIndex[] array2 = (TeamIndex[])(object)array;
			foreach (TeamIndex val2 in array2)
			{
				TeamDef teamDef = TeamCatalog.GetTeamDef(val2);
				if (teamDef != null)
				{
					teamDef.softCharacterLimit = val.Value;
					((BaseUnityPlugin)this).Logger.LogInfo((object)string.Concat(val2, " cap set to ", val.Value));
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

GuaranteedHalcyonShrine.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace GuaranteedHalcyonShrine
{
	[BepInPlugin("custom.GuaranteedHalcyonShrine", "GuaranteedHalcyonShrine", "1.2.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class GuaranteedHalcyonShrinePlugin : BaseUnityPlugin
	{
		internal static GuaranteedHalcyonShrinePlugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> GuaranteeStage1;

		internal static ConfigEntry<bool> GuaranteeStage2;

		internal static ConfigEntry<bool> GuaranteeStage5;

		internal static ConfigEntry<bool> ApplyOnLoops;

		internal static ConfigEntry<bool> LockStage1;

		internal static ConfigEntry<bool> LockStage2;

		internal static ConfigEntry<bool> LockStage5;

		internal static ConfigEntry<bool> Stage5Instakill;

		internal static ConfigEntry<string> LockedText;

		internal static ConfigEntry<bool> BlockStage3;

		internal static ConfigEntry<bool> BlockStage4;

		private static bool shrineDefeated;

		private static HalcyoniteShrineInteractable stageShrine;

		private static bool shrineSearched;

		private static FieldInfo fShrineEsm;

		internal static ConfigEntry<string> SpawnCardPath;

		internal static ConfigEntry<bool> BuffEnabled;

		internal static ConfigEntry<bool> GildedOnly;

		internal static ConfigEntry<float> HealthMultiplier;

		internal static ConfigEntry<float> DamageMultiplier;

		private static InteractableSpawnCard shrineCard;

		private static BodyIndex halcyoniteBodyIndex = (BodyIndex)(-1);

		private static Action<CharacterBody, float> setDamage;

		private static readonly Dictionary<CharacterBody, int> curseSnap = new Dictionary<CharacterBody, int>();

		private void Awake()
		{
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Expected O, but got Unknown
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Expected O, but got Unknown
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Expected O, but got Unknown
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Expected O, but got Unknown
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Expected O, but got Unknown
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_0489: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Expected O, but got Unknown
			//IL_0496: Expected O, but got Unknown
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			GuaranteeStage1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "GuaranteeStage1", true, "Guarantee a Shrine of Halcyon on stage 1.");
			GuaranteeStage2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "GuaranteeStage2", true, "Guarantee a Shrine of Halcyon on stage 2.");
			GuaranteeStage5 = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "GuaranteeStage5", true, "Guarantee a Shrine of Halcyon on stage 5.");
			LockStage1 = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter", "LockStage1", true, "The stage 1 teleporter cannot be activated until the shrine's Halcyonite is defeated.");
			LockStage2 = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter", "LockStage2", true, "The stage 2 teleporter cannot be activated until the shrine's Halcyonite is defeated.");
			LockStage5 = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter", "LockStage5", true, "The stage 5 primordial teleporter cannot be activated until the shrine's Halcyonite is defeated.");
			LockedText = ((BaseUnityPlugin)this).Config.Bind<string>("Teleporter", "LockedPrompt", "Defeat the Halcyonite first", "Prompt shown on a locked teleporter.");
			Stage5Instakill = ((BaseUnityPlugin)this).Config.Bind<bool>("Halcyonite", "Stage5Instakill", true, "Every attack from the stage 5 shrine Halcyonite kills instantly (ignores armor, block, shields, barrier and vanilla one-shot protection; revives and OneShotRework still work).");
			BlockStage3 = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "BlockStage3", true, "The Shrine of Halcyon never spawns on stage 3.");
			BlockStage4 = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "BlockStage4", true, "The Shrine of Halcyon never spawns on stage 4.");
			ApplyOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "ApplyOnLoops", false, "If true, also guarantee on stages 6/7, 11/12, ...");
			SpawnCardPath = ((BaseUnityPlugin)this).Config.Bind<string>("Spawn", "SpawnCardPath", "RoR2/DLC2/iscShrineHalcyonite.asset", "Addressable path of the shrine spawn card. Alternative: RoR2/DLC2/iscShrineHalcyoniteTier1.asset");
			BuffEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Halcyonite", "Enabled", true, "Buff the Gilded Halcyonite spawned by the Shrine of Halcyon.");
			GildedOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Halcyonite", "GildedOnly", true, "If true, only shrine-spawned Halcyonites with the Gilded (Aurelionite) elite affix are buffed. If false, every Halcyonite spawned by the shrine is buffed.");
			HealthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Halcyonite", "HealthMultiplier", 1f, "Max health multiplier (2 = double).");
			DamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Halcyonite", "DamageMultiplier", 5f, "Damage multiplier (3 = triple). Applied as an exact multiplier on top of all other damage bonuses.");
			AsyncOperationHandle<InteractableSpawnCard> val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)SpawnCardPath.Value);
			val.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> h)
			{
				shrineCard = h.Result;
				if (!Object.op_Implicit((Object)(object)shrineCard))
				{
					Log.LogError((object)("Shrine spawn card not found: " + SpawnCardPath.Value));
				}
			};
			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)
				halcyoniteBodyIndex = BodyCatalog.FindBodyIndex("HalcyoniteBody");
			});
			SceneDirector.onPostPopulateSceneServer += OnPostPopulateScene;
			Harmony val2 = new Harmony("custom.GuaranteedHalcyonShrine");
			MethodInfo dmgSetter = AccessTools.PropertySetter(typeof(CharacterBody), "damage");
			if (dmgSetter != null)
			{
				try
				{
					setDamage = (Action<CharacterBody, float>)Delegate.CreateDelegate(typeof(Action<CharacterBody, float>), dmgSetter);
				}
				catch
				{
					setDamage = delegate(CharacterBody b, float v)
					{
						dmgSetter.Invoke(b, new object[1] { v });
					};
				}
			}
			else
			{
				Log.LogError((object)"CharacterBody.damage setter not found; damage multiplier disabled.");
			}
			MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null);
			HarmonyMethod val3 = new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "RecalculateStatsPostfix", (Type[])null);
			val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			methodInfo = AccessTools.Method(typeof(HalcyoniteShrineInteractable), "Start", (Type[])null, (Type[])null);
			val3 = new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "ShrineStartPostfix", (Type[])null);
			val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetInteractability", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "TeleporterInteractabilityPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetContextString", (Type[])null, (Type[])null), new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "TeleporterContextPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			val2.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "TakeDamagePrefix", (Type[])null), new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "CursePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(DirectorCore), "TrySpawnObject", new Type[1] { typeof(DirectorSpawnRequest) }, (Type[])null), new HarmonyMethod(typeof(GuaranteedHalcyonShrinePlugin), "TrySpawnPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Stage.onStageStartGlobal += delegate
			{
				shrineDefeated = false;
				stageShrine = null;
				shrineSearched = false;
			};
			GlobalEventManager.onCharacterDeathGlobal += OnDeath;
		}

		private static void OnPostPopulateScene(SceneDirector director)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			try
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)shrineCard))
				{
					return;
				}
				SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
				if (!Object.op_Implicit((Object)(object)mostRecentSceneDef) || (int)mostRecentSceneDef.sceneType != 1)
				{
					return;
				}
				int num = StagePos();
				if (Blocked(num))
				{
					HalcyoniteShrineInteractable[] array = Object.FindObjectsOfType<HalcyoniteShrineInteractable>();
					foreach (HalcyoniteShrineInteractable val in array)
					{
						if (Object.op_Implicit((Object)(object)val))
						{
							NetworkServer.Destroy(((Component)val).gameObject);
						}
					}
				}
				else if (((num == 0 && GuaranteeStage1.Value) || (num == 1 && GuaranteeStage2.Value) || (num == 4 && GuaranteeStage5.Value)) && !Object.op_Implicit((Object)(object)Object.FindObjectOfType<HalcyoniteShrineInteractable>()))
				{
					DirectorCore instance = DirectorCore.instance;
					InteractableSpawnCard obj = shrineCard;
					DirectorPlacementRule val2 = new DirectorPlacementRule();
					val2.placementMode = (PlacementMode)4;
					GameObject val3 = instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)obj, val2, Run.instance.stageRng));
					Log.LogInfo((object)((!Object.op_Implicit((Object)(object)val3)) ? "Failed to place Shrine of Halcyon." : "Spawned guaranteed Shrine of Halcyon."));
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static int StagePos()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return -1;
			}
			int stageClearCount = Run.instance.stageClearCount;
			if (stageClearCount >= 5 && !ApplyOnLoops.Value)
			{
				return -1;
			}
			return stageClearCount % 5;
		}

		private static bool Blocked(int pos)
		{
			return (pos == 2 && BlockStage3.Value) || (pos == 3 && BlockStage4.Value);
		}

		private static bool TrySpawnPrefix(DirectorSpawnRequest directorSpawnRequest, ref GameObject __result)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Invalid comparison between Unknown and I4
			try
			{
				SpawnCard val = directorSpawnRequest?.spawnCard;
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)Run.instance))
				{
					return true;
				}
				if (((Object)val).name.IndexOf("ShrineHalcyonite", StringComparison.OrdinalIgnoreCase) < 0 && (!Object.op_Implicit((Object)(object)val.prefab) || !Object.op_Implicit((Object)(object)val.prefab.GetComponent<HalcyoniteShrineInteractable>())))
				{
					return true;
				}
				SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
				if (!Object.op_Implicit((Object)(object)mostRecentSceneDef) || (int)mostRecentSceneDef.sceneType != 1)
				{
					return true;
				}
				if (!Blocked(StagePos()))
				{
					return true;
				}
				__result = null;
				return false;
			}
			catch
			{
				return true;
			}
		}

		private static HalcyoniteShrineInteractable Shrine()
		{
			if (!Object.op_Implicit((Object)(object)stageShrine) && !shrineSearched)
			{
				stageShrine = Object.FindObjectOfType<HalcyoniteShrineInteractable>();
				shrineSearched = Object.op_Implicit((Object)(object)stageShrine);
			}
			if (!Object.op_Implicit((Object)(object)stageShrine))
			{
				shrineSearched = false;
			}
			return stageShrine;
		}

		private static bool ShrineFinished(HalcyoniteShrineInteractable s)
		{
			try
			{
				if (fShrineEsm == null)
				{
					fShrineEsm = AccessTools.Field(typeof(HalcyoniteShrineInteractable), "stateMachine");
				}
				EntityStateMachine val = (EntityStateMachine)((!(fShrineEsm != null)) ? null : /*isinst with value type is only supported in some contexts*/);
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = ((Component)s).GetComponent<EntityStateMachine>();
				}
				return Object.op_Implicit((Object)(object)val) && val.state != null && ((object)val.state).GetType().FullName == "EntityStates.ShrineHalcyonite.ShrineHalcyoniteFinished";
			}
			catch
			{
				return false;
			}
		}

		internal static bool TeleporterLocked()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			if (shrineDefeated)
			{
				return false;
			}
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (!Object.op_Implicit((Object)(object)mostRecentSceneDef) || (int)mostRecentSceneDef.sceneType != 1)
			{
				return false;
			}
			int num = StagePos();
			if ((num != 0 || !LockStage1.Value) && (num != 1 || !LockStage2.Value) && (num != 4 || !LockStage5.Value))
			{
				return false;
			}
			HalcyoniteShrineInteractable val = Shrine();
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			if (ShrineFinished(val))
			{
				shrineDefeated = true;
				return false;
			}
			return true;
		}

		private static bool TeleporterInteractabilityPrefix(ref Interactability __result)
		{
			try
			{
				if (TeleporterLocked())
				{
					__result = (Interactability)1;
					return false;
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return true;
		}

		private static bool TeleporterContextPrefix(ref string __result)
		{
			try
			{
				if (TeleporterLocked())
				{
					__result = LockedText.Value;
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		private static bool IsGilded(CharacterBody body)
		{
			//IL_0044: 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)
			BuffDef eliteAurelionite = Buffs.EliteAurelionite;
			EquipmentDef eliteAurelioniteEquipment = Equipment.EliteAurelioniteEquipment;
			return (Object.op_Implicit((Object)(object)eliteAurelionite) && body.HasBuff(eliteAurelionite)) || (Object.op_Implicit((Object)(object)eliteAurelioniteEquipment) && Object.op_Implicit((Object)(object)body.inventory) && body.inventory.currentEquipmentIndex == eliteAurelioniteEquipment.equipmentIndex);
		}

		private static void OnDeath(DamageReport r)
		{
			//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)
			try
			{
				if (NetworkServer.active && r != null && Object.op_Implicit((Object)(object)r.victimBody) && Object.op_Implicit((Object)(object)r.victimMaster) && r.victimBody.bodyIndex == halcyoniteBodyIndex)
				{
					HalcyonShrineSpawn component = ((Component)r.victimMaster).GetComponent<HalcyonShrineSpawn>();
					if (Object.op_Implicit((Object)(object)component) && (component.gilded || IsGilded(r.victimBody)))
					{
						shrineDefeated = true;
						Log.LogInfo((object)"Shrine Halcyonite defeated; teleporter unlocked.");
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void SnapCurse(CharacterBody b)
		{
			if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)Buffs.PermanentCurse) && !curseSnap.ContainsKey(b))
			{
				curseSnap[b] = b.GetBuffCount(Buffs.PermanentCurse);
			}
		}

		private static void RestoreCurse(HealthComponent hc)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CharacterBody val = ((!Object.op_Implicit((Object)(object)hc)) ? null : hc.body);
				if (Object.op_Implicit((Object)(object)val) && curseSnap.TryGetValue(val, out var value))
				{
					curseSnap.Remove(val);
					if (val.GetBuffCount(Buffs.PermanentCurse) > value)
					{
						val.SetBuffCount(Buffs.PermanentCurse.buffIndex, value);
					}
				}
			}
			catch
			{
			}
		}

		private static void CursePostfix(HealthComponent __instance)
		{
			RestoreCurse(__instance);
		}

		private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Invalid comparison between Unknown and I4
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)__instance) || !Stage5Instakill.Value)
			{
				return;
			}
			try
			{
				if (!Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					return;
				}
				CharacterBody body = __instance.body;
				if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent) || (int)body.teamComponent.teamIndex != 1)
				{
					return;
				}
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				if (!Object.op_Implicit((Object)(object)component) || (Object)(object)component == (Object)(object)body || component.bodyIndex != halcyoniteBodyIndex || !Object.op_Implicit((Object)(object)component.master))
				{
					return;
				}
				HalcyonShrineSpawn component2 = ((Component)component.master).GetComponent<HalcyonShrineSpawn>();
				if (Object.op_Implicit((Object)(object)component2) && component2.stage5)
				{
					if (body.HasBuff(Buffs.HiddenInvincibility) || body.HasBuff(Buffs.Immune))
					{
						damageInfo.rejected = true;
						return;
					}
					SnapCurse(__instance.body);
					damageInfo.damage = Mathf.Max(damageInfo.damage, __instance.fullCombinedHealth * 10f + 1000000f);
					ref DamageTypeCombo damageType = ref damageInfo.damageType;
					damageType.damageType = (DamageType)(damageType.damageType | 0x40042);
					ref DamageTypeCombo damageType2 = ref damageInfo.damageType;
					damageType2.damageType = (DamageType)(damageType2.damageType & -65537);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)ex.Message);
			}
		}

		private static void RecalculateStatsPostfix(CharacterBody __instance)
		{
			if (setDamage != null && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.master))
			{
				HalcyonBuffed component = ((Component)__instance.master).GetComponent<HalcyonBuffed>();
				if (Object.op_Implicit((Object)(object)component) && Mathf.Abs(component.damageMult - 1f) > 0.0001f)
				{
					setDamage(__instance, __instance.damage * component.damageMult);
				}
			}
		}

		private static void ShrineStartPostfix(HalcyoniteShrineInteractable __instance)
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)__instance))
			{
				object? obj = AccessTools.Field(typeof(HalcyoniteShrineInteractable), "combatDirector")?.GetValue(__instance);
				Hook((CombatDirector)((obj is CombatDirector) ? obj : null));
				object? obj2 = AccessTools.Field(typeof(HalcyoniteShrineInteractable), "activationDirector")?.GetValue(__instance);
				Hook((CombatDirector)((obj2 is CombatDirector) ? obj2 : null));
			}
		}

		private static void Hook(CombatDirector director)
		{
			if (Object.op_Implicit((Object)(object)director) && director.onSpawnedServer != null)
			{
				((UnityEvent<GameObject>)(object)director.onSpawnedServer).AddListener((UnityAction<GameObject>)OnShrineSpawnedMonster);
			}
		}

		private static void OnShrineSpawnedMonster(GameObject masterObject)
		{
			if (Object.op_Implicit((Object)(object)masterObject))
			{
				if (!Object.op_Implicit((Object)(object)masterObject.GetComponent<HalcyonShrineSpawn>()))
				{
					HalcyonShrineSpawn halcyonShrineSpawn = masterObject.AddComponent<HalcyonShrineSpawn>();
					halcyonShrineSpawn.stage5 = StagePos() == 4;
				}
				((MonoBehaviour)Instance).StartCoroutine(BuffWhenReady(masterObject));
			}
		}

		private static IEnumerator BuffWhenReady(GameObject masterObject)
		{
			yield return (object)new WaitForSeconds(0.5f);
			if (!Object.op_Implicit((Object)(object)masterObject))
			{
				yield break;
			}
			CharacterMaster master = masterObject.GetComponent<CharacterMaster>();
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				yield break;
			}
			CharacterBody body = master.GetBody();
			if (!Object.op_Implicit((Object)(object)body) || body.bodyIndex != halcyoniteBodyIndex)
			{
				yield break;
			}
			bool isGilded = IsGilded(body);
			HalcyonShrineSpawn spm = ((Component)master).GetComponent<HalcyonShrineSpawn>();
			if (Object.op_Implicit((Object)(object)spm) && isGilded)
			{
				spm.gilded = true;
			}
			if (BuffEnabled.Value && (!GildedOnly.Value || isGilded) && !Object.op_Implicit((Object)(object)((Component)master).GetComponent<HalcyonBuffed>()))
			{
				HalcyonBuffed marker = ((Component)master).gameObject.AddComponent<HalcyonBuffed>();
				int hpStacks = Mathf.Max(0, Mathf.RoundToInt((HealthMultiplier.Value - 1f) * 10f));
				if (hpStacks > 0)
				{
					master.inventory.GiveItemPermanent(Items.BoostHp, hpStacks);
				}
				float before = body.damage;
				marker.damageMult = Mathf.Max(0f, DamageMultiplier.Value);
				body.RecalculateStats();
				Log.LogInfo((object)("Buffed shrine Halcyonite: +" + hpStacks * 10 + "% HP, damage " + before + " -> " + body.damage + " (x" + marker.damageMult + ")."));
			}
		}
	}
	public class HalcyonShrineSpawn : MonoBehaviour
	{
		public bool stage5;

		public bool gilded;
	}
	public class HalcyonBuffed : MonoBehaviour
	{
		public float damageMult = 1f;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

HIFUEngineerTweaks.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Engi.EngiBubbleShield;
using EntityStates.Engi.EngiMissilePainter;
using EntityStates.Engi.EngiWeapon;
using EntityStates.Engi.Mine;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.EntityStates.Engi.EngiBubbleShield;
using On.EntityStates.Engi.EngiMissilePainter;
using On.EntityStates.Engi.EngiWeapon;
using On.EntityStates.Engi.Mine;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HIFUEngineerTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c851b88ff6b1e5840f4928b4d5fee06ffa2e1698")]
[assembly: AssemblyProduct("HIFUEngineerTweaks")]
[assembly: AssemblyTitle("HIFUEngineerTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 HIFUEngineerTweaks
{
	public class ConfigManager
	{
		internal static bool ConfigChanged;

		internal static bool VersionChanged;

		public static T HandleConfig<T>(ConfigEntryBase entry, ConfigFile config, string name)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
				where x.Name == "Bind"
				select x).First();
			methodInfo = methodInfo.MakeGenericMethod(typeof(T));
			object[] parameters = new object[3]
			{
				(object)new ConfigDefinition(Regex.Replace(config.ConfigFilePath, "\\W", "") + " : " + entry.Definition.Section, name),
				entry.DefaultValue,
				(object)new ConfigDescription(entry.Description.Description, (AcceptableValueBase)null, Array.Empty<object>())
			};
			ConfigEntryBase val = (ConfigEntryBase)methodInfo.Invoke(config, parameters);
			if (Main._preVersioning)
			{
				entry.BoxedValue = entry.DefaultValue;
			}
			if (!ConfigEqual(val.DefaultValue, val.BoxedValue) && VersionChanged)
			{
				entry.BoxedValue = entry.DefaultValue;
				val.BoxedValue = val.DefaultValue;
			}
			return default(T);
		}

		private static bool ConfigEqual(object a, object b)
		{
			if (a.Equals(b))
			{
				return true;
			}
			if (float.TryParse(a.ToString(), out var result) && float.TryParse(b.ToString(), out var result2) && (double)Mathf.Abs(result - result2) < 0.0001)
			{
				return true;
			}
			return false;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("zzzHIFU.HIFUEngineerTweaks", "HIFUEngineerTweaks", "1.1.6")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "zzzHIFU.HIFUEngineerTweaks";

		public const string PluginAuthor = "zzzHIFU";

		public const string PluginName = "HIFUEngineerTweaks";

		public const string PluginVersion = "1.1.6";

		public static ConfigFile HETConfig;

		public static ConfigFile HETBackupConfig;

		public static ManualLogSource HETLogger;

		public static bool _preVersioning;

		public static ConfigEntry<bool> enableAutoConfig { get; set; }

		public static ConfigEntry<string> latestVersion { get; set; }

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			HETLogger = ((BaseUnityPlugin)this).Logger;
			HETConfig = ((BaseUnityPlugin)this).Config;
			HETBackupConfig = new ConfigFile(Paths.ConfigPath + "\\zzzHIFU.HIFUEngineerTweaks.Backup.cfg", true);
			HETBackupConfig.Bind<string>(": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :");
			enableAutoConfig = HETConfig.Bind<bool>("Config", "Enable Auto Config Sync", true, "Disabling this would stop HIFUEngineerTweaks from syncing config whenever a new version is found.");
			_preVersioning = !((Dictionary<ConfigDefinition, string>)AccessTools.DeclaredPropertyGetter(typeof(ConfigFile), "OrphanedEntries").Invoke(HETConfig, null)).Keys.Any((ConfigDefinition x) => x.Key == "Latest Version");
			latestVersion = HETConfig.Bind<string>("Config", "Latest Version", "1.1.6", "DO NOT CHANGE THIS");
			if (enableAutoConfig.Value && (_preVersioning || latestVersion.Value != "1.1.6"))
			{
				latestVersion.Value = "1.1.6";
				ConfigManager.VersionChanged = true;
				HETLogger.LogInfo((object)"Config Autosync Enabled.");
			}
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(TweakBase))
				select type;
			HETLogger.LogInfo((object)"==+----------------==TWEAKS==----------------+==");
			foreach (Type item in enumerable)
			{
				TweakBase tweakBase = (TweakBase)Activator.CreateInstance(item);
				if (ValidateTweak(tweakBase))
				{
					tweakBase.Init();
				}
			}
			IEnumerable<Type> enumerable2 = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(MiscBase))
				select type;
			HETLogger.LogInfo((object)"==+----------------==MISC==----------------+==");
			foreach (Type item2 in enumerable2)
			{
				MiscBase miscBase = (MiscBase)Activator.CreateInstance(item2);
				if (ValidateMisc(miscBase))
				{
					miscBase.Init();
				}
			}
		}

		public bool ValidateTweak(TweakBase tb)
		{
			if (tb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(tb.Name, "Enable?", AllBossRouteDefaultEnabled(tb.Name), "Vanilla is false").Value)
			{
				return true;
			}
			return false;
		}

		public bool ValidateMisc(MiscBase mb)
		{
			if (mb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(mb.Name, "Enable?", AllBossRouteDefaultEnabled(mb.Name), "Vanilla is false").Value)
			{
				return true;
			}
			return false;
		}

		private void PeripheryMyBeloved()
		{
		}

		private static bool AllBossRouteDefaultEnabled(string name)
		{
			switch (name)
			{
			default:
				return true;
			case ": Special : TR12 Gauss Auto Turret":
			case ": Special :: TR58 Carbonizer Turret":
			case ":: Misc : Base Stats":
				return false;
			}
		}
	}
	public abstract class MiscBase
	{
		public abstract string Name { get; }

		public virtual bool isEnabled { get; } = true;

		public T ConfigOption<T>(T value, string name, string description)
		{
			ConfigEntry<T> val = Main.HETConfig.Bind<T>(Name, name, value, description);
			ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HETBackupConfig, name);
			return val.Value;
		}

		public abstract void Hooks();

		public string d(float f)
		{
			return f * 100f + "%";
		}

		public virtual void Init()
		{
			Hooks();
			Main.HETLogger.LogInfo((object)("Added " + Name));
		}
	}
	public abstract class MiscBase<T> : MiscBase where T : MiscBase<T>
	{
		public static T instance { get; set; }

		public MiscBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class TweakBase
	{
		public abstract string Name { get; }

		public abstract string SkillToken { get; }

		public abstract string DescText { get; }

		public virtual bool isEnabled { get; } = true;

		public T ConfigOption<T>(T value, string name, string description)
		{
			ConfigEntry<T> val = Main.HETConfig.Bind<T>(Name, name, value, description);
			ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HETBackupConfig, name);
			return val.Value;
		}

		public abstract void Hooks();

		public string d(float f)
		{
			return f * 100f + "%";
		}

		public virtual void Init()
		{
			Hooks();
			string text = "ENGI_" + SkillToken.ToUpper() + "_DESCRIPTION";
			LanguageAPI.Add(text, DescText);
			Main.HETLogger.LogInfo((object)("Added " + Name));
		}
	}
	public abstract class TweakBase<T> : TweakBase where T : TweakBase<T>
	{
		public static T instance { get; set; }

		public TweakBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
			}
			instance = this as T;
		}
	}
}
namespace HIFUEngineerTweaks.Skills
{
	public class BouncingGrenades : TweakBase
	{
		public static float damage;

		public static int maximumGrenadesCount;

		public static float chargeTime;

		public static float aoe;

		public override string Name => ": Primary : Bouncing Grenades";

		public override string SkillToken => "primary";

		public override string DescText => "Fire <style=cIsDamage>" + maximumGrenadesCount + "</style> grenades that deal <style=cIsDamage>" + d(damage) + " damage</style> each.";

		public override void Init()
		{
			damage = ConfigOption(3f, "Damage", "Decimal. Vanilla is 1");
			maximumGrenadesCount = ConfigOption(3, "Grenade Count", "Vanilla is 8");
			aoe = ConfigOption(7f, "Area of Effect", "Vanilla is 3.5");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Changes();
			ChargeGrenades.OnEnter += new hook_OnEnter(ChargeGrenades_OnEnter);
			FireGrenades.OnEnter += new hook_OnEnter(FireGrenades_OnEnter);
		}

		private void FireGrenades_OnEnter(orig_OnEnter orig, FireGrenades self)
		{
			FireGrenades.damageCoefficient = damage;
			FireGrenades.fireDuration = 0.2f;
			FireGrenades.baseDuration = 1f;
			orig.Invoke(self);
		}

		private void ChargeGrenades_OnEnter(orig_OnEnter orig, ChargeGrenades self)
		{
			ChargeGrenades.baseMaxChargeTime = 0f;
			ChargeGrenades.baseTotalDuration = 0f;
			ChargeGrenades.maxCharges = 0;
			ChargeGrenades.maxGrenadeCount = maximumGrenadesCount;
			ChargeGrenades.minGrenadeCount = maximumGrenadesCount;
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiGrenadeProjectile.prefab").WaitForCompletion();
			ProjectileImpactExplosion component = val.GetComponent<ProjectileImpactExplosion>();
			((ProjectileExplosion)component).blastRadius = aoe;
		}
	}
	public class BubbleShield : TweakBase
	{
		public static float damage;

		public static float cooldown;

		public static float duration;

		public static float aoe;

		public static float ticks;

		public static float procCoefficient;

		public static bool changeShape;

		public static float size;

		public static int charges;

		public static int chargesToConsume;

		public static int chargesToRecharge;

		public override string Name => ": Utility : Bubble Shield";

		public override string SkillToken => "utility";

		public override string DescText => "Place an <style=cIsUtility>impenetrable shield</style> that blocks all incoming damage" + ((damage > 0f) ? (" and deals <style=cIsDamage>" + d(damage / ticks) + "</style> damage per second to nearby enemies.") : ".");

		public override void Init()
		{
			damage = ConfigOption(1f, "Damage per Tick", "Decimal. Vanilla is 0");
			cooldown = ConfigOption(12f, "Cooldown", "Vanilla is 25");
			duration = ConfigOption(15f, "Duration", "Vanilla is 15");
			aoe = ConfigOption(30f, "Damage Area of Effect", "Default is 30");
			ticks = ConfigOption(0.2f, "Time per Tick", "Default is 1");
			procCoefficient = ConfigOption(0f, "Proc Coefficient", "Default is 0");
			size = ConfigOption(60f, "Size", "Vanilla is 20, for 10m Radius\nKnockback area is equal to this as well");
			charges = ConfigOption(1, "Charges", "Vanilla is 1");
			chargesToConsume = ConfigOption(1, "Charges Required", "Vanilla is 1");
			chargesToRecharge = ConfigOption(1, "Charges to Recharge", "Vanilla is 1\nThis is so Bandolier and Hardlight Afterburner aren't as cracked");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(CharacterMaster_GetDeployableSameSlotLimit);
			Deployed.OnEnter += new hook_OnEnter(Deployed_OnEnter);
			Changes();
		}

		private void Deployed_OnEnter(orig_OnEnter orig, Deployed self)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Deployed.lifetime = duration;
			orig.Invoke(self);
			ChildLocator component = ((EntityState)self).GetComponent<ChildLocator>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((Component)component.FindChild(Deployed.childLocatorString)).gameObject.transform.localScale = new Vector3(size, size, size);
			}
		}

		private int CharacterMaster_GetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 3)
			{
				return 2 + self.inventory.GetItemCount(Items.UtilitySkillMagazine);
			}
			return orig.Invoke(self, slot);
		}

		private void Changes()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiBodyPlaceBubbleShield.asset").WaitForCompletion();
			val.baseRechargeInterval = cooldown;
			val.baseMaxStock = charges;
			val.stockToConsume = chargesToConsume;
			val.rechargeStock = chargesToRecharge;
			val.requiredStock = chargesToConsume;
			float timer = 0f;
			Deployed.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, Deployed self)
			{
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: 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_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: 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_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d7: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self);
				timer += Time.fixedDeltaTime;
				if (timer > ticks && self != null && (Object)(object)((EntityState)self).gameObject != (Object)null && (Object)(object)((EntityState)self).gameObject.GetComponent<Deployable>() != (Object)null && (Object)(object)((EntityState)self).gameObject.GetComponent<Deployable>().ownerMaster != (Object)null && (Object)(object)((EntityState)self).gameObject.GetComponent<Deployable>().ownerMaster.GetBodyObject() != (Object)null && (Object)(object)((EntityState)self).gameObject.GetComponent<Deployable>().ownerMaster.GetBody() != (Object)null)
				{
					CharacterMaster ownerMaster = ((EntityState)self).gameObject.GetComponent<Deployable>().ownerMaster;
					if (((EntityState)self).isAuthority)
					{
						new BlastAttack
						{
							attacker = ownerMaster.GetBodyObject(),
							baseDamage = ownerMaster.GetBody().damage * damage,
							baseForce = 0f,
							crit = ownerMaster.GetBody().RollCrit(),
							damageType = DamageTypeCombo.op_Implicit((DamageType)8),
							procCoefficient = procCoefficient,
							radius = aoe,
							falloffModel = (FalloffModel)0,
							position = ((EntityState)self).transform.position,
							attackerFiltering = (AttackerFiltering)2,
							teamIndex = ownerMaster.GetBody().teamComponent.teamIndex
						}.Fire();
						new BlastAttack
						{
							attacker = ownerMaster.GetBodyObject(),
							baseDamage = 0f,
							baseForce = 2500f,
							crit = false,
							damageType = DamageTypeCombo.op_Implicit((DamageType)32),
							procCoefficient = 0f,
							radius = size / 2f,
							position = ((EntityState)self).transform.position,
							attackerFiltering = (AttackerFiltering)2,
							teamIndex = ownerMaster.GetBody().teamComponent.teamIndex,
							falloffModel = (FalloffModel)0
						}.Fire();
						timer = 0f;
					}
				}
			};
		}
	}
	public class PressureMines : TweakBase
	{
		public static float damageScale;

		public static float aoeScale;

		public static int charges;

		public static float cooldown;

		public override string Name => ": Secondary : Pressure Mines";

		public override string SkillToken => "secondary";

		public override string DescText => "Place a two-stage mine that deals <style=cIsDamage>300% damage</style>, or <style=cIsDamage>" + Mathf.Round(300f * damageScale) + "% damage</style> if fully armed. Can hold up to " + charges + ".";

		public override void Init()
		{
			damageScale = ConfigOption(16f, "Damage Scale", "Decimal. Vanilla is 3");
			aoeScale = ConfigOption(4f, "Area of Effect Scale", "Vanilla is 2");
			charges = ConfigOption(1, "Charges", "Vanilla is 4");
			cooldown = ConfigOption(12f, "Cooldown", "Vanilla is 8");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			Changes();
			CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(CharacterMaster_GetDeployableSameSlotLimit);
			BaseMineArmingState.OnEnter += new hook_OnEnter(BaseMineArmingState_OnEnter);
			MineArmingWeak.FixedUpdate += new hook_FixedUpdate(MineArmingWeak_FixedUpdate);
		}

		private void MineArmingWeak_FixedUpdate(orig_FixedUpdate orig, MineArmingWeak self)
		{
			MineArmingWeak.duration = 1.5f;
			orig.Invoke(self);
		}

		private void BaseMineArmingState_OnEnter(orig_OnEnter orig, BaseMineArmingState self)
		{
			if (self is MineArmingFull)
			{
				self.damageScale = damageScale;
				self.blastRadiusScale = aoeScale;
				self.forceScale = 6f;
			}
			orig.Invoke(self);
		}

		private int CharacterMaster_GetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 0)
			{
				return 8 + self.GetBody().inventory.GetItemCount(Items.SecondarySkillMagazine);
			}
			return orig.Invoke(self, slot);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiBodyPlaceMine.asset").WaitForCompletion();
			val.baseMaxStock = charges;
			val.baseRechargeInterval = cooldown;
		}
	}
	public class SpiderMines : TweakBase
	{
		public static float damage;

		public static int charges;

		public static float cooldown;

		public override string Name => ": Secondary :: Spider Mines";

		public override string SkillToken => "spidermine";

		public override string DescText => "Place a robot mine that deals <style=cIsDamage>" + d(damage) + " damage</style> when an enemy walks nearby. Can hold up to " + charges + ".";

		public override void Init()
		{
			damage = ConfigOption(8f, "Damage", "Decimal. Vanilla is 6");
			charges = ConfigOption(4, "Charges", "Vanilla is 4");
			cooldown = ConfigOption(4f, "Cooldown", "Vanilla is 8");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Changes();
			CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(CharacterMaster_GetDeployableSameSlotLimit);
			FireMines.OnEnter += new hook_OnEnter(FireMines_OnEnter);
		}

		private void FireMines_OnEnter(orig_OnEnter orig, FireMines self)
		{
			if (self is FireSpiderMine)
			{
				self.damageCoefficient = damage;
			}
			orig.Invoke(self);
		}

		private int CharacterMaster_GetDeployableSameSlotLimit(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 5)
			{
				return 8 + self.inventory.GetItemCount(Items.SecondarySkillMagazine);
			}
			return orig.Invoke(self, slot);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiBodyPlaceSpiderMine.asset").WaitForCompletion();
			val.baseMaxStock = charges;
			val.baseRechargeInterval = cooldown;
		}
	}
	public class ThermalHarpoons : TweakBase
	{
		public static float damage;

		public static float cooldown;

		public static int charges;

		public static int chargesToRecharge;

		public static float range;

		public override string Name => ": Utility :: Thermal Harpoons";

		public override string SkillToken => "skill_harpoon";

		public override string DescText => "Enter <style=cIsUtility>target painting mode</style> to launch heat-seeking harpoon missiles that deal <style=cIsDamage>" + d(damage) + " damage</style> each. Can store up to " + charges + ".";

		public override void Init()
		{
			damage = ConfigOption(5f, "Damage", "Decimal. Vanilla is 5");
			cooldown = ConfigOption(2f, "Cooldown", "Vanilla is 2.5");
			charges = ConfigOption(4, "Charges", "Vanilla is 4");
			chargesToRecharge = ConfigOption(1, "Charges to Recharge", "Vanilla is 1");
			range = ConfigOption(9999, "Range", "Vanilla is 150");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			Changes();
			Fire.OnEnter += new hook_OnEnter(Fire_OnEnter);
			Paint.OnEnter += new hook_OnEnter(Paint_OnEnter);
		}

		private void Paint_OnEnter(orig_OnEnter orig, Paint self)
		{
			Paint.maxDistance = range;
			orig.Invoke(self);
		}

		private void Fire_OnEnter(orig_OnEnter orig, Fire self)
		{
			Fire.damageCoefficient = damage;
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Engi/EngiHarpoons.asset").WaitForCompletion();
			val.rechargeStock = chargesToRecharge;
			val.baseMaxStock = charges;
			val.baseRechargeInterval = cooldown;
		}
	}
	public class TR12GaussAutoTurret : TweakBase
	{
		public override string Name => ": Special : TR12 Gauss Auto Turret";

		public override string SkillToken => "special";

		public override string DescText => "Place a turret that <style=cIsUtility>inherits all your items.</style> Fires a cannon for <style=cIsDamage>100% damage</style>. Can place up to 2.";

		public override void Init()
		{
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		public static void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiTurretBody.prefab").WaitForCompletion().GetComponent<CharacterBody>();
			component.baseDamage = 14f;
			component.baseMaxHealth = 150f;
		}
	}
	public class TR58CarbonizerTurret : TweakBase
	{
		public override string Name => ": Special :: TR58 Carbonizer Turret";

		public override string SkillToken => "special_alt1";

		public override string DescText => "Place a <style=cIsUtility>mobile</style> turret that <style=cIsUtility>inherits all your items.</style> Fires a laser for <style=cIsDamage>200% damage per second</style> that <style=cIsUtility>slows enemies</style>. Can place up to 2.";

		public override void Init()
		{
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		public static void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiWalkerTurretMaster.prefab").WaitForCompletion();
			Component[] components = (Component[])(object)val.GetComponents<AISkillDriver>();
			Component[] array = components;
			AISkillDriver val2 = (from x in val.GetComponents<AISkillDriver>()
				where x.customName == "ReturnToLeader"
				select x).First();
			val2.shouldSprint = true;
			val2.minDistance = 35f;
			CharacterBody component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiWalkerTurretBody.prefab").WaitForCompletion().GetComponent<CharacterBody>();
			component.baseDamage = 14f;
			component.baseMoveSpeed = 11f;
			component.baseMaxHealth = 100f;
		}
	}
}
namespace HIFUEngineerTweaks.Misc
{
	public class BaseStats : MiscBase
	{
		public static float baseDamage;

		public static float baseJumpPower;

		public static float baseMoveSpeed;

		public static SkillDef defectivePropellants;

		public override string Name => ":: Misc : Base Stats";

		public override void Init()
		{
			baseDamage = ConfigOption(12f, "Base Damage", "Decimal. Vanilla is 14");
			baseJumpPower = ConfigOption(20f, "Base Jump Power", "Vanilla is 15");
			baseMoveSpeed = ConfigOption(7.5f, "Base Move Speed", "Vanilla is 7");
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		public static void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody component = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Engi/EngiBody.prefab").WaitForCompletion().GetComponent<CharacterBody>();
			component.baseDamage = baseDamage;
			component.baseJumpPower = baseJumpPower;
			component.baseMoveSpeed = baseMoveSpeed;
		}
	}
}

HIFULoaderTweaks.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Loader;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.EntityStates;
using On.EntityStates.Loader;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HIFULoaderTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4d7154fe3f0d979e2c36e00123e1830f3d3a5859")]
[assembly: AssemblyProduct("HIFULoaderTweaks")]
[assembly: AssemblyTitle("HIFULoaderTweaks")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 HIFULoaderTweaks
{
	public class ConfigManager
	{
		internal static bool ConfigChanged;

		internal static bool VersionChanged;

		public static T HandleConfig<T>(ConfigEntryBase entry, ConfigFile config, string name)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Expected O, but got Unknown
			MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
				where x.Name == "Bind"
				select x).First();
			methodInfo = methodInfo.MakeGenericMethod(typeof(T));
			object[] parameters = new object[3]
			{
				(object)new ConfigDefinition(Regex.Replace(config.ConfigFilePath, "\\W", "") + " : " + entry.Definition.Section, name),
				entry.DefaultValue,
				(object)new ConfigDescription(entry.Description.Description, (AcceptableValueBase)null, Array.Empty<object>())
			};
			ConfigEntryBase val = (ConfigEntryBase)methodInfo.Invoke(config, parameters);
			if (Main._preVersioning)
			{
				entry.BoxedValue = entry.DefaultValue;
			}
			if (!ConfigEqual(val.DefaultValue, val.BoxedValue) && VersionChanged)
			{
				entry.BoxedValue = entry.DefaultValue;
				val.BoxedValue = val.DefaultValue;
			}
			return default(T);
		}

		private static bool ConfigEqual(object a, object b)
		{
			if (a.Equals(b))
			{
				return true;
			}
			if (float.TryParse(a.ToString(), out var result) && float.TryParse(b.ToString(), out var result2) && (double)Mathf.Abs(result - result2) < 0.0001)
			{
				return true;
			}
			return false;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("HIFU.HIFULoaderTweaks", "HIFULoaderTweaks", "1.1.5")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.HIFULoaderTweaks";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "HIFULoaderTweaks";

		public const string PluginVersion = "1.1.5";

		public static ConfigFile HLTConfig;

		public static ConfigFile HLTBackupConfig;

		public static ManualLogSource HLTLogger;

		public static bool _preVersioning;

		public static ConfigEntry<bool> enableAutoConfig { get; set; }

		public static ConfigEntry<string> latestVersion { get; set; }

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			HLTLogger = ((BaseUnityPlugin)this).Logger;
			HLTConfig = ((BaseUnityPlugin)this).Config;
			HLTBackupConfig = new ConfigFile(Paths.ConfigPath + "\\HIFU.HIFULoaderTweaks.Backup.cfg", true);
			HLTBackupConfig.Bind<string>(": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :");
			enableAutoConfig = HLTConfig.Bind<bool>("Config", "Enable Auto Config Sync", true, "Disabling this would stop HIFULoaderTweaks from syncing config whenever a new version is found.");
			_preVersioning = !((Dictionary<ConfigDefinition, string>)AccessTools.DeclaredPropertyGetter(typeof(ConfigFile), "OrphanedEntries").Invoke(HLTConfig, null)).Keys.Any((ConfigDefinition x) => x.Key == "Latest Version");
			latestVersion = HLTConfig.Bind<string>("Config", "Latest Version", "1.1.5", "DO NOT CHANGE THIS");
			if (enableAutoConfig.Value && (_preVersioning || latestVersion.Value != "1.1.5"))
			{
				latestVersion.Value = "1.1.5";
				ConfigManager.VersionChanged = true;
				HLTLogger.LogInfo((object)"Config Autosync Enabled.");
			}
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(TweakBase))
				select type;
			HLTLogger.LogInfo((object)"==+----------------==TWEAKS==----------------+==");
			foreach (Type item in enumerable)
			{
				TweakBase tweakBase = (TweakBase)Activator.CreateInstance(item);
				if (ValidateTweak(tweakBase))
				{
					tweakBase.Init();
				}
			}
			IEnumerable<Type> enumerable2 = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(MiscBase))
				select type;
			HLTLogger.LogInfo((object)"==+----------------==MISC==----------------+==");
			foreach (Type item2 in enumerable2)
			{
				MiscBase miscBase = (MiscBase)Activator.CreateInstance(item2);
				if (ValidateMisc(miscBase))
				{
					miscBase.Init();
				}
			}
		}

		public bool ValidateTweak(TweakBase tb)
		{
			if (tb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(tb.Name, "Enable?", AllBossRouteDefaultEnabled(tb.Name), "Vanilla is false").Value)
			{
				return true;
			}
			return false;
		}

		public bool ValidateMisc(MiscBase mb)
		{
			if (mb.isEnabled && ((BaseUnityPlugin)this).Config.Bind<bool>(mb.Name, "Enable?", AllBossRouteDefaultEnabled(mb.Name), "Vanilla is false").Value)
			{
				return true;
			}
			return false;
		}

		private void PeripheryMyBeloved()
		{
		}

		private static bool AllBossRouteDefaultEnabled(string name)
		{
			if (!(name == ":: Misc :: Base Stats"))
			{
				return true;
			}
			return false;
		}
	}
	public abstract class MiscBase
	{
		public abstract string Name { get; }

		public virtual bool isEnabled { get; } = true;

		public T ConfigOption<T>(T value, string name, string description)
		{
			ConfigEntry<T> val = Main.HLTConfig.Bind<T>(Name, name, value, description);
			ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HLTBackupConfig, name);
			return val.Value;
		}

		public abstract void Hooks();

		public string d(float f)
		{
			return f * 100f + "%";
		}

		public virtual void Init()
		{
			Hooks();
			Main.HLTLogger.LogInfo((object)("Added " + Name));
		}
	}
	public abstract class MiscBase<T> : MiscBase where T : MiscBase<T>
	{
		public static T instance { get; set; }

		public MiscBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class TweakBase
	{
		public abstract string Name { get; }

		public abstract string SkillToken { get; }

		public abstract string DescText { get; }

		public virtual bool isEnabled { get; } = true;

		public T ConfigOption<T>(T value, string name, string description)
		{
			ConfigEntry<T> val = Main.HLTConfig.Bind<T>(Name, name, value, description);
			ConfigManager.HandleConfig<T>((ConfigEntryBase)(object)val, Main.HLTBackupConfig, name);
			return val.Value;
		}

		public abstract void Hooks();

		public string d(float f)
		{
			return f * 100f + "%";
		}

		public virtual void Init()
		{
			Hooks();
			string text = "LOADER_" + SkillToken.ToUpper() + "_DESCRIPTION";
			LanguageAPI.Add(text, DescText);
			Main.HLTLogger.LogInfo((object)("Added " + Name));
		}
	}
	public abstract class TweakBase<T> : TweakBase where T : TweakBase<T>
	{
		public static T instance { get; set; }

		public TweakBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class " + typeof(T).Name + " was instantiated twice");
			}
			instance = this as T;
		}
	}
}
namespace HIFULoaderTweaks.Skills
{
	public class ChargedGauntlet : TweakBase
	{
		public static float minDamage;

		public static float maxDamage;

		public static float chargeRate;

		public static float speedCoeff;

		public static float cooldown;

		public static bool formula;

		public override string Name => ": Utility : Charged Gauntlet";

		public override string SkillToken => "utility";

		public override string DescText => "<style=cIsUtility>Heavy</style>. Charge up a <style=cIsUtility>piercing</style> punch for <style=cIsDamage>" + d(minDamage) + "-" + d(maxDamage) + " damage</style>.";

		public override void Init()
		{
			minDamage = ConfigOption(6f, "Minimum Damage", "Decimal. Vanilla is ???");
			maxDamage = ConfigOption(40f, "Maximum Damage", "Decimal. Vanilla is ???");
			chargeRate = ConfigOption(1.5f, "Charge Duration", "Vanilla is 2.5");
			speedCoeff = ConfigOption(1.5f, "Speed Coefficient", "Decimal. Vanilla is 0.3");
			cooldown = ConfigOption(6f, "Cooldown", "Vanilla is 5");
			formula = ConfigOption(value: true, "Damage Formula", "Damage based on total charge, MinDamage and MaxDamage + SpeedCoeff * (Current velocity - 20~90, depending on total charge)");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			BaseChargeFist.OnEnter += new hook_OnEnter(BaseChargeFist_OnEnter);
			BaseSwingChargedFist.OnEnter += new hook_OnEnter(BaseSwingChargedFist_OnEnter);
			Changes();
		}

		private void BaseSwingChargedFist_OnEnter(orig_OnEnter orig, BaseSwingChargedFist self)
		{
			if (self is SwingChargedFist)
			{
				BaseSwingChargedFist.velocityDamageCoefficient = speedCoeff;
				orig.Invoke(self);
				self.bonusDamage -= BaseSwingChargedFist.velocityDamageCoefficient * ((BaseState)self).damageStat * Mathf.Lerp(self.minLungeSpeed, self.maxLungeSpeed, self.charge);
				((BasicMeleeAttack)self).damageCoefficient = Mathf.Lerp(minDamage, maxDamage, self.charge);
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void BaseChargeFist_OnEnter(orig_OnEnter orig, BaseChargeFist self)
		{
			if (self is ChargeFist)
			{
				self.baseChargeDuration = chargeRate;
			}
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			SteppedSkillDef val = Addressables.LoadAssetAsync<SteppedSkillDef>((object)"RoR2/Base/Loader/ChargeFist.asset").WaitForCompletion();
			((SkillDef)val).baseRechargeInterval = cooldown;
		}
	}
	public class GrappleFist : TweakBase
	{
		public static float cooldown;

		public static float range;

		public override string Name => ": Secondary : Grapple Fist";

		public override string SkillToken => "secondary";

		public override string DescText => "Fire your gauntlet forward, <style=cIsUtility>pulling</style> you to the target.";

		public override void Init()
		{
			cooldown = ConfigOption(5f, "Cooldown", "Vanilla is 5");
			range = ConfigOption(80f, "Max Range", "Vanilla is 80");
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Loader/FireHook.asset").WaitForCompletion();
			val.baseRechargeInterval = cooldown;
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderHook.prefab").WaitForCompletion();
			ProjectileGrappleController component = val2.GetComponent<ProjectileGrappleController>();
			component.maxTravelDistance = range;
		}
	}
	public class Knuckleboom : TweakBase
	{
		public static float damage;

		public static float fireRate;

		public static float burstDamage;

		public static float burstAoE;

		public static float barrierGain;

		public override string Name => ": Primary : Knuckleboom";

		public override string SkillToken => "primary";

		public override string DescText => "Swing at nearby enemies for <style=cIsDamage>" + d(damage) + " damage</style>. Every third hit knocks up for an additional <style=cIsDamage>" + d(burstDamage) + " damage</style> in a large radius.";

		public override void Init()
		{
			damage = ConfigOption(3.2f, "Damage", "Decimal. Vanilla is 3.2");
			burstDamage = ConfigOption(3.9f, "Third Hit Damage", "Decimal. Vanilla is 0");
			burstAoE = ConfigOption(20f, "Third Hit AoE", "Vanilla is 0");
			fireRate = ConfigOption(1.67f, "Fire Rate", "Vanilla is 1.66666667");
			barrierGain = ConfigOption(0.04f, "Barrier Gain per Hit", "Decimal. Vanilla is 0.05");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			BasicMeleeAttack.OnEnter += new hook_OnEnter(BasicMeleeAttack_OnEnter);
			BasicMeleeAttack.OnMeleeHitAuthority += new hook_OnMeleeHitAuthority(BasicMeleeAttack_OnMeleeHitAuthority);
			LoaderMeleeAttack.OnMeleeHitAuthority += new hook_OnMeleeHitAuthority(LoaderMeleeAttack_OnMeleeHitAuthority);
		}

		private void LoaderMeleeAttack_OnMeleeHitAuthority(orig_OnMeleeHitAuthority orig, LoaderMeleeAttack self)
		{
			LoaderMeleeAttack.barrierPercentagePerHit = barrierGain;
			orig.Invoke(self);
		}

		private void BasicMeleeAttack_OnMeleeHitAuthority(orig_OnMeleeHitAuthority orig, BasicMeleeAttack self)
		{
			if (self is LoaderMeleeAttack)
			{
				((Component)((EntityState)self).characterBody).gameObject.GetComponent<KnuckleboomButBased>().HitCount++;
			}
			orig.Invoke(self);
		}

		private void BasicMeleeAttack_OnEnter(orig_OnEnter orig, BasicMeleeAttack self)
		{
			if (self is LoaderMeleeAttack)
			{
				self.baseDuration = 1f / fireRate;
				self.damageCoefficient = damage;
				self.pushAwayForce = 50f;
				if ((Object)(object)((Component)((EntityState)self).characterBody).gameObject.GetComponent<KnuckleboomButBased>() == (Object)null)
				{
					((Component)((EntityState)self).characterBody).gameObject.AddComponent<KnuckleboomButBased>();
				}
			}
			orig.Invoke(self);
		}
	}
	public class KnuckleboomButBased : MonoBehaviour
	{
		public int HitCount;

		public CharacterBody body;

		public void Start()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		public void FixedUpdate()
		{
			//IL_001a: 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)
			//IL_0026: 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_0042: Expected O, but got Unknown
			//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)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			if (HitCount >= 3)
			{
				EffectManager.SpawnEffect(GroundSlam.blastEffectPrefab, new EffectData
				{
					origin = body.footPosition,
					scale = Knuckleboom.burstAoE
				}, true);
				if (Util.HasEffectiveAuthority(((Component)this).gameObject))
				{
					new BlastAttack
					{
						attacker = ((Component)body).gameObject,
						baseDamage = body.damage * Knuckleboom.burstDamage,
						baseForce = 50f,
						bonusForce = new Vector3(0f, 1500f, 0f),
						crit = body.RollCrit(),
						damageType = DamageTypeCombo.op_Implicit((DamageType)0),
						procCoefficient = 1f,
						radius = Knuckleboom.burstAoE,
						position = body.footPosition,
						attackerFiltering = (AttackerFiltering)2,
						teamIndex = body.teamComponent.teamIndex,
						falloffModel = (FalloffModel)0,
						impactEffect = EffectCatalog.FindEffectIndexFromPrefab(GroundSlam.blastImpactEffectPrefab)
					}.Fire();
				}
				HitCount = 0;
			}
		}
	}
	public class M551Pylon : TweakBase
	{
		public static float damage;

		public static float cooldown;

		public static float aoe;

		public static float fireRate;

		public static float procCoefficient;

		public static int bounces;

		public static float lifetime;

		public override string Name => ": Special : M551 Pylon";

		public override string SkillToken => "special";

		public override string DescText => "Throw a floating pylon that repeatedly <style=cIsDamage>zaps</style> up to <style=cIsDamage>3</style> nearby enemies for <style=cIsDamage>" + d(damage) + " damage</style>. Can be <style=cIsUtility>grappled</style>.";

		public override void Init()
		{
			damage = ConfigOption(1f, "Damage", "Decimal. Vanilla is 1");
			aoe = ConfigOption(25f, "Area of Effect", "Vanilla is 25");
			cooldown = ConfigOption(10f, "Cooldown", "Vanilla is 20");
			fireRate = ConfigOption(3f, "Fire Rate", "Vanilla is 1");
			procCoefficient = ConfigOption(0.5f, "Proc Coefficient", "Vanilla is 0.5");
			bounces = ConfigOption(3, "Bounce Count", "Vanilla is 0");
			lifetime = ConfigOption(15f, "Lifetime", "Vanilla is 15");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Changes();
			ThrowPylon.OnEnter += new hook_OnEnter(ThrowPylon_OnEnter);
		}

		private void ThrowPylon_OnEnter(orig_OnEnter orig, ThrowPylon self)
		{
			ThrowPylon.damageCoefficient = damage;
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Loader/ThrowPylon.asset").WaitForCompletion();
			val.baseRechargeInterval = cooldown;
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderPylon.prefab").WaitForCompletion();
			ProjectileProximityBeamController component = val2.GetComponent<ProjectileProximityBeamController>();
			component.attackInterval = 1f / fireRate;
			component.attackRange = aoe;
			component.procCoefficient = procCoefficient;
			component.bounces = bounces;
			ProjectileSimple component2 = val2.GetComponent<ProjectileSimple>();
			component2.lifetime = lifetime;
		}
	}
	public class SpikedFist : TweakBase
	{
		public static float massLimit;

		public static float cooldown;

		public static float range;

		public override string Name => ": Secondary :: Spiked Fist";

		public override string SkillToken => "yankhook";

		public override string DescText => "<style=cIsDamage>Stunning</style>. Fire your gauntlet forward, dealing <style=cIsDamage>320% damage</style>. <style=cIsUtility>Pulls</style> you to heavy targets. Light targets are <style=cIsUtility>pulled to YOU</style> instead.";

		public override void Init()
		{
			massLimit = ConfigOption(9999f, "Mass Limit", "Vanilla is 250");
			cooldown = ConfigOption(10f, "Cooldown", "Vanilla is 5");
			range = ConfigOption(480f, "Max Range", "Vanilla is 80");
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderYankHook.prefab").WaitForCompletion();
			ProjectileGrappleController component = val.GetComponent<ProjectileGrappleController>();
			component.yankMassLimit = massLimit;
			component.maxTravelDistance = range;
			SkillDef val2 = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Loader/FireYankHook.asset").WaitForCompletion();
			val2.baseRechargeInterval = cooldown;
		}
	}
	public class ThunderGauntlet : TweakBase
	{
		public static float damage;

		public static float chargeRate;

		public static float speedCoeff;

		public static float cooldown;

		public static bool formula;

		public override string Name => ": Utility :: Thunder Gauntlet";

		public override string SkillToken => "utility_alt1";

		public override string DescText => "<style=cIsUtility>Heavy</style>. Charge up a <style=cIsUtility>single-target</style> punch for <style=cIsDamage>" + d(damage) + " damage</style> that <style=cIsDamage>shocks</style> enemies in a cone for <style=cIsDamage>900% damage</style>.";

		public override void Init()
		{
			damage = ConfigOption(21f, "Damage", "Decimal. Vanilla is ???");
			chargeRate = ConfigOption(0.01f, "Charge Duration", "Vanilla is 0.4");
			speedCoeff = ConfigOption(1.5f, "Speed Coefficient", "Decimal. Vanilla is 0.3");
			cooldown = ConfigOption(5f, "Cooldown", "Vanilla is 5");
			formula = ConfigOption(value: true, "Damage Formula", "Damage + SpeedCoeff * (Current velocity - 90)");
			base.Init();
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			BaseChargeFist.OnEnter += new hook_OnEnter(BaseChargeFist_OnEnter);
			BaseSwingChargedFist.OnEnter += new hook_OnEnter(BaseSwingChargedFist_OnEnter);
			Changes();
		}

		private void BaseSwingChargedFist_OnEnter(orig_OnEnter orig, BaseSwingChargedFist self)
		{
			if (self is SwingZapFist)
			{
				BaseSwingChargedFist.velocityDamageCoefficient = speedCoeff;
				((BasicMeleeAttack)self).damageCoefficient = damage;
				orig.Invoke(self);
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void BaseChargeFist_OnEnter(orig_OnEnter orig, BaseChargeFist self)
		{
			if (self is ChargeZapFist)
			{
				self.baseChargeDuration = chargeRate;
			}
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			SteppedSkillDef val = Addressables.LoadAssetAsync<SteppedSkillDef>((object)"RoR2/Base/Loader/ChargeZapFist.asset").WaitForCompletion();
			((SkillDef)val).baseRechargeInterval = cooldown;
		}
	}
	public class Thunderslam : TweakBase
	{
		public static float damage;

		public static float cooldown;

		public static float aoe;

		public static float yVelocityCoeff;

		public static bool formula;

		public static BuffDef fallDamageReduction;

		public override string Name => ": Special :: Thunderslam";

		public override string SkillToken => "special_alt";

		public override string DescText => "<style=cIsUtility>Very Heavy</style>. <style=cIsDamage>Stunning</style>. Slam your fists down, dealing <style=cIsDamage>" + d(damage) + "</style> damage on impact.";

		public override void Init()
		{
			damage = ConfigOption(20f, "Damage", "Decimal. Vanilla is 20");
			aoe = ConfigOption(30f, "Area of Effect", "Vanilla is 11");
			cooldown = ConfigOption(24f, "Cooldown", "Vanilla is 8");
			yVelocityCoeff = ConfigOption(2f, "Y Axis Speed Coefficient", "Vanilla is 0");
			formula = ConfigOption(value: true, "Damage Formula", "if Damage + Y Velocity * -1 * YVelocityCoeff >=\nDamage + YVelocityCoeff * 25,\nset the Damage to that");
			fallDamageReduction = ScriptableObject.CreateInstance<BuffDef>();
			fallDamageReduction.isHidden = true;
			fallDamageReduction.isDebuff = false;
			fallDamageReduction.canStack = false;
			fallDamageReduction.isCooldown = false;
			ContentAddition.AddBuffDef(fallDamageReduction);
			base.Init();
		}

		public override void Hooks()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			Changes();
			GroundSlam.OnEnter += new hook_OnEnter(GroundSlam_OnEnter);
			GroundSlam.FixedUpdate += new hook_FixedUpdate(GroundSlam_FixedUpdate);
			GroundSlam.OnExit += new hook_OnExit(GroundSlam_OnExit);
			GlobalEventManager.OnCharacterHitGroundServer += new hook_OnCharacterHitGroundServer(GlobalEventManager_OnCharacterHitGroundServer);
		}

		private void GlobalEventManager_OnCharacterHitGroundServer(orig_OnCharacterHitGroundServer orig, GlobalEventManager self, CharacterBody characterBody, HitGroundInfo info)
		{
			//IL_0031: 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_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 (characterBody.HasBuff(fallDamageReduction))
			{
				ref Vector3 velocity = ref info.velocity;
				velocity *= 0.75f;
			}
			orig.Invoke(self, characterBody, info);
		}

		private void GroundSlam_OnExit(orig_OnExit orig, GroundSlam self)
		{
			GroundSlam.blastDamageCoefficient = damage;
			orig.Invoke(self);
			if (Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
			{
				((EntityState)self).characterBody.RemoveBuff(fallDamageReduction);
			}
		}

		private void GroundSlam_FixedUpdate(orig_FixedUpdate orig, GroundSlam self)
		{
			if (((EntityState)self).isAuthority && Object.op_Implicit((Object)(object)((EntityState)self).characterMotor))
			{
				float num = damage + ((EntityState)self).characterMotor.velocity.y * -1f * yVelocityCoeff;
				if (num >= damage + yVelocityCoeff * 25f)
				{
					GroundSlam.blastDamageCoefficient = num;
				}
				orig.Invoke(self);
			}
		}

		private void GroundSlam_OnEnter(orig_OnEnter orig, GroundSlam self)
		{
			GroundSlam.blastRadius = aoe;
			if (Object.op_Implicit((Object)(object)((EntityState)self).characterBody))
			{
				((EntityState)self).characterBody.AddBuff(fallDamageReduction);
			}
			orig.Invoke(self);
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			SteppedSkillDef val = Addressables.LoadAssetAsync<SteppedSkillDef>((object)"RoR2/Base/Loader/GroundSlam.asset").WaitForCompletion();
			((SkillDef)val).baseRechargeInterval = cooldown;
			LanguageAPI.Add("KEYWORD_VERY_HEAVY", "<style=cKeywordName>Very Heavy</style><style=cSub>The skill deals much more damage the faster you are falling. <color=#FF7F7F>Watch out for backblast</color>.</style>");
			string[] keywordTokens = new string[1] { "KEYWORD_VERY_HEAVY" };
			SkillFamily val2 = Addressables.LoadAssetAsync<SkillFamily>((object)"RoR2/Base/Loader/LoaderBodySpecialFamily.asset").WaitForCompletion();
			val2.variants[1].skillDef.keywordTokens = keywordTokens;
		}
	}
}
namespace HIFULoaderTweaks.Misc
{
	public class FallDamageReduction : MiscBase
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_TakeDamage <>9__5_0;

			internal void <Changes>b__5_0(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				if (damageInfo != null && ((Enum)damageInfo.damageType.damageType).HasFlag((Enum)(object)(DamageType)2097152) && Object.op_Implicit((Object)(object)self.body) && ((Object)self.body).name == "LoaderBody(Clone)")
				{
					damageInfo.damage *= 1f - fallDamageReduction;
				}
				orig.Invoke(self, damageInfo);
			}
		}

		public static float fallDamageReduction;

		public override string Name => ":: Misc : Scrap Barrier";

		public override void Init()
		{
			fallDamageReduction = ConfigOption(0.5f, "Fall Damage Reduction", "Decimal. Vanilla is 1");
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		public static void Changes()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_0075: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				hook_TakeDamage val = delegate(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
				{
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					if (damageInfo != null && ((Enum)damageInfo.damageType.damageType).HasFlag((Enum)(object)(DamageType)2097152) && Object.op_Implicit((Object)(object)self.body) && ((Object)self.body).name == "LoaderBody(Clone)")
					{
						damageInfo.damage *= 1f - fallDamageReduction;
					}
					orig.Invoke(self, damageInfo);
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			HealthComponent.TakeDamage += (hook_TakeDamage)obj;
			LanguageAPI.Add("LOADER_PASSIVE_DESCRIPTION", "The Loader has her fall damage <style=cIsUtility>reduced by " + fallDamageReduction * 100f + "%</style>. Striking enemies with the Loader's gauntlets grants a <style=cIsHealing>temporary barrier</style>.");
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderBody.prefab").WaitForCompletion();
			CharacterBody component = val2.GetComponent<CharacterBody>();
			component.bodyFlags = (BodyFlags)(component.bodyFlags & -2);
		}
	}
	public class StatChanges : MiscBase
	{
		public static float baseMaxHealth;

		public static float armor;

		public override string Name => ":: Misc :: Base Stats";

		public override void Init()
		{
			baseMaxHealth = ConfigOption(110f, "Base Max Health", "Vanilla is 160");
			armor = ConfigOption(0f, "Base Armor", "Vanilla is 20");
			base.Init();
		}

		public override void Hooks()
		{
			Changes();
		}

		private void Changes()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Loader/LoaderBody.prefab").WaitForCompletion();
			CharacterBody component = val.GetComponent<CharacterBody>();
			component.baseMaxHealth = baseMaxHealth;
			component.levelMaxHealth = baseMaxHealth * 0.3f;
			component.baseArmor = armor;
		}
	}
}

HarvesterHexes.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using RoR2.Orbs;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace HarvesterHexes
{
	[BepInPlugin("custom.HarvesterHexes", "HarvesterHexes", "1.0.0")]
	public class HarvesterHexesPlugin : BaseUnityPlugin
	{
		private class HexesGranted : MonoBehaviour
		{
		}

		internal static ManualLogSource Log;

		private static ConfigEntry<bool> modEnabled;

		private static ConfigEntry<int> blindnessCount;

		private static ConfigEntry<int> famineCount;

		private void Awake()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Replace the 3 random hexes the Anima Harvester gives each player at the start of its second phase with the fixed hexes below.");
			blindnessCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HexOfBlindnessCount", 1, "Hex of Blindness given to each player.");
			famineCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "HexOfFamineCount", 6, "Hex of Famine given to each player.");
			try
			{
				new Harmony("custom.HarvesterHexes").Patch((MethodBase)AccessTools.Method(typeof(ChampRushMissionController), "TryGiveHexes", (Type[])null, (Type[])null), new HarmonyMethod(typeof(HarvesterHexesPlugin), "TryGiveHexesPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not hook the Anima Harvester hexes: " + ex));
			}
		}

		private static bool TryGiveHexesPrefix(ChampRushMissionController __instance, CharacterBody reaperBody)
		{
			if (!modEnabled.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)__instance))
			{
				return true;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<HexesGranted>()))
				{
					return false;
				}
				((Component)__instance).gameObject.AddComponent<HexesGranted>();
				List<ItemDef> list = new List<ItemDef>();
				ItemDef val = Resolve(Items.Blindness, "Blindness");
				ItemDef val2 = Resolve(Items.LowerHealing, "LowerHealing");
				for (int i = 0; i < Mathf.Max(0, blindnessCount.Value); i++)
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						break;
					}
					list.Add(val);
				}
				for (int j = 0; j < Mathf.Max(0, famineCount.Value); j++)
				{
					if (!Object.op_Implicit((Object)(object)val2))
					{
						break;
					}
					list.Add(val2);
				}
				Log.LogInfo((object)("Anima Harvester phase 2: giving each player " + blindnessCount.Value + "x Hex of Blindness and " + famineCount.Value + "x Hex of Famine."));
				((MonoBehaviour)__instance).StartCoroutine(GiveHexes(__instance, reaperBody, list));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Anima Harvester hexes failed, falling back to the vanilla hexes: " + ex));
				return true;
			}
			return false;
		}

		private static ItemDef Resolve(ItemDef field, string name)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)field))
			{
				return field;
			}
			ItemIndex val = ItemCatalog.FindItemIndex(name);
			ItemDef obj = (((int)val == -1) ? null : ItemCatalog.GetItemDef(val));
			if (!Object.op_Implicit((Object)(object)obj))
			{
				Log.LogWarning((object)("Could not find item " + name + "."));
			}
			return obj;
		}

		private static IEnumerator GiveHexes(ChampRushMissionController controller, CharacterBody reaperBody, List<ItemDef> hexes)
		{
			WaitForSeconds wait = new WaitForSeconds(0.25f);
			List<PlayerCharacterMasterController> players = PlayerCharacterMasterController.instances.ToList();
			foreach (ItemDef hex in hexes)
			{
				foreach (PlayerCharacterMasterController item in players)
				{
					if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.master) && Object.op_Implicit((Object)(object)item.master.inventory))
					{
						Inventory inventory = item.master.inventory;
						CharacterBody body = item.master.GetBody();
						if (Object.op_Implicit((Object)(object)reaperBody) || Object.op_Implicit((Object)(object)body))
						{
							ItemTransferOrb.DispatchItemTransferOrb(new DispatchArgs
							{
								origin = (Object.op_Implicit((Object)(object)reaperBody) ? reaperBody.corePosition : body.corePosition),
								inventoryToGrantTo = inventory,
								itemIndex = hex.itemIndex,
								permanentCount = 1,
								isPickup = true,
								travelDuration = 1f
							});
						}
						else
						{
							inventory.GiveItemPermanent(hex.itemIndex, 1);
						}
						yield return wait;
						if (!Object.op_Implicit((Object)(object)controller))
						{
							yield break;
						}
					}
				}
			}
		}
	}
}

HauntPortalOnStage4.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace HauntPortalOnStage4
{
	[BepInPlugin("custom.HauntPortalOnStage4", "HauntPortalOnStage4", "1.3.0")]
	public class HauntPortalPlugin : BaseUnityPlugin
	{
		public const string GUID = "custom.HauntPortalOnStage4";

		public const string NAME = "HauntPortalOnStage4";

		public const string VERSION = "1.3.0";

		private const string SpawnCardPath = "RoR2/DLC3/iscHardwareProgPortal_Haunt.asset";

		private static InteractableSpawnCard hauntPortalCard;

		private ConfigEntry<bool> applyOnLoops;

		private ConfigEntry<string> frogPortal;

		private const string NullPortalPath = "RoR2/Base/PortalArena/PortalArena.prefab";

		private const string NullPortalMessage = "<style=cIsUtility>A Null Portal has opened...</style>";

		private static GameObject nullPortalPrefab;

		private const string FrogPath = "RoR2/Base/moon/FrogInteractable.prefab";

		private const string VoidPortalCardPath = "RoR2/DLC1/PortalVoid/iscVoidPortal.asset";

		internal static ManualLogSource Log;

		private static ConfigEntry<bool> noNullPortal;

		private static ConfigEntry<bool> alwaysVoidPortal;

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_009d: Expected O, but got Unknown
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Expected O, but got Unknown
			applyOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyOnLoops", false, "If true, also spawns the portal on the 4th stage of every loop (stage 9, 14, ...).");
			AsyncOperationHandle<InteractableSpawnCard> val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC3/iscHardwareProgPortal_Haunt.asset");
			val.Completed += delegate(AsyncOperationHandle<InteractableSpawnCard> handle)
			{
				hauntPortalCard = handle.Result;
				if ((Object)(object)hauntPortalCard == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load RoR2/DLC3/iscHardwareProgPortal_Haunt.asset");
				}
			};
			TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterCharged;
			frogPortal = ((BaseUnityPlugin)this).Config.Bind<string>("Commencement Frog", "Portal", "NullPortal", new ConfigDescription("Which portal Commencement's frog opens: NullPortal (to the Void Fields), VoidLocus, or Vanilla (its usual portal).", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "NullPortal", "VoidLocus", "Vanilla" }), Array.Empty<object>()));
			if (frogPortal.Value != "Vanilla")
			{
				SetupFrog(frogPortal.Value == "VoidLocus");
			}
			noNullPortal = ((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "NoNullPortal", true, "The Null Portal (to the next stage) never opens in the Void Fields: the only way out is the void portal that opens once every cell is breached.");
			alwaysVoidPortal = ((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "AlwaysVoidPortal", true, "The void portal always opens once every cell in the Void Fields is breached, Eclipse included (Eclipse normally blocks it).");
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				Harmony val2 = new Harmony("custom.HauntPortalOnStage4");
				val2.Patch((MethodBase)AccessTools.Method(typeof(PortalSpawner), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HauntPortalPlugin), "PortalSpawnerStartPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				val2.Patch((MethodBase)AccessTools.Method(typeof(MissionCompleted), "OnEnter", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HauntPortalPlugin), "ArenaCompletedPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Void Fields hooks: " + ex));
			}
			Stage.onStageStartGlobal += delegate
			{
				if (InArena())
				{
					HideNullPortals(null);
				}
			};
		}

		private static bool InArena()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef))
			{
				return mostRecentSceneDef.cachedName == "arena";
			}
			return false;
		}

		private static void PortalSpawnerStartPostfix(PortalSpawner __instance)
		{
			//IL_0098: 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_00ae: Expected O, but got Unknown
			try
			{
				if (!NetworkServer.active || !alwaysVoidPortal.Value || !Object.op_Implicit((Object)(object)__instance) || __instance.WillSpawn || !InArena())
				{
					return;
				}
				InteractableSpawnCard portalSpawnCard = __instance.PortalSpawnCard;
				if (Object.op_Implicit((Object)(object)portalSpawnCard) && ((Object)portalSpawnCard).name.IndexOf("Void", StringComparison.OrdinalIgnoreCase) >= 0 && (!Object.op_Implicit((Object)(object)__instance.requiredExpansion) || !Object.op_Implicit((Object)(object)Run.instance) || Run.instance.IsExpansionEnabled(__instance.requiredExpansion)))
				{
					__instance.WillSpawn = true;
					if (!string.IsNullOrEmpty(__instance.spawnPreviewMessageToken))
					{
						Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
						{
							baseToken = __instance.spawnPreviewMessageToken
						});
					}
					Log.LogInfo((object)"The Void Fields' void portal will open when every cell is breached.");
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Void Fields void portal: " + ex.Message));
			}
		}

		private static void ArenaCompletedPostfix()
		{
			try
			{
				HideNullPortals(Object.op_Implicit((Object)(object)ArenaMissionController.instance) ? ArenaMissionController.instance.clearedEffect : null);
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Void Fields null portal: " + ex.Message));
			}
		}

		private static void HideNullPortals(GameObject clearedEffect)
		{
			//IL_0036: 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)
			if (!noNullPortal.Value || !InArena())
			{
				return;
			}
			SceneExitController[] array = Resources.FindObjectsOfTypeAll<SceneExitController>();
			foreach (SceneExitController val in array)
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					continue;
				}
				Scene scene = ((Component)val).gameObject.scene;
				if (((Scene)(ref scene)).IsValid())
				{
					bool flag = ((Object)((Component)val).gameObject).name.StartsWith("PortalArena", StringComparison.OrdinalIgnoreCase);
					bool flag2 = Object.op_Implicit((Object)(object)clearedEffect) && ((Component)val).transform.IsChildOf(clearedEffect.transform) && val.useRunNextStageScene;
					if ((flag || flag2) && ((Component)val).gameObject.activeSelf)
					{
						((Component)val).gameObject.SetActive(false);
						Log.LogInfo((object)"Closed the Void Fields' Null Portal.");
					}
					else if (flag || flag2)
					{
						((Behaviour)val).enabled = false;
					}
				}
			}
		}

		private void SetupFrog(bool voidLocus)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (Chainloader.PluginInfos.ContainsKey("mwmw.VoidLocusAfterMithrix"))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"The VoidLocusAfterMithrix mod is still installed. Its change is part of HauntPortalOnStage4, so remove it or it may fight over the frog.");
			}
			try
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/moon/FrogInteractable.prefab").WaitForCompletion();
				InteractableSpawnCard val2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/PortalVoid/iscVoidPortal.asset").WaitForCompletion();
				PortalSpawner val3 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<PortalSpawner>() : null);
				if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val2))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find the frog or a portal spawn card; the frog is unchanged.");
					return;
				}
				if (voidLocus)
				{
					val3.portalSpawnCard = val2;
					((BaseUnityPlugin)this).Logger.LogInfo((object)"Commencement frog now opens a Void Locus portal.");
					return;
				}
				nullPortalPrefab = FindNullPortal();
				if (!Object.op_Implicit((Object)(object)nullPortalPrefab))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find the Null Portal; the frog is unchanged.");
					return;
				}
				NullPortalSpawnCard nullPortalSpawnCard = ScriptableObject.CreateInstance<NullPortalSpawnCard>();
				Type[] array = new Type[2]
				{
					typeof(InteractableSpawnCard),
					typeof(SpawnCard)
				};
				for (int i = 0; i < array.Length; i++)
				{
					FieldInfo[] fields = array[i].GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					foreach (FieldInfo fieldInfo in fields)
					{
						fieldInfo.SetValue(nullPortalSpawnCard, fieldInfo.GetValue(val2));
					}
				}
				((Object)nullPortalSpawnCard).name = "iscNullPortalFrog";
				((SpawnCard)nullPortalSpawnCard).prefab = nullPortalPrefab;
				val3.portalSpawnCard = (InteractableSpawnCard)(object)nullPortalSpawnCard;
				val3.spawnMessageToken = "<style=cIsUtility>A Null Portal has opened...</style>";
				if (Object.op_Implicit((Object)(object)nullPortalPrefab.GetComponent<NetworkIdentity>()))
				{
					ClientScene.RegisterPrefab(nullPortalPrefab);
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Commencement frog now opens a Null Portal (" + ((Object)nullPortalPrefab).name + ")."));
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Commencement frog: " + ex));
			}
		}

		private GameObject FindNullPortal()
		{
			GameObject val = TryLoadPrefab("RoR2/Base/PortalArena/PortalArena.prefab");
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			try
			{
				foreach (IResourceLocator resourceLocator in Addressables.ResourceLocators)
				{
					foreach (object key in resourceLocator.Keys)
					{
						if (key is string text && text.EndsWith("/PortalArena.prefab", StringComparison.OrdinalIgnoreCase))
						{
							val = TryLoadPrefab(text);
							if (Object.op_Implicit((Object)(object)val))
							{
								((BaseUnityPlugin)this).Logger.LogInfo((object)("Null Portal found at " + text));
								return val;
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("Null Portal search: " + ex.Message));
			}
			try
			{
				val = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/PortalArena");
			}
			catch (Exception)
			{
			}
			return val;
		}

		private static GameObject TryLoadPrefab(string key)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				IList<IResourceLocation> list = Addressables.LoadResourceLocationsAsync((object)key, typeof(GameObject)).WaitForCompletion();
				if (list == null || list.Count == 0)
				{
					return null;
				}
				return Addressables.LoadAssetAsync<GameObject>((object)key).WaitForCompletion();
			}
			catch (Exception)
			{
				return null;
			}
		}

		private void OnDestroy()
		{
			TeleporterInteraction.onTeleporterChargedGlobal -= OnTeleporterCharged;
		}

		private void OnTeleporterCharged(TeleporterInteraction teleporter)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: 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)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || (Object)(object)Run.instance == (Object)null || (Object)(object)teleporter == (Object)null)
			{
				return;
			}
			int stageClearCount = Run.instance.stageClearCount;
			if (!((!applyOnLoops.Value) ? (stageClearCount == 3) : (stageClearCount % 5 == 3)))
			{
				return;
			}
			if ((Object)(object)hauntPortalCard == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Haunt portal spawn card not loaded; cannot spawn portal.");
				return;
			}
			DirectorPlacementRule val = new DirectorPlacementRule
			{
				minDistance = 10f,
				maxDistance = 40f,
				placementMode = (PlacementMode)1,
				position = ((Component)teleporter).transform.position
			};
			DirectorSpawnRequest val2 = new DirectorSpawnRequest((SpawnCard)(object)hauntPortalCard, val, Run.instance.stageRng);
			GameObject val3 = ((!((Object)(object)DirectorCore.instance != (Object)null)) ? null : DirectorCore.instance.TrySpawnObject(val2));
			if ((Object)(object)val3 == (Object)null)
			{
				Vector3 val4 = ((Component)teleporter).transform.position + ((Component)teleporter).transform.forward * 12f + Vector3.up * 5f;
				RaycastHit val5 = default(RaycastHit);
				if (Physics.Raycast(val4, Vector3.down, ref val5, 50f, LayerMask.GetMask(new string[1] { "World" })))
				{
					val4 = ((RaycastHit)(ref val5)).point;
				}
				val.placementMode = (PlacementMode)0;
				val.position = val4;
				val3 = ((!((Object)(object)DirectorCore.instance != (Object)null)) ? null : DirectorCore.instance.TrySpawnObject(val2));
			}
			if ((Object)(object)val3 != (Object)null)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<style=cIsUtility>An Encrypted Portal has opened...</style>"
				});
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Spawned Solutional Haunt portal at " + ((object)val3.transform.position/*cast due to .constrained prefix*/).ToString()));
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to spawn Solutional Haunt portal.");
			}
		}
	}
	public class NullPortalSpawnCard : InteractableSpawnCard
	{
		protected override void Spawn(Vector3 position, Quaternion rotation, DirectorSpawnRequest directorSpawnRequest, ref SpawnResult result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((InteractableSpawnCard)this).Spawn(position, rotation, directorSpawnRequest, ref result);
			try
			{
				GameObject spawnedInstance = result.spawnedInstance;
				SceneExitController val = (Object.op_Implicit((Object)(object)spawnedInstance) ? spawnedInstance.GetComponent<SceneExitController>() : null);
				SceneDef val2 = SceneCatalog.FindSceneDef("arena");
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2))
				{
					val.useRunNextStageScene = false;
					val.destinationScene = val2;
				}
				else
				{
					Debug.LogWarning((object)"[HauntPortalOnStage4] Couldn't point the Null Portal at the Void Fields.");
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[HauntPortalOnStage4] Null Portal destination: " + ex.Message));
			}
		}
	}
}

HealthbarImmune.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.UI;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HealthbarImmune;

[BepInPlugin("com.DestroyedClone.HealthbarImmune", "Healthbar Immune", "1.0.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class HealthbarImmunePlugin : BaseUnityPlugin
{
	public static ConfigEntry<string> cfgCharacterBlacklist;

	public static Color ImmuneColor = Color.yellow;

	public static string token = "IMMUNE_TO_DAMAGE_HITMARKER";

	public static string currentLanguageToken = "NOHIT";

	internal static ManualLogSource _logger;

	public static List<BodyIndex> bannedBodies = new List<BodyIndex>();

	public void Awake()
	{
		//IL_0034: 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_006d: Expected O, but got Unknown
		_logger = ((BaseUnityPlugin)this).Logger;
		cfgCharacterBlacklist = ((BaseUnityPlugin)this).Config.Bind<string>("", "Character Blacklist", "", "Blacklisted characters if needed. Use body name, and seperate by commas.\n CommandoBody,HuntressBody");
		new Harmony("com.DestroyedClone.HealthbarImmune").Patch((MethodBase)AccessTools.Method(typeof(HealthBar), "UpdateBarInfos", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HealthbarImmunePlugin), "UpdateBarInfosPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Language.onCurrentLanguageChanged += Language_onCurrentLanguageChanged;
		if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
		{
			ModSupport_RiskOfOptions.Initialize();
		}
		((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)SetupDictionary);
	}

	public static void SetupDictionary()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Invalid comparison between Unknown and I4
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		_logger.LogMessage((object)"Setting up banned bodies.");
		bannedBodies.Clear();
		string[] array = cfgCharacterBlacklist.Value.Split(',');
		List<string> list = new List<string>();
		List<string> list2 = new List<string>();
		string[] array2 = array;
		foreach (string text in array2)
		{
			if (!string.IsNullOrWhiteSpace(text))
			{
				BodyIndex val = BodyCatalog.FindBodyIndex(text.Trim());
				if ((int)val == -1)
				{
					list2.Add(text);
					continue;
				}
				bannedBodies.Add(val);
				list.Add(text);
			}
		}
		if (list.Count > 0)
		{
			_logger.LogMessage((object)("Successfully blacklisted: " + string.Join(", ", list.ToArray())));
		}
		if (list2.Count > 0)
		{
			_logger.LogMessage((object)("Failed to blacklist: " + string.Join(", ", list2.ToArray())));
		}
	}

	private void Language_onCurrentLanguageChanged()
	{
		if (Language.currentLanguage != null)
		{
			currentLanguageToken = Language.GetString(token);
		}
	}

	public static bool IsImmune(HealthComponent source)
	{
		if (!Object.op_Implicit((Object)(object)source))
		{
			return false;
		}
		if (source.godMode)
		{
			return true;
		}
		CharacterBody body = source.body;
		if (!Object.op_Implicit((Object)(object)body))
		{
			return false;
		}
		if (!body.HasBuff(Buffs.HiddenInvincibility) && !body.HasBuff(Buffs.Immune))
		{
			if (Object.op_Implicit((Object)(object)Buffs.HiddenRejectAllDamage))
			{
				return body.HasBuff(Buffs.HiddenRejectAllDamage);
			}
			return false;
		}
		return true;
	}

	private static void UpdateBarInfosPostfix(HealthBar __instance)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)__instance.source) || !Object.op_Implicit((Object)(object)__instance.source.body) || bannedBodies.Contains(__instance.source.body.bodyIndex))
		{
			return;
		}
		Transform val = ((Component)__instance).transform.Find("Slash");
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		HGTextMeshProUGUI component = ((Component)val).GetComponent<HGTextMeshProUGUI>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			return;
		}
		if (((TMP_Text)component).text == currentLanguageToken)
		{
			if (IsImmune(__instance.source))
			{
				if (Object.op_Implicit((Object)(object)__instance.currentHealthText))
				{
					((TMP_Text)__instance.currentHealthText).text = "";
				}
				if (Object.op_Implicit((Object)(object)__instance.fullHealthText))
				{
					((TMP_Text)__instance.fullHealthText).text = "";
				}
				if (Object.op_Implicit((Object)(object)__instance.spriteAsNumberManager))
				{
					((Component)__instance.spriteAsNumberManager).gameObject.SetActive(false);
				}
				((Component)val).gameObject.SetActive(true);
				__instance.barInfoCollection.trailingOverHealthbarInfo.color = ImmuneColor;
				return;
			}
			((TMP_Text)component).text = "/";
			if (Object.op_Implicit((Object)(object)__instance.currentHealthText))
			{
				float num = (__instance.displayStringCurrentHealth = Mathf.Ceil(__instance.source.combinedHealth));
				((TMP_Text)__instance.currentHealthText).text = num.ToString();
			}
			if (Object.op_Implicit((Object)(object)__instance.fullHealthText))
			{
				float num2 = (__instance.displayStringFullHealth = Mathf.Ceil(__instance.source.fullHealth));
				((TMP_Text)__instance.fullHealthText).text = num2.ToString();
			}
			if (Object.op_Implicit((Object)(object)__instance.spriteAsNumberManager))
			{
				((Component)__instance.spriteAsNumberManager).gameObject.SetActive(true);
			}
			((Component)val).gameObject.SetActive(false);
		}
		else if (IsImmune(__instance._source))
		{
			__instance.barInfoCollection.trailingOverHealthbarInfo.color = ImmuneColor;
			((TMP_Text)component).text = currentLanguageToken;
			if (Object.op_Implicit((Object)(object)__instance.currentHealthText))
			{
				((TMP_Text)__instance.currentHealthText).text = "";
			}
			if (Object.op_Implicit((Object)(object)__instance.fullHealthText))
			{
				((TMP_Text)__instance.fullHealthText).text = "";
			}
			if (__instance.scaleHealthbarWidth)
			{
				float num3 = Util.Remap(__instance.maxHealthbarWidth, __instance.minHealthbarHealth, __instance.maxHealthbarHealth, __instance.minHealthbarWidth, __instance.maxHealthbarWidth);
				__instance.rectTransform.sizeDelta = new Vector2(num3, __instance.rectTransform.sizeDelta.y);
			}
		}
	}
}
public static class ModSupport_RiskOfOptions
{
	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	public static void Initialize()
	{
		//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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		ModSettingsManager.SetModDescription("Makes the healthbar look like how it does in ROR1 when immune", "com.DestroyedClone.HealthbarImmune", "Healthbar Immune");
		ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(HealthbarImmunePlugin.cfgCharacterBlacklist, new InputFieldConfig
		{
			submitOn = (SubmitEnum)6
		}));
		HealthbarImmunePlugin.cfgCharacterBlacklist.SettingChanged += CfgCharacterBlacklist_SettingChanged;
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private static void CfgCharacterBlacklist_SettingChanged(object sender, EventArgs e)
	{
		string value = HealthbarImmunePlugin.cfgCharacterBlacklist.Value.Trim();
		HealthbarImmunePlugin.cfgCharacterBlacklist.Value = value;
		HealthbarImmunePlugin.SetupDictionary();
	}
}

HiddenStageTime.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using RoR2;
using UnityEngine;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace HiddenStageTime
{
	[BepInPlugin("custom.HiddenStageTime", "HiddenStageTime", "1.0.0")]
	public class HiddenStageTimePlugin : BaseUnityPlugin
	{
		internal static ConfigEntry<string> Excluded;

		private static HashSet<string> excluded = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private void Awake()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			Excluded = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FrozenScenes", "bazaar,computationalexchange", "Comma-separated scene names where the run timer stays stopped. Every other hidden stage advances time.");
			string[] array = Excluded.Value.Split(new char[1] { ',' });
			foreach (string text in array)
			{
				string text2 = text.Trim();
				if (text2.Length > 0)
				{
					excluded.Add(text2);
				}
			}
			Harmony val = new Harmony("custom.HiddenStageTime");
			MethodInfo methodInfo = AccessTools.Method(typeof(Run), "ShouldUpdateRunStopwatch", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(HiddenStageTimePlugin), "Postfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void Postfix(Run __instance, ref bool __result)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Invalid comparison between Unknown and I4
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Invalid comparison between Unknown and I4
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Invalid comparison between Unknown and I4
			if (!__result && Object.op_Implicit((Object)(object)__instance) && !(__instance is InfiniteTowerRun))
			{
				SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
				if (Object.op_Implicit((Object)(object)mostRecentSceneDef) && ((int)mostRecentSceneDef.sceneType == 2 || (int)mostRecentSceneDef.sceneType == 5 || (int)mostRecentSceneDef.sceneType == 4) && !excluded.Contains(mostRecentSceneDef.cachedName))
				{
					__result = __instance.livingPlayerCount > 0;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

InstakillBossAttacks.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace InstakillBossAttacks
{
	[BepInPlugin("custom.InstakillBossAttacks", "InstakillBossAttacks", "1.5.4")]
	public class InstakillBossAttacksPlugin : BaseUnityPlugin
	{
		public const string GUID = "custom.InstakillBossAttacks";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> LaserGridEnabled;

		internal static ConfigEntry<bool> HarvesterEnabled;

		internal static ConfigEntry<bool> PlayersTeamOnly;

		internal static ConfigEntry<bool> MalachiteAlwaysPhase2;

		internal static ConfigEntry<bool> BypassDefenses;

		internal static ConfigEntry<bool> SolusOrbsEnabled;

		internal static ConfigEntry<bool> ProvLasersEnabled;

		internal static ConfigEntry<bool> MithrixWavesEnabled;

		internal static ConfigEntry<bool> GazeEnabled;

		internal static ConfigEntry<bool> Stage4BossEnabled;

		internal static ConfigEntry<string> SolusOrbNames;

		internal static ConfigEntry<string> MithrixWaveNames;

		internal static ConfigEntry<string> GazeStateKeywords;

		internal static ConfigEntry<string> MithrixPizzaNames;

		internal static ConfigEntry<string> MithrixPizzaExclude;

		internal static ConfigEntry<string> StormKeywords;

		internal static ConfigEntry<string> StormProjNames;

		internal static ConfigEntry<bool> StormEnabled;

		internal static ConfigEntry<bool> LogBossHits;

		internal static ConfigEntry<bool> BlueWallsEnabled;

		internal static ConfigEntry<bool> RedWallsEnabled;

		internal static ConfigEntry<bool> BeamEnabled;

		internal static ConfigEntry<string> BlueWallNames;

		internal static ConfigEntry<string> RedWallNames;

		private static string[] blueWallNames;

		private static string[] redWallNames;

		[ThreadStatic]
		private static int beamDepth;

		internal static ConfigEntry<float> StormGrace;

		internal static ConfigEntry<bool> MithrixPizzaEnabled;

		internal static ConfigEntry<bool> AurelioniteEnabled;

		internal static ConfigEntry<bool> AllyAurelioniteEnabled;

		private static readonly HashSet<BodyIndex> aurelioniteBodies = new HashSet<BodyIndex>();

		private static string[] solusOrbNames;

		private static string[] mithrixWaveNames;

		private static string[] gazeKeywords;

		private static string[] mithrixPizzaNames;

		private static string[] mithrixPizzaExclude;

		private static string[] stormKeywords;

		private static string[] stormProjNames;

		private static readonly HashSet<EntityStateMachine> stormEsms = new HashSet<EntityStateMachine>();

		private static float lastStormEnd = -999f;

		private static readonly HashSet<string> loggedHits = new HashSet<string>();

		[ThreadStatic]
		private static int laserGridDepth;

		[ThreadStatic]
		private static int provLaserDepth;

		[ThreadStatic]
		private static int gazeDepth;

		private static BodyIndex fsBoss = (BodyIndex)(-1);

		private static BodyIndex fsShard = (BodyIndex)(-1);

		private static BodyIndex fsBroken = (BodyIndex)(-1);

		internal static bool harvesterPhase2;

		private static BodyIndex reaperBody = (BodyIndex)(-1);

		private static BodyIndex reaperMalachite = (BodyIndex)(-1);

		private static BodyIndex reaperSoul = (BodyIndex)(-1);

		private Harmony harmony;

		private static readonly Dictionary<CharacterBody, int> curseSnap = new Dictionary<CharacterBody, int>();

		private void Awake()
		{
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Expected O, but got Unknown
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Expected O, but got Unknown
			//IL_0691: Expected O, but got Unknown
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c5: Expected O, but got Unknown
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Expected O, but got Unknown
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			LaserGridEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SolusWing", "LaserGridInstakill", true, "The Solus Wing fight laser grid kills instantly on contact.");
			HarvesterEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AnimaHarvester", "Phase2Instakill", false, "Every Anima Harvester attack during phase 2 kills instantly.");
			StormEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("AnimaHarvester", "LightningStormInstakill", true, "The Anima Harvester lightning attack that spawns AoE telegraphs around the arena (Bramble Storm) kills instantly, both phases.");
			StormKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("AnimaHarvester", "LightningStateKeywords", "BrambleStorm", "Comma-separated keywords; Anima Harvester states containing one of these count as the lightning attack.");
			StormProjNames = ((BaseUnityPlugin)this).Config.Bind<string>("AnimaHarvester", "LightningProjectileNames", "BrambleStormSpike", "Comma-separated projectile name prefixes fired by the lightning attack.");
			StormGrace = ((BaseUnityPlugin)this).Config.Bind<float>("AnimaHarvester", "LightningGraceSeconds", 4f, "Projectiles from the lightning attack still kill for this many seconds after the attack state ends.");
			LogBossHits = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "LogBossHits", true, "Log the projectile and attacker state names (once each) when the Anima Harvester, Solus Heart or Solus Wing hits a player. Use to identify attack names.");
			MalachiteAlwaysPhase2 = ((BaseUnityPlugin)this).Config.Bind<bool>("AnimaHarvester", "MalachiteFormCountsAsPhase2", true, "Attacks from the malachite Anima Harvester body always count as phase 2, even if the phase change was not detected.");
			Stage4BossEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage4", "TeleporterBossInstakill", true, "Every attack from the stage 4 teleporter boss(es) kills instantly (also stages 9, 14, ... on loops).");
			PlayersTeamOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayerTeamOnly", true, "Only the player team (survivors, drones, allies) is instakilled.");
			BypassDefenses = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BypassDefensiveItems", true, "Instakill ignores armor, block chance (Tougher Times, Safer Spaces), shields, barrier and vanilla one-shot protection. Revive items still work. OneShotRework protection still triggers.");
			BlueWallsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SolusWing", "BlueWallRingInstakill", true, "The ring of blue walls (Grav Pulse projectiles) kills instantly. The central pulse blast does not.");
			BlueWallNames = ((BaseUnityPlugin)this).Config.Bind<string>("SolusWing", "BlueWallProjectileNames", "SolusWingGravPulseProjectileThin,SolusWingGravPulseProjectile(", "Comma-separated projectile name prefixes counted as the blue walls.");
			RedWallsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SolusWing", "RedWallInstakill", true, "The uneven red walls (glitched Grav Pulse projectiles) kill instantly. The central pulse blast does not.");
			RedWallNames = ((BaseUnityPlugin)this).Config.Bind<string>("SolusWing", "RedWallProjectileNames", "SolusWingGravPulseProjectileGlitched", "Comma-separated projectile name prefixes counted as the red walls.");
			BeamEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SolusWing", "GiantLaserInstakill", true, "The giant overheat laser (normal and glitched) kills instantly.");
			SolusOrbsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("SolusHeart", "RedOrbInstakill", false, "Solus Heart red orb (DDOS) projectiles kill instantly.");
			SolusOrbNames = ((BaseUnityPlugin)this).Config.Bind<string>("SolusHeart", "RedOrbProjectileNames", "TeleportComboLaserProjectile", "Comma-separated projectile name prefixes counted as the red orbs (fired while dashing around the arena). The blue orb cluster is SolusHeart_DDOSProjectile.");
			ProvLasersEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("EchoOfProvidence", "VerticalLaserInstakill", true, "The thin vertical lasers in the Echo of Providence fight (every phase that uses them) kill instantly.");
			MithrixWavesEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Mithrix", "ShockwaveInstakill", false, "Grounded shockwaves from Mithrix and Umbral Mithrix (hammer slams, leap landings, every phase) kill instantly.");
			MithrixWaveNames = ((BaseUnityPlugin)this).Config.Bind<string>("Mithrix", "ShockwaveProjectileNames", "BrotherSunderWave,UmbralLeapWave", "Comma-separated projectile name prefixes counted as grounded shockwaves.");
			MithrixPizzaEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Mithrix", "PizzaLaserInstakill", true, "Mithrix's rotating pizza laser lines (ultimate) kill instantly, every phase, including Umbral Mithrix versions.");
			MithrixPizzaNames = ((BaseUnityPlugin)this).Config.Bind<string>("Mithrix", "PizzaLaserProjectileNames", "BrotherUltLineProjectile,UmbralUltLine,P4UltLine,StaticUltLine", "Comma-separated projectile name prefixes counted as pizza laser lines.");
			MithrixPizzaExclude = ((BaseUnityPlugin)this).Config.Bind<string>("Mithrix", "PizzaLaserExcludedNames", "BrotherUltLineProjectileStatic", "Comma-separated projectile name prefixes never counted as pizza lasers (default: the random lines during the arena detonation after Mithrix is defeated).");
			GazeEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("FalseSon", "StatueLaserInstakill", true, "The Lunar Gaze laser (fired from the Providence statue) in the False Son fight kills instantly, including the Stormbound False Son version. Hits that deal no damage (e.g. before lock-on) stay harmless.");
			GazeStateKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("FalseSon", "LaserStateKeywords", "LunarGaze", "Comma-separated keywords; a damaging direct hit from the False Son boss while any of its states contains one of these counts as the laser.");
			AurelioniteEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Aurelionite", "AllAttacksInstakill", true, "Every attack from an Aurelionite fighting against you kills instantly: the Gilded Coast boss and the one that joins False Son in phase 3, including StormboundFalseSon's versions of her attacks (laser, crown, rocks, beams). An Aurelionite on your side never instakills anything.");
			AllyAurelioniteEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Aurelionite", "AllyAttacksKillEnemies", true, "Every attack from an Aurelionite on your side (summoned by the Halcyon Seed) instantly kills any enemy it hits, bosses included. Enemies that are currently immune (e.g. during a scripted phase) stay immune.");
			solusOrbNames = Split(SolusOrbNames.Value);
			mithrixWaveNames = Split(MithrixWaveNames.Value);
			gazeKeywords = Split(GazeStateKeywords.Value);
			mithrixPizzaNames = Split(MithrixPizzaNames.Value);
			mithrixPizzaExclude = Split(MithrixPizzaExclude.Value);
			stormKeywords = Split(StormKeywords.Value);
			blueWallNames = Split(BlueWallNames.Value);
			redWallNames = Split(RedWallNames.Value);
			stormProjNames = Split(StormProjNames.Value);
			harmony = new Harmony("custom.InstakillBossAttacks");
			PatchDepth("RoR2.Projectile.ProvidenceLaserController", new string[2] { "FireLaser", "FixedUpdate" }, "ProvEnter", "ProvExit");
			PatchDepth("EntityStates.PrimeMeridian.LunarGazeLaserFire", new string[2] { "FixedUpdate", "OnEnter" }, "GazeEnter", "GazeExit");
			PatchDepth("EntityStates.PrimeMeridian.LunarGazeLaserFirePlus", new string[2] { "FixedUpdate", "OnEnter" }, "GazeEnter", "GazeExit");
			PatchDepth("EntityStates.SolusWing.SolusWingOverheatBeam", new string[1] { "FireBeamBulletAuthority" }, "BeamEnter", "BeamExit");
			Type type = AccessTools.TypeByName("EntityStates.Missions.SolutionalHaunt.SolusWingBossEncounter.LaserGrid.FireLaserGridState");
			MethodInfo methodInfo2;
			HarmonyMethod val2;
			if (type != null)
			{
				string[] array = new string[2] { "FireLaser", "FixedUpdate" };
				foreach (string text in array)
				{
					MethodInfo methodInfo = AccessTools.Method(type, text, (Type[])null, (Type[])null);
					if (!(methodInfo == null))
					{
						try
						{
							Harmony obj = harmony;
							methodInfo2 = methodInfo;
							HarmonyMethod val = new HarmonyMethod(typeof(InstakillBossAttacksPlugin), "GridEnter", (Type[])null);
							val2 = new HarmonyMethod(typeof(InstakillBossAttacksPlugin), "GridExit", (Type[])null);
							obj.Patch((MethodBase)methodInfo2, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null);
						}
						catch (Exception ex)
						{
							Log.LogError((object)("Patch " + text + ": " + ex));
						}
					}
				}
			}
			else
			{
				Log.LogWarning((object)"FireLaserGridState not found.");
			}
			MethodInfo methodInfo3 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(typeof(InstakillBossAttacksPlugin), "TakeDamagePrefix", (Type[])null), new HarmonyMethod(typeof(InstakillBossAttacksPlugin), "CursePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Harmony obj2 = harmony;
			methodInfo2 = AccessTools.Method(typeof(EntityStateMachine), "SetState", (Type[])null, (Type[])null);
			val2 = new HarmonyMethod(typeof(InstakillBossAttacksPlugin), "SetStatePostfix", (Type[])null);
			obj2.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Stage.onStageStartGlobal += delegate
			{
				harvesterPhase2 = false;
				stormEsms.Clear();
				lastStormEnd = -999f;
			};
			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_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_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)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: 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_0055: Unknown result type (might be due to invalid IL or missing references)
				reaperBody = BodyCatalog.FindBodyIndex("ReaperBossBody");
				reaperMalachite = BodyCatalog.FindBodyIndex("ReaperBossMalachiteBody");
				reaperSoul = BodyCatalog.FindBodyIndex("ReaperBossSoulBody");
				fsBoss = BodyCatalog.FindBodyIndex("FalseSonBossBody");
				fsShard = BodyCatalog.FindBodyIndex("FalseSonBossBodyLunarShard");
				fsBroken = BodyCatalog.FindBodyIndex("FalseSonBossBodyBrokenLunarShard");
				aurelioniteBodies.Clear();
				for (int j = 0; j < BodyCatalog.bodyCount; j++)
				{
					string bodyName = BodyCatalog.GetBodyName((BodyIndex)j);
					if (bodyName != null && bodyName.IndexOf("TitanGold", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						aurelioniteBodies.Add((BodyIndex)j);
					}
				}
				Log.LogInfo((object)("Aurelionite bodies: " + aurelioniteBodies.Count + "."));
			});
		}

		private static string[] Split(string v)
		{
			if (string.IsNullOrEmpty(v))
			{
				return new string[0];
			}
			return Array.FindAll(Array.ConvertAll(v.Split(new char[1] { ',' }), (string x) => x.Trim()), (string x) => x.Length > 0);
		}

		private void PatchDepth(string typeName, string[] methods, string pre, string fin)
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Expected O, but got Unknown
			Type type = AccessTools.TypeByName(typeName);
			if (type == null)
			{
				Log.LogWarning((object)(typeName + " not found."));
				return;
			}
			foreach (string text in methods)
			{
				MethodInfo methodInfo = AccessTools.DeclaredMethod(type, text, (Type[])null, (Type[])null);
				if (!(methodInfo == null))
				{
					try
					{
						Harmony obj = harmony;
						MethodInfo methodInfo2 = methodInfo;
						HarmonyMethod val = new HarmonyMethod(typeof(InstakillBossAttacksPlugin), pre, (Type[])null);
						HarmonyMethod val2 = new HarmonyMethod(typeof(InstakillBossAttacksPlugin), fin, (Type[])null);
						obj.Patch((MethodBase)methodInfo2, val, (HarmonyMethod)null, (HarmonyMethod)null, val2, (HarmonyMethod)null);
					}
					catch (Exception ex)
					{
						Log.LogError((object)("Patch " + typeName + "." + text + ": " + ex));
					}
				}
			}
		}

		private static void BeamEnter()
		{
			beamDepth++;
		}

		private static Exception BeamExit(Exception __exception)
		{
			if (beamDepth > 0)
			{
				beamDepth--;
			}
			return __exception;
		}

		private static void ProvEnter()
		{
			provLaserDepth++;
		}

		private static Exception ProvExit(Exception __exception)
		{
			if (provLaserDepth > 0)
			{
				provLaserDepth--;
			}
			return __exception;
		}

		private static void GazeEnter()
		{
			gazeDepth++;
		}

		private static Exception GazeExit(Exception __exception)
		{
			if (gazeDepth > 0)
			{
				gazeDepth--;
			}
			return __exception;
		}

		private static bool NameMatches(GameObject go, string[] prefixes)
		{
			if (!Object.op_Implicit((Object)(object)go) || prefixes == null || prefixes.Length == 0)
			{
				return false;
			}
			string name = ((Object)go).name;
			foreach (string value in prefixes)
			{
				if (name.StartsWith(value, StringComparison.OrdinalIgnoreCase))
				{
					return true;
				}
			}
			return false;
		}

		private static bool FromHaunt(GameObject attacker)
		{
			if (!Object.op_Implicit((Object)(object)attacker))
			{
				return false;
			}
			return ((Object)attacker).name.IndexOf("BrotherHaunt", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private static bool IsFalseSonBoss(CharacterBody b)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0025: 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)
			if (!Object.op_Implicit((Object)(object)b))
			{
				return false;
			}
			BodyIndex bodyIndex = b.bodyIndex;
			if ((int)bodyIndex != -1)
			{
				if (bodyIndex != fsBoss && bodyIndex != fsShard)
				{
					return bodyIndex == fsBroken;
				}
				return true;
			}
			return false;
		}

		private static bool InGazeState(CharacterBody b)
		{
			if (gazeKeywords == null || gazeKeywords.Length == 0)
			{
				return false;
			}
			EntityStateMachine[] components = ((Component)b).GetComponents<EntityStateMachine>();
			foreach (EntityStateMachine val in components)
			{
				if (!Object.op_Implicit((Object)(object)val) || val.state == null)
				{
					continue;
				}
				string fullName = ((object)val.state).GetType().FullName;
				string[] array = gazeKeywords;
				foreach (string value in array)
				{
					if (fullName.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static void GridEnter()
		{
			laserGridDepth++;
		}

		private static Exception GridExit(Exception __exception)
		{
			if (laserGridDepth > 0)
			{
				laserGridDepth--;
			}
			return __exception;
		}

		private static bool HasKeyword(string n, string[] keys)
		{
			if (keys == null || string.IsNullOrEmpty(n))
			{
				return false;
			}
			foreach (string value in keys)
			{
				if (n.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private static void SetStatePostfix(EntityStateMachine __instance, EntityState newState)
		{
			if (newState == null)
			{
				return;
			}
			string fullName = ((object)newState).GetType().FullName;
			try
			{
				if (fullName.StartsWith("EntityStates.ChampRushReaper.", StringComparison.Ordinal) || (Object.op_Implicit((Object)(object)__instance) && IsReaper(((Component)__instance).GetComponent<CharacterBody>())))
				{
					if (HasKeyword(fullName, stormKeywords))
					{
						stormEsms.Add(__instance);
					}
					else if (stormEsms.Remove(__instance))
					{
						lastStormEnd = Time.time;
					}
				}
			}
			catch
			{
			}
			if (fullName == null)
			{
				return;
			}
			switch (fullName.Length)
			{
			case 54:
				switch (fullName[38])
				{
				default:
					return;
				case 'S':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperSpawnSecondPhase"))
					{
						return;
					}
					break;
				case 'F':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperFightSecondPhase"))
					{
						return;
					}
					break;
				case 's':
					if (!(fullName == "EntityStates.ChampRushReaper.PhaseTransitionSpawnState"))
					{
						return;
					}
					break;
				}
				goto IL_0160;
			case 43:
				switch (fullName[38])
				{
				default:
					return;
				case 'S':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperSpawn"))
					{
						return;
					}
					break;
				case 'F':
					if (!(fullName == "EntityStates.Missions.ChampRush.ReaperFight"))
					{
						return;
					}
					break;
				}
				break;
			case 61:
				if (!(fullName == "EntityStates.ChampRushReaper.ReaperSecondPhaseSpawnTransition"))
				{
					return;
				}
				goto IL_0160;
			case 46:
				if (!(fullName == "EntityStates.Missions.ChampRush.StartChampRush"))
				{
					return;
				}
				break;
			case 41:
				if (!(fullName == "EntityStates.Missions.ChampRush.Aftermath"))
				{
					return;
				}
				break;
			case 40:
				if (!(fullName == "EntityStates.Missions.ChampRush.Finished"))
				{
					return;
				}
				break;
			case 45:
				if (!(fullName == "EntityStates.Missions.ChampRush.FailChampRush"))
				{
					return;
				}
				break;
			default:
				return;
				IL_0160:
				harvesterPhase2 = true;
				return;
			}
			harvesterPhase2 = false;
		}

		private static void LogHit(CharacterBody atk, GameObject inf)
		{
			try
			{
				string text = string.Empty;
				EntityStateMachine[] components = ((Component)atk).GetComponents<EntityStateMachine>();
				foreach (EntityStateMachine val in components)
				{
					if (Object.op_Implicit((Object)(object)val) && val.state != null)
					{
						string text2 = text;
						text = text2 + val.customName + "=" + ((object)val.state).GetType().Name + " ";
					}
				}
				string item = ((Object)atk).name + "|" + ((!Object.op_Implicit((Object)(object)inf)) ? "null" : ((Object)inf).name) + "|" + text;
				if (loggedHits.Count <= 200 && loggedHits.Add(item))
				{
					Log.LogInfo((object)("[BossHit] attacker=" + ((Object)atk).name + " inflictor=" + ((!Object.op_Implicit((Object)(object)inf)) ? "null" : ((Object)inf).name) + " states: " + text));
				}
			}
			catch
			{
			}
		}

		private static bool IsAurelionite(CharacterBody b)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)b))
			{
				return false;
			}
			if ((int)b.bodyIndex != -1 && aurelioniteBodies.Contains(b.bodyIndex))
			{
				return true;
			}
			return ((Object)b).name.IndexOf("TitanGold", StringComparison.OrdinalIgnoreCase) >= 0;
		}

		private static bool IsReaper(CharacterBody b)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0025: 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)
			if (!Object.op_Implicit((Object)(object)b))
			{
				return false;
			}
			BodyIndex bodyIndex = b.bodyIndex;
			if ((int)bodyIndex != -1)
			{
				if (bodyIndex != reaperBody && bodyIndex != reaperMalachite)
				{
					return bodyIndex == reaperSoul;
				}
				return true;
			}
			return false;
		}

		private static void SnapCurse(CharacterBody b)
		{
			if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)Buffs.PermanentCurse) && !curseSnap.ContainsKey(b))
			{
				curseSnap[b] = b.GetBuffCount(Buffs.PermanentCurse);
			}
		}

		private static void RestoreCurse(HealthComponent hc)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CharacterBody val = ((!Object.op_Implicit((Object)(object)hc)) ? null : hc.body);
				if (Object.op_Implicit((Object)(object)val) && curseSnap.TryGetValue(val, out var value))
				{
					curseSnap.Remove(val);
					if (val.GetBuffCount(Buffs.PermanentCurse) > value)
					{
						val.SetBuffCount(Buffs.PermanentCurse.buffIndex, value);
					}
				}
			}
			catch
			{
			}
		}

		private static void CursePostfix(HealthComponent __instance)
		{
			RestoreCurse(__instance);
		}

		private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo)
		{
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Invalid comparison between Unknown and I4
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Invalid comparison between Unknown and I4
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)__instance) || damageInfo.rejected)
			{
				return;
			}
			try
			{
				CharacterBody body = __instance.body;
				if (AllyAurelioniteEnabled.Value && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.teamComponent) && (int)body.teamComponent.teamIndex != 1)
				{
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component) && (Object)(object)component != (Object)(object)body && Object.op_Implicit((Object)(object)component.teamComponent) && (int)component.teamComponent.teamIndex == 1 && IsAurelionite(component))
					{
						if (__instance.alive && !body.HasBuff(Buffs.HiddenInvincibility) && !body.HasBuff(Buffs.Immune))
						{
							damageInfo.rejected = true;
							__instance.Suicide(damageInfo.attacker, damageInfo.inflictor, damageInfo.damageType);
						}
						return;
					}
				}
				if (PlayersTeamOnly.Value && (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent) || (int)body.teamComponent.teamIndex != 1))
				{
					return;
				}
				bool flag = false;
				if (LaserGridEnabled.Value && laserGridDepth > 0)
				{
					flag = true;
				}
				if (!flag && ProvLasersEnabled.Value && provLaserDepth > 0)
				{
					flag = true;
				}
				if (!flag && BeamEnabled.Value && beamDepth > 0 && damageInfo.damage > 0f)
				{
					flag = true;
				}
				GameObject inflictor = damageInfo.inflictor;
				if (!flag && Object.op_Implicit((Object)(object)inflictor))
				{
					if (SolusOrbsEnabled.Value && NameMatches(inflictor, solusOrbNames))
					{
						flag = true;
					}
					else if (RedWallsEnabled.Value && NameMatches(inflictor, redWallNames))
					{
						flag = true;
					}
					else if (BlueWallsEnabled.Value && NameMatches(inflictor, blueWallNames) && !NameMatches(inflictor, redWallNames))
					{
						flag = true;
					}
					else if (MithrixWavesEnabled.Value && NameMatches(inflictor, mithrixWaveNames))
					{
						flag = true;
					}
					else if (MithrixPizzaEnabled.Value && NameMatches(inflictor, mithrixPizzaNames) && !NameMatches(inflictor, mithrixPizzaExclude) && !FromHaunt(damageInfo.attacker))
					{
						flag = true;
					}
				}
				if (!flag && GazeEnabled.Value && damageInfo.damage > 0f)
				{
					if (gazeDepth > 0)
					{
						flag = true;
					}
					else if (Object.op_Implicit((Object)(object)damageInfo.attacker))
					{
						CharacterBody component2 = damageInfo.attacker.GetComponent<CharacterBody>();
						if (IsFalseSonBoss(component2) && (!Object.op_Implicit((Object)(object)inflictor) || (Object)(object)inflictor == (Object)(object)damageInfo.attacker) && InGazeState(component2))
						{
							flag = true;
						}
					}
				}
				CharacterBody val = ((!Object.op_Implicit((Object)(object)damageInfo.attacker)) ? null : damageInfo.attacker.GetComponent<CharacterBody>());
				if (LogBossHits.Value && Object.op_Implicit((Object)(object)val) && (IsReaper(val) || ((Object)val).name.StartsWith("SolusHeart", StringComparison.OrdinalIgnoreCase) || ((Object)val).name.StartsWith("SolusWing", StringComparison.OrdinalIgnoreCase)))
				{
					LogHit(val, inflictor);
				}
				if (!flag && StormEnabled.Value && IsReaper(val) && (Object)(object)val != (Object)(object)body)
				{
					bool flag2 = false;
					stormEsms.RemoveWhere((EntityStateMachine e) => !Object.op_Implicit((Object)(object)e));
					foreach (EntityStateMachine stormEsm in stormEsms)
					{
						if ((Object)(object)((Component)stormEsm).gameObject == (Object)(object)((Component)val).gameObject)
						{
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						EntityStateMachine[] components = ((Component)val).GetComponents<EntityStateMachine>();
						foreach (EntityStateMachine val2 in components)
						{
							if (Object.op_Implicit((Object)(object)val2) && val2.state != null && HasKeyword(((object)val2.state).GetType().FullName, stormKeywords))
							{
								flag2 = true;
								break;
							}
						}
					}
					bool flag3 = Object.op_Implicit((Object)(object)inflictor) && (Object)(object)inflictor != (Object)(object)damageInfo.attacker && NameMatches(inflictor, stormProjNames);
					if (flag2 && (flag3 || !Object.op_Implicit((Object)(object)inflictor) || (Object)(object)inflictor == (Object)(object)damageInfo.attacker))
					{
						flag = true;
					}
					else if (flag3 && Time.time - lastStormEnd <= StormGrace.Value)
					{
						flag = true;
					}
				}
				if (!flag && HarvesterEnabled.Value && Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					CharacterBody val3 = val;
					if (IsReaper(val3) && (Object)(object)val3 != (Object)(object)body && (harvesterPhase2 || (MalachiteAlwaysPhase2.Value && val3.bodyIndex == reaperMalachite)))
					{
						flag = true;
					}
				}
				if (!flag && Stage4BossEnabled.Value && Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)Run.instance) && Run.instance.stageClearCount % 5 == 3)
				{
					CharacterBody component3 = damageInfo.attacker.GetComponent<CharacterBody>();
					TeleporterInteraction instance = TeleporterInteraction.instance;
					if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.master) && Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.bossGroup) && Object.op_Implicit((Object)(object)instance.bossGroup.combatSquad))
					{
						try
						{
							if (instance.bossGroup.combatSquad.readOnlyMembersList.Contains(component3.master))
							{
								flag = true;
							}
						}
						catch
						{
						}
					}
				}
				if (!flag && AurelioniteEnabled.Value && Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)body && IsAurelionite(val))
				{
					TeamIndex val4 = (TeamIndex)((!Object.op_Implicit((Object)(object)val.teamComponent)) ? (-1) : ((int)val.teamComponent.teamIndex));
					TeamIndex val5 = (TeamIndex)((!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent)) ? (-1) : ((int)body.teamComponent.teamIndex));
					if ((int)val4 != 1 && val4 != val5)
					{
						flag = true;
					}
				}
				if (!flag || (Object.op_Implicit((Object)(object)body) && (Object)(object)damageInfo.attacker == (Object)(object)((Component)body).gameObject))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)body) && (body.HasBuff(Buffs.HiddenInvincibility) || body.HasBuff(Buffs.Immune)))
				{
					damageInfo.rejected = true;
					return;
				}
				SnapCurse(__instance.body);
				damageInfo.damage = Mathf.Max(damageInfo.damage, __instance.fullCombinedHealth * 10f + 1000000f);
				if (BypassDefenses.Value)
				{
					ref DamageType damageType = ref damageInfo.damageType.damageType;
					damageType = (DamageType)((uint)damageType | 0x40042u);
					ref DamageType damageType2 = ref damageInfo.damageType.damageType;
					damageType2 = (DamageType)((uint)damageType2 & 0xFFFEFFFFu);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("TakeDamagePrefix: " + ex.Message));
			}
		}
	}
}

MiscellaneousBuffs.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Acolyte.Backpack;
using EntityStates.Acolyte.Weapon;
using EntityStates.CaptainDefenseMatrixItem;
using EntityStates.Chef;
using EntityStates.Drifter;
using EntityStates.FalseSon;
using EntityStates.LilReaper.Weapon;
using EntityStates.Railgunner.Weapon;
using EntityStates.Seeker;
using EntityStates.Toolbot;
using HG;
using HarmonyLib;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace MiscellaneousBuffs
{
	[BepInPlugin("custom.MiscellaneousBuffs", "MiscellaneousBuffs", "1.5.3")]
	public class MiscellaneousBuffsPlugin : BaseUnityPlugin
	{
		private class Boosted : MonoBehaviour
		{
		}

		private class PowerModeTracker : MonoBehaviour
		{
			public int activeStates;
		}

		private class PolarFieldState : MonoBehaviour
		{
			public bool resolved;

			public bool isPolarField;

			public bool logged;
		}

		private class ChefFoodCount : MonoBehaviour
		{
			public int count;
		}

		private class ContentProvider : IContentPackProvider
		{
			private readonly ContentPack pack = new ContentPack();

			public string identifier => "custom.MiscellaneousBuffs";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.MiscellaneousBuffs", null);
				}
				catch
				{
				}
				if (Object.op_Implicit((Object)(object)chefFeastBuff))
				{
					pack.buffDefs.Add((BuffDef[])(object)new BuffDef[1] { chefFeastBuff });
				}
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(pack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		private class ChefPeriodicFood : MonoBehaviour
		{
			private CharacterBody body;

			private float timer;

			private void Awake()
			{
				body = ((Component)this).GetComponent<CharacterBody>();
			}

			private void FixedUpdate()
			{
				if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive && !(chefPeriodicFoodInterval.Value <= 0f))
				{
					timer += Time.fixedDeltaTime;
					if (!(timer < chefPeriodicFoodInterval.Value))
					{
						timer = 0f;
						SpawnChefFood(body, Mathf.Max(1, chefPeriodicFoodIngredients.Value));
					}
				}
			}
		}

		private class AirborneMage : MonoBehaviour
		{
			private CharacterBody body;

			private bool wasAirborne;

			private void Awake()
			{
				body = ((Component)this).GetComponent<CharacterBody>();
			}

			private void FixedUpdate()
			{
				if (!Object.op_Implicit((Object)(object)body))
				{
					return;
				}
				bool flag = MageAirborne(body);
				bool flag2 = flag && !wasAirborne;
				if (flag != wasAirborne)
				{
					wasAirborne = flag;
					body.MarkAllStatsDirty();
				}
				if (!flag || !NetworkServer.active || !mageAirImmunity.Value || (!flag2 && !HasDebuffOrDot(body)))
				{
					return;
				}
				try
				{
					CleanseSystem.CleanseBodyServer(body, true, false, false, true, flag2, false);
				}
				catch (Exception)
				{
				}
			}
		}

		private class EchoInvincible : MonoBehaviour
		{
			public int activeStates;
		}

		private class StateInvincible : MonoBehaviour
		{
			public readonly HashSet<EntityState> states = new HashSet<EntityState>();

			public bool added;

			public float releaseAt = -1f;

			private void FixedUpdate()
			{
				if (releaseAt >= 0f && states.Count == 0 && Time.fixedTime >= releaseAt)
				{
					releaseAt = -1f;
					Release();
				}
			}

			public void Release()
			{
				if (added)
				{
					added = false;
					CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component) && component.HasBuff(Buffs.HiddenRejectAllDamage))
					{
						component.RemoveBuff(Buffs.HiddenRejectAllDamage);
					}
				}
			}
		}

		private class PalmClientScaled : MonoBehaviour
		{
		}

		private class UnseenHandPending
		{
			public float timer;

			public Vector3 position;

			public bool fired;
		}

		private class TornadoInvincible : MonoBehaviour
		{
			public int count;

			public readonly HashSet<EntityState> states = new HashSet<EntityState>();
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__94_0;

			public static Func<string, string> <>9__172_0;

			public static MatchEvaluator <>9__172_2;

			public static Func<string, string> <>9__172_1;

			internal void <Awake>b__94_0(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new ContentProvider());
			}

			internal string <ApplyDescriptions>b__172_0(string t)
			{
				return Regex.Replace(t, "[0-9]+(\\.[0-9]+)?% HP", Num(harvestFruitHealing.Value) + "% HP");
			}

			internal string <ApplyDescriptions>b__172_1(string t)
			{
				if (laserDurationMult.Value > 0f && laserDurationMult.Value != 1f)
				{
					t = Regex.Replace(t, "for <style=cIsUtility>([0-9]+(\\.[0-9]+)?)s</style>", (Match m) => "for <style=cIsUtility>" + Num(float.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture) * laserDurationMult.Value) + "s</style>");
				}
				if (laserInvincible.Value)
				{
					t += " <style=cIsUtility>Invincible</style> while firing.";
				}
				return t;
			}

			internal string <ApplyDescriptions>b__172_2(Match m)
			{
				return "for <style=cIsUtility>" + Num(float.Parse(m.Groups[1].Value, CultureInfo.InvariantCulture) * laserDurationMult.Value) + "s</style>";
			}
		}

		internal static ManualLogSource Log;

		private static ConfigEntry<float> chefFoodHealing;

		private static ConfigEntry<float> chefFoodDamageBoost;

		private static ConfigEntry<float> chefFoodBoostSeconds;

		private static ConfigEntry<float> chefPeriodicFoodInterval;

		private static ConfigEntry<int> chefPeriodicFoodIngredients;

		internal static BuffDef chefFeastBuff;

		private static BodyIndex chefIndex = (BodyIndex)(-1);

		private static ConfigEntry<float> toolbotHealthMultiplier;

		private static ConfigEntry<float> acolytePrimaryDamage;

		private static ConfigEntry<float> acolyteQuickstrikeDamage;

		private const float VanillaAcolytePrimaryDamage = 150f;

		private const float VanillaAcolyteQuickstrikeDamage = 200f;

		private static ConfigEntry<float> mageAirDamage;

		private static ConfigEntry<float> mageAirArmor;

		private static ConfigEntry<bool> mageAirImmunity;

		private static BodyIndex mageIndex = (BodyIndex)(-1);

		private static string magePassiveToken;

		private static string chefPassiveToken;

		private static string acolytePrimaryToken;

		private static string[] acolytePrimaryKeywords = new string[0];

		private static ConfigEntry<float> blinkCooldown;

		private static ConfigEntry<float> powerModeArmor;

		private static ConfigEntry<float> plasmaBoltRadius;

		private static ConfigEntry<bool> polarFieldDeletes;

		private static ConfigEntry<float> polarFieldCooldown;

		private static ConfigEntry<float> polarFieldRadius;

		private static ConfigEntry<bool> polarFieldEffect;

		private static ConfigEntry<float> stepCooldown;

		private static ConfigEntry<float> palmSize;

		private static ConfigEntry<float> palmDamage;

		private static ConfigEntry<float> palmHealing;

		private static ConfigEntry<float> palmSpeed;

		private static ConfigEntry<float> palmRange;

		private static ConfigEntry<float> soulStormDps;

		private static ConfigEntry<float> empoweredSoulStormDps;

		private static ConfigEntry<bool> animaEchoInvincible;

		private static ConfigEntry<int> sacrificeConvictions;

		private static ConfigEntry<bool> sacrificeKillBonus;

		private static ConfigEntry<float> sacrificeCooldown;

		private static ConfigEntry<float> animaEchoDuration;

		private static ConfigEntry<bool> unseenHandTeleport;

		private static ConfigEntry<float> unseenHandFireDelay;

		private static ConfigEntry<float> bladeSlingCooldown;

		private static ConfigEntry<float> javelinCooldown;

		private static ConfigEntry<float> quickstrikeCooldown;

		private static ConfigEntry<float> favorArmor;

		private const float VanillaFavorArmor = 20f;

		private static ConfigEntry<float> carbonizerCooldown;

		private static ConfigEntry<float> tornadoCooldown;

		private static ConfigEntry<bool> tornadoInvincible;

		private static ConfigEntry<float> tornadoDamage;

		private static ConfigEntry<float> firewallCooldown;

		private static ConfigEntry<float> ejectionCoreCooldown;

		private static ConfigEntry<float> marksmanDamage;

		private static bool marksmanLogged;

		private static ConfigEntry<float> unseenHandCooldown;

		private static ConfigEntry<float> unseenHandDamage;

		private static ConfigEntry<float> moddedDamageMultiplier;

		private static bool exposeLogged;

		private static ConfigEntry<float> exposeDamage;

		private static ConfigEntry<bool> mercShields;

		private static bool exposeHooked;

		private const float VanillaExposeDamage = 350f;

		private static ConfigEntry<float> chefUtilityCooldownMult;

		private static ConfigEntry<float> glazeCooldown;

		private static ConfigEntry<bool> glazeInvincible;

		private static ConfigEntry<float> glazeInvincibleExtraSeconds;

		private static ConfigEntry<float> harvestFruitHealing;

		private static ConfigEntry<float> soulSpiralInvincibleSeconds;

		private static ConfigEntry<int> lunarRuinMaxStacks;

		private static ConfigEntry<float> lunarStakeLightningDamage;

		private static ConfigEntry<bool> laserInvincible;

		private static ConfigEntry<float> laserDurationMult;

		private static ConfigEntry<float> laserCooldown;

		private const float VanillaStakeLightningDamage = 150f;

		private static BodyIndex falseSonIndex = (BodyIndex)(-1);

		private static ConfigEntry<bool> updateDescriptions;

		private const float VanillaPowerModeArmor = 100f;

		private const float VanillaSoulStormDps = 300f;

		private const float VanillaEmpoweredSoulStormDps = 1200f;

		private static BodyIndex toolbotIndex = (BodyIndex)(-1);

		private static BodyIndex railgunnerIndex = (BodyIndex)(-1);

		private static bool loadChangesApplied;

		private static readonly Dictionary<string, string> originalText = new Dictionary<string, string>();

		private static FieldRef<PalmBlastProjectileController, float> palmHealRadius;

		private static FieldRef<PalmBlastProjectileController, float> palmHealingToApply;

		private static FieldRef<PalmBlastProjectileController, ProjectileOverlapAttack> palmOverlap;

		private static FieldRef<PalmBlastProjectileController, float> palmBaseSize;

		private static FieldRef<PalmBlastProjectileController, float> palmSizePerStack;

		private static FieldRef<PalmBlastProjectileController, float> palmFinalSpeed;

		private static FieldRef<PalmBlastProjectileController, ProjectileSimple> palmSimple;

		private static bool palmTravelLogged;

		private static FieldRef<UnseenHand, bool> uhReleased;

		private static FieldRef<UnseenHand, bool> uhGood;

		private static FieldRef<UnseenHand, GameObject> uhIndicator;

		private static readonly ConditionalWeakTable<UnseenHand, UnseenHandPending> uhPending = new ConditionalWeakTable<UnseenHand, UnseenHandPending>();

		private static readonly ConditionalWeakTable<EntityState, object> tornadoBoosted = new ConditionalWeakTable<EntityState, object>();

		private static readonly Dictionary<string, string> writtenText = new Dictionary<string, string>();

		private static bool r2Looked;

		private static MethodInfo r2AddOverlay;

		private static readonly Dictionary<string, object> r2Overlays = new Dictionary<string, object>();

		private void Awake()
		{
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Expected O, but got Unknown
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0925: Expected O, but got Unknown
			//IL_0e6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e7b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			updateDescriptions = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UpdateDescriptions", true, "Rewrite the in-game skill descriptions to match the values below (also shown by LookingGlass).");
			chefFoodHealing = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "FoodHealingMultiplier", 5f, "Multiplier for the healing of CHEF's passive food drops. 1 = vanilla.");
			chefFoodDamageBoost = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "FoodDamageBoostPercent", 100f, "Eating CHEF's food also gives this much extra damage (100 = double damage). 0 = off.");
			chefFoodBoostSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "FoodBoostSecondsPerIngredient", 5f, "Seconds of the food damage boost per cooking effect the enemy had (each different CHEF skill used on it), so a 2-skill meal lasts 10s.");
			chefPeriodicFoodInterval = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "PeriodicFoodInterval", 20f, "CHEF drops a meal near himself every this many seconds. 0 = never.");
			chefPeriodicFoodIngredients = ((BaseUnityPlugin)this).Config.Bind<int>("CHEF", "PeriodicFoodIngredients", 2, "The periodic meal counts as if this many different CHEF skills were used (healing and boost length).");
			chefUtilityCooldownMult = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "UtilityCooldownMultiplier", 0.5f, "Multiplier for the cooldowns of both CHEF utility skills (Roll and Oil Spill). 1 = vanilla.");
			glazeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "GlazeCooldown", 4f, "Glaze (special) cooldown in seconds. 0 = unchanged.");
			glazeInvincible = ((BaseUnityPlugin)this).Config.Bind<bool>("CHEF", "GlazeInvincible", true, "CHEF takes no damage of any kind while firing Glaze.");
			glazeInvincibleExtraSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("CHEF", "GlazeInvincibleExtraSeconds", 1f, "With GlazeInvincible on, CHEF stays invincible for this many seconds after he stops firing Glaze. 0 = ends when firing ends.");
			harvestFruitHealing = ((BaseUnityPlugin)this).Config.Bind<float>("REX", "HarvestFruitHealing", 200f, "Healing from each fruit dropped by DIRECTIVE: Harvest, in % of max HP. Vanilla is 25. Overrides other mods' fruit healing (e.g. FruitySurvivorTweaks). 0 = unchanged.");
			soulSpiralInvincibleSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "SoulSpiralInvincibleSeconds", 2f, "Seeker takes no damage of any kind for this many seconds when she uses Soul Spiral. 0 = off.");
			lunarRuinMaxStacks = ((BaseUnityPlugin)this).Config.Bind<int>("False Son", "LunarRuinMaxStacks", 5, "False Son can't take an enemy past this many Lunar Ruin stacks. Hitting an enemy that already has this many refreshes its stacks instead of adding more. 0 = no cap (vanilla).");
			lunarStakeLightningDamage = ((BaseUnityPlugin)this).Config.Bind<float>("False Son", "LunarStakesLightningDamage", 900f, "Damage of the lightning strikes from Lunar Stakes, in %. Vanilla is 150.");
			laserInvincible = ((BaseUnityPlugin)this).Config.Bind<bool>("False Son", "LaserOfTheFatherInvincible", true, "False Son takes no damage of any kind while firing Laser of the Father.");
			laserDurationMult = ((BaseUnityPlugin)this).Config.Bind<float>("False Son", "LaserOfTheFatherDurationMultiplier", 1.5f, "Laser of the Father fires this many times longer (Growth bonus included). 1 = vanilla.");
			laserCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("False Son", "LaserOfTheFatherCooldown", 15f, "Laser of the Father cooldown in seconds. Vanilla is 15. 0 = unchanged.");
			toolbotHealthMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("MUL-T", "MaxHealthMultiplier", 1.5f, "Multiplier for MUL-T's base max health and max health gained per level. 1 = vanilla.");
			acolytePrimaryDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "PrimaryDamage", 300f, "Blade Slice (primary) combo hit damage, in %. Vanilla is 150 (the finisher scales the same way).");
			acolyteQuickstrikeDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "QuickstrikeDamage", 390f, "Quickstrike (sprinting / jumping Blade Slice) hit damage, in %. Vanilla is 200.");
			mageAirDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Artificer", "AirborneDamageMultiplier", 2f, "Damage multiplier while Artificer is in the air. 1 = off.");
			mageAirArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Artificer", "AirborneArmor", 100f, "Armor gained while Artificer is in the air. 0 = off.");
			mageAirImmunity = ((BaseUnityPlugin)this).Config.Bind<bool>("Artificer", "AirborneImmunity", true, "While in the air, Artificer ignores all knockback (Ion Surge still works) and stuns, can't receive debuffs or damage-over-time, and any she has are removed immediately. Item cooldowns are kept.");
			blinkCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Huntress", "BlinkCooldown", 1f, "Blink cooldown in seconds. Vanilla is 7.");
			powerModeArmor = ((BaseUnityPlugin)this).Config.Bind<float>("MUL-T", "PowerModeArmor", 200f, "Armor gained while in Power Mode. Vanilla is 100.");
			plasmaBoltRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Artificer", "PlasmaBoltBlastRadius", 18f, "Plasma Bolt explosion radius in meters. Vanilla is 6.");
			polarFieldDeletes = ((BaseUnityPlugin)this).Config.Bind<bool>("Railgunner", "PolarFieldDeletesProjectiles", true, "Polar Field Device deletes enemy projectiles inside it for its whole duration, instead of slowing them. It still slows enemies.");
			polarFieldCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Railgunner", "PolarFieldCooldown", 6f, "Polar Field Device cooldown in seconds. Vanilla is 12.");
			polarFieldRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Railgunner", "PolarFieldRadiusMultiplier", 2f, "Polar Field Device radius multiplier (slow area, projectile deletion area and its visual ring). 1 = vanilla.");
			polarFieldEffect = ((BaseUnityPlugin)this).Config.Bind<bool>("Railgunner", "PolarFieldDeletionEffect", false, "Show a Defense Matrix laser (with its sound) for each projectile the Polar Field deletes. Off = deletions are invisible and silent.");
			stepCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("False Son", "StepOfTheBrothersCooldown", 4f, "Step of the Brothers cooldown in seconds (per use). Vanilla is 8.");
			palmSize = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "PalmBlastSizeMultiplier", 3.5f, "Palm Blast size multiplier (the hand and its healing radius). 1 = vanilla.");
			palmDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "PalmBlastDamageMultiplier", 3.5f, "Palm Blast damage multiplier. 1 = vanilla.");
			palmHealing = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "PalmBlastHealingMultiplier", 3.5f, "Palm Blast ally healing multiplier. 1 = vanilla.");
			palmSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "PalmBlastSpeedMultiplier", 1.5f, "Palm Blast travel speed multiplier. 1 = vanilla.");
			palmRange = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "PalmBlastRange", 1500f, "How far Palm Blast travels (in metres) before it disappears. 1500 is enough to cross any stage. 0 = vanilla range.");
			soulStormDps = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "SoulStormDamagePerSecond", 1200f, "Soul Storm (Anima Harvester form) damage per second, in %. Vanilla is 300.");
			empoweredSoulStormDps = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "EmpoweredSoulStormDamagePerSecond", 9000f, "Empowered (reactivated) Soul Storm damage per second, in %. Vanilla is 1200.");
			animaEchoInvincible = ((BaseUnityPlugin)this).Config.Bind<bool>("Acolyte", "AnimaEchoInvincible", true, "Acolyte takes no damage of any kind for the whole Anima Echo Litany.");
			sacrificeConvictions = ((BaseUnityPlugin)this).Config.Bind<int>("Acolyte", "SacrificeConvictions", 2, "Convictions gained from every Sacrifice. Vanilla is 2.");
			sacrificeKillBonus = ((BaseUnityPlugin)this).Config.Bind<bool>("Acolyte", "SacrificeKillGrantsExtraConviction", false, "If true, killing with Sacrifice grants an extra Conviction (vanilla). If false, Sacrifice always grants exactly SacrificeConvictions.");
			sacrificeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "SacrificeCooldown", 6f, "Sacrifice cooldown in seconds. Vanilla is 10.");
			animaEchoDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "AnimaEchoDurationMultiplier", 2f, "How many times longer the Anima Echo Litany lasts: Convictions drain this many times slower. 2 = 7 Convictions last 18s instead of 9. 1 = vanilla.");
			bladeSlingCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "BladeSlingCooldown", 3f, "Blade Sling cooldown in seconds. Vanilla is 7.5.");
			javelinCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "JavelinCooldown", 4f, "Javelin cooldown in seconds. Vanilla is 7.5.");
			quickstrikeCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "QuickstrikeCooldown", 5f, "Blade Slice quickstrike recharge time in seconds (per quickstrike charge). Vanilla is 8.");
			favorArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Acolyte", "NkuhanasFavorArmor", 200f, "Armor granted by the N'kuhana's Favor passive. Vanilla is 20 (and not shown in its description).");
			carbonizerCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Engineer", "CarbonizerTurretCooldown", 3f, "TR58 Carbonizer Turret (mobile turret) cooldown in seconds. Vanilla is 30.");
			tornadoCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Drifter", "TornadoSlamCooldown", 4f, "Tornado Slam cooldown in seconds. Vanilla is 8.");
			tornadoInvincible = ((BaseUnityPlugin)this).Config.Bind<bool>("Drifter", "TornadoSlamInvincible", true, "Drifter takes no damage of any kind for the whole Tornado Slam (charge, spin and final slam).");
			tornadoDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Drifter", "TornadoSlamDamageMultiplier", 4f, "Multiplier for all Tornado Slam damage (spin hits and the final slam). 1 = vanilla.");
			firewallCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Operator", "FirewallCooldown", 2f, "FIREWALL cooldown in seconds. Vanilla is 8.");
			ejectionCoreCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Operator", "EjectionCoreCooldown", 3f, "Ejection Core cooldown in seconds. Vanilla is 8.");
			marksmanDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Railgunner", "HH44MarksmanDamage", 1000f, "HH44 Marksman shot damage, in %. Vanilla is 400.");
			unseenHandCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "UnseenHandCooldown", 5f, "Unseen Hand cooldown in seconds. Vanilla is 6.");
			unseenHandDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "UnseenHandDamage", 900f, "Unseen Hand damage, in %. Vanilla is 600.");
			unseenHandTeleport = ((BaseUnityPlugin)this).Config.Bind<bool>("Seeker", "UnseenHandTeleport", true, "Seeker teleports to where the Unseen Hand comes out of the ground.");
			unseenHandFireDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Seeker", "UnseenHandTeleportFireDelay", 0.1f, "With UnseenHandTeleport on: seconds between the teleport and the hand coming out, so the camera (where sounds are heard from) has caught up and the hand's sounds aren't dropped as too far away. 0 = fire on the same tick.");
			moddedDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Modded Survivors", "BaseDamageMultiplier", 1.6f, "Base damage (and damage gained per level) multiplier for every playable survivor added by a mod, i.e. anything that isn't part of the vanilla cast. 1 = unchanged.");
			exposeDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Mercenary", "ExposeDamage", 600f, "Extra damage when Mercenary consumes Expose, in % of his base damage. Vanilla is 350. (Replaces the OverexposedMercenary mod.)");
			mercShields = ((BaseUnityPlugin)this).Config.Bind<bool>("Mercenary", "ShieldsInsteadOfHealth", true, "All but 1 of Mercenary's base max HP, and all of his max HP per level, become base shield and shield per level instead (like Transcendence, without its extra 50%): vanilla 110 HP (+33 per level) becomes 1 HP and 109 shield (+33 per level). HP from items is unchanged.");
			try
			{
				chefFeastBuff = ScriptableObject.CreateInstance<BuffDef>();
				((Object)chefFeastBuff).name = "MiscBuffsChefFeast";
				chefFeastBuff.buffColor = new Color(1f, 0.55f, 0.15f);
				chefFeastBuff.canStack = false;
				chefFeastBuff.isDebuff = false;
				chefFeastBuff.isCooldown = false;
				chefFeastBuff.isHidden = false;
				object obj = <>c.<>9__94_0;
				if (obj == null)
				{
					CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
					{
						add.Invoke((IContentPackProvider)(object)new ContentProvider());
					};
					<>c.<>9__94_0 = val;
					obj = (object)val;
				}
				ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			}
			catch (Exception ex)
			{
				Log.LogError((object)("CHEF food buff: " + ex));
				chefFeastBuff = null;
			}
			Harmony val2 = new Harmony("custom.MiscellaneousBuffs");
			TryPatch(val2, typeof(HealthPickup), "OnTriggerStay", "ChefFoodPrefix", "ChefFoodPostfix");
			TryPatchExact(val2, typeof(BaseBladeCombo), "OnEnter", Type.EmptyTypes, "BladeComboPrefix", null);
			TryPatchExact(val2, typeof(CharacterMotor), "ApplyForceImpulse", new Type[1] { typeof(PhysForceInfo).MakeByRefType() }, "MageForcePrefix", null);
			TryPatchExact(val2, typeof(ImmuneToDebuffBehavior), "TryApplyOverride", new Type[1] { typeof(CharacterBody) }, "MageDebuffPrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "OnTakeDamageServer", new Type[1] { typeof(DamageReport) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetStun", new Type[1] { typeof(float) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetFrozen", new Type[1] { typeof(float) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetShock", new Type[1] { typeof(float) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetPain", Type.EmptyTypes, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetMidasTouchFrozen", new Type[1] { typeof(float) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "OverrideStun", new Type[1] { typeof(float) }, "MageHurtStatePrefix", null);
			TryPatchExact(val2, typeof(SetStateOnHurt), "SetImmobilize", new Type[2]
			{
				typeof(GameObject),
				typeof(GameObject)
			}, "MageHurtStatePrefix", null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			TryPatch(val2, typeof(ToolbotDualWieldBase), "OnEnter", null, "PowerModeEnterPostfix");
			TryPatch(val2, typeof(ToolbotDualWieldBase), "OnExit", null, "PowerModeExitPostfix");
			TryPatch(val2, typeof(CharacterBody), "RecalculateStats", null, "RecalculateStatsPostfix");
			TryPatch(val2, typeof(SlowDownProjectiles), "OnTriggerEnter", "SlowDownTriggerPrefix", null);
			TryPatch(val2, typeof(SlowDownProjectiles), "FixedUpdate", "SlowDownFixedUpdatePrefix", null);
			try
			{
				palmHealRadius = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("healRadius");
				palmHealingToApply = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("healingToApply");
				palmOverlap = AccessTools.FieldRefAccess<PalmBlastProjectileController, ProjectileOverlapAttack>("projectileOverlap");
				TryPatch(val2, typeof(PalmBlastProjectileController), "Init", null, "PalmBlastInitPostfix");
				palmBaseSize = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("projectileSize");
				palmSizePerStack = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("bonusProjectileSizePerStack");
				palmFinalSpeed = AccessTools.FieldRefAccess<PalmBlastProjectileController, float>("finalProjectileSpeed");
				palmSimple = AccessTools.FieldRefAccess<PalmBlastProjectileController, ProjectileSimple>("projectileSimple");
				TryPatch(val2, typeof(ProjectileController), "Start", null, "ProjectileStartPostfix");
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Palm Blast changes disabled: " + ex2.Message));
			}
			TryPatch(val2, typeof(BackpackActivate), "OnEnter", "AnimaEchoEnterPrefix", "AnimaEchoEnterPostfix");
			try
			{
				uhReleased = AccessTools.FieldRefAccess<UnseenHand, bool>("skillReleased");
				uhGood = AccessTools.FieldRefAccess<UnseenHand, bool>("goodPlacement");
				uhIndicator = AccessTools.FieldRefAccess<UnseenHand, GameObject>("areaIndicatorInstance");
				TryPatch(val2, typeof(UnseenHand), "FixedUpdate", "UnseenHandPrefix", null);
				TryPatch(val2, typeof(UnseenHand), "Update", "UnseenHandUpdatePrefix", null);
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Unseen Hand teleport disabled: " + ex3.Message));
			}
			TryPatch(val2, typeof(BackpackActivate), "OnExit", null, "AnimaEchoExitPostfix");
			TryPatch(val2, typeof(Sacrifice), "FireOrb", "SacrificeFireOrbPrefix", null);
			TryPatch(val2, typeof(AcolyteFormController), "OnKilledOtherServer", "SacrificeKillPrefix", null);
			TryPatch(val2, typeof(BaseFireSnipe), "OnEnter", "SnipeEnterPrefix", null);
			TryPatch(val2, typeof(ChargeTornadoSlam), "OnEnter", null, "TornadoEnterPostfix");
			TryPatch(val2, typeof(ChargeTornadoSlam), "OnExit", null, "TornadoExitPostfix");
			TryPatch(val2, typeof(TornadoSlam), "OnEnter", "TornadoDamagePrefix", "TornadoEnterPostfix");
			TryPatch(val2, typeof(BluntForceTornado), "OnEnter", "TornadoDamagePrefix", "TornadoEnterPostfix");
			TryPatch(val2, typeof(BasicMeleeAttack), "OnExit", null, "TornadoExitPostfix");
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null);
				if (methodInfo != null)
				{
					val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(MiscellaneousBuffsPlugin), "ExposeTranspiler", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null);
				}
				else
				{
					Log.LogWarning((object)"HealthComponent.TakeDamageProcess not found; Expose damage unchanged.");
				}
			}
			catch (Exception ex4)
			{
				Log.LogError((object)("Expose damage hook failed: " + ex4));
			}
			if (Chainloader.PluginInfos.ContainsKey("rotatingfumos.OverexposedMercenary"))
			{
				Log.LogWarning((object)"The OverexposedMercenary mod is still installed. Its Expose change is now part of MiscellaneousBuffs, so you can remove it.");
			}
			TryPatch(val2, typeof(Glaze), "OnEnter", null, "GlazeEnterPostfix");
			TryPatch(val2, typeof(Glaze), "OnExit", null, "StateInvincibleExitPostfix");
			TryPatch(val2, typeof(LaserFatherCharged), "OnEnter", null, "LaserEnterPostfix");
			TryPatch(val2, typeof(LaserFatherCharged), "OnExit", null, "StateInvincibleExitPostfix");
			TryPatch(val2, typeof(SoulSpiral), "OnEnter", null, "SoulSpiralEnterPostfix");
			TryPatch(val2, typeof(HealthPickup), "OnTriggerStay", "HarvestFruitPrefix", null);
			TryPatchExact(val2, typeof(DotController), "InflictDot", new Type[1] { typeof(InflictDotInfo).MakeByRefType() }, "LunarRuinDotPrefix", null);
			TryPatchExact(val2, typeof(GlobalEventManager), "ProcessHitEnemy", new Type[2]
			{
				typeof(DamageInfo),
				typeof(GameObject)
			}, "LunarRuinHitPrefix", "LunarRuinHitPostfix");
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded));
			Language.onCurrentLanguageChanged += OnLanguageChanged;
		}

		private static void TryPatchExact(Harmony harmony, Type type, string method, Type[] args, string prefix, string postfix)
		{
			//IL_0065: 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)
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, method, args, (Type[])null);
				if (methodInfo == null)
				{
					Log.LogWarning((object)("Could not find " + type.Name + "." + method + "; that change is disabled."));
				}
				else
				{
					harmony.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(MiscellaneousBuffsPlugin), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(MiscellaneousBuffsPlugin), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not hook " + type.Name + "." + method + ": " + ex));
			}
		}

		private static void TryPatch(Harmony harmony, Type type, string method, string prefix, string postfix)
		{
			//IL_0063: 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)
			try
			{
				MethodInfo methodInfo = AccessTools.Method(type, method, (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					Log.LogWarning((object)("Could not find " + type.Name + "." + method + "; that change is disabled."));
				}
				else
				{
					harmony.Patch((MethodBase)methodInfo, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(MiscellaneousBuffsPlugin), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(MiscellaneousBuffsPlugin), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not hook " + type.Name + "." + method + ": " + ex));
			}
		}

		private static void OnGameLoaded()
		{
			//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_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_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)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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)
			toolbotIndex = BodyCatalog.FindBodyIndex("ToolbotBody");
			railgunnerIndex = BodyCatalog.FindBodyIndex("RailgunnerBody");
			mageIndex = BodyCatalog.FindBodyIndex("MageBody");
			chefIndex = BodyCatalog.FindBodyIndex("ChefBody");
			falseSonIndex = BodyCatalog.FindBodyIndex("FalseSonBody");
			try
			{
				if (Object.op_Implicit((Object)(object)chefFeastBuff) && !Object.op_Implicit((Object)(object)chefFeastBuff.iconSprite) && Object.op_Implicit((Object)(object)Buffs.PowerBuff))
				{
					chefFeastBuff.iconSprite = Buffs.PowerBuff.iconSprite;
				}
			}
			catch (Exception)
			{
			}
			magePassiveToken = PassiveToken("MageBody");
			chefPassiveToken = PassiveToken("ChefBody", survivorFallback: true);
			try
			{
				SkillDef val = FindSkill("AcolyteBody", "ACOLYTE_PRIMARY_NAME");
				if (Object.op_Implicit((Object)(object)val))
				{
					acolytePrimaryToken = val.skillDescriptionToken;
					acolytePrimaryKeywords = val.keywordTokens ?? new string[0];
				}
			}
			catch (Exception)
			{
			}
			if (loadChangesApplied)
			{
				return;
			}
			loadChangesApplied = true;
			SetCooldown("HuntressBody", "HUNTRESS_UTILITY_NAME", blinkCooldown.Value, "Huntress Blink");
			SetCooldown("RailgunnerBody", "RAILGUNNER_UTILITY_ALT_NAME", polarFieldCooldown.Value, "Polar Field Device");
			SetCooldown("FalseSonBody", "FALSESON_UTILITY_NAME", stepCooldown.Value, "Step of the Brothers");
			SetCooldown("AcolyteBody", "ACOLYTE_SPECIAL_NAME", sacrificeCooldown.Value, "Acolyte Sacrifice");
			SetCooldown("AcolyteBody", "ACOLYTE_UTILITY_NAME", bladeSlingCooldown.Value, "Acolyte Blade Sling");
			SetCooldown("AcolyteBody", "ACOLYTE_UTILITY_ALT_NAME", javelinCooldown.Value, "Acolyte Javelin");
			SetCooldown("AcolyteBody", "ACOLYTE_PRIMARY_NAME", quickstrikeCooldown.Value, "Acolyte quickstrike (Blade Slice)");
			SetCooldown("EngiBody", "ENGI_SPECIAL_ALT1_NAME", carbonizerCooldown.Value, "Engineer TR58 Carbonizer Turret");
			float oldSeconds = SetCooldown("DrifterBody", "DRIFTER_UTILITY_ALT_NAME", tornadoCooldown.Value, "Drifter Tornado Slam");
			SetMatchingCooldowns("DRIFTER_UTILITY_ALT_A_NAME", oldSeconds, tornadoCooldown.Value, "Drifter Tornado Slam (bag)");
			SetCooldown("DroneTechBody", "DRONETECH_UTILITY_ALT_NAME", firewallCooldown.Value, "Operator FIREWALL");
			SetCooldown("DroneTechBody", "DRONETECH_SPECIAL_NAME", ejectionCoreCooldown.Value, "Operator Ejection Core");
			SetCooldown("SeekerBody", "SEEKER_SECONDARY_NAME", unseenHandCooldown.Value, "Seeker Unseen Hand");
			ScaleCooldowns(new string[2] { "CHEF_UTILITY_NAME", "CHEF_UTILITY_ALT_NAME" }, chefUtilityCooldownMult.Value, "CHEF utility");
			if (glazeCooldown.Value > 0f)
			{
				SetCooldown("ChefBody", "CHEF_SPECIAL_NAME", glazeCooldown.Value, "CHEF Glaze");
			}
			if (laserCooldown.Value > 0f)
			{
				SetCooldown("FalseSonBody", "FALSESON_SPECIAL_NAME", laserCooldown.Value, "False Son Laser of the Father");
			}
			ScaleStakeLightning();
			try
			{
				float fistDamageCoefficient = UnseenHand.fistDamageCoefficient;
				UnseenHand.fistDamageCoefficient = unseenHandDamage.Value / 100f;
				Log.LogInfo((object)("Unseen Hand damage " + Num(fistDamageCoefficient * 100f) + "% -> " + Num(unseenHandDamage.Value) + "%"));
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Unseen Hand: " + ex3));
			}
			ScaleModdedSurvivors(moddedDamageMultiplier.Value);
			try
			{
				GameObject val2 = BodyCatalog.FindBodyPrefab("ToolbotBody");
				CharacterBody val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent<CharacterBody>() : null);
				if (Object.op_Implicit((Object)(object)val3) && toolbotHealthMultiplier.Value != 1f)
				{
					float baseMaxHealth = val3.baseMaxHealth;
					val3.baseMaxHealth *= toolbotHealthMultiplier.Value;
					val3.levelMaxHealth *= toolbotHealthMultiplier.Value;
					Log.LogInfo((object)("MUL-T max health " + Num(baseMaxHealth) + " -> " + Num(val3.baseMaxHealth) + " (+" + Num(val3.levelMaxHealth) + " per level)"));
				}
			}
			catch (Exception ex4)
			{
				Log.LogError((object)("MUL-T health: " + ex4));
			}
			try
			{
				GameObject val4 = BodyCatalog.FindBodyPrefab("MercBody");
				CharacterBody val5 = (Object.op_Implicit((Object)(object)val4) ? val4.GetComponent<CharacterBody>() : null);
				if (Object.op_Implicit((Object)(object)val5) && mercShields.Value && val5.baseMaxHealth > 1f)
				{
					float baseMaxHealth2 = val5.baseMaxHealth;
					float levelMaxHealth = val5.levelMaxHealth;
					val5.baseMaxShield += baseMaxHealth2 - 1f;
					val5.levelMaxShield += levelMaxHealth;
					val5.baseMaxHealth = 1f;
					val5.levelMaxHealth = 0f;
					Log.LogInfo((object)("Mercenary " + Num(baseMaxHealth2) + " HP (+" + Num(levelMaxHealth) + " per level) -> 1 HP and " + Num(val5.baseMaxShield) + " shield (+" + Num(val5.levelMaxShield) + " per level)"));
				}
			}
			catch (Exception ex5)
			{
				Log.LogError((object)("Mercenary shields: " + ex5));
			}
			ScalePolarField(polarFieldRadius.Value);
			try
			{
				GameObject projectilePrefab = ProjectileCatalog.GetProjectilePrefab(ProjectileCatalog.FindProjectileIndex("MageLightningboltBasic"));
				ProjectileExplosion val6 = (Object.op_Implicit((Object)(object)projectilePrefab) ? projectilePrefab.GetComponent<ProjectileExplosion>() : null);
				if (Object.op_Implicit((Object)(object)val6))
				{
					Log.LogInfo((object)("Plasma Bolt blast radius " + val6.blastRadius + "m -> " + plasmaBoltRadius.Value + "m"));
					val6.blastRadius = plasmaBoltRadius.Value;
				}
				else
				{
					Log.LogWarning((object)"Plasma Bolt projectile not found; its radius is unchanged.");
				}
			}
			catch (Exception ex6)
			{
				Log.LogError((object)("Plasma Bolt: " + ex6));
			}
			try
			{
				float projectileDamageCoefficient = SoulStorm.projectileDamageCoefficient;
				SoulStorm.projectileDamageCoefficient *= soulStormDps.Value / 300f;
				Log.LogInfo((object)("Soul Storm projectile damage " + projectileDamageCoefficient + " -> " + SoulStorm.projectileDamageCoefficient));
				projectileDamageCoefficient = ReactivateSoulStorm.projectileDamageCoefficient;
				ReactivateSoulStorm.projectileDamageCoefficient *= empoweredSoulStormDps.Value / 1200f;
				Log.LogInfo((object)("Empowered Soul Storm projectile damage " + projectileDamageCoefficient + " -> " + ReactivateSoulStorm.projectileDamageCoefficient));
			}
			catch (Exception ex7)
			{
				Log.LogError((object)("Soul Storm: " + ex7));
			}
			ApplyDescriptions();
		}

		private static float SetCooldown(string bodyName, string nameToken, float seconds, string label)
		{
			try
			{
				SkillDef val = null;
				GameObject val2 = BodyCatalog.FindBodyPrefab(bodyName);
				if (Object.op_Implicit((Object)(object)val2))
				{
					GenericSkill[] components = val2.GetComponents<GenericSkill>();
					for (int i = 0; i < components.Length; i++)
					{
						if (Object.op_Implicit((Object)(object)val))
						{
							break;
						}
						SkillFamily val3 = (Object.op_Implicit((Object)(object)components[i]) ? components[i].skillFamily : null);
						if (!Object.op_Implicit((Object)(object)val3) || val3.variants == null)
						{
							continue;
						}
						for (int j = 0; j < val3.variants.Length; j++)
						{
							SkillDef skillDef = val3.variants[j].skillDef;
							if (Object.op_Implicit((Object)(object)skillDef) && skillDef.skillNameToken == nameToken)
							{
								val = skillDef;
								break;
							}
						}
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs)
					{
						if (Object.op_Implicit((Object)(object)allSkillDef) && allSkillDef.skillNameToken == nameToken)
						{
							val = allSkillDef;
							break;
						}
					}
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.LogWarning((object)(label + " skill (" + nameToken + " on " + bodyName + ") not found; its cooldown is unchanged."));
					return -1f;
				}
				float baseRechargeInterval = val.baseRechargeInterval;
				Log.LogInfo((object)(label + " (" + val.name + ") cooldown " + baseRechargeInterval + "s -> " + seconds + "s"));
				val.baseRechargeInterval = seconds;
				return baseRechargeInterval;
			}
			catch (Exception ex)
			{
				Log.LogError((object)(label + ": " + ex));
				return -1f;
			}
		}

		private static void ScaleCooldowns(string[] nameTokens, float multiplier, string label)
		{
			if (multiplier <= 0f || multiplier == 1f)
			{
				return;
			}
			try
			{
				int num = 0;
				foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs)
				{
					if (Object.op_Implicit((Object)(object)allSkillDef) && Array.IndexOf(nameTokens, allSkillDef.skillNameToken) >= 0)
					{
						float baseRechargeInterval = allSkillDef.baseRechargeInterval;
						allSkillDef.baseRechargeInterval *= multiplier;
						Log.LogInfo((object)(label + " (" + allSkillDef.name + ") cooldown " + baseRechargeInterval + "s -> " + allSkillDef.baseRechargeInterval + "s"));
						num++;
					}
				}
				if (num == 0)
				{
					Log.LogWarning((object)(label + " skills not found; their cooldowns are unchanged."));
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)(label + ": " + ex));
			}
		}

		private static void ScaleStakeLightning()
		{
			try
			{
				float num = lunarStakeLightningDamage.Value / 150f;
				if (lunarStakeLightningDamage.Value <= 0f || num == 1f)
				{
					return;
				}
				int num2 = 0;
				for (int i = 0; i < ProjectileCatalog.projectilePrefabCount; i++)
				{
					GameObject projectilePrefab = ProjectileCatalog.GetProjectilePrefab(i);
					LunarStakesLightningController val = (Object.op_Implicit((Object)(object)projectilePrefab) ? projectilePrefab.GetComponent<LunarStakesLightningController>() : null);
					if (Object.op_Implicit((Object)(object)val))
					{
						float childDamageCoefficient = val.childDamageCoefficient;
						val.childDamageCoefficient *= num;
						Log.LogInfo((object)("Lunar Stakes lightning (" + ((Object)projectilePrefab).name + ") damage coefficient " + childDamageCoefficient + " -> " + val.childDamageCoefficient));
						num2++;
					}
				}
				if (num2 == 0)
				{
					Log.LogWarning((object)"Lunar Stakes projectile not found; its lightning damage is unchanged.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Lunar Stakes lightning: " + ex));
			}
		}

		private static SkillDef FindSkill(string bodyName, string nameToken)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = BodyCatalog.FindBodyPrefab(bodyName);
			if (Object.op_Implicit((Object)(object)val))
			{
				GenericSkill[] components = val.GetComponents<GenericSkill>();
				foreach (GenericSkill val2 in components)
				{
					SkillFamily val3 = (Object.op_Implicit((Object)(object)val2) ? val2.skillFamily : null);
					if (!Object.op_Implicit((Object)(object)val3) || val3.variants == null)
					{
						continue;
					}
					Variant[] variants = val3.variants;
					foreach (Variant val4 in variants)
					{
						if (Object.op_Implicit((Object)(object)val4.skillDef) && val4.skillDef.skillNameToken == nameToken)
						{
							return val4.skillDef;
						}
					}
				}
			}
			return null;
		}

		private static string PassiveToken(string bodyName, bool survivorFallback = false)
		{
			try
			{
				GameObject val = BodyCatalog.FindBodyPrefab(bodyName);
				SkillLocator val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<SkillLocator>() : null);
				if (Object.op_Implicit((Object)(object)val2) && val2.passiveSkill.enabled && !string.IsNullOrEmpty(val2.passiveSkill.skillDescriptionToken))
				{
					return val2.passiveSkill.skillDescriptionToken;
				}
				if (Object.op_Implicit((Object)(object)val))
				{
					GenericSkill[] components = val.GetComponents<GenericSkill>();
					foreach (GenericSkill val3 in components)
					{
						SkillFamily val4 = (Object.op_Implicit((Object)(object)val3) ? val3.skillFamily : null);
						if (Object.op_Implicit((Object)(object)val3) && ((val3.skillName ?? "").IndexOf("passive", StringComparison.OrdinalIgnoreCase) >= 0 || (Object.op_Implicit((Object)(object)val4) && val4.name.IndexOf("passive", StringComparison.OrdinalIgnoreCase) >= 0)) && val4.variants != null && val4.variants.Length != 0 && Object.op_Implicit((Object)(object)val4.variants[0].skillDef) && !string.IsNullOrEmpty(val4.variants[0].skillDef.skillDescriptionToken))
						{
							return val4.variants[0].skillDef.skillDescriptionToken;
						}
					}
				}
				if (Object.op_Implicit((Object)(object)val2) && !string.IsNullOrEmpty(val2.passiveSkill.skillDescriptionToken))
				{
					return val2.passiveSkill.skillDescriptionToken;
				}
				SurvivorDef val5 = ((survivorFallback && Object.op_Implicit((Object)(object)val)) ? SurvivorCatalog.FindSurvivorDefFromBody(val) : null);
				if (Object.op_Implicit((Object)(object)val5) && !string.IsNullOrEmpty(val5.descriptionToken))
				{
					Log.LogInfo((object)(bodyName + " has no passive; its changes are added to its character description (" + val5.descriptionToken + ")."));
					return val5.descriptionToken;
				}
			}
			catch (Exception)
			{
			}
			Log.LogWarning((object)(bodyName + " passive description not found; its text is unchanged."));
			return null;
		}

		private static void SetMatchingCooldowns(string nameToken, float oldSeconds, float seconds, string label)
		{
			if (oldSeconds <= 0f)
			{
				return;
			}
			try
			{
				foreach (SkillDef allSkillDef in SkillCatalog.allSkillDefs)
				{
					if (Object.op_Implicit((Object)(object)allSkillDef) && allSkillDef.skillNameToken == nameToken && Mathf.Abs(allSkillDef.baseRechargeInterval - oldSeconds) < 0.001f)
					{
						Log.LogInfo((object)(label + " (" + allSkillDef.name + ") cooldown " + allSkillDef.baseRechargeInterval + "s -> " + seconds + "s"));
						allSkillDef.baseRechargeInterval = seconds;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)(label + ": " + ex));
			}
		}

		private static void ScaleModdedSurvivors(float multiplier)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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)
			if (multiplier <= 0f || multiplier == 1f)
			{
				return;
			}
			try
			{
				HashSet<CharacterBody> hashSet = new HashSet<CharacterBody>();
				Enumerator<ReadOnlyContentPack> enumerator = ContentManager.allLoadedContentPacks.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ReadOnlyContentPack current = enumerator.Current;
						string text = ((ReadOnlyContentPack)(ref current)).identifier ?? string.Empty;
						if (text.StartsWith("RoR2.", StringComparison.Ordinal) && text != "RoR2.LegacyModContent")
						{
							continue;
						}
						AssetEnumerator<SurvivorDef> enumerator2 = ((ReadOnlyContentPack)(ref current)).survivorDefs.GetEnumerator();
						try
						{
							while (enumerator2.MoveNext())
							{
								SurvivorDef current2 = enumerator2.Current;
								CharacterBody val = ((Object.op_Implicit((Object)(object)current2) && Object.op_Implicit((Object)(object)current2.bodyPrefab)) ? current2.bodyPrefab.GetComponent<CharacterBody>() : null);
								if (Object.op_Implicit((Object)(object)val) && hashSet.Add(val))
								{
									float baseDamage = val.baseDamage;
									val.baseDamage *= multiplier;
									val.levelDamage *= multiplier;
									Log.LogInfo((object)("Modded survivor " + current2.cachedName + " (" + text + ") base damage " + Num(baseDamage) + " -> " + Num(val.baseDamage)));
								}
							}
						}
						finally
						{
							((IDisposable)enumerator2/*cast due to .constrained prefix*/).Dispose();
						}
					}
				}
				finally
				{
					((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				if (hashSet.Count == 0)
				{
					Log.LogInfo((object)"No modded survivors found; nothing to scale.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Modded survivors: " + ex));
			}
		}

		private static void ScalePolarField(float multiplier)
		{
			//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 (multiplier <= 0f || multiplier == 1f)
			{
				return;
			}
			try
			{
				GameObject val = null;
				int num = ProjectileCatalog.FindProjectileIndex("RailgunnerMineAltDetonated");
				if (num >= 0)
				{
					val = ProjectileCatalog.GetProjectilePrefab(num);
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/Railgunner/RailgunnerMineAltDetonated.prefab").WaitForCompletion();
				}
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.LogWarning((object)"Polar Field prefab not found; its radius is unchanged.");
					return;
				}
				int num2 = 0;
				int num3 = 0;
				BuffWard[] componentsInChildren = val.GetComponentsInChildren<BuffWard>(true);
				foreach (BuffWard val2 in componentsInChildren)
				{
					Log.LogInfo((object)("Polar Field slow radius " + val2.radius + "m -> " + val2.radius * multiplier + "m"));
					val2.radius *= multiplier;
					num2++;
				}
				SlowDownProjectiles[] componentsInChildren2 = val.GetComponentsInChildren<SlowDownProjectiles>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					SphereCollider[] components = ((Component)componentsInChildren2[i]).GetComponents<SphereCollider>();
					foreach (SphereCollider obj in components)
					{
						obj.radius *= multiplier;
						num3++;
					}
				}
				if (num2 == 0 && num3 == 0)
				{
					Log.LogWarning((object)"Polar Field has no slow area or projectile area to scale; its radius is unchanged.");
					return;
				}
				Log.LogInfo((object)("Polar Field radius x" + multiplier + " (" + num2 + " slow area, " + num3 + " projectile area)."));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Polar Field radius: " + ex));
			}
		}

		private static bool IsChefFood(HealthPickup pickup, out GameObject root)
		{
			root = (Object.op_Implicit((Object)(object)pickup.baseObject) ? pickup.baseObject : ((Component)((Component)pickup).transform.root).gameObject);
			if (!Object.op_Implicit((Object)(object)root.GetComponentInChildren<ChefFoodPickController>(true)) && !Object.op_Implicit((Object)(object)root.GetComponentInParent<ChefFoodPickController>()))
			{
				return ((Object)root).name.StartsWith("ChefFoodPickup", StringComparison.OrdinalIgnoreCase);
			}
			return true;
		}

		private static void ChefFoodPrefix(HealthPickup __instance, Collider other, out CharacterBody __state)
		{
			//IL_005e: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			__state = null;
			try
			{
				if (!Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				GameObject root;
				bool flag = IsChefFood(__instance, out root);
				if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<Boosted>()))
				{
					((Component)__instance).gameObject.AddComponent<Boosted>();
					if (flag)
					{
						if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInParent<ChefFoodCount>()))
						{
							Transform root2 = ((Component)__instance).transform.root;
							((Component)root2).gameObject.AddComponent<ChefFoodCount>().count = Mathf.Max(1, Mathf.RoundToInt(root2.localScale.x / 0.75f));
						}
						__instance.flatHealing *= chefFoodHealing.Value;
						__instance.fractionalHealing *= chefFoodHealing.Value;
					}
				}
				if (flag && NetworkServer.active && __instance.alive && Object.op_Implicit((Object)(object)other) && Object.op_Implicit((Object)(object)__instance.teamFilter) && TeamComponent.GetObjectTeam(((Component)other).gameObject) == __instance.teamFilter.teamIndex)
				{
					__state = ((Component)other).GetComponent<CharacterBody>();
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)ex.Message);
			}
		}

		private static void ChefFoodPostfix(HealthPickup __instance, CharacterBody __state)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Invalid comparison between Unknown and I4
			try
			{
				if (Object.op_Implicit((Object)(object)__state) && Object.op_Implicit((Object)(object)chefFeastBuff) && (int)chefFeastBuff.buffIndex != -1 && !(chefFoodDamageBoost.Value <= 0f) && !(chefFoodBoostSeconds.Value <= 0f))
				{
					ChefFoodCount componentInParent = ((Component)__instance).GetComponentInParent<ChefFoodCount>();
					int num = (Object.op_Implicit((Object)(object)componentInParent) ? componentInParent.count : 2);
					__state.AddTimedBuff(chefFeastBuff, chefFoodBoostSeconds.Value * (float)num);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("CHEF food boost: " + ex.Message));
			}
		}

		private static void SpawnChefFood(CharacterBody chef, int ingredients)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_004d: 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_0054: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = LegacyResourcesAPI.Load<GameObject>("Chef/ChefFoodPickup");
				if (Object.op_Implicit((Object)(object)val))
				{
					Vector2 insideUnitCircle = Random.insideUnitCircle;
					Vector2 val2 = ((Vector2)(ref insideUnitCircle)).normalized * 3f;
					Vector3 val3 = chef.corePosition + new Vector3(val2.x, 1f, val2.y);
					GameObject obj = Object.Instantiate<GameObject>(val, val3, Random.rotation);
					TeamFilter component = obj.GetComponent<TeamFilter>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.teamIndex = (TeamIndex)((!Object.op_Implicit((Object)(object)chef.teamComponent)) ? 1 : ((int)chef.teamComponent.teamIndex));
					}
					HealthPickup componentInChildren = obj.GetComponentInChildren<HealthPickup>();
					if (Object.op_Implicit((Object)(object)componentInChildren))
					{
						componentInChildren.flatHealing = 2f * (float)ingredients;
						componentInChildren.fractionalHealing = 0.04f * (float)ingredients;
					}
					obj.AddComponent<ChefFoodCount>().count = ingredients;
					float num = 0.75f * (float)ingredients;
					obj.transform.localScale = new Vector3(num, num, num);
					NetworkServer.Spawn(obj);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("CHEF periodic food: " + ex.Message));
			}
		}

		private static void OnBodyStart(CharacterBody body)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//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_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)
			try
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					if ((int)chefIndex != -1 && body.bodyIndex == chefIndex && NetworkServer.active && !Object.op_Implicit((Object)(object)((Component)body).GetComponent<ChefPeriodicFood>()))
					{
						((Component)body).gameObject.AddComponent<ChefPeriodicFood>();
					}
					if ((int)mageIndex != -1 && body.bodyIndex == mageIndex && !Object.op_Implicit((Object)(object)((Component)body).GetComponent<AirborneMage>()))
					{
						((Component)body).gameObject.AddComponent<AirborneMage>();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Body setup: " + ex.Message));
			}
		}

		private static void BladeComboPrefix(BaseBladeCombo __instance)
		{
			try
			{
				if (__instance is BladeCombo)
				{
					__instance.damageCoefficient *= acolytePrimaryDamage.Value / 150f;
				}
				else if (__instance is BladeJumpStrike || __instance is BladeSprintStrike)
				{
					__instance.damageCoefficient *= acolyteQuickstrikeDamage.Value / 200f;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Blade Slice damage: " + ex.Message));
			}
		}

		private static bool MageAirborne(CharacterBody body)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if ((int)mageIndex == -1 || !Object.op_Implicit((Object)(object)body) || body.bodyIndex != mageIndex)
			{
				return false;
			}
			CharacterMotor characterMotor = body.characterMotor;
			if (Object.op_Implicit((Object)(object)characterMotor) && !characterMotor.isGrounded && Object.op_Implicit((Object)(object)body.healthComponent))
			{
				return body.healthComponent.alive;
			}
			return false;
		}

		private static bool HasDebuffOrDot(CharacterBody body)
		{
			BuffIndex[] activeBuffsList = body.activeBuffsList;
			if (activeBuffsList != null)
			{
				for (int i = 0; i < body.activeBuffsListCount && i < activeBuffsList.Length; i++)
				{
					BuffDef buffDef = BuffCatalog.GetBuffDef(activeBuffsList[i]);
					if (Object.op_Implicit((Object)(object)buffDef) && buffDef.isDebuff)
					{
						return true;
					}
				}
			}
			DotController val = DotController.FindDotController(((Component)body).gameObject);
			if (Object.op_Implicit((Object)(object)val) && val.dotStackList != null)
			{
				return val.dotStackList.Count > 0;
			}
			return false;
		}

		private static bool MageForcePrefix(CharacterMotor __instance)
		{
			if (mageAirImmunity.Value)
			{
				return !MageAirborne(__instance.body);
			}
			return true;
		}

		private static bool MageDebuffPrefix(CharacterBody body, ref bool __result)
		{
			if (mageAirImmunity.Value && MageAirborne(body))
			{
				__result = true;
				return false;
			}
			return true;
		}

		private static bool MageHurtStatePrefix(SetStateOnHurt __instance)
		{
			if (mageAirImmunity.Value && Object.op_Implicit((Object)(object)__instance))
			{
				return !MageAirborne(((Component)__instance).GetComponent<CharacterBody>());
			}
			return true;
		}

		private static void PowerModeEnterPostfix(ToolbotDualWieldBase __instance)
		{
			try
			{
				CharacterBody val = BodyOf((EntityState)(object)__instance);
				if (Object.op_Implicit((Object)(object)ToolbotDualWieldBase.bonusBuff) && __instance.applyBonusBuff && Object.op_Implicit((Object)(object)val))
				{
					PowerModeTracker powerModeTracker = ((Component)val).GetComponent<PowerModeTracker>();
					if (!Object.op_Implicit((Object)(object)powerModeTracker))
					{
						powerModeTracker = ((Component)val).gameObject.AddComponent<PowerModeTracker>();
					}
					powerModeTracker.activeStates++;
					val.MarkAllStatsDirty();
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Power Mode: " + ex.Message));
			}
		}

		private static void PowerModeExitPostfix(ToolbotDualWieldBase __instance)
		{
			try
			{
				CharacterBody val = BodyOf((EntityState)(object)__instance);
				if (Object.op_Implicit((Object)(object)ToolbotDualWieldBase.bonusBuff) && __instance.applyBonusBuff && Object.op_Implicit((Object)(object)val))
				{
					PowerModeTracker component = ((Component)val).GetComponent<PowerModeTracker>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.activeStates = Mathf.Max(0, component.activeStates - 1);
						val.MarkAllStatsDirty();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Power Mode: " + ex.Message));
			}
		}

		private static CharacterBody BodyOf(EntityState state)
		{
			if (!Object.op_Implicit((Object)(object)state.outer))
			{
				return null;
			}
			return ((Component)state.outer).GetComponent<CharacterBody>();
		}

		private static void RecalculateStatsPostfix(CharacterBody __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Invalid comparison between Unknown and I4
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Invalid comparison between Unknown and I4
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)__instance.inventory) && Object.op_Implicit((Object)(object)Items.ConvertHealingToAttackSpeed) && __instance.inventory.GetItemCountEffective(Items.ConvertHealingToAttackSpeed) > 0)
			{
				__instance.armor += favorArmor.Value - 20f;
			}
			if (Object.op_Implicit((Object)(object)chefFeastBuff) && (int)chefFeastBuff.buffIndex != -1 && __instance.HasBuff(chefFeastBuff) && chefFoodDamageBoost.Value > 0f)
			{
				__instance.damage *= 1f + chefFoodDamageBoost.Value / 100f;
			}
			if (MageAirborne(__instance))
			{
				__instance.armor += mageAirArmor.Value;
				__instance.damage *= mageAirDamage.Value;
			}
			if ((int)toolbotIndex != -1 && __instance.bodyIndex == toolbotIndex)
			{
				PowerModeTracker component = ((Component)__instance).GetComponent<PowerModeTracker>();
				if (Object.op_Implicit((Object)(object)component) && component.activeStates > 0 && Object.op_Implicit((Object)(object)ToolbotDualWieldBase.bonusBuff) && __instance.HasBuff(ToolbotDualWieldBase.bonusBuff))
				{
					__instance.armor += powerModeArmor.Value - 100f;
				}
			}
		}

		private static bool IsPolarField(SlowDownProjectiles field)
		{
			//IL_0071: 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)
			if (!polarFieldDeletes.Value || !Object.op_Implicit((Object)(object)field))
			{
				return false;
			}
			PolarFieldState polarFieldState = ((Component)field).GetComponent<PolarFieldState>();
			if (!Object.op_Implicit((Object)(object)polarFieldState))
			{
				polarFieldState = ((Component)field).gameObject.AddComponent<PolarFieldState>();
			}
			if (!polarFieldState.resolved)
			{
				ProjectileController componentInParent = ((Component)field).GetComponentInParent<ProjectileController>();
				CharacterBody val = ((Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.owner)) ? componentInParent.owner.GetComponent<CharacterBody>() : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					polarFieldState.isPolarField = val.bodyIndex == railgunnerIndex;
					polarFieldState.resolved = true;
				}
				else
				{
					polarFieldState.isPolarField = ((Object)((Component)field).transform.root).name.IndexOf("RailgunnerMineAlt", StringComparison.OrdinalIgnoreCase) >= 0;
					polarFieldState.resolved = Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.owner);
				}
			}
			return polarFieldState.isPolarField;
		}

		private static bool SlowDownTriggerPrefix(SlowDownProjectiles __instance)
		{
			return !IsPolarField(__instance);
		}

		private static bool SlowDownFixedUpdatePrefix(SlowDownProjectiles __instance)
		{
			if (!IsPolarField(__instance))
			{
				return true;
			}
			if (NetworkServer.active)
			{
				DeleteProjectilesInside(__instance);
			}
			return false;
		}

		private static void DeleteProjectilesInside(SlowDownProjectiles field)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0067: 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_007f: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			try
			{
				Collider component = ((Component)field).GetComponent<Collider>();
				if (!Object.op_Implicit((Object)(object)component) || !component.enabled)
				{
					return;
				}
				TeamIndex val = (TeamIndex)((!Object.op_Implicit((Object)(object)field.teamFilter)) ? 1 : ((int)field.teamFilter.teamIndex));
				SphereCollider val2 = (SphereCollider)(object)((component is SphereCollider) ? component : null);
				Vector3 val3 = Vector3.zero;
				float num = 0f;
				if (Object.op_Implicit((Object)(object)val2))
				{
					Vector3 lossyScale = ((Component)val2).transform.lossyScale;
					float num2 = val2.radius * Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)));
					val3 = ((Component)val2).transform.TransformPoint(val2.center);
					num = num2 * num2;
				}
				ProjectileController componentInParent = ((Component)field).GetComponentInParent<ProjectileController>();
				List<ProjectileController> instancesList = InstanceTracker.GetInstancesList<ProjectileController>();
				List<ProjectileController> list = null;
				for (int i = 0; i < instancesList.Count; i++)
				{
					ProjectileController val4 = instancesList[i];
					if (!Object.op_Implicit((Object)(object)val4) || (Object)(object)val4 == (Object)(object)componentInParent || val4.cannotBeDeleted || !Object.op_Implicit((Object)(object)val4.teamFilter) || val4.teamFilter.teamIndex == val)
					{
						continue;
					}
					Vector3 position = ((Component)val4).transform.position;
					Vector3 val5;
					bool num3;
					if (!Object.op_Implicit((Object)(object)val2))
					{
						val5 = component.ClosestPoint(position) - position;
						num3 = ((Vector3)(ref val5)).sqrMagnitude < 0.0001f;
					}
					else
					{
						val5 = position - val3;
						num3 = ((Vector3)(ref val5)).sqrMagnitude <= num;
					}
					if (num3)
					{
						if (list == null)
						{
							list = new List<ProjectileController>();
						}
						list.Add(val4);
					}
				}
				if (list == null)
				{
					return;
				}
				PolarFieldState component2 = ((Component)field).GetComponent<PolarFieldState>();
				if (Object.op_Implicit((Object)(object)component2) && !component2.logged)
				{
					component2.logged = true;
					Log.LogDebug((object)"Polar Field deleting projectiles.");
				}
				Vector3 position2 = ((Component)field).transform.position;
				for (int j = 0; j < list.Count; j++)
				{
					ProjectileController val6 = list[j];
					if (Object.op_Implicit((Object)(object)val6))
					{
						if (polarFieldEffect.Value && Object.op_Implicit((Object)(object)DefenseMatrixOn.tracerEffectPrefab) && j < 8)
						{
							EffectManager.SpawnEffect(DefenseMatrixOn.tracerEffectPrefab, new EffectData
							{
								origin = ((Component)val6).transform.position,
								start = position2
							}, true);
						}
						EntityState.Destroy((Object)(object)((Component)val6).gameObject);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Polar Field: " + ex.Message));
			}
		}

		private static void ProjectileStartPostfix(ProjectileController __instance)
		{
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active || !Object.op_Implicit((Object)(object)__instance) || palmBaseSize == null)
			{
				return;
			}
			try
			{
				PalmBlastProjectileController component = ((Component)__instance).GetComponent<PalmBlastProjectileController>();
				if (Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)((Component)component).GetComponent<PalmClientScaled>()))
				{
					((Component)component).gameObject.AddComponent<PalmClientScaled>();
					float num = palmBaseSize.Invoke(component);
					CharacterBody val = (Object.op_Implicit((Object)(object)__instance.owner) ? __instance.owner.GetComponent<CharacterBody>() : null);
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)Buffs.ChakraBuff))
					{
						num += (float)val.GetBuffCount(Buffs.ChakraBuff) * palmSizePerStack.Invoke(component);
					}
					float num2 = ((palmSize.Value > 0f) ? palmSize.Value : 1f);
					Transform transform = ((Component)component).transform;
					transform.localScale *= num * num2;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Palm Blast (client size): " + ex.Message));
			}
		}

		private static void PalmBlastInitPostfix(PalmBlastProjectileController __instance)
		{
			//IL_0022: 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)
			try
			{
				float value = palmSize.Value;
				if (value > 0f && value != 1f)
				{
					Transform transform = ((Component)__instance).transform;
					transform.localScale *= value;
					palmHealRadius.Invoke(__instance) *= value;
				}
				palmHealingToApply.Invoke(__instance) *= palmHealing.Value;
				ProjectileOverlapAttack val = palmOverlap.Invoke(__instance);
				if (Object.op_Implicit((Object)(object)val))
				{
					val.damageCoefficient *= palmDamage.Value;
				}
				SetPalmTravel(__instance);
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Palm Blast: " + ex.Message));
			}
		}

		private static void SetPalmTravel(PalmBlastProjectileController palm)
		{
			if (palmFinalSpeed == null || palmSimple == null)
			{
				return;
			}
			ProjectileSimple val = palmSimple.Invoke(palm);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			float num = palmFinalSpeed.Invoke(palm);
			float lifetime = val.lifetime;
			float num2 = num;
			if (palmSpeed.Value > 0f && palmSpeed.Value != 1f && num2 > 0f)
			{
				num2 *= palmSpeed.Value;
				palmFinalSpeed.Invoke(palm) = num2;
				val.desiredForwardSpeed = num2;
			}
			if (palmRange.Value > 0f && num2 > 0f)
			{
				float num3 = palmRange.Value / num2;
				if (num3 > val.lifetime)
				{
					val.lifetime = num3;
				}
			}
			if (!palmTravelLogged)
			{
				palmTravelLogged = true;
				Log.LogInfo((object)("Palm Blast speed " + num + " -> " + num2 + " m/s, lifetime " + lifetime + "s -> " + val.lifetime + "s (range " + Mathf.RoundToInt(num * lifetime) + "m -> " + Mathf.RoundToInt(num2 * val.lifetime) + "m)."));
			}
		}

		private static void AnimaEchoEnterPrefix(BackpackActivate __instance)
		{
			if (animaEchoDuration.Value > 0f && animaEchoDuration.Value != 1f)
			{
				((BaseBackpackState)__instance).duration = ((BaseBackpackState)__instance).duration * animaEchoDuration.Value;
			}
		}

		private static void AnimaEchoEnterPostfix(BackpackActivate __instance)
		{
			try
			{
				if (!animaEchoInvincible.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)Buffs.HiddenRejectAllDamage))
				{
					return;
				}
				CharacterBody val = BodyOf((EntityState)(object)__instance);
				if (Object.op_Implicit((Object)(object)val))
				{
					EchoInvincible echoInvincible = ((Component)val).GetComponent<EchoInvincible>();
					if (!Object.op_Implicit((Object)(object)echoInvincible))
					{
						echoInvincible = ((Component)val).gameObject.AddComponent<EchoInvincible>();
					}
					echoInvincible.activeStates++;
					val.AddBuff(Buffs.HiddenRejectAllDamage);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Anima Echo: " + ex.Message));
			}
		}

		private static void AnimaEchoExitPostfix(BackpackActivate __instance)
		{
			try
			{
				if (NetworkServer.active)
				{
					CharacterBody val = BodyOf((EntityState)(object)__instance);
					EchoInvincible echoInvincible = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<EchoInvincible>() : null);
					if (Object.op_Implicit((Object)(object)echoInvincible) && echoInvincible.activeStates > 0)
					{
						echoInvincible.activeStates--;
						val.RemoveBuff(Buffs.HiddenRejectAllDamage);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Anima Echo: " + ex.Message));
			}
		}

		private static void SacrificeFireOrbPrefix(Sacrifice __instance)
		{
			if (sacrificeConvictions.Value >= 0)
			{
				__instance.soulValue = sacrificeConvictions.Value;
			}
		}

		private static bool SacrificeKillPrefix(AcolyteFormController __instance, DamageReport damageReport)
		{
			//IL_005f: 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_0064: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			if (sacrificeKillBonus.Value)
			{
				return true;
			}
			try
			{
				if (damageReport == null || damageReport.damageInfo == null || !((ProcChainMask)(ref damageReport.damageInfo.procChainMask)).HasProc((ProcType)30))
				{
					return true;
				}
				if (Object.op_Implicit((Object)(object)__instance.sacrificeKillEffectPrefab))
				{
					Vector3 val = (Object.op_Implicit((Object)(object)damageReport.victimBody) ? damageReport.victimBody.corePosition : damageReport.damageInfo.position);
					EffectManager.SimpleEffect(__instance.sacrificeKillEffectPrefab, val, Quaternion.identity, true);
				}
				return false;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Sacrifice: " + ex.Message));
				return true;
			}
		}

		private static bool UnseenHandPrefix(UnseenHand __instance)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!unseenHandTeleport.Value || !((EntityState)__instance).isAuthority)
				{
					return true;
				}
				if (uhPending.TryGetValue(__instance, out var value))
				{
					if (value.fired)
					{
						return true;
					}
					GameObject val = uhIndicator.Invoke(__instance);
					if (Object.op_Implicit((Object)(object)val))
					{
						val.transform.position = value.position;
					}
					uhGood.Invoke(__instance) = true;
					value.timer -= Time.fixedDeltaTime;
					if (value.timer > 0f)
					{
						return false;
					}
					value.fired = true;
					if (Object.op_Implicit((Object)(object)((EntityState)__instance).inputBank))
					{
						((EntityState)__instance).inputBank.skill2.down = false;
					}
					UpdateSoundPosition(((EntityState)__instance).characterBody);
					return true;
				}
				if (uhReleased.Invoke(__instance) || !uhGood.Invoke(__instance) || !Object.op_Implicit((Object)(object)((EntityState)__instance).inputBank) || ((EntityState)__instance).inputBank.skill2.down)
				{
					return true;
				}
				GameObject val2 = uhIndicator.Invoke(__instance);
				CharacterBody characterBody = ((EntityState)__instance).characterBody;
				if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)characterBody))
				{
					return true;
				}
				Vector3 position = val2.transform.position;
				TeleportHelper.TeleportBody(characterBody, position, false);
				UpdateSoundPosition(characterBody);
				if (unseenHandFireDelay.Value <= 0f)
				{
					return true;
				}
				uhPending.Add(__instance, new UnseenHandPending
				{
					timer = unseenHandFireDelay.Value,
					position = position
				});
				return false;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Unseen Hand teleport: " + ex.Message));
				return true;
			}
		}

		private static bool UnseenHandUpdatePrefix(UnseenHand __instance)
		{
			if (uhPending.TryGetValue(__instance, out var value))
			{
				return value.fired;
			}
			return true;
		}

		private static void UpdateSoundPosition(CharacterBody body)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Object.op_Implicit((Object)(object)body))
				{
					AkSoundEngine.SetObjectPosition(((Component)body).gameObject, body.transform);
				}
			}
			catch (Exception)
			{
			}
		}

		private static void SnipeEnterPrefix(BaseFireSnipe __instance)
		{
			if (__instance is FireSnipeLight && !(marksmanDamage.Value <= 0f))
			{
				if (!marksmanLogged)
				{
					marksmanLogged = true;
					Log.LogInfo((object)("HH44 Marksman damage " + Num(((GenericBulletBaseState)__instance).damageCoefficient * 100f) + "% -> " + Num(marksmanDamage.Value) + "%"));
				}
				((GenericBulletBaseState)__instance).damageCoefficient = marksmanDamage.Value / 100f;
			}
		}

		private static void TornadoDamagePrefix(BasicMeleeAttack __instance)
		{
			try
			{
				if (!(tornadoDamage.Value <= 0f) && tornadoDamage.Value != 1f && !tornadoBoosted.TryGetValue((EntityState)(object)__instance, out var _))
				{
					tornadoBoosted.Add((EntityState)(object)__instance, null);
					__instance.damageCoefficient *= tornadoDamage.Value;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Tornado Slam damage: " + ex.Message));
			}
		}

		private static bool IsTornadoState(EntityState state)
		{
			if (!(state is ChargeTornadoSlam) && !(state is TornadoSlam))
			{
				return state is BluntForceTornado;
			}
			return true;
		}

		private static void TornadoEnterPostfix(EntityState __instance)
		{
			try
			{
				if (!MiscellaneousBuffsPlugin.tornadoInvincible.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)Buffs.HiddenRejectAllDamage) || !IsTornadoState(__instance))
				{
					return;
				}
				CharacterBody val = BodyOf(__instance);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				TornadoInvincible tornadoInvincible = ((Component)val).GetComponent<TornadoInvincible>();
				if (!Object.op_Implicit((Object)(object)tornadoInvincible))
				{
					tornadoInvincible = ((Component)val).gameObject.AddComponent<TornadoInvincible>();
				}
				if (tornadoInvincible.states.Add(__instance))
				{
					tornadoInvincible.count++;
					if (tornadoInvincible.count == 1 && !val.HasBuff(Buffs.HiddenRejectAllDamage))
					{
						val.AddBuff(Buffs.HiddenRejectAllDamage);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Tornado Slam: " + ex.Message));
			}
		}

		private static void TornadoExitPostfix(EntityState __instance)
		{
			try
			{
				if (!NetworkServer.active || !IsTornadoState(__instance))
				{
					return;
				}
				CharacterBody val = BodyOf(__instance);
				TornadoInvincible tornadoInvincible = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<TornadoInvincible>() : null);
				if (Object.op_Implicit((Object)(object)tornadoInvincible) && tornadoInvincible.states.Remove(__instance))
				{
					tornadoInvincible.count = Mathf.Max(0, tornadoInvincible.count - 1);
					if (tornadoInvincible.count == 0 && val.HasBuff(Buffs.HiddenRejectAllDamage))
					{
						val.RemoveBuff(Buffs.HiddenRejectAllDamage);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Tornado Slam: " + ex.Message));
			}
		}

		private static void BeginStateInvincible(EntityState state)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Buffs.HiddenRejectAllDamage))
			{
				return;
			}
			CharacterBody val = BodyOf(state);
			if (Object.op_Implicit((Object)(object)val))
			{
				StateInvincible stateInvincible = ((Component)val).GetComponent<StateInvincible>();
				if (!Object.op_Implicit((Object)(object)stateInvincible))
				{
					stateInvincible = ((Component)val).gameObject.AddComponent<StateInvincible>();
				}
				stateInvincible.releaseAt = -1f;
				if (stateInvincible.states.Add(state) && !stateInvincible.added)
				{
					stateInvincible.added = true;
					val.AddBuff(Buffs.HiddenRejectAllDamage);
				}
			}
		}

		private static void StateInvincibleExitPostfix(EntityState __instance)
		{
			try
			{
				if (!NetworkServer.active)
				{
					return;
				}
				CharacterBody val = BodyOf(__instance);
				StateInvincible stateInvincible = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<StateInvincible>() : null);
				if (Object.op_Implicit((Object)(object)stateInvincible) && stateInvincible.states.Remove(__instance) && stateInvincible.states.Count <= 0 && stateInvincible.added)
				{
					float num = ((__instance is Glaze) ? glazeInvincibleExtraSeconds.Value : 0f);
					if (num > 0f)
					{
						stateInvincible.releaseAt = Time.fixedTime + num;
					}
					else
					{
						stateInvincible.Release();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Skill invincibility: " + ex.Message));
			}
		}

		private static void GlazeEnterPostfix(Glaze __instance)
		{
			try
			{
				if (glazeInvincible.Value)
				{
					BeginStateInvincible((EntityState)(object)__instance);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Glaze: " + ex.Message));
			}
		}

		private static void LaserEnterPostfix(LaserFatherCharged __instance)
		{
			try
			{
				if (laserDurationMult.Value > 0f && laserDurationMult.Value != 1f)
				{
					__instance.duration *= laserDurationMult.Value;
					if (Object.op_Implicit((Object)(object)((EntityState)__instance).characterBody))
					{
						((EntityState)__instance).characterBody.SetAimTimer(__instance.duration);
					}
				}
				if (laserInvincible.Value)
				{
					BeginStateInvincible((EntityState)(object)__instance);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Laser of the Father: " + ex.Message));
			}
		}

		private static void SoulSpiralEnterPostfix(SoulSpiral __instance)
		{
			try
			{
				if (!(soulSpiralInvincibleSeconds.Value <= 0f) && NetworkServer.active && Object.op_Implicit((Object)(object)Buffs.HiddenRejectAllDamage))
				{
					CharacterBody val = BodyOf((EntityState)(object)__instance);
					if (Object.op_Implicit((Object)(object)val))
					{
						val.AddTimedBuff(Buffs.HiddenRejectAllDamage, soulSpiralInvincibleSeconds.Value);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Soul Spiral: " + ex.Message));
			}
		}

		private static void HarvestFruitPrefix(HealthPickup __instance)
		{
			try
			{
				if (!(harvestFruitHealing.Value <= 0f) && Object.op_Implicit((Object)(object)__instance))
				{
					Transform root = ((Component)__instance).transform.root;
					if (Object.op_Implicit((Object)(object)root) && ((Object)root).name.StartsWith("TreebotFruitPack", StringComparison.Ordinal))
					{
						__instance.fractionalHealing = harvestFruitHealing.Value / 100f;
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private static bool IsFalseSon(GameObject attacker)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//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)
			if (!Object.op_Implicit((Object)(object)attacker) || (int)falseSonIndex == -1)
			{
				return false;
			}
			CharacterBody component = attacker.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				return component.bodyIndex == falseSonIndex;
			}
			return false;
		}

		private static void LunarRuinDotPrefix(ref InflictDotInfo inflictDotInfo)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			try
			{
				int value = lunarRuinMaxStacks.Value;
				if (value > 0 && (int)inflictDotInfo.dotIndex == 9 && IsFalseSon(inflictDotInfo.attackerObject) && (!inflictDotInfo.maxStacksFromAttacker.HasValue || inflictDotInfo.maxStacksFromAttacker.Value > (uint)value))
				{
					inflictDotInfo.maxStacksFromAttacker = (uint)value;
				}
			}
			catch (Exception)
			{
			}
		}

		private static void LunarRuinHitPrefix(DamageInfo damageInfo, GameObject victim, out int __state)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Invalid comparison between Unknown and I4
			__state = 0;
			try
			{
				int value = lunarRuinMaxStacks.Value;
				if (value <= 0 || !NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)victim) || !Object.op_Implicit((Object)(object)Buffs.lunarruin) || (damageInfo.damageType.damageType & 0x40000000) == 0 || !IsFalseSon(damageInfo.attacker))
				{
					return;
				}
				CharacterBody component = victim.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					__state = 1;
					if (component.GetBuffCount(Buffs.lunarruin) >= value)
					{
						ref DamageType damageType = ref damageInfo.damageType.damageType;
						damageType = (DamageType)((uint)damageType & 0xBFFFFFFFu);
						__state = 2;
						bool flag = (damageInfo.damageType.damageTypeExtended & 0x20000000) > 0;
						RefreshLunarRuin(component, flag ? 420f : 5f);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Lunar Ruin cap: " + ex.Message));
			}
		}

		private static void LunarRuinHitPostfix(DamageInfo damageInfo, GameObject victim, int __state)
		{
			try
			{
				if (__state == 2 && damageInfo != null)
				{
					ref DamageType damageType = ref damageInfo.damageType.damageType;
					damageType = (DamageType)((uint)damageType | 0x40000000u);
				}
				if (__state != 1 || !Object.op_Implicit((Object)(object)victim))
				{
					return;
				}
				CharacterBody component = victim.GetComponent<CharacterBody>();
				int value = lunarRuinMaxStacks.Value;
				for (int i = 0; i < 10; i++)
				{
					if (!Object.op_Implicit((Object)(object)component))
					{
						break;
					}
					int buffCount = component.GetBuffCount(Buffs.lunarruin);
					if (buffCount > value)
					{
						component.RemoveOldestTimedBuff(Buffs.lunarruin);
						if (component.GetBuffCount(Buffs.lunarruin) >= buffCount)
						{
							break;
						}
						continue;
					}
					break;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Lunar Ruin cap: " + ex.Message));
			}
		}

		private static void RefreshLunarRuin(CharacterBody body, float duration)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			body.SetTimedBuffDurationIfPresent(Buffs.lunarruin, duration, true);
			DotController val = DotController.FindDotController(((Component)body).gameObject);
			if (!Object.op_Implicit((Object)(object)val) || val.dotStackList == null)
			{
				return;
			}
			foreach (DotStack dotStack in val.dotStackList)
			{
				if (dotStack != null && (int)dotStack.dotIndex == 9 && dotStack.timer < duration)
				{
					dotStack.timer = duration;
					if (dotStack.totalDuration < duration)
					{
						dotStack.totalDuration = duration;
					}
				}
			}
		}

		private static float ExposeCoefficient()
		{
			return exposeDamage.Value / 100f;
		}

		private static IEnumerable<CodeInstruction> ExposeTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo operand = AccessTools.Method(typeof(MiscellaneousBuffsPlugin), "ExposeCoefficient", (Type[])null, (Type[])null);
			int num = 0;
			bool flag = false;
			for (int i = 0; i < list.Count; i++)
			{
				if (flag)
				{
					break;
				}
				CodeInstruction val = list[i];
				if (val.opcode == OpCodes.Ldsfld && val.operand is FieldInfo { Name: "MercExpose" })
				{
					num = 60;
				}
				else if (num > 0)
				{
					num--;
					if (val.opcode == OpCodes.Ldc_R4 && val.operand is float num2 && Mathf.Abs(num2 - 3.5f) < 0.0001f)
					{
						val.opcode = OpCodes.Call;
						val.operand = operand;
						flag = true;
					}
				}
			}
			if (flag)
			{
				exposeHooked = true;
				if (!exposeLogged)
				{
					exposeLogged = true;
					Log.LogInfo((object)("Mercenary Expose damage " + 350f + "% -> " + exposeDamage.Value + "%"));
				}
			}
			else if (!exposeLogged)
			{
				exposeLogged = true;
				Log.LogWarning((object)"Mercenary Expose damage not found in the game code; it is unchanged.");
			}
			return list;
		}

		private static void OnLanguageChanged()
		{
			ApplyDescriptions();
		}

		private static string Num(float value)
		{
			return value.ToString("0.##", CultureInfo.InvariantCulture);
		}

		private static void ApplyDescriptions()
		{
			try
			{
				if (!updateDescriptions.Value || Language.currentLanguage == null)
				{
					return;
				}
				Rewrite("TOOLBOT_SPECIAL_ALT_DESCRIPTION", new string[2]
				{
					"100 armor",
					Num(powerModeArmor.Value) + " armor"
				});
				Rewrite("MAGE_PRIMARY_LIGHTNING_DESCRIPTION", new string[2]
				{
					"in a small area",
					"in a large area (<style=cIsDamage>" + Num(plasmaBoltRadius.Value) + "m</style>)"
				});
				if (polarFieldDeletes.Value)
				{
					Rewrite("RAILGUNNER_UTILITY_ALT_DESCRIPTION", new string[2] { "all nearby <style=cIsUtility>enemies and projectiles</style>", "all nearby <style=cIsUtility>enemies</style> and <style=cIsDamage>deletes</style> enemy <style=cIsUtility>projectiles</style>" });
				}
				Rewrite("SEEKER_SPECIAL_ALT1_DESCRIPTION", new string[4]
				{
					"400%-700% damage",
					Num(400f * palmDamage.Value) + "%-" + Num(700f * palmDamage.Value) + "% damage",
					"<style=cIsDamage>piercing</style>, spectral hand",
					"<style=cIsDamage>piercing</style>, " + ((palmSize.Value > 1f) ? "<style=cIsUtility>huge</style>, " : "") + ((palmSpeed.Value > 1f) ? "<style=cIsUtility>fast</style>, " : "") + ((palmRange.Value > 0f) ? "<style=cIsUtility>long-range</style> " : "") + "spectral hand"
				});
				if (exposeHooked)
				{
					Rewrite("KEYWORD_EXPOSE", new string[2]
					{
						"+350% damage",
						"+" + Num(exposeDamage.Value) + "% damage"
					});
				}
				List<string> list = new List<string>();
				if (animaEchoDuration.Value > 1f)
				{
					list.Add("Invoke an <style=cIsDamage>Echo of Acolyte</style>.");
					list.Add("Invoke an <style=cIsDamage>Echo of Acolyte</style>. Convictions drain <style=cIsUtility>" + Num((1f - 1f / animaEchoDuration.Value) * 100f) + "% slower</style>.");
				}
				if (animaEchoInvincible.Value)
				{
					list.Add("During the Litany, your melee attacks");
					list.Add("During the Litany, you are <style=cIsUtility>invincible</style>, your melee attacks");
				}
				if (list.Count > 0)
				{
					Rewrite("ACOLYTE_SPECIAL_ALT_TRANSFORM_DESCRIPTION", list.ToArray());
				}
				Rewrite("ACOLYTE_SPECIAL_DESCRIPTION", (!sacrificeKillBonus.Value) ? new string[4]
				{
					"gain 2 <style=cIsDamage>Convictions</style>",
					"gain " + sacrificeConvictions.Value + " <style=cIsDamage>Convictions</style>",
					" Kills grant an extra Conviction.",
					""
				} : new string[2]
				{
					"gain 2 <style=cIsDamage>Convictions</style>",
					"gain " + sacrificeConvictions.Value + " <style=cIsDamage>Convictions</style>"
				});
				if (favorArmor.Value != 20f)
				{
					Rewrite("ACOLYTE_PASSIVE_DESCRIPTION", new string[2]
					{
						"into <style=cIsDamage>attack speed</style>.",
						"into <style=cIsDamage>attack speed</style>. Gain <style=cIsUtility>+" + Num(favorArmor.Value) + " armor</style>."
					});
				}
				Rewrite("RAILGUNNER_SECONDARY_ALT_DESCRIPTION", new string[2]
				{
					"<style=cIsDamage>400% damage</style>",
					"<style=cIsDamage>" + Num(marksmanDamage.Value) + "% damage</style>"
				});
				Rewrite("SEEKER_SECONDARY_DESCRIPTION", (!unseenHandTeleport.Value) ? new string[2]
				{
					"<style=cIsDamage>600% damage</style>",
					"<style=cIsDamage>" + Num(unseenHandDamage.Value) + "% damage</style>"
				} : new string[4]
				{
					"<style=cIsDamage>600% damage</style>",
					"<style=cIsDamage>" + Num(unseenHandDamage.Value) + "% damage</style>",
					"from the ground, dealing",
					"from the ground and <style=cIsUtility>teleport</style> to it, dealing"
				});
				float num = ((tornadoDamage.Value > 0f) ? tornadoDamage.Value : 1f);
				Rewrite("DRIFTER_UTILITY_ALT_DESCRIPTION", new string[6]
				{
					"Spin forwards",
					(tornadoInvincible.Value ? "<style=cIsUtility>Invincible</style>. " : "") + "Spin forwards",
					"<style=cIsDamage>220% damage</style>",
					"<style=cIsDamage>" + Num(220f * num) + "% damage</style>",
					"<style=cIsDamage>600%</style>",
					"<style=cIsDamage>" + Num(600f * num) + "%</style>"
				});
				Rewrite("DRIFTER_UTILITY_ALT_A_DESCRIPTION", new string[2]
				{
					"<style=cIsDamage>400%</style>",
					"<style=cIsDamage>" + Num(400f * num) + "%</style>"
				});
				if (!string.IsNullOrEmpty(acolytePrimaryToken))
				{
					string[] pairs = new string[4]
					{
						"150%",
						Num(acolyteP

NoSonorousWhispers.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace NoSonorousWhispers
{
	[BepInPlugin("custom.NoSonorousWhispers", "NoSonorousWhispers", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class NoSonorousWhispersPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private static readonly Dictionary<ItemIndex, int> bannedItems = new Dictionary<ItemIndex, int>();

		private static readonly HashSet<PickupIndex> bannedPickups = new HashSet<PickupIndex>();

		private static bool resolved;

		private static readonly Random rng = new Random();

		private static MethodInfo qGetItemOfQuality;

		private static MethodInfo qGetPickupOfQuality;

		private static Type qTierType;

		private static readonly FieldInfo fAllRecipes = AccessTools.Field(typeof(CraftableCatalog), "allRecipes");

		private static readonly FieldInfo fCraftableDefs = AccessTools.Field(typeof(CraftableCatalog), "craftableDefs");

		private static readonly FieldInfo fIngredientTable = AccessTools.Field(typeof(CraftableCatalog), "pickupToIngredientSearchTable");

		private static readonly FieldInfo fResultTable = AccessTools.Field(typeof(CraftableCatalog), "resultToRecipeSearchTable");

		private static readonly FieldInfo fEntryResult = AccessTools.Field(typeof(RecipeEntry), "result");

		private static readonly FieldInfo fEntrySlots = AccessTools.Field(typeof(RecipeEntry), "possibleIngredients");

		private static readonly FieldInfo fSlotPickups = AccessTools.Field(typeof(IngredientSlotEntry), "pickups");

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony h = new Harmony("custom.NoSonorousWhispers");
			Postfix(h, AccessTools.Method(typeof(Run), "BuildDropTable", (Type[])null, (Type[])null), "BuildDropTablePostfix");
			Prefix(h, AccessTools.Method(typeof(GenericPickupController), "CreatePickup", (Type[])null, (Type[])null), "CreatePickupPrefix");
			Prefix(h, AccessTools.Method(typeof(PickupPickerController), "SetOptionsServer", (Type[])null, (Type[])null), "PickerOptionsPrefix");
			Prefix(h, AccessTools.Method(typeof(PickupPickerController), "SetOptionsInternal", (Type[])null, (Type[])null), "PickerOptionsPrefix");
			MethodInfo[] methods = typeof(ShopTerminalBehavior).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo in methods)
			{
				ParameterInfo[] parameters = methodInfo.GetParameters();
				if (methodInfo.Name == "SetPickupIndex" && parameters.Length > 0 && parameters[0].ParameterType == typeof(PickupIndex))
				{
					Prefix(h, methodInfo, "ShopPickupIndexPrefix");
				}
				else if (methodInfo.Name == "SetPickup" && parameters.Length > 0 && parameters[0].ParameterType == typeof(UniquePickup))
				{
					Prefix(h, methodInfo, "ShopUniquePickupPrefix");
				}
			}
			MethodInfo[] methods2 = typeof(Inventory).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo methodInfo2 in methods2)
			{
				ParameterInfo[] parameters2 = methodInfo2.GetParameters();
				if (methodInfo2.Name.StartsWith("GiveItem", StringComparison.Ordinal) && parameters2.Length > 0 && parameters2[0].ParameterType == typeof(ItemIndex))
				{
					Prefix(h, methodInfo2, "GiveItemPrefix");
				}
			}
			Type typeFromHandle = typeof(CraftableCatalog);
			Postfix(h, AccessTools.Method(typeFromHandle, "Init", (Type[])null, (Type[])null), "PurgeCraftingPostfix");
			Postfix(h, AccessTools.Method(typeFromHandle, "SetCraftableDefs", (Type[])null, (Type[])null), "PurgeCraftingPostfix");
			string[] array = new string[4] { "FindApplicableRecipesByIngredients", "FindRecipesThatCanAcceptIngredients", "FindAllRelatedRecipes", "GetAllRecipes" };
			foreach (string text in array)
			{
				Postfix(h, AccessTools.Method(typeFromHandle, text, (Type[])null, (Type[])null), "FilterRecipeArrayPostfix");
			}
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				Resolve();
				PurgeCrafting();
			});
			Run.onRunStartGlobal += delegate(Run run)
			{
				Resolve();
				PurgeCrafting();
				PurgeRun(run);
			};
		}

		private void Prefix(Harmony h, MethodBase m, string name)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			if (m == null)
			{
				Log.LogWarning((object)("Hook target missing for " + name));
				return;
			}
			try
			{
				h.Patch(m, new HarmonyMethod(typeof(NoSonorousWhispersPlugin), name, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)string.Concat("Hook failed ", m.DeclaringType, ".", m.Name, ": ", ex.Message));
			}
		}

		private void Postfix(Harmony h, MethodBase m, string name)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			if (m == null)
			{
				Log.LogWarning((object)("Hook target missing for " + name));
				return;
			}
			try
			{
				HarmonyMethod val = new HarmonyMethod(typeof(NoSonorousWhispersPlugin), name, (Type[])null);
				h.Patch(m, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)string.Concat("Hook failed ", m.DeclaringType, ".", m.Name, ": ", ex.Message));
			}
		}

		private static void Resolve()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Invalid comparison between Unknown and I4
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Invalid comparison between Unknown and I4
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ItemDef itemDropChanceOnKill = Items.ItemDropChanceOnKill;
				if (!Object.op_Implicit((Object)(object)itemDropChanceOnKill) || (int)itemDropChanceOnKill.itemIndex == -1 || (resolved && bannedItems.Count > 1))
				{
					return;
				}
				bannedItems.Clear();
				bannedPickups.Clear();
				Ban(itemDropChanceOnKill.itemIndex, -1);
				Type type = AccessTools.TypeByName("ItemQualities.QualityCatalog");
				qTierType = AccessTools.TypeByName("ItemQualities.QualityTier");
				if (type != null && qTierType != null)
				{
					qGetItemOfQuality = AccessTools.Method(type, "GetItemIndexOfQuality", new Type[2]
					{
						typeof(ItemIndex),
						qTierType
					}, (Type[])null);
					qGetPickupOfQuality = AccessTools.Method(type, "GetPickupIndexOfQuality", new Type[2]
					{
						typeof(PickupIndex),
						qTierType
					}, (Type[])null);
					if (qGetItemOfQuality != null)
					{
						for (int i = 0; i <= 3; i++)
						{
							try
							{
								ItemIndex val = (ItemIndex)qGetItemOfQuality.Invoke(null, new object[2]
								{
									itemDropChanceOnKill.itemIndex,
									Enum.ToObject(qTierType, i)
								});
								if ((int)val != -1 && val != itemDropChanceOnKill.itemIndex)
								{
									Ban(val, i);
								}
							}
							catch
							{
							}
						}
					}
				}
				Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						ItemDef current = enumerator.Current;
						if (Object.op_Implicit((Object)(object)current) && (int)current.itemIndex != -1 && !bannedItems.ContainsKey(current.itemIndex) && ((Object)current).name != null && ((Object)current).name.StartsWith("ItemDropChanceOnKill", StringComparison.OrdinalIgnoreCase))
						{
							Ban(current.itemIndex, -1);
						}
					}
				}
				finally
				{
					((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				resolved = true;
				Log.LogInfo((object)("Banned " + bannedItems.Count + " Sonorous Whispers item(s)."));
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void Ban(ItemIndex idx, int quality)
		{
			//IL_0005: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0028: Unknown result type (might be due to invalid IL or missing references)
			bannedItems[idx] = quality;
			PickupIndex val = PickupCatalog.FindPickupIndex(idx);
			if (val != PickupIndex.none)
			{
				bannedPickups.Add(val);
			}
		}

		private static bool IsBanned(PickupIndex p)
		{
			//IL_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			if (!resolved)
			{
				Resolve();
			}
			return p != PickupIndex.none && bannedPickups.Contains(p);
		}

		private static bool IsBanned(ItemIndex i)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!resolved)
			{
				Resolve();
			}
			return (int)i != -1 && bannedItems.ContainsKey(i);
		}

		private static List<PickupIndex> ListForTier(Run run, ItemTier tier)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected I4, but got Unknown
			if (!Object.op_Implicit((Object)(object)run))
			{
				return null;
			}
			return (int)tier switch
			{
				0 => run.availableTier1DropList, 
				1 => run.availableTier2DropList, 
				2 => run.availableTier3DropList, 
				4 => run.availableBossDropList, 
				3 => run.availableLunarItemDropList, 
				6 => run.availableVoidTier1DropList, 
				7 => run.availableVoidTier2DropList, 
				8 => run.availableVoidTier3DropList, 
				9 => run.availableVoidBossDropList, 
				_ => run.availableTier3DropList, 
			};
		}

		private static PickupIndex Replacement(ItemIndex banned)
		{
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_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_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_009b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ItemDef itemDropChanceOnKill = Items.ItemDropChanceOnKill;
				ItemTier tier = (ItemTier)((!Object.op_Implicit((Object)(object)itemDropChanceOnKill)) ? 2 : ((int)itemDropChanceOnKill.tier));
				List<PickupIndex> list = ListForTier(Run.instance, tier);
				if (list == null)
				{
					return PickupIndex.none;
				}
				List<PickupIndex> list2 = list.Where((PickupIndex p) => !IsBanned(p)).ToList();
				if (list2.Count == 0)
				{
					return PickupIndex.none;
				}
				PickupIndex val = list2[rng.Next(list2.Count)];
				if (bannedItems.TryGetValue(banned, out var value) && value >= 0 && qGetPickupOfQuality != null)
				{
					try
					{
						PickupIndex val2 = (PickupIndex)qGetPickupOfQuality.Invoke(null, new object[2]
						{
							val,
							Enum.ToObject(qTierType, value)
						});
						if (val2 != PickupIndex.none && !IsBanned(val2))
						{
							val = val2;
						}
					}
					catch
					{
					}
				}
				return val;
			}
			catch
			{
				return PickupIndex.none;
			}
		}

		private static ItemIndex ItemOf(PickupIndex p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			PickupDef pickupDef = PickupCatalog.GetPickupDef(p);
			return (ItemIndex)((pickupDef == null) ? (-1) : ((int)pickupDef.itemIndex));
		}

		private static void BuildDropTablePostfix(Run __instance)
		{
			PurgeRun(__instance);
		}

		private static void PurgeRun(Run run)
		{
			//IL_00b9: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)run))
			{
				return;
			}
			Resolve();
			if (bannedItems.Count == 0)
			{
				return;
			}
			try
			{
				FieldInfo[] fields = typeof(Run).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (!(fieldInfo.FieldType != typeof(List<PickupIndex>)) && fieldInfo.GetValue(run) is List<PickupIndex> list)
					{
						list.RemoveAll((PickupIndex p) => bannedPickups.Contains(p));
					}
				}
				foreach (ItemIndex key in bannedItems.Keys)
				{
					try
					{
						run.availableItems.Remove(key);
					}
					catch
					{
					}
				}
				try
				{
					PickupDropTable.RegenerateAll(run);
				}
				catch
				{
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static bool CreatePickupPrefix(ref CreatePickupInfo createPickupInfo)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PickupIndex pickupIndex = ((CreatePickupInfo)(ref createPickupInfo)).pickupIndex;
				if (!IsBanned(pickupIndex))
				{
					return true;
				}
				PickupIndex val = Replacement(ItemOf(pickupIndex));
				if (val == PickupIndex.none)
				{
					return false;
				}
				((CreatePickupInfo)(ref createPickupInfo)).pickupIndex = val;
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return true;
		}

		private static void ShopPickupIndexPrefix(ref PickupIndex __0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			if (IsBanned(__0))
			{
				__0 = Replacement(ItemOf(__0));
			}
		}

		private static void ShopUniquePickupPrefix(ref UniquePickup __0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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)
			if (IsBanned(__0.pickupIndex))
			{
				__0.pickupIndex = Replacement(ItemOf(__0.pickupIndex));
			}
		}

		private static void PickerOptionsPrefix(ref Option[] __0)
		{
			if (__0 != null && __0.Any((Option o) => IsBanned(o.pickup.pickupIndex)))
			{
				__0 = __0.Where((Option o) => !IsBanned(o.pickup.pickupIndex)).ToArray();
			}
		}

		private static bool GiveItemPrefix(ref ItemIndex __0)
		{
			//IL_001a: 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)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Invalid comparison between Unknown and I4
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected I4, but got Unknown
			if (!NetworkServer.active || !IsBanned(__0))
			{
				return true;
			}
			ItemIndex val = ItemOf(Replacement(__0));
			if ((int)val == -1)
			{
				return false;
			}
			__0 = (ItemIndex)(int)val;
			return true;
		}

		private static void PurgeCraftingPostfix()
		{
			PurgeCrafting();
		}

		private static void FilterRecipeArrayPostfix(ref RecipeEntry[] __result)
		{
			if (__result != null && bannedPickups.Count != 0 && __result.Any(RecipeBanned))
			{
				__result = __result.Where((RecipeEntry r) => !RecipeBanned(r)).ToArray();
			}
		}

		private static bool RecipeBanned(RecipeEntry r)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (r == null)
			{
				return true;
			}
			try
			{
				if (IsBanned((PickupIndex)fEntryResult.GetValue(r)))
				{
					return true;
				}
				if (!(fEntrySlots.GetValue(r) is IngredientSlotEntry[] array))
				{
					return false;
				}
				IngredientSlotEntry[] array2 = array;
				foreach (IngredientSlotEntry val in array2)
				{
					PickupIndex[] array3 = ((val == null) ? null : (fSlotPickups.GetValue(val) as PickupIndex[]));
					if (array3 != null && array3.Length > 0 && array3.All(IsBanned))
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static void PurgeCrafting()
		{
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			Resolve();
			if (bannedPickups.Count == 0)
			{
				return;
			}
			int num = 0;
			try
			{
				List<RecipeEntry> list = ((!(fAllRecipes != null)) ? null : (fAllRecipes.GetValue(null) as List<RecipeEntry>));
				if (list != null)
				{
					num += list.RemoveAll(RecipeBanned);
					foreach (RecipeEntry item in list)
					{
						if (!(fEntrySlots.GetValue(item) is IngredientSlotEntry[] array))
						{
							continue;
						}
						IngredientSlotEntry[] array2 = array;
						foreach (IngredientSlotEntry val in array2)
						{
							PickupIndex[] array3 = ((val == null) ? null : (fSlotPickups.GetValue(val) as PickupIndex[]));
							if (array3 != null && array3.Any(IsBanned))
							{
								fSlotPickups.SetValue(val, array3.Where((PickupIndex p) => !IsBanned(p)).ToArray());
							}
						}
					}
					HashSet<RecipeEntry> keep = new HashSet<RecipeEntry>(list);
					FieldInfo[] array4 = new FieldInfo[2] { fIngredientTable, fResultTable };
					foreach (FieldInfo fieldInfo in array4)
					{
						Dictionary<PickupIndex, List<RecipeEntry>> dictionary = ((!(fieldInfo != null)) ? null : (fieldInfo.GetValue(null) as Dictionary<PickupIndex, List<RecipeEntry>>));
						if (dictionary == null)
						{
							continue;
						}
						foreach (PickupIndex bannedPickup in bannedPickups)
						{
							dictionary.Remove(bannedPickup);
						}
						foreach (KeyValuePair<PickupIndex, List<RecipeEntry>> item2 in dictionary)
						{
							item2.Value.RemoveAll((RecipeEntry e) => !keep.Contains(e));
						}
					}
				}
				CraftableDef[] array5 = ((!(fCraftableDefs != null)) ? null : (fCraftableDefs.GetValue(null) as CraftableDef[]));
				if (array5 != null)
				{
					CraftableDef[] array6 = array5.Where((CraftableDef d) => Object.op_Implicit((Object)(object)d) && !IsBanned(d.itemIndex)).ToArray();
					CraftableDef[] array7 = array6;
					foreach (CraftableDef val2 in array7)
					{
						if (val2.recipes == null)
						{
							continue;
						}
						val2.recipes = val2.recipes.Where((Recipe r) => r == null || r.ingredients == null || !r.ingredients.Any((RecipeIngredient val3) => val3 != null && IsBanned(val3.pickupIndex))).ToArray();
					}
					if (array6.Length != array5.Length)
					{
						fCraftableDefs.SetValue(null, array6);
						num += array5.Length - array6.Length;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Crafting purge failed: " + ex));
			}
			if (num > 0)
			{
				Log.LogInfo((object)("Removed " + num + " Sonorous Whispers recipe(s)."));
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

OmniSprint.dll

Decompiled 7 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OmniSprint")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OmniSprint")]
[assembly: AssemblyTitle("OmniSprint")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[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 OmniSprint
{
	[BepInPlugin("tpq.OmniSprint", "OmniSprint", "1.0.0")]
	public class OmniSprintPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "tpq.OmniSprint";

		public const string PluginName = "OmniSprint";

		public const string PluginVersion = "1.0.0";

		private void Awake()
		{
			PlayerCharacterMasterController.onPlayerAdded += OnPlayerAdded;
		}

		private static void OnPlayerAdded(PlayerCharacterMasterController player)
		{
			player.master.onBodyStart += OnBodyStart;
		}

		private static void OnBodyStart(CharacterBody body)
		{
			//IL_0003: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			body.bodyFlags = (BodyFlags)(body.bodyFlags | 0x20);
		}
	}
}

OneShotRework.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.VoidRaidCrab;
using HarmonyLib;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Audio;
using RoR2.ContentManagement;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace OneShotRework
{
	internal static class AkStop
	{
		private static MethodInfo stop;

		private static MethodInfo stopAny;

		private static bool searched;

		internal static void Stop(uint id)
		{
			if (id == 0)
			{
				return;
			}
			try
			{
				if (!searched)
				{
					searched = true;
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					foreach (Assembly assembly in assemblies)
					{
						Type type = null;
						try
						{
							type = assembly.GetType("AkSoundEngine", throwOnError: false);
						}
						catch
						{
						}
						if (!(type == null))
						{
							stop = type.GetMethod("StopPlayingID", new Type[1] { typeof(uint) });
							if (stop != null)
							{
								break;
							}
						}
					}
				}
				if (stop != null)
				{
					stop.Invoke(null, new object[1] { id });
					return;
				}
				if (stopAny == null)
				{
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					foreach (Assembly assembly2 in assemblies)
					{
						Type type2 = null;
						try
						{
							type2 = assembly2.GetType("AkSoundEngine", throwOnError: false);
						}
						catch
						{
						}
						if (type2 == null)
						{
							continue;
						}
						MethodInfo[] methods = type2.GetMethods();
						foreach (MethodInfo methodInfo in methods)
						{
							ParameterInfo[] parameters = methodInfo.GetParameters();
							if (methodInfo.Name == "StopPlayingID" && parameters.Length != 0 && parameters[0].ParameterType == typeof(uint))
							{
								stopAny = methodInfo;
								break;
							}
						}
						if (stopAny != null)
						{
							break;
						}
					}
				}
				if (stopAny != null)
				{
					ParameterInfo[] parameters2 = stopAny.GetParameters();
					object[] array = new object[parameters2.Length];
					array[0] = id;
					for (int k = 1; k < parameters2.Length; k++)
					{
						array[k] = ((!(parameters2[k].ParameterType == typeof(int))) ? ((!parameters2[k].ParameterType.IsValueType) ? null : Activator.CreateInstance(parameters2[k].ParameterType)) : ((object)0));
					}
					stopAny.Invoke(null, array);
				}
			}
			catch
			{
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("custom.OneShotRework", "OneShotRework", "1.6.4")]
	public class OneShotReworkPlugin : BaseUnityPlugin
	{
		private class Provider : IContentPackProvider
		{
			private readonly ContentPack pack = new ContentPack();

			public string identifier => "custom.OneShotRework";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.OneShotRework", null);
				}
				catch
				{
				}
				pack.buffDefs.Add((BuffDef[])(object)new BuffDef[4] { ReadyBuff, ActiveBuff, CooldownBuff, EmpowerBuff });
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(pack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		private struct HitState
		{
			public bool addedNonLethal;

			public OSPState state;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__46_0;

			public static Action<AsyncOperationHandle<GameObject>> <>9__46_1;

			public static Func<Dictionary<string, string>> <>9__46_4;

			public static Func<string> <>9__46_5;

			public static EventHandler<SettingChangedEventArgs> <>9__46_6;

			public static Action<AsyncOperationHandle<BuffDef>> <>9__55_0;

			public static Action<AsyncOperationHandle<BuffDef>> <>9__55_1;

			internal void <Awake>b__46_0(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new Provider());
			}

			internal void <Awake>b__46_1(AsyncOperationHandle<GameObject> h)
			{
				try
				{
					EffectComponent val = ((!Object.op_Implicit((Object)(object)h.Result)) ? null : h.Result.GetComponent<EffectComponent>());
					if (Object.op_Implicit((Object)(object)val) && !string.IsNullOrEmpty(val.soundName))
					{
						ImplosionSound = val.soundName;
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)ex.Message);
				}
			}

			internal Dictionary<string, string> <Awake>b__46_4()
			{
				//IL_000b: 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)
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string text = LGCompat.KeyName(ManualKey.Value);
				string text2 = LGCompat.KeyName(ShieldKey.Value);
				LGCompat.Add(dictionary, ReadyBuff, "One-Shot Protection Ready", "A fatal hit leaves you at <style=cIsHealing>1 HP</style> with <style=cIsUtility>" + InvincibleTime.Value + "s invincibility</style> and <style=cIsUtility>removes all curse</style>." + ((!ShieldKeyEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text2 + "]</style> to manually trigger the invincibility.")) + ((!ManualEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text + "]</style> to spend it on a significant damage boost instead.")));
				LGCompat.Add(dictionary, ActiveBuff, "One-Shot Protection Active", "<style=cIsUtility>Invincible.</style> Recharges afterwards.");
				LGCompat.Add(dictionary, EmpowerBuff, "Empowered", "Damage multiplier rises from <style=cIsDamage>" + ManualDamageMult.Value + "x</style> to <style=cIsDamage>" + ManualDamageMultEnd.Value + "x</style> over <style=cIsUtility>" + ManualDuration.Value + "s</style>.");
				LGCompat.Add(dictionary, CooldownBuff, "One-Shot Protection Recharging", "Recharges after <style=cIsUtility>" + CooldownTime.Value + "s</style> without getting hit while at <style=cIsHealing>full health</style>. Getting hit restarts the timer.");
				return dictionary;
			}

			internal string <Awake>b__46_5()
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				string text = ((!ManualEnabled.Value) ? null : LGCompat.KeyName(ManualKey.Value));
				string text2 = ((!ShieldKeyEnabled.Value) ? null : LGCompat.KeyName(ShieldKey.Value));
				if (text != null && text2 != null)
				{
					return text + "/" + text2;
				}
				return text ?? text2 ?? string.Empty;
			}

			internal void <Awake>b__46_6(object <p0>, SettingChangedEventArgs <p1>)
			{
				LGCompat.Apply();
			}

			internal void <CreateBuffs>b__55_0(AsyncOperationHandle<BuffDef> h)
			{
				if (!Object.op_Implicit((Object)(object)h.Result))
				{
					Log.LogWarning((object)"bdImmune not found");
					return;
				}
				ReadyBuff.iconSprite = h.Result.iconSprite;
				ActiveBuff.iconSprite = h.Result.iconSprite;
				EmpowerBuff.iconSprite = h.Result.iconSprite;
			}

			internal void <CreateBuffs>b__55_1(AsyncOperationHandle<BuffDef> h)
			{
				if (!Object.op_Implicit((Object)(object)h.Result))
				{
					Log.LogWarning((object)"bdPermanentCurse not found");
				}
				else
				{
					CooldownBuff.iconSprite = h.Result.iconSprite;
				}
			}
		}

		public const string GUID = "custom.OneShotRework";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> DisableVanilla;

		internal static ConfigEntry<bool> PlayersOnly;

		internal static ConfigEntry<bool> CountSelfDamage;

		internal static ConfigEntry<bool> ScreenTint;

		internal static ConfigEntry<float> TintStrength;

		internal static ConfigEntry<float> InvincibleTime;

		internal static ConfigEntry<float> CooldownTime;

		internal static ConfigEntry<string> SoundOverride;

		internal static ConfigEntry<string> ManualSound;

		internal static ConfigEntry<bool> RemoveCurse;

		internal static ConfigEntry<bool> ManualEnabled;

		internal static ConfigEntry<float> ManualDuration;

		internal static ConfigEntry<float> ManualDamageMult;

		internal static ConfigEntry<float> ManualDamageMultEnd;

		internal static readonly Dictionary<CharacterBody, float> empowerStart = new Dictionary<CharacterBody, float>();

		private static readonly List<CharacterBody> empTmp = new List<CharacterBody>();

		internal static ConfigEntry<KeyboardShortcut> ManualKey;

		internal static ConfigEntry<KeyboardShortcut> ShieldKey;

		internal static ConfigEntry<bool> ShieldKeyEnabled;

		internal static ConfigEntry<string> NoFullHpBodies;

		internal static ConfigEntry<bool> VoidEnabled;

		internal static ConfigEntry<string> VoidScenes;

		internal static ConfigEntry<float> VoidCooldown;

		internal static ConfigEntry<bool> VoidInstantFromPhase9;

		internal static ConfigEntry<float> InstantEmpowerVolume;

		private static PropertyInfo voidlingStage;

		private static bool voidlingLookedUp;

		private static string sceneCache;

		private static bool sceneIsVoid;

		internal static BuffDef ReadyBuff;

		internal static BuffDef ActiveBuff;

		internal static BuffDef CooldownBuff;

		internal static BuffDef EmpowerBuff;

		internal const string Cmd = "osp_empower";

		internal const string ShieldCmd = "osp_shield";

		internal static string ImplosionSound;

		private static Action<CharacterBody, float> setOspFraction;

		private static Action<CharacterBody, bool> setHasOsp;

		internal static bool InVoidScene()
		{
			if (!VoidEnabled.Value)
			{
				return false;
			}
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			string text = (Object.op_Implicit((Object)(object)mostRecentSceneDef) ? mostRecentSceneDef.cachedName : string.Empty);
			if (text != sceneCache)
			{
				sceneCache = text;
				sceneIsVoid = false;
				string[] array = VoidScenes.Value.Split(new char[1] { ',' });
				foreach (string text2 in array)
				{
					if (text2.Trim().Length > 0 && string.Equals(text2.Trim(), text, StringComparison.OrdinalIgnoreCase))
					{
						sceneIsVoid = true;
						break;
					}
				}
			}
			return sceneIsVoid;
		}

		internal static int VoidlingStage()
		{
			if (!voidlingLookedUp)
			{
				voidlingLookedUp = true;
				try
				{
					Type type = AccessTools.TypeByName("VoidlingRework.VoidlingReworkPlugin");
					voidlingStage = ((type == null) ? null : type.GetProperty("FightStage", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic));
				}
				catch
				{
				}
			}
			try
			{
				return (!(voidlingStage == null)) ? ((int)voidlingStage.GetValue(null, null)) : 0;
			}
			catch
			{
				return 0;
			}
		}

		internal static bool InstantRecharge()
		{
			if (VoidEnabled.Value && VoidInstantFromPhase9.Value && InVoidScene())
			{
				return VoidlingStage() >= 40;
			}
			return false;
		}

		internal static float EffectiveCooldown()
		{
			if (!InVoidScene())
			{
				return CooldownTime.Value;
			}
			return Mathf.Max(0f, VoidCooldown.Value);
		}

		private void Awake()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Expected O, but got Unknown
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Expected O, but got Unknown
			//IL_04e1: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			DisableVanilla = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableVanillaOneShotProtection", true, "Remove the vanilla one-shot protection.");
			PlayersOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayersOnly", true, "Only player-controlled survivors get the reworked protection.");
			CountSelfDamage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SelfDamageCountsAsHit", false, "If true, damage you deal to yourself also resets the timers.");
			InvincibleTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "InvincibilityDuration", 3f, "Seconds of invincibility after the protection triggers.");
			CooldownTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "CooldownTime", 20f, "Seconds the protection takes to recharge. It only charges while your health is full (shields and barrier don't count; curse lowers the full mark) and restarts every time you are hit.");
			RemoveCurse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveCurseOnTrigger", true, "When the protection saves you from a fatal hit, all curse stacks are removed.");
			ManualEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Empower", "Enabled", true, "Press the key while the protection is ready to spend it on a damage boost instead.");
			ManualKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Empower", "Key", new KeyboardShortcut((KeyCode)103, Array.Empty<KeyCode>()), "Key to spend the ready protection on the damage boost.");
			ManualDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "Duration", 5f, "Seconds the damage boost lasts.");
			ManualDamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "StartDamageMultiplier", 4f, "Damage multiplier when the boost starts. It rises linearly to EndDamageMultiplier over the boost duration.");
			ManualDamageMultEnd = ((BaseUnityPlugin)this).Config.Bind<float>("Empower", "EndDamageMultiplier", 24f, "Damage multiplier reached at the end of the boost.");
			NoFullHpBodies = ((BaseUnityPlugin)this).Config.Bind<string>("Timing", "NoFullHealthNeeded", "Acolyte", "Comma-separated survivors (body name or display name, partial match) that recharge without needing full health.");
			ShieldKeyEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("ManualShield", "Enabled", true, "Press the key while the protection is ready to trigger its invincibility (and curse removal) right away.");
			ShieldKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("ManualShield", "Key", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), "Key to trigger the ready protection's invincibility manually.");
			ManualSound = ((BaseUnityPlugin)this).Config.Bind<string>("Empower", "SoundEvent", "@voidling_spinbeam", "Sound played while the boost is active. @voidling_spinbeam = the voidling's giant sustained spinning laser (cut off when the boost ends). Any other value is played once as a Wwise event.");
			ScreenTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ScreenTint", true, "Tint your screen dark purple while the invincibility is active.");
			TintStrength = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ScreenTintStrength", 0.55f, "Opacity of the screen tint (0-1).");
			SoundOverride = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "SoundEventOverride", string.Empty, "Wwise sound event to play on activation. Empty = the Void Reaver implosion sound.");
			VoidEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Void", "Enabled", true, "In the void stages below the protection recharges faster and without full health, and from VoidlingRework's phase 9 on it recharges as soon as it ends.");
			VoidScenes = ((BaseUnityPlugin)this).Config.Bind<string>("Void", "Scenes", "arena,voidstage,voidraid", "Comma-separated scene names that count as void stages (Void Fields, Void Locus, Planetarium).");
			VoidCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Void", "CooldownTime", 10f, "Recharge time in the void stages. Full health isn't needed there (getting hit still restarts it).");
			VoidInstantFromPhase9 = ((BaseUnityPlugin)this).Config.Bind<bool>("Void", "InstantFromVoidlingPhase9", true, "From VoidlingRework's phase 9 on (through to the end of its final battle, phase 12), the protection is ready again as soon as its invincibility or the damage boost ends, and it works against every attack: void implosions (Voidling's and Void Reavers' black holes) and other instant kills trigger it like any fatal hit, and nothing gets through its invincibility.");
			InstantEmpowerVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Void", "EmpowerVolumeWithoutCooldown", 0.5f, "Volume of the damage boost's sound while the protection has no cooldown (VoidlingRework's phase 9 on). 1 = normal.");
			CreateBuffs();
			object obj = <>c.<>9__46_0;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
				{
					add.Invoke((IContentPackProvider)(object)new Provider());
				};
				<>c.<>9__46_0 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			AsyncOperationHandle<GameObject> val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Nullifier/NullifierDeathBombExplosion.prefab");
			val2.Completed += delegate(AsyncOperationHandle<GameObject> h)
			{
				try
				{
					EffectComponent val5 = ((!Object.op_Implicit((Object)(object)h.Result)) ? null : h.Result.GetComponent<EffectComponent>());
					if (Object.op_Implicit((Object)(object)val5) && !string.IsNullOrEmpty(val5.soundName))
					{
						ImplosionSound = val5.soundName;
					}
				}
				catch (Exception ex2)
				{
					Log.LogWarning((object)ex2.Message);
				}
			};
			MethodInfo f = AccessTools.PropertySetter(typeof(CharacterBody), "oneShotProtectionFraction");
			if (f != null)
			{
				setOspFraction = delegate(CharacterBody b, float v)
				{
					f.Invoke(b, new object[1] { v });
				};
			}
			MethodInfo hs = AccessTools.PropertySetter(typeof(CharacterBody), "hasOneShotProtection");
			if (hs != null)
			{
				setHasOsp = delegate(CharacterBody b, bool v)
				{
					hs.Invoke(b, new object[1] { v });
				};
			}
			Harmony val3 = new Harmony("custom.OneShotRework");
			MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null);
			HarmonyMethod val4 = new HarmonyMethod(typeof(OneShotReworkPlugin), "RecalcPostfix", (Type[])null);
			val3.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val4, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			val3.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(OneShotReworkPlugin), "TakeDamagePrefix", (Type[])null)
			{
				priority = 200
			}, new HarmonyMethod(typeof(OneShotReworkPlugin), "TakeDamagePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			LGCompat.Init(val3);
			LGCompat.Builder = delegate
			{
				//IL_000b: 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)
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string text = LGCompat.KeyName(ManualKey.Value);
				string text2 = LGCompat.KeyName(ShieldKey.Value);
				LGCompat.Add(dictionary, ReadyBuff, "One-Shot Protection Ready", "A fatal hit leaves you at <style=cIsHealing>1 HP</style> with <style=cIsUtility>" + InvincibleTime.Value + "s invincibility</style> and <style=cIsUtility>removes all curse</style>." + ((!ShieldKeyEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text2 + "]</style> to manually trigger the invincibility.")) + ((!ManualEnabled.Value) ? string.Empty : (" Press <style=cIsDamage>[" + text + "]</style> to spend it on a significant damage boost instead.")));
				LGCompat.Add(dictionary, ActiveBuff, "One-Shot Protection Active", "<style=cIsUtility>Invincible.</style> Recharges afterwards.");
				LGCompat.Add(dictionary, EmpowerBuff, "Empowered", "Damage multiplier rises from <style=cIsDamage>" + ManualDamageMult.Value + "x</style> to <style=cIsDamage>" + ManualDamageMultEnd.Value + "x</style> over <style=cIsUtility>" + ManualDuration.Value + "s</style>.");
				LGCompat.Add(dictionary, CooldownBuff, "One-Shot Protection Recharging", "Recharges after <style=cIsUtility>" + CooldownTime.Value + "s</style> without getting hit while at <style=cIsHealing>full health</style>. Getting hit restarts the timer.");
				return dictionary;
			};
			LGCompat.IconText[ReadyBuff] = delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				string text = ((!ManualEnabled.Value) ? null : LGCompat.KeyName(ManualKey.Value));
				string text2 = ((!ShieldKeyEnabled.Value) ? null : LGCompat.KeyName(ShieldKey.Value));
				return (text != null && text2 != null) ? (text + "/" + text2) : (text ?? text2 ?? string.Empty);
			};
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				LGCompat.Apply();
			};
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				try
				{
					RiskOfOptionsCompat.Init();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Risk of Options: " + ex.Message));
				}
			}
		}

		private void FixedUpdate()
		{
			if (empowerStart.Count == 0)
			{
				return;
			}
			empTmp.Clear();
			empTmp.AddRange(empowerStart.Keys);
			foreach (CharacterBody item in empTmp)
			{
				if (!Object.op_Implicit((Object)(object)item))
				{
					empowerStart.Remove(item);
				}
				else
				{
					item.MarkAllStatsDirty();
				}
			}
		}

		private void Update()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_004a: 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: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			//IL_008e: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00bc: Expected O, but got Unknown
			try
			{
				Console instance = Console.instance;
				if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("osp_shield"))
				{
					instance.concommandCatalog["osp_shield"] = new ConCommand
					{
						flags = (ConVarFlags)1,
						helpText = "Trigger a ready one-shot protection's invincibility.",
						action = new ConCommandDelegate(ShieldCommand)
					};
				}
				if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("osp_empower"))
				{
					instance.concommandCatalog["osp_empower"] = new ConCommand
					{
						flags = (ConVarFlags)1,
						helpText = "Spend a ready one-shot protection on a damage boost.",
						action = new ConCommandDelegate(EmpowerCommand)
					};
				}
			}
			catch
			{
			}
		}

		private static void EmpowerCommand(ConCommandArgs args)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && ManualEnabled.Value)
				{
					CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master);
					OSPState oSPState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<OSPState>());
					if (Object.op_Implicit((Object)(object)oSPState))
					{
						oSPState.Empower();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void ShieldCommand(ConCommandArgs args)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkServer.active && ShieldKeyEnabled.Value)
				{
					CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master);
					OSPState oSPState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<OSPState>());
					if (Object.op_Implicit((Object)(object)oSPState) && oSPState.phase == OSPState.Phase.Ready)
					{
						oSPState.Trigger();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		internal static bool Pressed(KeyboardShortcut k)
		{
			//IL_0002: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref k)).MainKey == 0)
			{
				return false;
			}
			IInputSystem current = UnityInput.Current;
			if (!current.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey))
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				if (!current.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		internal static void RequestEmpower(CharacterBody body)
		{
			Send(body, "osp_empower");
		}

		internal static void RequestShield(CharacterBody body)
		{
			Send(body, "osp_shield");
		}

		private static void Send(CharacterBody body, string cmd)
		{
			try
			{
				foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
				{
					if (readOnlyLocalUsers != null && !((Object)(object)readOnlyLocalUsers.cachedBody != (Object)(object)body) && Object.op_Implicit((Object)(object)readOnlyLocalUsers.currentNetworkUser))
					{
						Console.instance.SubmitCmd(readOnlyLocalUsers.currentNetworkUser, cmd, false);
						break;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private void CreateBuffs()
		{
			//IL_0014: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			ReadyBuff = MakeBuff("bdOSPReady", new Color(0.8f, 0.7f, 1f), stacks: false, cooldown: false);
			ActiveBuff = MakeBuff("bdOSPActive", new Color(0.72f, 0.18f, 1f), stacks: false, cooldown: false);
			EmpowerBuff = MakeBuff("bdOSPEmpower", new Color(1f, 0.35f, 0.75f), stacks: false, cooldown: false);
			CooldownBuff = MakeBuff("bdOSPCooldown", new Color(0.86f, 0.8f, 0.94f), stacks: true, cooldown: true);
			AsyncOperationHandle<BuffDef> val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdImmune.asset");
			val.Completed += delegate(AsyncOperationHandle<BuffDef> h)
			{
				if (!Object.op_Implicit((Object)(object)h.Result))
				{
					Log.LogWarning((object)"bdImmune not found");
				}
				else
				{
					ReadyBuff.iconSprite = h.Result.iconSprite;
					ActiveBuff.iconSprite = h.Result.iconSprite;
					EmpowerBuff.iconSprite = h.Result.iconSprite;
				}
			};
			AsyncOperationHandle<BuffDef> val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/EclipseRun/bdPermanentCurse.asset");
			val2.Completed += delegate(AsyncOperationHandle<BuffDef> h)
			{
				if (!Object.op_Implicit((Object)(object)h.Result))
				{
					Log.LogWarning((object)"bdPermanentCurse not found");
				}
				else
				{
					CooldownBuff.iconSprite = h.Result.iconSprite;
				}
			};
		}

		private static BuffDef MakeBuff(string name, Color color, bool stacks, bool cooldown)
		{
			//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.canStack = stacks;
			val.isDebuff = false;
			val.isHidden = false;
			try
			{
				AccessTools.Field(typeof(BuffDef), "isCooldown")?.SetValue(val, cooldown);
			}
			catch
			{
			}
			return val;
		}

		private static void RecalcPostfix(CharacterBody __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)__instance))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)EmpowerBuff) && (int)EmpowerBuff.buffIndex != -1 && __instance.HasBuff(EmpowerBuff))
			{
				if (!empowerStart.TryGetValue(__instance, out var value))
				{
					value = Time.fixedTime;
					empowerStart[__instance] = value;
				}
				float num = Mathf.Clamp01((Time.fixedTime - value) / Mathf.Max(0.1f, ManualDuration.Value));
				__instance.damage *= Mathf.Max(0f, Mathf.Lerp(ManualDamageMult.Value, ManualDamageMultEnd.Value, num));
			}
			else
			{
				empowerStart.Remove(__instance);
			}
			if (!DisableVanilla.Value || (!__instance.isPlayerControlled && PlayersOnly.Value))
			{
				return;
			}
			try
			{
				if (setOspFraction != null)
				{
					setOspFraction(__instance, 0f);
				}
				if (setHasOsp != null)
				{
					setHasOsp(__instance, arg2: false);
				}
			}
			catch
			{
			}
		}

		private static void OnBodyStart(CharacterBody body)
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<OSPVisuals>()))
			{
				((Component)body).gameObject.AddComponent<OSPVisuals>();
			}
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master) && (!PlayersOnly.Value || Object.op_Implicit((Object)(object)body.master.playerCharacterMasterController)))
			{
				OSPState oSPState = ((Component)body.master).GetComponent<OSPState>();
				if (!Object.op_Implicit((Object)(object)oSPState))
				{
					oSPState = ((Component)body.master).gameObject.AddComponent<OSPState>();
				}
				oSPState.OnNewBody(body);
			}
		}

		internal static OSPState StateFor(HealthComponent hc)
		{
			if (!Object.op_Implicit((Object)(object)hc) || !Object.op_Implicit((Object)(object)hc.body) || !Object.op_Implicit((Object)(object)hc.body.master))
			{
				return null;
			}
			return ((Component)hc.body.master).GetComponent<OSPState>();
		}

		private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo, out HitState __state)
		{
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			__state = default(HitState);
			try
			{
				if (!NetworkServer.active || damageInfo == null || damageInfo.rejected)
				{
					return;
				}
				OSPState oSPState = StateFor(__instance);
				if (!Object.op_Implicit((Object)(object)oSPState) || !__instance.alive || (Object.op_Implicit((Object)(object)damageInfo.attacker) && (Object)(object)damageInfo.attacker == (Object)(object)((Component)__instance).gameObject && !CountSelfDamage.Value))
				{
					return;
				}
				__state.state = oSPState;
				bool flag = InstantRecharge();
				if (oSPState.phase == OSPState.Phase.Active)
				{
					if (flag)
					{
						damageInfo.rejected = true;
					}
				}
				else if (oSPState.phase == OSPState.Phase.Empowered)
				{
					oSPState.RegisterHit();
				}
				else if (oSPState.phase == OSPState.Phase.Ready)
				{
					if (flag)
					{
						MakeInstantKillLethal(__instance, damageInfo);
					}
					if ((damageInfo.damageType.damageType & 1) == 0)
					{
						ref DamageType damageType = ref damageInfo.damageType.damageType;
						damageType = (DamageType)((uint)damageType | 1u);
						__state.addedNonLethal = true;
					}
				}
				else
				{
					oSPState.RegisterHit();
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void MakeInstantKillLethal(HealthComponent hc, DamageInfo damageInfo)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0023: 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_002f: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected I4, but got Unknown
			CharacterBody body = hc.body;
			bool flag = (damageInfo.damageType.damageType & 0x10000) != 0 && Object.op_Implicit((Object)(object)body) && (body.bodyFlags & 0x800) == 0;
			DamageTypeExtended val = (DamageTypeExtended)18;
			bool flag2 = (damageInfo.damageType.damageTypeExtended & val) > 0;
			if (flag || flag2)
			{
				ref DamageType damageType = ref damageInfo.damageType.damageType;
				damageType = (DamageType)((uint)damageType & 0xFFFEFFFFu);
				ref DamageTypeExtended damageTypeExtended = ref damageInfo.damageType.damageTypeExtended;
				damageTypeExtended &= ~val;
				if (flag)
				{
					damageInfo.damage = Mathf.Max(damageInfo.damage, hc.fullCombinedHealth * 10f + 1000000f);
				}
			}
		}

		private static void TakeDamagePostfix(HealthComponent __instance, DamageInfo damageInfo, HitState __state)
		{
			try
			{
				if (Object.op_Implicit((Object)(object)__state.state) && __state.addedNonLethal)
				{
					ref DamageType damageType = ref damageInfo.damageType.damageType;
					damageType = (DamageType)((uint)damageType & 0xFFFFFFFEu);
					if (__instance.alive && __instance.health <= 1.001f && !damageInfo.rejected)
					{
						__state.state.Trigger();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}
	internal static class LGCompat
	{
		private static readonly Dictionary<string, string> tokens = new Dictionary<string, string>();

		private static bool hooked;

		internal static Func<Dictionary<string, string>> Builder;

		internal static Dictionary<BuffDef, Func<string>> IconText = new Dictionary<BuffDef, Func<string>>();

		private static FieldInfo fStack;

		internal static void Init(Harmony h)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			if (!hooked)
			{
				hooked = true;
				RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Apply));
				try
				{
					Language.onCurrentLanguageChanged += Apply;
				}
				catch
				{
				}
				h.Patch((MethodBase)AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(typeof(LGCompat), "TokenPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MethodInfo methodInfo = AccessTools.Method(typeof(BuffIcon), "UpdateIcon", (Type[])null, (Type[])null);
				HarmonyMethod val = new HarmonyMethod(typeof(LGCompat), "IconPostfix", (Type[])null);
				h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		internal static string KeyName(KeyboardShortcut k)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			string text = KeyLabel(((KeyboardShortcut)(ref k)).MainKey);
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				text = KeyLabel(modifier) + "+" + text;
			}
			return text;
		}

		private unsafe static string KeyLabel(KeyCode c)
		{
			string text = ((object)(*(KeyCode*)(&c))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Alpha"))
			{
				text = text.Substring(5);
			}
			if (text.StartsWith("Left"))
			{
				text = "L" + text.Substring(4);
			}
			if (text.StartsWith("Right"))
			{
				text = "R" + text.Substring(5);
			}
			return text;
		}

		internal static void Apply()
		{
			try
			{
				tokens.Clear();
				if (Builder != null)
				{
					foreach (KeyValuePair<string, string> item in Builder())
					{
						tokens[item.Key] = item.Value;
					}
				}
				Language currentLanguage = Language.currentLanguage;
				if (currentLanguage == null || currentLanguage.stringsByToken == null)
				{
					return;
				}
				foreach (KeyValuePair<string, string> token in tokens)
				{
					currentLanguage.stringsByToken[token.Key] = token.Value;
				}
			}
			catch
			{
			}
		}

		internal static void Add(Dictionary<string, string> d, BuffDef b, string name, string desc)
		{
			if (Object.op_Implicit((Object)(object)b))
			{
				d["LG_TOKEN_NAME_" + ((Object)b).name] = name;
				d["LG_TOKEN_DESCRIPTION_" + ((Object)b).name] = desc;
			}
		}

		private static bool TokenPrefix(string token, ref string __result)
		{
			if (token != null && tokens.TryGetValue(token, out var value))
			{
				__result = value;
				return false;
			}
			return true;
		}

		private static void IconPostfix(BuffIcon __instance)
		{
			try
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.buffDef) || !IconText.TryGetValue(__instance.buffDef, out var value))
				{
					return;
				}
				if (fStack == null)
				{
					fStack = AccessTools.Field(typeof(BuffIcon), "stackCount");
				}
				Component val = (Component)((!(fStack != null)) ? null : /*isinst with value type is only supported in some contexts*/);
				if (Object.op_Implicit((Object)(object)val))
				{
					Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						val2.enabled = true;
					}
					val.gameObject.SetActive(true);
					PropertyInfo property = ((object)val).GetType().GetProperty("text");
					if (property != null)
					{
						property.SetValue(val, value(), null);
					}
				}
			}
			catch
			{
			}
		}
	}
	public class OSPState : MonoBehaviour
	{
		public enum Phase
		{
			Ready,
			Active,
			Cooldown,
			Empowered
		}

		public Phase phase;

		public float lastHitTime;

		public float activeUntil;

		public float charge;

		private CharacterMaster master;

		private void Awake()
		{
			master = ((Component)this).GetComponent<CharacterMaster>();
		}

		public void OnNewBody(CharacterBody body)
		{
			phase = Phase.Ready;
			ApplyBuffs(body);
		}

		public void RegisterHit()
		{
			lastHitTime = Time.fixedTime;
			charge = 0f;
		}

		public void Empower()
		{
			CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody());
			if (Object.op_Implicit((Object)(object)val) && phase == Phase.Ready && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
			{
				phase = Phase.Empowered;
				activeUntil = Time.fixedTime + Mathf.Max(0.1f, OneShotReworkPlugin.ManualDuration.Value);
				ApplyBuffs(val);
				OneShotReworkPlugin.Log.LogInfo((object)("One-shot protection spent on empower by " + val.GetDisplayName()));
			}
		}

		public void Trigger()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody());
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			phase = Phase.Active;
			float num = Mathf.Max(0.1f, OneShotReworkPlugin.InvincibleTime.Value);
			activeUntil = Time.fixedTime + num;
			val.AddTimedBuff(Buffs.HiddenInvincibility, num);
			if (OneShotReworkPlugin.RemoveCurse.Value && Object.op_Implicit((Object)(object)Buffs.PermanentCurse))
			{
				try
				{
					HealthComponent healthComponent = val.healthComponent;
					float num2 = ((!Object.op_Implicit((Object)(object)healthComponent)) ? 0f : healthComponent.health);
					if (val.GetBuffCount(Buffs.PermanentCurse) > 0)
					{
						val.SetBuffCount(Buffs.PermanentCurse.buffIndex, 0);
						val.RecalculateStats();
						if (Object.op_Implicit((Object)(object)healthComponent) && healthComponent.alive && healthComponent.health > num2)
						{
							healthComponent.Networkhealth = num2;
						}
					}
				}
				catch
				{
				}
			}
			ApplyBuffs(val);
			OneShotReworkPlugin.Log.LogInfo((object)("One-shot protection triggered for " + val.GetDisplayName()));
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			CharacterBody val = ((!Object.op_Implicit((Object)(object)master)) ? null : master.GetBody());
			float fixedTime = Time.fixedTime;
			bool flag = OneShotReworkPlugin.InstantRecharge();
			if ((phase == Phase.Active || phase == Phase.Empowered) && fixedTime >= activeUntil)
			{
				phase = ((!flag) ? Phase.Cooldown : Phase.Ready);
				lastHitTime = fixedTime;
				charge = 0f;
			}
			if (phase == Phase.Cooldown)
			{
				HealthComponent val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.healthComponent);
				if (Object.op_Implicit((Object)(object)val2) && val2.alive && (val2.health >= val2.fullHealth - 0.01f || NoFullHp(val) || OneShotReworkPlugin.InVoidScene()))
				{
					charge += Time.fixedDeltaTime;
				}
				if (flag || charge >= OneShotReworkPlugin.EffectiveCooldown())
				{
					phase = Phase.Ready;
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				ApplyBuffs(val);
			}
		}

		private static bool NoFullHp(CharacterBody b)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			string value = OneShotReworkPlugin.NoFullHpBodies.Value;
			if (!Object.op_Implicit((Object)(object)b) || string.IsNullOrEmpty(value))
			{
				return false;
			}
			string text = BodyCatalog.GetBodyName(b.bodyIndex) ?? string.Empty;
			string text2 = b.GetDisplayName() ?? string.Empty;
			string[] array = value.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text3 = array[i].Trim();
				if (text3.Length > 0 && (text.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf(text3, StringComparison.OrdinalIgnoreCase) >= 0))
				{
					return true;
				}
			}
			return false;
		}

		private int CooldownStacks()
		{
			if (phase != Phase.Cooldown)
			{
				return 0;
			}
			float num = OneShotReworkPlugin.EffectiveCooldown() - charge;
			return Mathf.Max(1, Mathf.CeilToInt(num));
		}

		private void ApplyBuffs(CharacterBody body)
		{
			if (Object.op_Implicit((Object)(object)body) && NetworkServer.active)
			{
				SetCount(body, OneShotReworkPlugin.ReadyBuff, (phase == Phase.Ready) ? 1 : 0);
				SetCount(body, OneShotReworkPlugin.ActiveBuff, (phase == Phase.Active) ? 1 : 0);
				SetCount(body, OneShotReworkPlugin.EmpowerBuff, (phase == Phase.Empowered) ? 1 : 0);
				SetCount(body, OneShotReworkPlugin.CooldownBuff, CooldownStacks());
			}
		}

		private static void SetCount(CharacterBody body, BuffDef buff, int count)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)buff) && (int)buff.buffIndex != -1)
			{
				int i;
				for (i = body.GetBuffCount(buff); i < count; i++)
				{
					body.AddBuff(buff);
				}
				while (i > count)
				{
					body.RemoveBuff(buff);
					i--;
				}
			}
		}
	}
	public class OSPVisuals : MonoBehaviour
	{
		private CharacterBody body;

		private bool wasActive;

		private bool wasEmpower;

		private uint beamEnterId;

		private string beamStop;

		private static Texture2D tintTex;

		private GameObject emitter;

		private GameObject Emitter()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)emitter))
			{
				emitter = new GameObject("OSPEmpowerSound");
				emitter.transform.SetParent(((Component)this).transform, false);
			}
			return emitter;
		}

		private void SetEmitterVolume()
		{
			//IL_0038: 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)
			try
			{
				float num = (OneShotReworkPlugin.InstantRecharge() ? Mathf.Clamp(OneShotReworkPlugin.InstantEmpowerVolume.Value, 0f, 4f) : 1f);
				ulong akGameObjectID = AkSoundEngine.GetAkGameObjectID(Emitter());
				AkSoundEngine.SetGameObjectOutputBusVolume(akGameObjectID, ulong.MaxValue, num);
				AkAudioListener[] array = Object.FindObjectsOfType<AkAudioListener>();
				foreach (AkAudioListener val in array)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						AkSoundEngine.SetGameObjectOutputBusVolume(akGameObjectID, AkSoundEngine.GetAkGameObjectID(((Component)val).gameObject), num);
					}
				}
			}
			catch (Exception ex)
			{
				OneShotReworkPlugin.Log.LogWarning((object)("Empower volume: " + ex.Message));
			}
		}

		private void StartBeam()
		{
			string value = OneShotReworkPlugin.ManualSound.Value;
			GameObject val = Emitter();
			if (value != "@voidling_spinbeam")
			{
				try
				{
					Util.PlaySound(value, val);
					SetEmitterVolume();
					return;
				}
				catch
				{
					return;
				}
			}
			try
			{
				string enterSoundString = SpinBeamAttack.enterSoundString;
				if (!string.IsNullOrEmpty(enterSoundString))
				{
					beamEnterId = Util.PlaySound(enterSoundString, val);
				}
				LoopSoundDef loopSound = SpinBeamAttack.loopSound;
				if (Object.op_Implicit((Object)(object)loopSound))
				{
					if (!string.IsNullOrEmpty(loopSound.startSoundName))
					{
						Util.PlaySound(loopSound.startSoundName, val);
					}
					beamStop = loopSound.stopSoundName;
				}
				SetEmitterVolume();
			}
			catch (Exception ex)
			{
				OneShotReworkPlugin.Log.LogWarning((object)("Beam sound: " + ex.Message));
			}
		}

		private void StopBeam()
		{
			try
			{
				if (beamEnterId != 0)
				{
					AkStop.Stop(beamEnterId);
				}
			}
			catch
			{
			}
			beamEnterId = 0u;
			try
			{
				if (!string.IsNullOrEmpty(beamStop))
				{
					Util.PlaySound(beamStop, Object.op_Implicit((Object)(object)emitter) ? emitter : ((Component)this).gameObject);
				}
			}
			catch
			{
			}
			beamStop = null;
		}

		private void OnDestroy()
		{
			if (wasEmpower)
			{
				StopBeam();
			}
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private bool Active()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			BuffDef activeBuff = OneShotReworkPlugin.ActiveBuff;
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)activeBuff) && (int)activeBuff.buffIndex != -1)
			{
				return body.HasBuff(activeBuff);
			}
			return false;
		}

		private static bool Has(CharacterBody b, BuffDef d)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1)
			{
				return b.HasBuff(d);
			}
			return false;
		}

		private void Update()
		{
			//IL_0023: 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)
			try
			{
				if (OneShotReworkPlugin.ManualEnabled.Value && Has(body, OneShotReworkPlugin.ReadyBuff) && OneShotReworkPlugin.Pressed(OneShotReworkPlugin.ManualKey.Value) && IsLocalPlayer() && !ChatOpen())
				{
					OneShotReworkPlugin.RequestEmpower(body);
				}
				else if (OneShotReworkPlugin.ShieldKeyEnabled.Value && Has(body, OneShotReworkPlugin.ReadyBuff) && OneShotReworkPlugin.Pressed(OneShotReworkPlugin.ShieldKey.Value) && IsLocalPlayer() && !ChatOpen())
				{
					OneShotReworkPlugin.RequestShield(body);
				}
			}
			catch
			{
			}
			bool flag = Has(body, OneShotReworkPlugin.EmpowerBuff);
			if (flag != wasEmpower)
			{
				wasEmpower = flag;
				if (flag)
				{
					StartBeam();
				}
				else
				{
					StopBeam();
				}
			}
			bool flag2 = Active();
			if (flag2 == wasActive)
			{
				return;
			}
			wasActive = flag2;
			if (!flag2)
			{
				return;
			}
			try
			{
				string text = OneShotReworkPlugin.SoundOverride.Value;
				if (string.IsNullOrEmpty(text))
				{
					text = OneShotReworkPlugin.ImplosionSound;
				}
				if (string.IsNullOrEmpty(text))
				{
					text = "Play_nullifier_death_vortex_explode";
				}
				Util.PlaySound(text, ((Component)this).gameObject);
			}
			catch (Exception ex)
			{
				OneShotReworkPlugin.Log.LogWarning((object)ex.Message);
			}
		}

		private bool IsLocalPlayer()
		{
			try
			{
				foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
				{
					if (readOnlyLocalUsers != null && (Object)(object)readOnlyLocalUsers.cachedBody == (Object)(object)body)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static bool ChatOpen()
		{
			try
			{
				ChatBox[] array = Object.FindObjectsOfType<ChatBox>();
				foreach (ChatBox val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && val.showInput)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private void OnGUI()
		{
			//IL_0060: 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_0045: Expected O, but got Unknown
			//IL_004c: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if ((wasActive || wasEmpower) && OneShotReworkPlugin.ScreenTint.Value && IsLocalPlayer())
			{
				if (!Object.op_Implicit((Object)(object)tintTex))
				{
					tintTex = new Texture2D(1, 1);
					tintTex.SetPixel(0, 0, Color.white);
					tintTex.Apply();
				}
				Color color = GUI.color;
				float num = Mathf.Clamp01(OneShotReworkPlugin.TintStrength.Value);
				GUI.color = ((!wasEmpower) ? new Color(0.2f, 0f, 0.32f, num) : new Color(1f, 0.35f, 0.75f, num * 0.6f));
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)tintTex);
				GUI.color = color;
			}
		}
	}
	internal static class RiskOfOptionsCompat
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Init()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Reworked one-shot protection: recharge at full health, empower and manual shield keys.");
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OneShotReworkPlugin.ManualKey));
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(OneShotReworkPlugin.ShieldKey));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ManualEnabled));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ShieldKeyEnabled));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(OneShotReworkPlugin.ScreenTint));
		}
	}
}

Parry.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using AK.Wwise;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.BrotherMonster;
using EntityStates.FalseSon;
using EntityStates.Halcyonite;
using HarmonyLib;
using RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.UI;
using RoR2.WwiseUtils;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace Parry
{
	internal static class AkStop
	{
		private static MethodInfo stop;

		private static MethodInfo stopAny;

		private static bool searched;

		internal static void Stop(uint id)
		{
			if (id == 0)
			{
				return;
			}
			try
			{
				if (!searched)
				{
					searched = true;
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					foreach (Assembly assembly in assemblies)
					{
						Type type = null;
						try
						{
							type = assembly.GetType("AkSoundEngine", throwOnError: false);
						}
						catch
						{
						}
						if (!(type == null))
						{
							stop = type.GetMethod("StopPlayingID", new Type[1] { typeof(uint) });
							if (stop != null)
							{
								break;
							}
						}
					}
				}
				if (stop != null)
				{
					stop.Invoke(null, new object[1] { id });
					return;
				}
				if (stopAny == null)
				{
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					foreach (Assembly assembly2 in assemblies)
					{
						Type type2 = null;
						try
						{
							type2 = assembly2.GetType("AkSoundEngine", throwOnError: false);
						}
						catch
						{
						}
						if (type2 == null)
						{
							continue;
						}
						MethodInfo[] methods = type2.GetMethods();
						foreach (MethodInfo methodInfo in methods)
						{
							ParameterInfo[] parameters = methodInfo.GetParameters();
							if (methodInfo.Name == "StopPlayingID" && parameters.Length != 0 && parameters[0].ParameterType == typeof(uint))
							{
								stopAny = methodInfo;
								break;
							}
						}
						if (stopAny != null)
						{
							break;
						}
					}
				}
				if (stopAny != null)
				{
					ParameterInfo[] parameters2 = stopAny.GetParameters();
					object[] array = new object[parameters2.Length];
					array[0] = id;
					for (int k = 1; k < parameters2.Length; k++)
					{
						array[k] = ((!(parameters2[k].ParameterType == typeof(int))) ? ((!parameters2[k].ParameterType.IsValueType) ? null : Activator.CreateInstance(parameters2[k].ParameterType)) : ((object)0));
					}
					stopAny.Invoke(null, array);
				}
			}
			catch
			{
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("custom.Parry", "Parry", "1.6.4")]
	public class ParryPlugin : BaseUnityPlugin
	{
		private class Provider : IContentPackProvider
		{
			private readonly ContentPack pack = new ContentPack();

			public string identifier => "custom.Parry";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.Parry", null);
				}
				catch
				{
				}
				pack.buffDefs.Add((BuffDef[])(object)new BuffDef[5] { ReadyBuff, WindowBuff, InvulnBuff, BoostBuff, CooldownBuff });
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(pack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__32_0;

			public static Func<Dictionary<string, string>> <>9__32_1;

			public static Func<string> <>9__32_2;

			public static EventHandler<SettingChangedEventArgs> <>9__32_3;

			public static Action<AsyncOperationHandle<BuffDef>> <>9__33_0;

			public static Action<AsyncOperationHandle<BuffDef>> <>9__33_1;

			internal void <Awake>b__32_0(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new Provider());
			}

			internal Dictionary<string, string> <Awake>b__32_1()
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string text = LGCompat.KeyName(Key.Value);
				string text2 = DamageMult.Value + "x";
				LGCompat.Add(dictionary, ReadyBuff, "Parry Ready", "Press <style=cIsDamage>[" + text + "]</style> to parry. A successful parry gives <style=cIsUtility>invincibility</style> and a <style=cIsDamage>damage boost</style>.");
				LGCompat.Add(dictionary, WindowBuff, "Parrying", "The next hit is <style=cIsUtility>parried</style>.");
				LGCompat.Add(dictionary, InvulnBuff, "Parried!", "<style=cIsUtility>Invincible</style> and damage multiplied by <style=cIsDamage>" + text2 + "</style>.");
				LGCompat.Add(dictionary, BoostBuff, "Parry Boost", "Damage multiplied by <style=cIsDamage>" + text2 + "</style>.");
				LGCompat.Add(dictionary, CooldownBuff, "Parry Recharging", "On cooldown.");
				return dictionary;
			}

			internal string <Awake>b__32_2()
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				return LGCompat.KeyName(Key.Value);
			}

			internal void <Awake>b__32_3(object <p0>, SettingChangedEventArgs <p1>)
			{
				LGCompat.Apply();
			}

			internal void <CreateBuffs>b__33_0(AsyncOperationHandle<BuffDef> r)
			{
				if (Object.op_Implicit((Object)(object)r.Result))
				{
					ReadyBuff.iconSprite = (WindowBuff.iconSprite = (InvulnBuff.iconSprite = (BoostBuff.iconSprite = r.Result.iconSprite)));
				}
			}

			internal void <CreateBuffs>b__33_1(AsyncOperationHandle<BuffDef> r)
			{
				if (Object.op_Implicit((Object)(object)r.Result))
				{
					CooldownBuff.iconSprite = r.Result.iconSprite;
				}
			}
		}

		public const string GUID = "custom.Parry";

		internal const string Cmd = "parry_activate";

		internal static ManualLogSource Log;

		internal static ConfigEntry<KeyboardShortcut> Key;

		internal static ConfigEntry<bool> PlayersOnly;

		internal static ConfigEntry<bool> ScreenTint;

		internal static ConfigEntry<float> WindowTime;

		internal static ConfigEntry<float> InvulnTime;

		internal static ConfigEntry<float> BoostTime;

		internal static ConfigEntry<float> DamageMult;

		internal static ConfigEntry<float> CooldownTime;

		internal static ConfigEntry<float> WindowTint;

		internal static ConfigEntry<float> BoostTint;

		internal static ConfigEntry<float> InvulnTint;

		internal static ConfigEntry<string> ParrySound;

		internal static ConfigEntry<string> ActivateSound;

		internal static ConfigEntry<int> ParryRepeat;

		internal static ConfigEntry<float> LaserSeconds;

		internal static ConfigEntry<bool> CutActivate;

		internal static BuffDef ReadyBuff;

		internal static BuffDef WindowBuff;

		internal static BuffDef InvulnBuff;

		internal static BuffDef BoostBuff;

		internal static BuffDef CooldownBuff;

		internal static readonly Color Lvl1 = new Color(0.25f, 0.62f, 0.25f);

		internal static readonly Color Lvl2 = new Color(0.4f, 0.92f, 0.4f);

		internal static readonly Color Lvl3 = new Color(0.78f, 1f, 0.78f);

		internal static readonly Color Pale = new Color(0.78f, 0.9f, 0.78f);

		private static string impactSound;

		private static bool impactLoaded;

		private static readonly Dictionary<string, List<string>> scanned = new Dictionary<string, List<string>>();

		private void Awake()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Expected O, but got Unknown
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Expected O, but got Unknown
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Key = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "ParryKey", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), "Key that opens the parry window.");
			PlayersOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PlayersOnly", true, "Only player-controlled survivors can parry.");
			WindowTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "ParryWindow", 1f, "Seconds the parry window stays open after pressing the key.");
			InvulnTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "InvincibilityTime", 1f, "Seconds of invincibility after a successful parry.");
			BoostTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "DamageBoostTime", 5f, "Seconds of boosted damage after a successful parry (includes the invincibility).");
			DamageMult = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "DamageMultiplier", 2.5f, "Damage multiplier after a successful parry.");
			CooldownTime = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "Cooldown", 15f, "Cooldown after the window closes without a parry, or after the damage boost ends.");
			ScreenTint = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "ScreenTint", true, "Green screen tint during the window and the boost.");
			WindowTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "WindowTintStrength", 0.08f, "Tint opacity during the parry window.");
			InvulnTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "InvincibleTintStrength", 0.38f, "Tint opacity during the invincibility right after a parry (strongest).");
			BoostTint = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "BoostTintStrength", 0.16f, "Tint opacity during the rest of the damage boost.");
			ParrySound = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "ParrySoundV6", "@mithrix_impact,@falseson_laser", "Sound events (comma-separated) played on a successful parry. Special values: @mithrix_impact, @falseson_laser (False Son's Laser of the Father, stopped after FalseSonLaserSeconds), @deus_parry, @halcyonite_laser, @gilded_gong, @mithrix_swing, @mithrix_pizza.");
			LaserSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "FalseSonLaserSeconds", 5f, "How long the False Son laser sound plays on a successful parry.");
			ParryRepeat = ((BaseUnityPlugin)this).Config.Bind<int>("Visuals", "ParrySoundRepeat", 3, "How many times the parry sound is layered (louder).");
			ActivateSound = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "ActivateSoundV7", "@halcyonite_laser", "Sound events (comma-separated) played when the parry window opens. Default: the Halcyonite laser. Special values: @halcyonite_laser, @deus_parry, @gilded_gong, @mithrix_impact, @mithrix_swing, @mithrix_pizza.");
			CutActivate = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "CutActivateSoundOnWindowEnd", false, "Stop the window-open sound when the window closes or the parry lands.");
			CreateBuffs();
			object obj = <>c.<>9__32_0;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
				{
					add.Invoke((IContentPackProvider)(object)new Provider());
				};
				<>c.<>9__32_0 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			Harmony val2 = new Harmony("custom.Parry");
			MethodInfo methodInfo = AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null);
			HarmonyMethod val3 = new HarmonyMethod(typeof(ParryPlugin), "RecalcPostfix", (Type[])null);
			val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			val2.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(ParryPlugin), "TakeDamagePrefix", (Type[])null)
			{
				priority = 800
			}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LoadSoundBanks));
			LGCompat.Init(val2);
			LGCompat.Builder = delegate
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				string text = LGCompat.KeyName(Key.Value);
				string text2 = DamageMult.Value + "x";
				LGCompat.Add(dictionary, ReadyBuff, "Parry Ready", "Press <style=cIsDamage>[" + text + "]</style> to parry. A successful parry gives <style=cIsUtility>invincibility</style> and a <style=cIsDamage>damage boost</style>.");
				LGCompat.Add(dictionary, WindowBuff, "Parrying", "The next hit is <style=cIsUtility>parried</style>.");
				LGCompat.Add(dictionary, InvulnBuff, "Parried!", "<style=cIsUtility>Invincible</style> and damage multiplied by <style=cIsDamage>" + text2 + "</style>.");
				LGCompat.Add(dictionary, BoostBuff, "Parry Boost", "Damage multiplied by <style=cIsDamage>" + text2 + "</style>.");
				LGCompat.Add(dictionary, CooldownBuff, "Parry Recharging", "On cooldown.");
				return dictionary;
			};
			LGCompat.IconText[ReadyBuff] = () => LGCompat.KeyName(Key.Value);
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				LGCompat.Apply();
			};
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				try
				{
					RiskOfOptionsCompat.Init();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Risk of Options: " + ex.Message));
				}
			}
		}

		private void CreateBuffs()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_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_009f: 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)
			ReadyBuff = MakeBuff("bdParryReady", Lvl1, cooldown: false);
			WindowBuff = MakeBuff("bdParryWindow", Lvl2, cooldown: false);
			InvulnBuff = MakeBuff("bdParryInvincible", Lvl3, cooldown: false);
			BoostBuff = MakeBuff("bdParryBoost", Lvl2, cooldown: false);
			CooldownBuff = MakeBuff("bdParryCooldown", Pale, cooldown: true);
			AsyncOperationHandle<BuffDef> val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/Common/bdImmune.asset");
			val.Completed += delegate(AsyncOperationHandle<BuffDef> r)
			{
				if (Object.op_Implicit((Object)(object)r.Result))
				{
					ReadyBuff.iconSprite = (WindowBuff.iconSprite = (InvulnBuff.iconSprite = (BoostBuff.iconSprite = r.Result.iconSprite)));
				}
			};
			AsyncOperationHandle<BuffDef> val2 = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/EclipseRun/bdPermanentCurse.asset");
			val2.Completed += delegate(AsyncOperationHandle<BuffDef> r)
			{
				if (Object.op_Implicit((Object)(object)r.Result))
				{
					CooldownBuff.iconSprite = r.Result.iconSprite;
				}
			};
		}

		private static BuffDef MakeBuff(string name, Color c, bool cooldown)
		{
			//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 = c;
			val.canStack = cooldown;
			val.isDebuff = false;
			val.isHidden = false;
			try
			{
				AccessTools.Field(typeof(BuffDef), "isCooldown")?.SetValue(val, cooldown);
			}
			catch
			{
			}
			return val;
		}

		internal static bool Pressed(KeyboardShortcut k)
		{
			//IL_0002: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref k)).MainKey == 0)
			{
				return false;
			}
			IInputSystem current = UnityInput.Current;
			if (!current.GetKeyDown(((KeyboardShortcut)(ref k)).MainKey))
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				if (!current.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		private static void LoadSoundBanks()
		{
			try
			{
				string text = (ParrySound.Value ?? string.Empty) + "," + (ActivateSound.Value ?? string.Empty);
				List<string> list = new List<string>();
				if (text.Contains("@mithrix"))
				{
					list.Add("BrotherBody");
				}
				if (text.Contains("@falseson"))
				{
					list.Add("FalseSonBossBody");
				}
				if (text.Contains("@falseson_laser"))
				{
					list.Add("FalseSonBody");
				}
				if (text.Contains("@halcyonite"))
				{
					list.Add("HalcyoniteBody");
				}
				if (text.Contains("@gilded_gong"))
				{
					list.Add("TitanGoldBody");
				}
				HashSet<string> hashSet = new HashSet<string>();
				if (text.Contains("@falseson_laser"))
				{
					hashSet.Add("char_falseson");
				}
				foreach (string item in list)
				{
					GameObject val = BodyCatalog.FindBodyPrefab(item);
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					AkBank[] componentsInChildren = val.GetComponentsInChildren<AkBank>(true);
					foreach (AkBank val2 in componentsInChildren)
					{
						string text2 = (((Object)(object)val2 == (Object)null || val2.data == null) ? null : ((BaseType)val2.data).Name);
						if (!string.IsNullOrEmpty(text2))
						{
							hashSet.Add(text2);
						}
					}
					SoundbankLoader[] componentsInChildren2 = val.GetComponentsInChildren<SoundbankLoader>(true);
					foreach (SoundbankLoader val3 in componentsInChildren2)
					{
						if ((Object)(object)val3 == (Object)null || val3.soundbankStrings == null)
						{
							continue;
						}
						string[] soundbankStrings = val3.soundbankStrings;
						foreach (string text3 in soundbankStrings)
						{
							if (!string.IsNullOrEmpty(text3))
							{
								hashSet.Add(text3);
							}
						}
					}
				}
				List<string> list2 = new List<string>();
				foreach (string item2 in hashSet)
				{
					try
					{
						AkBankManager.LoadBank(item2, false, false);
						list2.Add(item2);
					}
					catch (Exception ex)
					{
						Log.LogWarning((object)("Sound bank " + item2 + ": " + ex.Message));
					}
				}
				if (list2.Count > 0)
				{
					Log.LogInfo((object)("Parry sounds: loaded sound banks " + string.Join(", ", list2.ToArray()) + "."));
				}
				else
				{
					Log.LogWarning((object)("Parry sounds: no sound banks found for " + string.Join(", ", list.ToArray()) + ". If the parry is silent, install SoundFixer."));
				}
			}
			catch (Exception ex2)
			{
				Log.LogWarning((object)("Parry sound banks: " + ex2.Message));
			}
		}

		private static List<string> SoundsIn(string path)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (scanned.TryGetValue(path, out var value))
			{
				return value;
			}
			value = new List<string>();
			try
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)path).WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val))
				{
					Component[] componentsInChildren = val.GetComponentsInChildren<Component>(true);
					foreach (Component val2 in componentsInChildren)
					{
						if (!Object.op_Implicit((Object)(object)val2))
						{
							continue;
						}
						FieldInfo[] fields = ((object)val2).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						foreach (FieldInfo fieldInfo in fields)
						{
							if (!(fieldInfo.FieldType != typeof(string)))
							{
								string text = fieldInfo.GetValue(val2) as string;
								if (!string.IsNullOrEmpty(text) && text.StartsWith("Play_", StringComparison.OrdinalIgnoreCase) && !value.Contains(text))
								{
									value.Add(text);
								}
							}
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Sound scan " + path + ": " + ex.Message));
			}
			Log.LogInfo((object)("Sounds in " + path + ": " + ((value.Count <= 0) ? "none" : string.Join(", ", value.ToArray()))));
			scanned[path] = value;
			return value;
		}

		private static string FirstSound(params string[] paths)
		{
			for (int i = 0; i < paths.Length; i++)
			{
				List<string> list = SoundsIn(paths[i]);
				if (list.Count > 0)
				{
					return list[0];
				}
			}
			return null;
		}

		private static IEnumerable<string> Resolve(string token)
		{
			switch (token)
			{
			case "@deus_parry":
			{
				string text6 = FirstSound("RoR2/DLC3/Parry/ParryEffect.prefab", "RoR2/DLC3/Parry/ParryOrbEffect.prefab", "RoR2/DLC3/Parry/ParryHalo.prefab");
				if (!string.IsNullOrEmpty(text6))
				{
					yield return text6;
				}
				break;
			}
			case "@gilded_gong":
			{
				string text5 = FirstSound("RoR2/DLC2/Elites/EliteAurelionite/AffixAurelionitePreStrikeProjectile.prefab", "RoR2/DLC2/Elites/EliteAurelionite/AffixAurelionitePreFistGhost.prefab", "RoR2/DLC2/Elites/EliteAurelionite/EliteAurelioniteSummonPillarVFX.prefab", "RoR2/DLC2/Elites/EliteAurelionite/AffixAurelioniteStrikeEffect.prefab");
				if (!string.IsNullOrEmpty(text5))
				{
					yield return text5;
				}
				break;
			}
			case "@halcyonite_laser":
			{
				string text3 = null;
				try
				{
					text3 = TriLaser.attackSoundString;
				}
				catch
				{
				}
				if (string.IsNullOrEmpty(text3))
				{
					text3 = FirstSound("RoR2/DLC2/Halcyonite/LaserTriLaser.prefab", "RoR2/DLC2/Halcyonite/MuzzleflashTriLaser.prefab", "RoR2/DLC2/Halcyonite/ExplosionTriLaser.prefab");
				}
				if (!string.IsNullOrEmpty(text3))
				{
					yield return text3;
				}
				break;
			}
			case "@mithrix_swing":
			{
				string text4 = null;
				try
				{
					text4 = WeaponSlam.attackSoundString;
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(text4))
				{
					yield return text4;
				}
				break;
			}
			case "@mithrix_impact":
			case "@mithrix_slam":
				if (!impactLoaded)
				{
					impactLoaded = true;
					try
					{
						GameObject val = WeaponSlam.slamImpactEffect;
						if (!Object.op_Implicit((Object)(object)val))
						{
							val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Brother/BrotherSlamImpact.prefab").WaitForCompletion();
						}
						EffectComponent val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<EffectComponent>());
						impactSound = ((!Object.op_Implicit((Object)(object)val2)) ? null : val2.soundName);
					}
					catch
					{
					}
				}
				if (token == "@mithrix_slam")
				{
					string text2 = null;
					try
					{
						text2 = WeaponSlam.attackSoundString;
					}
					catch
					{
					}
					if (!string.IsNullOrEmpty(text2))
					{
						yield return text2;
					}
				}
				if (!string.IsNullOrEmpty(impactSound))
				{
					yield return impactSound;
				}
				break;
			case "@mithrix_pizza":
			{
				string text = null;
				string b = null;
				try
				{
					text = UltEnterState.soundString;
				}
				catch
				{
				}
				try
				{
					b = UltChannelState.enterSoundString;
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(text))
				{
					yield return text;
				}
				if (!string.IsNullOrEmpty(b))
				{
					yield return b;
				}
				break;
			}
			default:
				yield return token;
				break;
			case "@falseson_laser":
				break;
			}
		}

		internal static List<uint> PlayAll(string list, GameObject go, int repeat = 1)
		{
			List<uint> list2 = new List<uint>();
			if (string.IsNullOrEmpty(list))
			{
				return list2;
			}
			string[] array = list.Split(new char[1] { ',' });
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0)
				{
					continue;
				}
				foreach (string item in Resolve(text))
				{
					for (int j = 0; j < Mathf.Max(1, repeat); j++)
					{
						list2.Add(Util.PlaySound(item, go));
					}
				}
			}
			return list2;
		}

		internal static bool Has(CharacterBody b, BuffDef d)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)b) && Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1)
			{
				return b.HasBuff(d);
			}
			return false;
		}

		private static void RecalcPostfix(CharacterBody __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance) && (Has(__instance, InvulnBuff) || Has(__instance, BoostBuff)))
			{
				__instance.damage *= Mathf.Max(0f, DamageMult.Value);
			}
		}

		private static void OnBodyStart(CharacterBody body)
		{
			if (Object.op_Implicit((Object)(object)body))
			{
				if (!Object.op_Implicit((Object)(object)((Component)body).GetComponent<ParryVisuals>()))
				{
					((Component)body).gameObject.AddComponent<ParryVisuals>();
				}
				if (NetworkServer.active && Object.op_Implicit((Object)(object)body.master) && (!PlayersOnly.Value || Object.op_Implicit((Object)(object)body.master.playerCharacterMasterController)))
				{
					(((Component)body.master).GetComponent<ParryState>() ?? ((Component)body.master).gameObject.AddComponent<ParryState>()).OnNewBody(body);
				}
			}
		}

		private static void TakeDamagePrefix(HealthComponent __instance, DamageInfo damageInfo)
		{
			//IL_0071: 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)
			try
			{
				if (NetworkServer.active && damageInfo != null && !damageInfo.rejected && Object.op_Implicit((Object)(object)__instance) && Object.op_Implicit((Object)(object)__instance.body) && Object.op_Implicit((Object)(object)__instance.body.master))
				{
					ParryState component = ((Component)__instance.body.master).GetComponent<ParryState>();
					if (Object.op_Implicit((Object)(object)component) && component.phase == ParryState.Phase.Window && (!(damageInfo.damage <= 0f) || (damageInfo.damageType.damageType & 0x50000) != 0))
					{
						damageInfo.rejected = true;
						component.Parried();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private void Update()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_004a: 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: Expected O, but got Unknown
			//IL_0061: Expected O, but got Unknown
			try
			{
				Console instance = Console.instance;
				if (Object.op_Implicit((Object)(object)instance) && instance.concommandCatalog != null && !instance.concommandCatalog.ContainsKey("parry_activate"))
				{
					instance.concommandCatalog["parry_activate"] = new ConCommand
					{
						flags = (ConVarFlags)1,
						helpText = "Open the parry window.",
						action = new ConCommandDelegate(ParryCommand)
					};
				}
			}
			catch
			{
			}
		}

		private static void ParryCommand(ConCommandArgs args)
		{
			//IL_0007: 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)
			try
			{
				if (NetworkServer.active)
				{
					CharacterMaster val = ((!Object.op_Implicit((Object)(object)args.sender)) ? null : args.sender.master);
					ParryState parryState = ((!Object.op_Implicit((Object)(object)val)) ? null : ((Component)val).GetComponent<ParryState>());
					if (Object.op_Implicit((Object)(object)parryState))
					{
						parryState.Open();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		internal static void Request(CharacterBody body)
		{
			try
			{
				foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
				{
					if (readOnlyLocalUsers != null && !((Object)(object)readOnlyLocalUsers.cachedBody != (Object)(object)body) && Object.op_Implicit((Object)(object)readOnlyLocalUsers.currentNetworkUser))
					{
						Console.instance.SubmitCmd(readOnlyLocalUsers.currentNetworkUser, "parry_activate", false);
						break;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}
	internal static class LGCompat
	{
		private static readonly Dictionary<string, string> tokens = new Dictionary<string, string>();

		private static bool hooked;

		internal static Func<Dictionary<string, string>> Builder;

		internal static Dictionary<BuffDef, Func<string>> IconText = new Dictionary<BuffDef, Func<string>>();

		private static FieldInfo fStack;

		internal static void Init(Harmony h)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Expected O, but got Unknown
			if (!hooked)
			{
				hooked = true;
				RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Apply));
				try
				{
					Language.onCurrentLanguageChanged += Apply;
				}
				catch
				{
				}
				h.Patch((MethodBase)AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), new HarmonyMethod(typeof(LGCompat), "TokenPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				MethodInfo methodInfo = AccessTools.Method(typeof(BuffIcon), "UpdateIcon", (Type[])null, (Type[])null);
				HarmonyMethod val = new HarmonyMethod(typeof(LGCompat), "IconPostfix", (Type[])null);
				h.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		internal static string KeyName(KeyboardShortcut k)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			string text = KeyLabel(((KeyboardShortcut)(ref k)).MainKey);
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				text = KeyLabel(modifier) + "+" + text;
			}
			return text;
		}

		private unsafe static string KeyLabel(KeyCode c)
		{
			string text = ((object)(*(KeyCode*)(&c))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Alpha"))
			{
				text = text.Substring(5);
			}
			if (text.StartsWith("Left"))
			{
				text = "L" + text.Substring(4);
			}
			if (text.StartsWith("Right"))
			{
				text = "R" + text.Substring(5);
			}
			return text;
		}

		internal static void Apply()
		{
			try
			{
				tokens.Clear();
				if (Builder != null)
				{
					foreach (KeyValuePair<string, string> item in Builder())
					{
						tokens[item.Key] = item.Value;
					}
				}
				Language currentLanguage = Language.currentLanguage;
				if (currentLanguage == null || currentLanguage.stringsByToken == null)
				{
					return;
				}
				foreach (KeyValuePair<string, string> token in tokens)
				{
					currentLanguage.stringsByToken[token.Key] = token.Value;
				}
			}
			catch
			{
			}
		}

		internal static void Add(Dictionary<string, string> d, BuffDef b, string name, string desc)
		{
			if (Object.op_Implicit((Object)(object)b))
			{
				d["LG_TOKEN_NAME_" + ((Object)b).name] = name;
				d["LG_TOKEN_DESCRIPTION_" + ((Object)b).name] = desc;
			}
		}

		private static bool TokenPrefix(string token, ref string __result)
		{
			if (token != null && tokens.TryGetValue(token, out var value))
			{
				__result = value;
				return false;
			}
			return true;
		}

		private static void IconPostfix(BuffIcon __instance)
		{
			try
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.buffDef) || !IconText.TryGetValue(__instance.buffDef, out var value))
				{
					return;
				}
				if (fStack == null)
				{
					fStack = AccessTools.Field(typeof(BuffIcon), "stackCount");
				}
				Component val = (Component)((!(fStack != null)) ? null : /*isinst with value type is only supported in some contexts*/);
				if (Object.op_Implicit((Object)(object)val))
				{
					Behaviour val2 = (Behaviour)(object)((val is Behaviour) ? val : null);
					if (Object.op_Implicit((Object)(object)val2))
					{
						val2.enabled = true;
					}
					val.gameObject.SetActive(true);
					PropertyInfo property = ((object)val).GetType().GetProperty("text");
					if (property != null)
					{
						property.SetValue(val, value(), null);
					}
				}
			}
			catch
			{
			}
		}
	}
	public class ParryState : MonoBehaviour
	{
		public enum Phase
		{
			Ready,
			Window,
			Invuln,
			Boost,
			Cooldown
		}

		public Phase phase;

		private float phaseEnd;

		private float boostEnd;

		private CharacterMaster master;

		private void Awake()
		{
			master = ((Component)this).GetComponent<CharacterMaster>();
		}

		public void OnNewBody(CharacterBody body)
		{
			phase = Phase.Ready;
			Apply(body);
		}

		private CharacterBody Body()
		{
			if (Object.op_Implicit((Object)(object)master))
			{
				return master.GetBody();
			}
			return null;
		}

		public void Open()
		{
			CharacterBody val = Body();
			if (Object.op_Implicit((Object)(object)val) && phase == Phase.Ready && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
			{
				phase = Phase.Window;
				phaseEnd = Time.fixedTime + Mathf.Max(0.05f, ParryPlugin.WindowTime.Value);
				Apply(val);
			}
		}

		public void Parried()
		{
			CharacterBody val = Body();
			if (Object.op_Implicit((Object)(object)val))
			{
				float num = Mathf.Max(0f, ParryPlugin.InvulnTime.Value);
				phase = Phase.Invuln;
				phaseEnd = Time.fixedTime + num;
				boostEnd = Time.fixedTime + Mathf.Max(num, ParryPlugin.BoostTime.Value);
				if (num > 0f)
				{
					val.AddTimedBuff(Buffs.HiddenInvincibility, num);
				}
				Apply(val);
			}
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			float fixedTime = Time.fixedTime;
			switch (phase)
			{
			case Phase.Window:
				if (fixedTime >= phaseEnd)
				{
					StartCooldown(fixedTime);
				}
				break;
			case Phase.Invuln:
				if (fixedTime >= phaseEnd)
				{
					phase = ((!(fixedTime >= boostEnd)) ? Phase.Boost : Phase.Cooldown);
				}
				if (phase == Phase.Cooldown)
				{
					StartCooldown(fixedTime);
				}
				break;
			case Phase.Boost:
				if (fixedTime >= boostEnd)
				{
					StartCooldown(fixedTime);
				}
				break;
			case Phase.Cooldown:
				if (fixedTime >= phaseEnd)
				{
					phase = Phase.Ready;
				}
				break;
			}
			CharacterBody val = Body();
			if (Object.op_Implicit((Object)(object)val))
			{
				Apply(val);
			}
		}

		private void StartCooldown(float now)
		{
			phase = Phase.Cooldown;
			phaseEnd = now + Mathf.Max(0f, ParryPlugin.CooldownTime.Value);
		}

		private void Apply(CharacterBody b)
		{
			if (Object.op_Implicit((Object)(object)b) && NetworkServer.active)
			{
				Set(b, ParryPlugin.ReadyBuff, (phase == Phase.Ready) ? 1 : 0);
				Set(b, ParryPlugin.WindowBuff, (phase == Phase.Window) ? 1 : 0);
				Set(b, ParryPlugin.InvulnBuff, (phase == Phase.Invuln) ? 1 : 0);
				Set(b, ParryPlugin.BoostBuff, (phase == Phase.Boost) ? 1 : 0);
				Set(b, ParryPlugin.CooldownBuff, (phase == Phase.Cooldown) ? Mathf.Max(1, Mathf.CeilToInt(phaseEnd - Time.fixedTime)) : 0);
			}
		}

		private static void Set(CharacterBody b, BuffDef d, int n)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if (Object.op_Implicit((Object)(object)d) && (int)d.buffIndex != -1)
			{
				int i;
				for (i = b.GetBuffCount(d); i < n; i++)
				{
					b.AddBuff(d);
				}
				while (i > n)
				{
					b.RemoveBuff(d);
					i--;
				}
			}
		}
	}
	public class ParryVisuals : MonoBehaviour
	{
		private CharacterBody body;

		private bool wasWindow;

		private bool wasParried;

		private bool invuln;

		private List<uint> swingIds;

		private List<uint> laserIds;

		private string laserStop;

		private static Texture2D tex;

		private void StopSwing()
		{
			if (swingIds == null)
			{
				return;
			}
			foreach (uint swingId in swingIds)
			{
				try
				{
					if (swingId != 0)
					{
						AkStop.Stop(swingId);
					}
				}
				catch
				{
				}
			}
			swingIds = null;
		}

		private void OnDestroy()
		{
			StopSwing();
			StopLaser();
		}

		private IEnumerator FalseSonLaser()
		{
			StopLaser();
			laserIds = new List<uint>();
			try
			{
				string playAttackSoundString = LaserFatherCharged.playAttackSoundString;
				string playLoopSoundString = LaserFatherCharged.playLoopSoundString;
				laserStop = LaserFatherCharged.stopLoopSoundString;
				if (!string.IsNullOrEmpty(playAttackSoundString))
				{
					laserIds.Add(Util.PlaySound(playAttackSoundString, ((Component)this).gameObject));
				}
				if (!string.IsNullOrEmpty(playLoopSoundString))
				{
					laserIds.Add(Util.PlaySound(playLoopSoundString, ((Component)this).gameObject));
				}
			}
			catch (Exception ex)
			{
				ParryPlugin.Log.LogWarning((object)("False Son laser sound: " + ex.Message));
			}
			yield return (object)new WaitForSeconds(Mathf.Max(0.1f, ParryPlugin.LaserSeconds.Value));
			StopLaser();
		}

		private void StopLaser()
		{
			if (laserIds == null)
			{
				return;
			}
			try
			{
				if (!string.IsNullOrEmpty(laserStop))
				{
					Util.PlaySound(laserStop, ((Component)this).gameObject);
				}
			}
			catch
			{
			}
			foreach (uint laserId in laserIds)
			{
				AkStop.Stop(laserId);
			}
			laserIds = null;
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private bool IsLocal()
		{
			try
			{
				foreach (LocalUser readOnlyLocalUsers in LocalUserManager.readOnlyLocalUsersList)
				{
					if (readOnlyLocalUsers != null && (Object)(object)readOnlyLocalUsers.cachedBody == (Object)(object)body)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private static bool ChatOpen()
		{
			try
			{
				ChatBox[] array = Object.FindObjectsOfType<ChatBox>();
				foreach (ChatBox val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && val.showInput)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			return false;
		}

		private void Update()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (ParryPlugin.Has(body, ParryPlugin.ReadyBuff) && ParryPlugin.Pressed(ParryPlugin.Key.Value) && IsLocal() && !ChatOpen())
				{
					ParryPlugin.Request(body);
				}
			}
			catch
			{
			}
			bool flag = ParryPlugin.Has(body, ParryPlugin.WindowBuff);
			bool flag2 = ParryPlugin.Has(body, ParryPlugin.InvulnBuff) || ParryPlugin.Has(body, ParryPlugin.BoostBuff);
			if (flag && !wasWindow)
			{
				swingIds = ParryPlugin.PlayAll(ParryPlugin.ActivateSound.Value, ((Component)this).gameObject);
			}
			if (!flag && wasWindow && ParryPlugin.CutActivate.Value)
			{
				StopSwing();
			}
			if (flag2 && !wasParried)
			{
				if (ParryPlugin.CutActivate.Value)
				{
					StopSwing();
				}
				ParryPlugin.PlayAll(ParryPlugin.ParrySound.Value, ((Component)this).gameObject, ParryPlugin.ParryRepeat.Value);
				if ((ParryPlugin.ParrySound.Value ?? string.Empty).Contains("@falseson_laser"))
				{
					((MonoBehaviour)this).StartCoroutine(FalseSonLaser());
				}
			}
			wasWindow = flag;
			wasParried = flag2;
			invuln = ParryPlugin.Has(body, ParryPlugin.InvulnBuff);
		}

		private void OnGUI()
		{
			//IL_0060: 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_0045: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if ((wasWindow || wasParried) && ParryPlugin.ScreenTint.Value && IsLocal())
			{
				if (!Object.op_Implicit((Object)(object)tex))
				{
					tex = new Texture2D(1, 1);
					tex.SetPixel(0, 0, Color.white);
					tex.Apply();
				}
				Color color = GUI.color;
				float num = Mathf.Clamp01(invuln ? ParryPlugin.InvulnTint.Value : ((!wasParried) ? ParryPlugin.WindowTint.Value : ParryPlugin.BoostTint.Value));
				GUI.color = new Color(0.25f, 1f, 0.3f, num);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)tex);
				GUI.color = color;
			}
		}
	}
	internal static class RiskOfOptionsCompat
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Init()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			ModSettingsManager.SetModDescription("Press a key to open a short parry window; parrying an enemy hit grants brief invincibility and a damage boost.");
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(ParryPlugin.Key));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ParryPlugin.ScreenTint));
		}
	}
}

RexEnhancements.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates.Treebot;
using EntityStates.Treebot.Weapon;
using HarmonyLib;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace RexEnhancements
{
	[BepInPlugin("com.Sagittariod.RexEnhancements", "Rex Enhancements", "1.1.0")]
	public class RexEnhancementsPlugin : BaseUnityPlugin
	{
		private class RexContentPackProvider : IContentPackProvider
		{
			private readonly ContentPack contentPack = new ContentPack();

			public string identifier => "com.Sagittariod.RexEnhancements";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					PropertyInfo propertyInfo = AccessTools.Property(typeof(ContentPack), "identifier");
					if (propertyInfo != null)
					{
						propertyInfo.SetValue(contentPack, identifier, null);
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Could not set content pack identifier: " + ex.Message));
				}
				contentPack.buffDefs.Add((BuffDef[])(object)new BuffDef[1] { curseCleanserBuff });
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(contentPack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		public class MortarHitTracker : MonoBehaviour
		{
			public int hits;
		}

		public class ConvalescenceController : MonoBehaviour
		{
			public CharacterBody body;

			public BuffDef buffDef;

			public float remainingTime;

			private void Awake()
			{
				body = ((Component)this).GetComponent<CharacterBody>();
			}

			public void AddStack()
			{
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)buffDef))
				{
					int buffCount = body.GetBuffCount(buffDef);
					remainingTime += 9f * Mathf.Pow(0.815f, (float)buffCount);
					UpdateBuffStacks();
				}
			}

			private void FixedUpdate()
			{
				if (NetworkServer.active && !(remainingTime <= 0f))
				{
					remainingTime -= Time.fixedDeltaTime;
					if (remainingTime <= 0f)
					{
						remainingTime = 0f;
						ClearBuffs();
						Object.Destroy((Object)(object)this);
					}
					else
					{
						UpdateBuffStacks();
					}
				}
			}

			private void UpdateBuffStacks()
			{
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)buffDef))
				{
					int stacksForTime = GetStacksForTime(remainingTime);
					int i;
					for (i = body.GetBuffCount(buffDef); i < stacksForTime; i++)
					{
						body.AddBuff(buffDef);
					}
					while (i > stacksForTime)
					{
						body.RemoveBuff(buffDef);
						i--;
					}
				}
			}

			private void ClearBuffs()
			{
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)buffDef))
				{
					for (int num = body.GetBuffCount(buffDef); num > 0; num--)
					{
						body.RemoveBuff(buffDef);
					}
				}
			}

			public static int GetStacksForTime(float t)
			{
				if (t <= 0f)
				{
					return 0;
				}
				int num = 0;
				float num2 = 0f;
				float num3 = 10f;
				while (t > num2)
				{
					num++;
					num2 += num3;
					num3 *= 0.815f;
					if (num > 100)
					{
						break;
					}
				}
				return num;
			}
		}

		internal static ManualLogSource Log;

		public static ConfigEntry<float> maxBonusDamage;

		public static ConfigEntry<float> maxBonusArmor;

		public static ConfigEntry<float> brambleVolleyDamage;

		public static ConfigEntry<float> disperseCooldown;

		public static ConfigEntry<bool> harvestEndlagReduction;

		public static ConfigEntry<float> injectProcCoefficient;

		public static ConfigEntry<float> injectDamage;

		public static ConfigEntry<bool> enableNewPassive;

		public static ConfigEntry<bool> enableConvalescenceBuff;

		public static BuffDef curseCleanserBuff;

		private const string TreebotBodyPath = "RoR2/Base/Treebot/TreebotBody.prefab";

		private const string KeywordToken = "KEYWORD_CONVALESCENCE";

		private const string TreebotNameToken = "TREEBOT_BODY_NAME";

		internal static readonly Dictionary<string, string> LanguageOverrides = new Dictionary<string, string>();

		private static readonly HashSet<string> ConvalescenceSkillTokens = new HashSet<string> { "TREEBOT_SECONDARY_DESCRIPTION", "TREEBOT_SECONDARY_ALT1_DESCRIPTION", "TREEBOT_SPECIAL_DESCRIPTION", "TREEBOT_SPECIAL_ALT1_DESCRIPTION" };

		private static Action<CharacterBody, float> setDamage;

		private static Action<CharacterBody, float> setArmor;

		private static Action<CharacterBody, float> setMaxHealth;

		private static Action<CharacterBody, float> setCursePenalty;

		private static BodyIndex treebotBodyIndex = (BodyIndex)(-1);

		private Harmony harmony;

		private void Awake()
		{
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			enableNewPassive = ((BaseUnityPlugin)this).Config.Bind<bool>("Passive", "Enable New Passive", true, "If true, grants a new passive which increases armor and damage based on missing health");
			maxBonusDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Passive", "Max Bonus Damage", 4f, "Maximum percentage damage increase granted when at minimum health");
			maxBonusArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Passive", "Max Bonus Armor", 50f, "Maximum armor increase granted when at minimum health");
			harvestEndlagReduction = ((BaseUnityPlugin)this).Config.Bind<bool>("Existing Skills", "Enable Faster Harvest", true, "If true, halves the endlag of DIRECTIVE: HARVEST");
			injectProcCoefficient = ((BaseUnityPlugin)this).Config.Bind<float>("Existing Skills", "DIRECTIVE - Inject Proc Coefficient", 0.8f, "Proc coefficient for DIRECTIVE: INJECT");
			brambleVolleyDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Skills - Utility", "Bramble Volley Damage", 40f, "Damage coefficient for Bramble Volley");
			disperseCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Skills - Utility", "Directive Disperse Cooldown", 0.01f, "Base cooldown in seconds for Directive: DISPERSE");
			injectDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Existing Skills", "DIRECTIVE - Inject Damage", 0.8f, "Damage coefficient for DIRECTIVE: INJECT");
			enableConvalescenceBuff = ((BaseUnityPlugin)this).Config.Bind<bool>("Existing Skills", "Enable Convalescence Buff", true, "If true, specific abilities grant the Convalescence buff which temporarily reduce Curse");
			setDamage = MakeSetter("damage");
			setArmor = MakeSetter("armor");
			setMaxHealth = MakeSetter("maxHealth");
			setCursePenalty = MakeSetter("cursePenalty");
			SetupBuff();
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)delegate(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new RexContentPackProvider());
			};
			BuildLanguage();
			harmony = new Harmony("com.Sagittariod.RexEnhancements");
			Patch(AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), "LanguagePrefix");
			Patch(AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null), null, "RecalculateStatsPostfix");
			Patch(AccessTools.Method(typeof(TreebotFireFruitSeed), "OnEnter", (Type[])null, (Type[])null), "FireFruitSeedPrefix");
			Patch(AccessTools.Method(typeof(FireSyringe), "OnEnter", (Type[])null, (Type[])null), "FireSyringePrefix");
			Patch(AccessTools.Method(typeof(FirePlantSonicBoom), "OnEnter", (Type[])null, (Type[])null), "FirePlantSonicBoomPrefix");
			Patch(AccessTools.Method(typeof(GlobalEventManager), "OnHitEnemy", new Type[2]
			{
				typeof(DamageInfo),
				typeof(GameObject)
			}, (Type[])null), null, "OnHitEnemyPostfix");
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoaded));
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(OnGameLoaded));
		}

		private void Patch(MethodInfo target, string prefix = null, string postfix = null)
		{
			//IL_0043: 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)
			if (target == null)
			{
				Log.LogError((object)("Patch target not found for " + (prefix ?? postfix)));
				return;
			}
			try
			{
				harmony.Patch((MethodBase)target, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(RexEnhancementsPlugin), prefix, (Type[])null), (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(RexEnhancementsPlugin), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)string.Concat("Failed to patch ", target.DeclaringType, ".", target.Name, ": ", ex));
			}
		}

		private static Action<CharacterBody, float> MakeSetter(string property)
		{
			MethodInfo setter = AccessTools.PropertySetter(typeof(CharacterBody), property);
			if (setter == null)
			{
				Log.LogError((object)("CharacterBody." + property + " setter not found."));
				return delegate
				{
				};
			}
			try
			{
				return (Action<CharacterBody, float>)Delegate.CreateDelegate(typeof(Action<CharacterBody, float>), setter);
			}
			catch
			{
				return delegate(CharacterBody b, float v)
				{
					setter.Invoke(b, new object[1] { v });
				};
			}
		}

		private void SetupBuff()
		{
			curseCleanserBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)curseCleanserBuff).name = "Convalescence";
			curseCleanserBuff.canStack = true;
			curseCleanserBuff.isDebuff = false;
			curseCleanserBuff.isHidden = false;
			curseCleanserBuff.iconSprite = LoadSpriteFromManifest("Convalescence.png");
		}

		private Sprite LoadSpriteFromManifest(string fileName)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_00e4: 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)
			try
			{
				using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RexEnhancements." + fileName);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2);
				Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
				MethodInfo methodInfo = ((!(type != null)) ? null : type.GetMethod("LoadImage", new Type[2]
				{
					typeof(Texture2D),
					typeof(byte[])
				}));
				if (methodInfo == null)
				{
					Log.LogWarning((object)"ImageConversion.LoadImage not found; buff icon unavailable.");
					return null;
				}
				methodInfo.Invoke(null, new object[2] { val, array });
				return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return null;
			}
		}

		private void OnGameLoaded()
		{
			//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_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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			treebotBodyIndex = BodyCatalog.FindBodyIndex("TreebotBody");
			try
			{
				SkillDef val = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/Base/Treebot/TreebotBodySonicBoom.asset").WaitForCompletion();
				if (Object.op_Implicit((Object)(object)val))
				{
					val.baseRechargeInterval = disperseCooldown.Value;
				}
				else
				{
					Log.LogWarning((object)"DIRECTIVE: DISPERSE skill not found.");
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			try
			{
				ModifyPrefabs();
			}
			catch (Exception ex2)
			{
				Log.LogError((object)ex2);
			}
			try
			{
				GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Treebot/TreebotBody.prefab").WaitForCompletion();
				SkillLocator val3 = ((!Object.op_Implicit((Object)(object)val2)) ? null : val2.GetComponent<SkillLocator>());
				if (!Object.op_Implicit((Object)(object)val3))
				{
					Log.LogWarning((object)"REX SkillLocator not found.");
					return;
				}
				if (enableNewPassive.Value)
				{
					val3.passiveSkill.keywordToken = string.Empty;
				}
				if (enableConvalescenceBuff.Value)
				{
					AddKeyword(val3.secondary);
					AddKeyword(val3.special);
				}
			}
			catch (Exception ex3)
			{
				Log.LogError((object)ex3);
			}
		}

		private static void AddKeyword(GenericSkill slot)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)slot))
			{
				return;
			}
			SkillFamily skillFamily = slot.skillFamily;
			if (!Object.op_Implicit((Object)(object)skillFamily) || skillFamily.variants == null)
			{
				return;
			}
			Variant[] variants = skillFamily.variants;
			for (int i = 0; i < variants.Length; i++)
			{
				Variant val = variants[i];
				SkillDef skillDef = val.skillDef;
				if (Object.op_Implicit((Object)(object)skillDef) && ConvalescenceSkillTokens.Contains(skillDef.skillDescriptionToken))
				{
					string[] array = skillDef.keywordTokens ?? new string[0];
					if (!array.Contains("KEYWORD_CONVALESCENCE"))
					{
						skillDef.keywordTokens = array.Concat(new string[1] { "KEYWORD_CONVALESCENCE" }).ToArray();
					}
				}
			}
		}

		private static void ModifyPrefabs()
		{
			//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)
			string[] array = new string[2] { "RoR2/Base/Treebot/SyringeProjectile.prefab", "RoR2/Base/Treebot/SyringeProjectileHealing.prefab" };
			foreach (string text in array)
			{
				GameObject val = Addressables.LoadAssetAsync<GameObject>((object)text).WaitForCompletion();
				ProjectileController val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetComponent<ProjectileController>());
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.procCoefficient = injectProcCoefficient.Value;
				}
				else
				{
					Log.LogWarning((object)("Projectile not found: " + text));
				}
			}
		}

		private static void BuildLanguage()
		{
			LanguageOverrides["TREEBOT_PRIMARY_DESCRIPTION"] = $"Fire 3 syringes for <style=cIsDamage>3x{injectDamage.Value * 100f}% damage</style>. The last syringe <style=cIsDamage>Weakens</style> and <style=cIsHealing>heals for 60% of damage dealt</style>.";
			LanguageOverrides["TREEBOT_UTILITY_ALT1_DESCRIPTION"] = $"<style=cIsHealth>20% HP</style>. Fire a <style=cIsUtility>Sonic Boom</style> that damages enemies for <style=cIsDamage>{brambleVolleyDamage.Value * 100f}% damage</style>. <style=cIsHealing>Heals for every target hit</style>.";
			if (enableNewPassive.Value)
			{
				LanguageOverrides["TREEBOT_PASSIVE_NAME"] = "Adaptive Plating";
				LanguageOverrides["TREEBOT_PASSIVE_DESCRIPTION"] = string.Format("Gain up to <style=cIsUtility>{1} armor</style> and deal up to <style=cIsDamage>+{0}% damage</style> based on your <style=cIsHealth>missing health</style>.", maxBonusDamage.Value * 100f, maxBonusArmor.Value);
			}
			else
			{
				LanguageOverrides["TREEBOT_PASSIVE_NAME"] = "Natural Toxins";
				LanguageOverrides["TREEBOT_PASSIVE_DESCRIPTION"] = "Certain attacks <style=cIsDamage>Weaken</style> enemies hit, reducing their movement speed, armor, and damage.";
			}
			LanguageOverrides["TREEBOT_SPECIAL_DESCRIPTION"] = "<style=cIsHealth>25% HP</style>. Fire a flower that <style=cIsDamage>roots</style> for <style=cIsDamage>200% damage</style>. <style=cIsHealing>Heals for every target hit</style>." + ((!enableConvalescenceBuff.Value) ? string.Empty : " <style=cIsUtility>Direct hits grant Convalescence.</style>");
			LanguageOverrides["TREEBOT_SPECIAL_ALT1_DESCRIPTION"] = "Fire a bolt that deals <style=cIsDamage>330% damage</style> and <style=cIsDamage>injects</style> an enemy. On death, drop multiple <style=cIsHealing>healing fruits</style> that heal for <style=cIsHealing>25% HP</style>." + ((!enableConvalescenceBuff.Value) ? string.Empty : " <style=cIsUtility>Direct hits grant Convalescence.</style>");
			LanguageOverrides["TREEBOT_SECONDARY_ALT1_DESCRIPTION"] = "Launch a series of seed bullets into the sky, raining down for <style=cIsDamage>450% damage per second</style>." + ((!enableConvalescenceBuff.Value) ? string.Empty : " <style=cIsUtility>Every 4 hits grants Convalescence.</style>");
			LanguageOverrides["TREEBOT_SECONDARY_DESCRIPTION"] = "<style=cIsHealth>15% HP</style>. Launch a mortar into the sky for <style=cIsDamage>450% damage</style>." + ((!enableConvalescenceBuff.Value) ? string.Empty : " <style=cIsUtility>Each hit grants Convalescence.</style>");
			if (enableConvalescenceBuff.Value)
			{
				LanguageOverrides["KEYWORD_CONVALESCENCE"] = "<style=cKeywordName>Convalescence</style><style=cSub>Reduces current <style=cIsHealth>Curse</style> by 15% per stack. Higher stacks have shorter durations.</style>";
			}
		}

		private static bool LanguagePrefix(string token, ref string __result)
		{
			if (token != null && LanguageOverrides.TryGetValue(token, out var value))
			{
				__result = value;
				return false;
			}
			return true;
		}

		private static bool IsRex(CharacterBody body)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//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)
			if (!Object.op_Implicit((Object)(object)body))
			{
				return false;
			}
			if ((int)treebotBodyIndex != -1)
			{
				return body.bodyIndex == treebotBodyIndex;
			}
			return body.baseNameToken == "TREEBOT_BODY_NAME";
		}

		private static void RecalculateStatsPostfix(CharacterBody __instance)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			try
			{
				if (!IsRex(__instance))
				{
					return;
				}
				HealthComponent healthComponent = __instance.healthComponent;
				if (!Object.op_Implicit((Object)(object)healthComponent))
				{
					return;
				}
				if (enableNewPassive.Value && healthComponent.fullHealth > 0f)
				{
					float num = Mathf.Clamp01(healthComponent.health / healthComponent.fullHealth);
					setDamage(__instance, __instance.damage * (1f + maxBonusDamage.Value * (1f - num)));
					setArmor(__instance, __instance.armor + maxBonusArmor.Value * (1f - num));
				}
				if (enableConvalescenceBuff.Value && Object.op_Implicit((Object)(object)curseCleanserBuff) && (int)curseCleanserBuff.buffIndex != -1)
				{
					int buffCount = __instance.GetBuffCount(curseCleanserBuff);
					if (buffCount > 0 && !(__instance.cursePenalty <= 1f))
					{
						float cursePenalty = __instance.cursePenalty;
						float num2 = __instance.maxHealth * cursePenalty;
						float num3 = num2 - __instance.maxHealth;
						float num4 = num3 * Mathf.Pow(0.85f, (float)buffCount);
						float num5 = num2 - num4;
						setMaxHealth(__instance, num5);
						setCursePenalty(__instance, num2 / num5);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void FireFruitSeedPrefix(TreebotFireFruitSeed __instance)
		{
			if (harvestEndlagReduction.Value)
			{
				__instance.baseDuration = 0.5f;
			}
		}

		private static void FireSyringePrefix()
		{
			FireSyringe.damageCoefficient = injectDamage.Value;
		}

		private static void FirePlantSonicBoomPrefix()
		{
			FirePlantSonicBoom.damageCoefficient = brambleVolleyDamage.Value;
		}

		private static void OnHitEnemyPostfix(DamageInfo damageInfo)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			try
			{
				if (!enableConvalescenceBuff.Value || !NetworkServer.active || damageInfo == null || !Object.op_Implicit((Object)(object)curseCleanserBuff) || (int)curseCleanserBuff.buffIndex == -1 || !Object.op_Implicit((Object)(object)damageInfo.attacker) || !Object.op_Implicit((Object)(object)damageInfo.inflictor))
				{
					return;
				}
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				if (!IsRex(component))
				{
					return;
				}
				string name = ((Object)damageInfo.inflictor).name;
				bool flag = false;
				if (name.Contains("TreebotFruitSeed") || name.Contains("TreebotMortar2") || name.Contains("TreebotFlower"))
				{
					flag = true;
				}
				else if (name.Contains("TreebotMortar"))
				{
					MortarHitTracker mortarHitTracker = ((Component)component).GetComponent<MortarHitTracker>();
					if (!Object.op_Implicit((Object)(object)mortarHitTracker))
					{
						mortarHitTracker = ((Component)component).gameObject.AddComponent<MortarHitTracker>();
					}
					mortarHitTracker.hits++;
					if (mortarHitTracker.hits >= 4)
					{
						flag = true;
						mortarHitTracker.hits = 0;
					}
				}
				if (flag)
				{
					ConvalescenceController convalescenceController = ((Component)component).GetComponent<ConvalescenceController>();
					if (!Object.op_Implicit((Object)(object)convalescenceController))
					{
						convalescenceController = ((Component)component).gameObject.AddComponent<ConvalescenceController>();
						convalescenceController.buffDef = curseCleanserBuff;
					}
					convalescenceController.AddStack();
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

SaveSlots.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Missions.AccessCodes.Node;
using EntityStates.Missions.BrotherEncounter;
using EntityStates.ShrineHalcyonite;
using EntityStates.VoidCamp;
using HG.Reflection;
using HarmonyLib;
using ProperSave;
using ProperSave.Data;
using ProperSave.SaveData;
using ProperSave.Utils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("ProperSave")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: OptIn]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace SaveSlots
{
	[BepInPlugin("custom.SaveSlots", "SaveSlots", "1.5.3")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SaveSlotsPlugin : BaseUnityPlugin
	{
		public const string GUID = "custom.SaveSlots";

		public const string Version = "1.5.3";

		public const int SlotCount = 100;

		internal static SaveSlotsPlugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<string> FolderConfig;

		internal static ConfigEntry<bool> SaveStageStart;

		internal static ConfigEntry<bool> CpShrine;

		internal static ConfigEntry<bool> CpTeleporter;

		internal static ConfigEntry<bool> CpMithrix;

		internal static ConfigEntry<bool> CpFalseSon;

		internal static ConfigEntry<bool> CpVoidling;

		internal static ConfigEntry<bool> RemoveUsed;

		internal static ConfigEntry<bool> DeathButton;

		internal static ConfigEntry<bool> ImportProperSave;

		internal static ConfigEntry<bool> ChatMessages;

		internal static int activeSlot = -1;

		internal static int nextNewRunSlot = -1;

		internal static Checkpoint pendingCheckpoint;

		internal static List<PlayerBackup> pendingBackups;

		internal static bool justLoaded;

		internal static bool newRunFirstStage;

		internal static RunRngData firstStageRng;

		internal static Restore restore;

		internal static bool overridePostRunToLobby;

		private static string announcement;

		private static float nextScan;

		internal static string Folder
		{
			get
			{
				string text = ((FolderConfig == null) ? string.Empty : FolderConfig.Value);
				if (string.IsNullOrWhiteSpace(text))
				{
					text = Path.Combine(Paths.BepInExRootPath, "SaveSlots");
				}
				return text;
			}
		}

		private static string ImportedListPath => Path.Combine(Folder, "propersave_imported.txt");

		private void Awake()
		{
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			FolderConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Slots", "Folder", string.Empty, "Folder for the save slot files. Empty = BepInEx/SaveSlots in this mod profile.");
			SaveStageStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "SaveAtStageStart", true, "Save into the run's slot at the start of every stage (like ProperSave).");
			ChatMessages = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "ChatMessages", true, "Say in chat when the run is saved and which slot it uses.");
			CpShrine = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "HalcyonShrine", true, "Save when a Halcyon Shrine is activated. Loading it puts you beside the shrine and activates it again.");
			CpTeleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Teleporter", true, "Save when the teleporter is activated. Loading it puts you beside the teleporter and activates it again (Mountain Shrine stacks and portal orbs are kept).");
			CpMithrix = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Mithrix", true, "Save when the Mithrix fight starts. Loading it puts you in the arena and starts the fight (no pillars or climb).");
			CpFalseSon = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "FalseSon", true, "Save when the False Son fight starts. Loading it starts the fight (no climb).");
			CpVoidling = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "Voidling", true, "Save at the end of VoidlingRework's phases 1, 5, 8 and 11. Loading one starts the next phase (2, 6, 9 or 12).");
			RemoveUsed = ((BaseUnityPlugin)this).Config.Bind<bool>("Checkpoints", "KeepUsedInteractablesUsed", true, "Things used before a checkpoint stay used when it's loaded: chests, barrels, terminals, drones and cleared void seeds are gone, and shrines (Mountain, Halcyon, Descent and the rest) stay where they were but can't be used again. Their effects carry over: Mountain Shrine bosses, Access Nodes, portal orbs and extra portals.");
			ImportProperSave = ((BaseUnityPlugin)this).Config.Bind<bool>("Slots", "ImportProperSaveSave", true, "When the host opens the Save Slots window, the save ProperSave itself would continue for this lobby (one made without SaveSlots, e.g. before switching to it) is copied into the first empty slot, once per save. The ProperSave file is left as it is.");
			DeathButton = ((BaseUnityPlugin)this).Config.Bind<bool>("Death screen", "LoadButton", true, "Add a button to the game over screen that loads the run's slot again (not added when RespawnButton is installed; its button loads the slot instead).");
			InstallHooks(new Harmony("custom.SaveSlots"));
			Stage.onServerStageBegin += OnServerStageBegin;
			SceneDirector.onPostPopulateSceneServer += delegate
			{
				if (Object.op_Implicit((Object)(object)Instance))
				{
					((MonoBehaviour)Instance).StartCoroutine(ScanSoon());
				}
			};
			Run.onRunDestroyGlobal += delegate
			{
				restore = null;
				Interactables.Reset();
			};
			SceneManager.activeSceneChanged += delegate
			{
				SlotMenu.Close();
			};
			Log.LogInfo((object)("SaveSlots ready: " + 100 + " slots in " + Folder));
		}

		private void Update()
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance) && Time.unscaledTime >= nextScan)
			{
				nextScan = Time.unscaledTime + 8f;
				try
				{
					Interactables.Scan();
				}
				catch (Exception ex)
				{
					Log.LogDebug((object)("Scan: " + ex.Message));
				}
			}
		}

		private static IEnumerator ScanSoon()
		{
			yield return (object)new WaitForSeconds(1f);
			try
			{
				Interactables.Scan();
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Scan: " + ex.Message));
			}
		}

		private static void InstallHooks(Harmony h)
		{
			Type type = typeof(SaveFile).Assembly.GetType("ProperSave.Saving");
			Type type2 = typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI");
			Patch(h, AccessTools.Method(type, "SaveGame", (Type[])null, (Type[])null), "SkipPrefix", null);
			Patch(h, AccessTools.Method(type, "RunOnServerGameOver", (Type[])null, (Type[])null), "SkipPrefix", null);
			Patch(h, AccessTools.Method(typeof(Loading), "LoadLobby", (Type[])null, (Type[])null), "LoadLobbyPrefix", null);
			Patch(h, AccessTools.Method(type2, "LoadOnInputEvent", (Type[])null, (Type[])null), "LobbyButtonPrefix", null);
			Patch(h, AccessTools.Method(type2, "UpdateLobbyControls", (Type[])null, (Type[])null), null, "LobbyControlsPostfix");
			Patch(h, AccessTools.Method(typeof(Run), "Start", (Type[])null, (Type[])null), "RunStartPrefix", null);
			Patch(h, AccessTools.Method(typeof(Run), "GenerateStageRNG", (Type[])null, (Type[])null), "GenerateStageRngPrefix", null);
			Patch(h, AccessTools.Method(typeof(Run), "AdvanceStage", (Type[])null, (Type[])null), "AdvanceStagePrefix", null);
			Patch(h, AccessTools.Method(typeof(Stage), "RespawnCharacter", (Type[])null, (Type[])null), "RespawnCharacterPrefix", null);
			Patch(h, AccessTools.Method(typeof(HalcyoniteShrineInteractable), "TrackInteractions", (Type[])null, (Type[])null), "ShrinePrefix", null);
			Patch(h, AccessTools.Method(typeof(IdleState), "OnInteractionBegin", (Type[])null, (Type[])null), "TeleporterPrefix", null);
			Patch(h, AccessTools.Method(typeof(PreEncounter), "OnEnter", (Type[])null, (Type[])null), null, "MithrixPostfix");
			Patch(h, AccessTools.Method(typeof(MeridianEventTriggerInteraction), "HandleInitializeMeridianEvent", (Type[])null, (Type[])null), "FalseSonPrefix", null);
			Patch(h, AccessTools.Method(typeof(VoidRaidGauntletController), "TryOpenGauntlet", (Type[])null, (Type[])null), null, "GauntletPostfix");
			Patch(h, AccessTools.Method(typeof(ScriptedCombatEncounter), "BeginEncounter", (Type[])null, (Type[])null), "BeginEncounterPrefix", null, 800);
			Patch(h, AccessTools.Method(typeof(GameEndReportPanelController), "SetDisplayData", (Type[])null, (Type[])null), null, "GameEndPostfix");
			Patch(h, AccessTools.Method(typeof(MinionData), "LoadMinion", (Type[])null, (Type[])null), "LoadMinionPrefix", null);
			PatchFinalizer(h, AccessTools.Method(typeof(PlayerData), "LoadPlayer", (Type[])null, (Type[])null), "LoadPlayerFinalizer");
			PatchFinalizer(h, AccessTools.Method(typeof(SaveFile), "LoadPlayers", (Type[])null, (Type[])null), "LoadPlayersFinalizer");
			Patch(h, AccessTools.Method(typeof(EntityStateMachine), "SetState", new Type[1] { typeof(EntityState) }, (Type[])null), null, "SetStatePostfix");
			Type type3 = AccessTools.TypeByName("VoidlingRework.VLController");
			if (type3 != null)
			{
				Patch(h, AccessTools.Method(type3, "EnterP4", (Type[])null, (Type[])null), null, "VoidlingP4Postfix");
				MethodInfo methodInfo = AccessTools.Method(type3, "EndP11", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					Patch(h, methodInfo, null, "VoidlingP12Postfix");
				}
			}
			foreach (MethodInfo item in PostRunMethods())
			{
				Patch(h, item, "PostRunPrefix", null);
			}
		}

		private static void PatchFinalizer(Harmony h, MethodBase target, string finalizer)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (target == null)
			{
				Log.LogWarning((object)("Hook target missing for " + finalizer));
				return;
			}
			try
			{
				h.Patch(target, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(typeof(SaveSlotsPlugin), finalizer, (Type[])null), (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Hooking " + finalizer + ": " + ex));
			}
		}

		private static void Patch(Harmony h, MethodBase target, string prefix, string postfix, int prefixPriority = -1)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (target == null)
			{
				Log.LogWarning((object)("Hook target missing for " + (prefix ?? postfix)));
				return;
			}
			try
			{
				HarmonyMethod val = null;
				if (prefix != null)
				{
					val = new HarmonyMethod(typeof(SaveSlotsPlugin), prefix, (Type[])null);
					if (prefixPriority >= 0)
					{
						val.priority = prefixPriority;
					}
				}
				h.Patch(target, val, (postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(SaveSlotsPlugin), postfix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Could not hook " + target.DeclaringType?.Name + "." + target.Name + ": " + ex));
			}
		}

		private static IEnumerable<MethodInfo> PostRunMethods()
		{
			List<MethodInfo> list = new List<MethodInfo>();
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				Type[] types;
				try
				{
					types = assembly.GetTypes();
				}
				catch (ReflectionTypeLoadException ex)
				{
					types = ex.Types;
				}
				catch
				{
					continue;
				}
				if (types == null)
				{
					continue;
				}
				Type[] array = types;
				foreach (Type type in array)
				{
					if (!(type == null) && (!(type != typeof(Run)) || type.IsSubclassOf(typeof(Run))))
					{
						MethodInfo method = type.GetMethod("HandlePostRunDestination", BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (method != null && !method.IsAbstract)
						{
							list.Add(method);
						}
					}
				}
			}
			return list;
		}

		private static bool SkipPrefix()
		{
			return false;
		}

		private static bool LoadLobbyPrefix(ref IEnumerator __result)
		{
			__result = LoadSlotRoutine((activeSlot >= 0) ? activeSlot : SlotStore.MostRecent());
			return false;
		}

		private static bool LobbyButtonPrefix()
		{
			SlotMenu.Open();
			return false;
		}

		private static void LobbyControlsPostfix()
		{
			try
			{
				object? obj = AccessTools.Field(typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI"), "lobbyButton")?.GetValue(null);
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					bool flag = IsLobbyHost();
					HGButton component = val.GetComponent<HGButton>();
					if (Object.op_Implicit((Object)(object)component))
					{
						((Selectable)component).interactable = flag;
						component.hoverToken = "Load a save slot, or pick the slot the next new run saves into.";
					}
					LanguageTextMeshController component2 = val.GetComponent<LanguageTextMeshController>();
					if (Object.op_Implicit((Object)(object)component2) && component2.token != "Save Slots")
					{
						component2.token = "Save Slots";
					}
					SetLobbyTooltip(val, flag);
				}
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Lobby button: " + ex.Message));
			}
		}

		internal static void RefreshLobbyTooltip()
		{
			try
			{
				object? obj = AccessTools.Field(typeof(SaveFile).Assembly.GetType("ProperSave.LobbyUI"), "lobbyButton")?.GetValue(null);
				GameObject val = (GameObject)((obj is GameObject) ? obj : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					SetLobbyTooltip(val, IsLobbyHost());
				}
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Lobby tooltip: " + ex.Message));
			}
		}

		private static void SetLobbyTooltip(GameObject button, bool host)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			TooltipProvider component = button.GetComponent<TooltipProvider>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.SetContent(new TooltipContent
				{
					titleToken = "Save Slots",
					overrideBodyText = (host ? ("Next new run saves into: " + NewRunSlotText() + ".") : "Only the host can load or choose save slots."),
					titleColor = Color.black,
					disableBodyRichText = false
				});
			}
		}

		internal static bool IsLobbyHost()
		{
			try
			{
				if (!NetworkServer.active && NetworkClient.active)
				{
					return false;
				}
				return PlatformSystems.lobbyManager == null || PlatformSystems.lobbyManager.isInLobby == PlatformSystems.lobbyManager.ownsLobby;
			}
			catch
			{
				return NetworkServer.active;
			}
		}

		private static void RunStartPrefix()
		{
			if (NetworkServer.active)
			{
				restore = null;
				Interactables.Reset();
				firstStageRng = null;
				if (Loading.IsLoading)
				{
					newRunFirstStage = false;
					return;
				}
				newRunFirstStage = true;
				justLoaded = false;
				pendingCheckpoint = null;
				activeSlot = ((nextNewRunSlot >= 0) ? nextNewRunSlot : SlotStore.FirstEmpty());
				nextNewRunSlot = -1;
				announcement = ((activeSlot >= 0) ? ("This run saves into slot " + (activeSlot + 1) + ".") : "All save slots are full, so this run isn't being saved. Delete a slot or choose one in the Save Slots menu.");
			}
		}

		private static void GenerateStageRngPrefix(Run __instance)
		{
			if (NetworkServer.active && newRunFirstStage && firstStageRng == null)
			{
				firstStageRng = MakeRng(__instance);
			}
		}

		private static void AdvanceStagePrefix()
		{
			newRunFirstStage = false;
		}

		internal static RunRngData MakeRng(Run run)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_005a: 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_0093: Expected O, but got Unknown
			RngData val = RngData.Create(run.runRNG);
			return new RunRngData
			{
				runRng = RngData.Create(run.runRNG),
				nextStageRng = ((run.nextStageRng != null) ? RngData.Create(run.nextStageRng) : val),
				stageRngGenerator = ((run.stageRngGenerator != null) ? RngData.Create(run.stageRngGenerator) : val),
				loopRngGenerator = ((run.loopRngGenerator != null) ? RngData.Create(run.loopRngGenerator) : val),
				rerollStageRng = ((run.rerollStageRng != null) ? RngData.Create(run.rerollStageRng) : val)
			};
		}

		internal static string NewRunSlotText()
		{
			if (nextNewRunSlot >= 0)
			{
				return "slot " + (nextNewRunSlot + 1) + (SlotStore.Exists(nextNewRunSlot) ? " (replacing the run saved there)" : " (chosen)");
			}
			int num = SlotStore.FirstEmpty();
			if (num < 0)
			{
				return "nothing, all slots are full";
			}
			return "slot " + (num + 1) + " (first empty)";
		}

		private static void OnServerStageBegin(Stage stage)
		{
			//IL_0042: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Invalid comparison between Unknown and I4
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance))
			{
				return;
			}
			try
			{
				restore = null;
				Interactables.Reset();
				SceneDef val = ((!Object.op_Implicit((Object)(object)stage)) ? null : stage.sceneDef);
				string text;
				if (Object.op_Implicit((Object)(object)val))
				{
					text = val.cachedName;
				}
				else
				{
					Scene activeScene = SceneManager.GetActiveScene();
					text = ((Scene)(ref activeScene)).name;
				}
				string text2 = text;
				if (announcement != null)
				{
					Say(announcement);
					announcement = null;
				}
				if (justLoaded)
				{
					justLoaded = false;
					try
					{
						PlayerBackup.Verify(pendingBackups, "stage start");
					}
					catch (Exception ex)
					{
						Log.LogWarning((object)("Inventory check: " + ex.Message));
					}
					pendingBackups = null;
					Checkpoint checkpoint = pendingCheckpoint;
					pendingCheckpoint = null;
					if (checkpoint != null && checkpoint.kind != CpKind.None)
					{
						if (checkpoint.scene == text2)
						{
							StartRestore(stage, checkpoint);
							return;
						}
						Log.LogWarning((object)("Checkpoint was saved in " + checkpoint.scene + " but the run loaded into " + text2 + "; it starts from the stage start."));
					}
				}
				else if (Object.op_Implicit((Object)(object)val) && (int)val.sceneType != 0 && (int)val.sceneType != 3 && SaveStageStart.Value)
				{
					SaveNow(null);
				}
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Stage start: " + ex2));
			}
		}

		private static bool LoadMinionPrefix(MinionData __instance, CharacterMaster playerMaster)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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)
			GameObject val = null;
			try
			{
				if (__instance == null || __instance.masterIndex == MasterIndex.none || !Object.op_Implicit((Object)(object)playerMaster))
				{
					return false;
				}
				GameObject masterPrefab = MasterCatalog.GetMasterPrefab(__instance.masterIndex);
				if (!Object.op_Implicit((Object)(object)masterPrefab))
				{
					Log.LogWarning((object)("An ally of " + ((Object)playerMaster).name + " couldn't be restored (its master no longer exists)."));
					return false;
				}
				val = Object.Instantiate<GameObject>(masterPrefab);
				CharacterMaster component = val.GetComponent<CharacterMaster>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					throw new Exception(((Object)masterPrefab).name + " has no CharacterMaster");
				}
				component.teamIndex = (TeamIndex)1;
				if (__instance.master != null)
				{
					__instance.master.LoadMaster(component, true);
				}
				CharacterMaster val2 = playerMaster;
				if (Object.op_Implicit((Object)(object)val2.minionOwnership) && Object.op_Implicit((Object)(object)val2.minionOwnership.ownerMaster))
				{
					val2 = val2.minionOwnership.ownerMaster;
				}
				if (Object.op_Implicit((Object)(object)component.minionOwnership))
				{
					component.minionOwnership.SetOwner(val2);
				}
				AIOwnership component2 = val.GetComponent<AIOwnership>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.ownerMaster = playerMaster;
				}
				BaseAI component3 = val.GetComponent<BaseAI>();
				if (Object.op_Implicit((Object)(object)component3) && component3.leader != null)
				{
					component3.leader.gameObject = ((Component)playerMaster).gameObject;
				}
				if (__instance.devotedLemurianData != null)
				{
					try
					{
						DevotedLemurianController component4 = ((Component)component).GetComponent<DevotedLemurianController>();
						if (Object.op_Implicit((Object)(object)component4))
						{
							__instance.devotedLemurianData.LoadData(component4);
							component4._lemurianMaster = component;
							component4._devotionInventoryController = CharacterMasterData.GetDevotionInventoryController(playerMaster);
						}
					}
					catch (Exception ex)
					{
						Log.LogWarning((object)("Devoted lemurian: " + ex.Message));
					}
				}
				if (__instance.droneRepairData != null)
				{
					try
					{
						DroneRepairMaster component5 = ((Component)component).GetComponent<DroneRepairMaster>();
						if (Object.op_Implicit((Object)(object)component5))
						{
							__instance.droneRepairData.LoadData(component5);
						}
					}
					catch (Exception ex2)
					{
						Log.LogWarning((object)("Drone repair data: " + ex2.Message));
					}
				}
				NetworkServer.Spawn(val);
			}
			catch (Exception ex3)
			{
				Log.LogWarning((object)("An ally of " + (Object.op_Implicit((Object)(object)playerMaster) ? ((Object)playerMaster).name : "a player") + " couldn't be restored and was skipped: " + ex3.Message));
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)val);
				}
			}
			return false;
		}

		private static Exception LoadPlayerFinalizer(Exception __exception, NetworkUser player)
		{
			if (__exception != null)
			{
				Log.LogError((object)("ProperSave couldn't fully load " + (Object.op_Implicit((Object)(object)player) ? player.userName : "a player") + " (SaveSlots will restore their items from its own copy): " + __exception));
			}
			return null;
		}

		private static Exception LoadPlayersFinalizer(Exception __exception)
		{
			if (__exception != null)
			{
				Log.LogError((object)("Loading the players: " + __exception));
			}
			try
			{
				PlayerBackup.Verify(pendingBackups, "run start");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Inventory check: " + ex));
			}
			return null;
		}

		private static void SetStatePostfix(EntityStateMachine __instance, EntityState newState)
		{
			if (NetworkServer.active && newState is Deactivate && Object.op_Implicit((Object)(object)__instance))
			{
				Interactables.MarkVoidSeedCleared(((Component)__instance).gameObject);
			}
		}

		internal static void SaveCheckpoint(Checkpoint cp)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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)
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || activeSlot < 0 || (restore != null && !restore.done) || Loading.IsLoading)
			{
				return;
			}
			try
			{
				Scene activeScene = SceneManager.GetActiveScene();
				cp.scene = ((Scene)(ref activeScene)).name;
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody());
					string text = UserKey(instance);
					if (Object.op_Implicit((Object)(object)val) && text != null && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
					{
						cp.players.Add(new KeyValuePair<string, Vector3>(text, val.footPosition));
					}
				}
				if (cp.spot == Vector3.zero)
				{
					cp.spot = (Vector3)(((??)NearestPlayer(cp.anchor)) ?? cp.anchor);
				}
				CaptureStageEffects(cp);
				if (RemoveUsed.Value)
				{
					cp.used = Interactables.Used(cp.exclude);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Checkpoint data: " + ex.Message));
			}
			SaveNow(cp);
		}

		internal static void SaveNow(Checkpoint cp)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance) || activeSlot < 0 || Loading.IsLoading)
			{
				return;
			}
			int num = activeSlot;
			try
			{
				PrepareStageRng();
				SaveFileHeader val = new SaveFileHeader();
				val.FillFromCurrentRun();
				SaveFile val2 = new SaveFile();
				val2.FillFromCurrentRun();
				bool flag = ProperSavePlugin.Resilient == null || ProperSavePlugin.Resilient.Value;
				byte[] array;
				using (MemoryStream memoryStream = new MemoryStream())
				{
					using BinaryWriter binaryWriter = new BinaryWriter(memoryStream);
					val.Write(binaryWriter, flag);
					val2.Write(binaryWriter, flag);
					binaryWriter.Flush();
					array = memoryStream.ToArray();
				}
				SlotInfo slotInfo = SlotInfo.FromCurrentRun(num, val, cp);
				List<PlayerBackup> backups = null;
				try
				{
					backups = PlayerBackup.CaptureAll();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Inventory backup: " + ex.Message));
				}
				SlotStore.Write(num, slotInfo, cp, array, backups);
				ProperSavePlugin.CurrentSave = new SaveFileMetadata
				{
					Header = val,
					Body = val2,
					ForceLoad = false
				};
				Say("Saved to slot " + (num + 1) + ": " + slotInfo.kindLabel + ".");
				Log.LogInfo((object)("Saved slot " + (num + 1) + " (" + slotInfo.kindLabel + ", " + slotInfo.scene + ", " + array.Length + " bytes)."));
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Save failed: " + ex2));
				Say("Saving to slot " + (num + 1) + " failed (see the log).");
			}
			finally
			{
				try
				{
					ObjectBuffer.Clear();
				}
				catch
				{
				}
			}
		}

		private static void PrepareStageRng()
		{
			//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_0036: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene;
			if (newRunFirstStage)
			{
				if (firstStageRng == null)
				{
					Log.LogWarning((object)"The first stage's RNG wasn't recorded; this save won't regenerate the stage exactly.");
					firstStageRng = MakeRng(Run.instance);
				}
				Saving.PreStageRng = firstStageRng;
				activeScene = SceneManager.GetActiveScene();
				Saving.PreStageSceneName = ((Scene)(ref activeScene)).name;
			}
			else if (Saving.PreStageRng == null)
			{
				Log.LogWarning((object)"No stage RNG recorded; this save won't regenerate the stage exactly.");
				Saving.PreStageRng = MakeRng(Run.instance);
				activeScene = SceneManager.GetActiveScene();
				Saving.PreStageSceneName = ((Scene)(ref activeScene)).name;
			}
			if (string.IsNullOrEmpty(Saving.PreStageSceneName))
			{
				activeScene = SceneManager.GetActiveScene();
				Saving.PreStageSceneName = ((Scene)(ref activeScene)).name;
			}
		}

		internal static string ImportProperSaveFile()
		{
			//IL_011f: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			if (ImportProperSave == null || !ImportProperSave.Value || !Object.op_Implicit((Object)(object)PreGameController.instance))
			{
				return null;
			}
			SaveFileMetadata val = null;
			try
			{
				val = SaveFileMetadata.GetCurrentLobbySaveMetadata((NetworkUser)null) ?? SoloProperSave();
				if (val == null || val.Header == null || !val.FilePath.HasValue || ProperSavePlugin.SavesFileSystem == null || !ProperSavePlugin.SavesFileSystem.FileExists(val.FilePath.Value))
				{
					return null;
				}
				DateTime dateTime = val.Header.SaveDate;
				try
				{
					DateTime lastWriteTime = ProperSavePlugin.SavesFileSystem.GetLastWriteTime(val.FilePath.Value);
					if (dateTime.Year < 2000 || lastWriteTime > dateTime)
					{
						dateTime = lastWriteTime;
					}
				}
				catch
				{
				}
				string item = val.FileName + "|" + dateTime.Ticks;
				HashSet<string> hashSet = ReadImported();
				if (hashSet.Contains(item))
				{
					return null;
				}
				int num = SlotStore.FirstEmpty();
				if (num < 0)
				{
					return "Your ProperSave save can't be imported: every slot is full. Delete one and open this window again.";
				}
				byte[] array;
				using (Stream stream = ProperSavePlugin.SavesFileSystem.OpenFile(val.FilePath.Value, FileMode.Open, FileAccess.Read, FileShare.None))
				{
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
				using (MemoryStream input = new MemoryStream(array))
				{
					using BinaryReader binaryReader = new BinaryReader(input);
					SaveFileHeader.Read(binaryReader);
				}
				SlotInfo slotInfo = SlotInfo.FromHeader(num, val.Header, (dateTime.Kind == DateTimeKind.Utc) ? dateTime : dateTime.ToUniversalTime());
				SlotStore.Write(num, slotInfo, null, array);
				hashSet.Add(item);
				Directory.CreateDirectory(Folder);
				File.WriteAllLines(ImportedListPath, hashSet.ToArray());
				Log.LogInfo((object)("Imported ProperSave's save \"" + val.FileName + "\" into slot " + (num + 1) + " (" + slotInfo.OneLine() + ")."));
				return "Imported your ProperSave save into slot " + (num + 1) + ".";
			}
			catch (Exception ex)
			{
				Log.LogError((object)("ProperSave import" + ((val == null) ? "" : (" (\"" + val.FileName + "\")")) + ": " + ex));
				return "Your ProperSave save couldn't be imported (see the log).";
			}
			finally
			{
				try
				{
					ObjectBuffer.Clear();
				}
				catch
				{
				}
			}
		}

		private static SaveFileMetadata SoloProperSave()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (NetworkUser.readOnlyInstancesList.Count != 1 || LocalUserManager.readOnlyLocalUsersList.Count == 0 || !Object.op_Implicit((Object)(object)PreGameController.instance))
				{
					return null;
				}
				string profile = Path.GetFileNameWithoutExtension(LocalUserManager.readOnlyLocalUsersList[0].userProfile.fileName ?? string.Empty);
				GameModeIndex mode = PreGameController.instance.gameModeIndex;
				return ((IEnumerable<SaveFileMetadata>)SaveFileMetadata.SavesMetadata).FirstOrDefault((Func<SaveFileMetadata, bool>)((SaveFileMetadata m) => m != null && m.Header != null && m.Header.Users != null && m.Header.Users.Length == 1 && m.Header.GameMode == mode && Path.GetFileNameWithoutExtension(m.Header.UserProfileId ?? string.Empty) == profile));
			}
			catch
			{
				return null;
			}
		}

		private static HashSet<string> ReadImported()
		{
			HashSet<string> hashSet = new HashSet<string>();
			try
			{
				if (File.Exists(ImportedListPath))
				{
					string[] array = File.ReadAllLines(ImportedListPath);
					foreach (string text in array)
					{
						if (!string.IsNullOrWhiteSpace(text))
						{
							hashSet.Add(text.Trim());
						}
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Imported list: " + ex.Message));
			}
			return hashSet;
		}

		internal static IEnumerator LoadSlotRoutine(int slot)
		{
			yield return null;
			LoadSlot(slot);
		}

		internal static bool LoadSlot(int slot)
		{
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			string text = CanLoad(slot);
			if (text != null)
			{
				SlotMenu.ShowStatus(text);
				Log.LogInfo((object)("Can't load slot " + (slot + 1) + ": " + text));
				return false;
			}
			SlotInfo slotInfo = SlotStore.Read(slot, withBlob: true);
			if (slotInfo == null || !slotInfo.exists || slotInfo.blob == null)
			{
				SlotMenu.ShowStatus("Slot " + (slot + 1) + " couldn't be read" + ((slotInfo == null || slotInfo.error == null) ? "." : (": " + slotInfo.error)));
				return false;
			}
			SaveFileHeader val;
			SaveFile val2;
			try
			{
				using MemoryStream input = new MemoryStream(slotInfo.blob);
				using BinaryReader binaryReader = new BinaryReader(input);
				val = SaveFileHeader.Read(binaryReader);
				val2 = SaveFile.Read(binaryReader);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Reading slot " + (slot + 1) + ": " + ex));
				SlotMenu.ShowStatus("Slot " + (slot + 1) + " couldn't be read (see the log).");
				return false;
			}
			finally
			{
				try
				{
					ObjectBuffer.Clear();
				}
				catch
				{
				}
			}
			if (PreGameController.instance.gameModeIndex != val.GameMode)
			{
				SlotMenu.ShowStatus("Slot " + (slot + 1) + " is a " + ModeName(val.GameMode) + " run; switch the lobby to that mode first.");
				return false;
			}
			if (val.ContentHash != ProperSavePlugin.ContentHash)
			{
				Log.LogWarning((object)("Slot " + (slot + 1) + " was saved with a different mod list; loading anyway."));
			}
			activeSlot = slot;
			nextNewRunSlot = -1;
			pendingCheckpoint = slotInfo.checkpoint;
			pendingBackups = slotInfo.backups;
			justLoaded = true;
			newRunFirstStage = false;
			firstStageRng = null;
			Saving.PreStageRng = val2.RunData.runRng;
			Saving.PreStageSceneName = val2.RunData.previousSceneName;
			ProperSavePlugin.CurrentSave = new SaveFileMetadata
			{
				Header = val,
				Body = val2,
				ForceLoad = false
			};
			announcement = "Loaded slot " + (slot + 1) + ": " + slotInfo.kindLabel + ".";
			Log.LogInfo((object)("Loading slot " + (slot + 1) + " (" + slotInfo.kindLabel + ", " + slotInfo.scene + ")."));
			SlotMenu.Close();
			Loading.IsLoading = true;
			PreGameController.instance.StartRun();
			return true;
		}

		internal static string CanLoad(int slot)
		{
			if (slot < 0 || slot >= 100)
			{
				return "There's no save to load.";
			}
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				return "A run is already in progress.";
			}
			if (Loading.IsLoading)
			{
				return "Already loading.";
			}
			if (!Object.op_Implicit((Object)(object)PreGameController.instance))
			{
				return "Load from the character select screen.";
			}
			if (!IsLobbyHost())
			{
				return "Only the host can load.";
			}
			if (!SlotStore.Exists(slot))
			{
				return "Slot " + (slot + 1) + " is empty.";
			}
			return null;
		}

		internal static string ModeName(GameModeIndex index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string gameModeName = GameModeCatalog.GetGameModeName(index);
				return string.IsNullOrEmpty(gameModeName) ? "different" : gameModeName.Replace("Run", string.Empty);
			}
			catch
			{
				return "different";
			}
		}

		private static void StartRestore(Stage stage, Checkpoint cp)
		{
			restore = new Restore
			{
				cp = cp,
				stage = stage
			};
			Log.LogInfo((object)("Restoring checkpoint: " + cp.Label()));
			if (cp.kind == CpKind.Voidling)
			{
				TryOpenVoidGauntlets();
			}
			((MonoBehaviour)Instance).StartCoroutine(RestoreRoutine(restore));
		}

		private static IEnumerator RestoreRoutine(Restore r)
		{
			Checkpoint cp = r.cp;
			float t0 = Time.time;
			if (cp.kind == CpKind.Voidling)
			{
				while (!r.voidOpened && Time.time - t0 < 20f)
				{
					if (restore != r)
					{
						yield break;
					}
					TryOpenVoidGauntlets();
					yield return (object)new WaitForSeconds(0.25f);
				}
			}
			t0 = Time.time;
			while (Time.time - t0 < 20f && !AllPlayersSpawned())
			{
				if (restore != r)
				{
					yield break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			yield return (object)new WaitForSeconds(1f);
			if (restore != r)
			{
				yield break;
			}
			try
			{
				if (RemoveUsed.Value && cp.used.Count > 0)
				{
					Interactables.Apply(cp.used);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Used interactables: " + ex.Message));
			}
			try
			{
				RestoreStageEffects(cp);
			}
			catch (Exception ex2)
			{
				Log.LogWarning((object)("Stage effects: " + ex2.Message));
			}
			IEnumerator routine = null;
			switch (cp.kind)
			{
			case CpKind.Teleporter:
				routine = RestoreTeleporter(r);
				break;
			case CpKind.Shrine:
				routine = RestoreShrine(r);
				break;
			case CpKind.Mithrix:
				routine = RestoreMithrix(r);
				break;
			case CpKind.FalseSon:
				routine = RestoreFalseSon(r);
				break;
			case CpKind.Voidling:
				routine = RestoreVoidling(r);
				break;
			}
			if (routine != null)
			{
				while (true)
				{
					bool flag;
					try
					{
						flag = routine.MoveNext();
					}
					catch (Exception ex3)
					{
						Log.LogError((object)("Restoring " + cp.Label() + ": " + ex3));
						break;
					}
					if (!flag)
					{
						break;
					}
					yield return routine.Current;
					if (restore != r)
					{
						yield break;
					}
				}
			}
			if (restore == r)
			{
				r.done = true;
				Log.LogInfo((object)("Checkpoint restored: " + cp.Label()));
			}
		}

		private static bool AllPlayersSpawned()
		{
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.networkUser) && Object.op_Implicit((Object)(object)instance.master) && !Object.op_Implicit((Object)(object)instance.master.GetBody()))
				{
					return false;
				}
			}
			return true;
		}

		private static Interactor FirstInteractor()
		{
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody());
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
				{
					Interactor component = ((Component)val).GetComponent<Interactor>();
					if (Object.op_Implicit((Object)(object)component))
					{
						return component;
					}
				}
			}
			return null;
		}

		private static IEnumerator RestoreTeleporter(Restore r)
		{
			float t0 = Time.time;
			while (!Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && Time.time - t0 < 10f)
			{
				yield return (object)new WaitForSeconds(0.25f);
			}
			TeleporterInteraction instance = TeleporterInteraction.instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				Log.LogWarning((object)"No teleporter found to activate.");
				yield break;
			}
			try
			{
				Type type = AccessTools.TypeByName("GuaranteedHalcyonShrine.GuaranteedHalcyonShrinePlugin");
				((type == null) ? null : AccessTools.Field(type, "shrineDefeated"))?.SetValue(null, true);
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Halcyon lock: " + ex.Message));
			}
			Interactor val = FirstInteractor();
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.LogWarning((object)"No player to activate the teleporter.");
			}
			else if (instance.isIdle)
			{
				instance.OnInteractionBegin(val);
			}
		}

		private static IEnumerator RestoreShrine(Restore r)
		{
			Checkpoint cp = r.cp;
			HalcyoniteShrineInteractable shrine = null;
			float t0 = Time.time;
			while (Time.time - t0 < 10f)
			{
				shrine = NearestShrine(cp.anchor);
				if (Object.op_Implicit((Object)(object)shrine))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			if (!Object.op_Implicit((Object)(object)shrine))
			{
				Log.LogWarning((object)"No Halcyon Shrine found to activate.");
			}
			else if (shrine.interactions <= 0)
			{
				Interactor val = FirstInteractor();
				PurchaseInteraction component = ((Component)shrine).GetComponent<PurchaseInteraction>();
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)component) && component.available)
				{
					component.OnInteractionBegin(val);
				}
				yield return (object)new WaitForSeconds(0.5f);
				if (Object.op_Implicit((Object)(object)shrine) && shrine.interactions == 0)
				{
					shrine.TrackInteractions();
				}
			}
		}

		private static HalcyoniteShrineInteractable NearestShrine(Vector3 pos)
		{
			//IL_001e: 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_0024: 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)
			HalcyoniteShrineInteractable result = null;
			float num = float.MaxValue;
			HalcyoniteShrineInteractable[] array = Object.FindObjectsOfType<HalcyoniteShrineInteractable>();
			foreach (HalcyoniteShrineInteractable val in array)
			{
				Vector3 val2 = ((Component)val).transform.position - pos;
				float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					result = val;
				}
			}
			return result;
		}

		private static IEnumerator RestoreMithrix(Restore r)
		{
			Checkpoint cp = r.cp;
			EntityStateMachine esm = null;
			float t0 = Time.time;
			while (Time.time - t0 < 10f)
			{
				esm = FindBrotherEncounter(cp.objectPath);
				if (Object.op_Implicit((Object)(object)esm))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			if (!Object.op_Implicit((Object)(object)esm))
			{
				Log.LogWarning((object)"Mithrix's arena wasn't found.");
				yield break;
			}
			if (!((Component)esm).gameObject.activeInHierarchy)
			{
				Transform val = ((Component)esm).transform;
				while (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.SetActive(true);
					val = val.parent;
				}
			}
			yield return (object)new WaitForSeconds(0.5f);
			if (Object.op_Implicit((Object)(object)esm) && !(esm.state is PreEncounter) && !(esm.state is BrotherEncounterBaseState))
			{
				esm.SetNextState((EntityState)new PreEncounter());
			}
		}

		private static EntityStateMachine FindBrotherEncounter(string path)
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			EntityStateMachine val = null;
			EntityStateMachine[] array = Resources.FindObjectsOfTypeAll<EntityStateMachine>();
			foreach (EntityStateMachine val2 in array)
			{
				if (!Object.op_Implicit((Object)(object)val2) || ((Component)val2).gameObject.scene != activeScene)
				{
					continue;
				}
				ChildLocator component = ((Component)val2).GetComponent<ChildLocator>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.FindChild("PreEncounter")) && Object.op_Implicit((Object)(object)component.FindChild("ArenaWalls")))
				{
					if (!string.IsNullOrEmpty(path) && PathOf(((Component)val2).transform) == path)
					{
						return val2;
					}
					if (!Object.op_Implicit((Object)(object)val))
					{
						val = val2;
					}
				}
			}
			return val;
		}

		internal static string PathOf(Transform t)
		{
			StringBuilder stringBuilder = new StringBuilder();
			while (Object.op_Implicit((Object)(object)t))
			{
				stringBuilder.Insert(0, "/" + ((Object)t).name);
				t = t.parent;
			}
			return stringBuilder.ToString();
		}

		private static IEnumerator RestoreFalseSon(Restore r)
		{
			MeridianEventTriggerInteraction trigger = null;
			float t0 = Time.time;
			while (Time.time - t0 < 10f)
			{
				trigger = MeridianEventTriggerInteraction.instance;
				if (!Object.op_Implicit((Object)(object)trigger))
				{
					trigger = ((IEnumerable<MeridianEventTriggerInteraction>)Resources.FindObjectsOfTypeAll<MeridianEventTriggerInteraction>()).FirstOrDefault((Func<MeridianEventTriggerInteraction, bool>)((MeridianEventTriggerInteraction m) => Object.op_Implicit((Object)(object)m) && ((Component)m).gameObject.scene == SceneManager.GetActiveScene()));
				}
				if (Object.op_Implicit((Object)(object)trigger))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			if (!Object.op_Implicit((Object)(object)trigger))
			{
				Log.LogWarning((object)"False Son's event trigger wasn't found.");
				yield break;
			}
			if (!((Component)trigger).gameObject.activeInHierarchy)
			{
				((Component)trigger).gameObject.SetActive(true);
				yield return null;
			}
			if (!trigger.isTriggered)
			{
				trigger.HandleInitializeMeridianEvent();
				BoxCollider component = ((Component)trigger).GetComponent<BoxCollider>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Collider)component).enabled = false;
				}
			}
		}

		internal static void TryOpenVoidGauntlets()
		{
			//IL_0133: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: 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_00b2: 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_00a3: 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)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			Restore restore = SaveSlotsPlugin.restore;
			if (restore == null || restore.cp.kind != CpKind.Voidling || restore.voidOpened)
			{
				return;
			}
			VoidRaidGauntletController instance = VoidRaidGauntletController.instance;
			if (!Object.op_Implicit((Object)(object)instance) || !instance.hasShuffled || instance.followingDonuts == null || instance.followingDonuts.Length == 0)
			{
				return;
			}
			int num = Mathf.Clamp(restore.cp.phase, 2, 5);
			int num2 = (restore.voidEncounterIndex = (restore.voidGauntletTarget = Mathf.Min(num - 1, 2)));
			int num3 = 0;
			while (instance.gauntletIndex < num2 && num3++ < 4)
			{
				DonutInfo val = instance.currentDonut ?? instance.initialDonut;
				Vector3 val2 = ((val == null || !Object.op_Implicit((Object)(object)val.crabPosition)) ? Vector3.zero : val.crabPosition.position);
				if (!instance.TryOpenGauntlet(val2, NetworkInstanceId.Invalid))
				{
					break;
				}
			}
			DonutInfo val3 = instance.followingDonuts[Mathf.Clamp(num2 - 1, 0, instance.followingDonuts.Length - 1)];
			if (val3 != null)
			{
				if (Object.op_Implicit((Object)(object)val3.root) && !val3.root.activeSelf)
				{
					val3.root.SetActive(true);
				}
				restore.voidSpawn = (Object.op_Implicit((Object)(object)val3.returnPoint) ? val3.returnPoint.position : ((!Object.op_Implicit((Object)(object)val3.crabPosition)) ? Vector3.zero : val3.crabPosition.position));
				restore.voidFace = ((!Object.op_Implicit((Object)(object)val3.crabPosition)) ? restore.voidSpawn : val3.crabPosition.position);
				restore.voidOpened = true;
				Log.LogInfo((object)("Voidling checkpoint: opened the way to phase " + Checkpoint.VoidlingPhaseNumber(num) + "'s arena."));
			}
		}

		private static IEnumerator RestoreVoidling(Restore r)
		{
			VoidRaidGauntletController g = VoidRaidGauntletController.instance;
			if (!Object.op_Implicit((Object)(object)g) || !r.voidOpened)
			{
				Log.LogWarning((object)"Voidling's arenas weren't found.");
				yield break;
			}
			int num = 0;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterMaster val = ((!Object.op_Implicit((Object)(object)instance)) ? null : instance.master);
				CharacterBody val2 = ((!Object.op_Implicit((Object)(object)val)) ? null : val.GetBody());
				if (Object.op_Implicit((Object)(object)val2) && Flat(val2.footPosition - r.voidSpawn) > 60f)
				{
					Vector3 val3 = Ring(r.voidSpawn, num++);
					RespawnArgs val4 = new RespawnArgs
					{
						spawnBodyArgs = new SpawnBodyArgs
						{
							spawnPointPosition = val3,
							spawnPointRotation = Face(val3, r.voidFace),
							spawnPointIsFootPos = true
						},
						ignoreMetamorphosis = true
					};
					val.Respawn(ref val4);
				}
			}
			yield return (object)new WaitForSeconds(1.5f);
			ScriptedCombatEncounter[] phaseEncounters = g.phaseEncounters;
			if (phaseEncounters == null || r.voidEncounterIndex >= phaseEncounters.Length)
			{
				yield break;
			}
			ScriptedCombatEncounter val5 = phaseEncounters[r.voidEncounterIndex];
			bool flag = false;
			if (r.cp.phase >= 4)
			{
				try
				{
					Type type = AccessTools.TypeByName("VoidlingRework.VoidlingReworkPlugin");
					PropertyInfo propertyInfo = ((type == null) ? null : AccessTools.Property(type, (r.cp.phase >= 5) ? "CheckpointStartPhase12" : "CheckpointStartPhase9"));
					if (propertyInfo != null)
					{
						propertyInfo.SetValue(null, true, null);
						flag = true;
					}
					else if (r.cp.phase >= 5)
					{
						Log.LogWarning((object)"This VoidlingRework can't start at phase 12; the last arena's fight starts from phase 6.");
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Phase " + ((r.cp.phase >= 5) ? "12" : "9") + " start: " + ex.Message));
				}
			}
			if (Object.op_Implicit((Object)(object)val5) && !val5.hasSpawnedServer)
			{
				val5.BeginEncounter();
			}
			if (r.cp.phase != 4 || flag)
			{
				yield break;
			}
			Type vl = AccessTools.TypeByName("VoidlingRework.VLController");
			if (vl == null)
			{
				yield break;
			}
			FieldInfo phaseField = AccessTools.Field(vl, "phase");
			FieldInfo stageField = AccessTools.Field(vl, "stage");
			MethodInfo enterP4 = AccessTools.Method(vl, "EnterP4", (Type[])null, (Type[])null);
			if (phaseField == null || stageField == null || enterP4 == null)
			{
				yield break;
			}
			float t0 = Time.time;
			float seen = -1f;
			while (Time.time - t0 < 90f)
			{
				Object val6 = ((IEnumerable<Object>)Object.FindObjectsOfType(vl)).FirstOrDefault((Func<Object, bool>)((Object o) => Object.op_Implicit(o) && (int)phaseField.GetValue(o) == 3));
				if (val6 != (Object)null)
				{
					int num2 = (int)stageField.GetValue(val6);
					if (num2 >= 40)
					{
						yield break;
					}
					if (num2 >= 30)
					{
						if (seen < 0f)
						{
							seen = Time.time;
						}
						if (Time.time - seen >= 3f)
						{
							enterP4.Invoke(val6, null);
							Log.LogInfo((object)"Voidling checkpoint: phase 9 started.");
							yield break;
						}
					}
				}
				yield return (object)new WaitForSeconds(0.25f);
			}
			Log.LogWarning((object)"The last arena's voidling never appeared, so phase 9 couldn't start.");
		}

		private static bool BeginEncounterPrefix(ScriptedCombatEncounter __instance)
		{
			try
			{
				Restore restore = SaveSlotsPlugin.restore;
				if (!NetworkServer.active || restore == null || restore.cp.kind != CpKind.Voidling)
				{
					return true;
				}
				VoidRaidGauntletController instance = VoidRaidGauntletController.instance;
				if (!Object.op_Implicit((Object)(object)instance) || instance.phaseEncounters == null)
				{
					return true;
				}
				int num = Array.IndexOf(instance.phaseEncounters, __instance);
				int num2 = Mathf.Min(Mathf.Clamp(restore.cp.phase, 2, 5) - 1, 2);
				if (num >= 0 && num < num2)
				{
					Log.LogInfo((object)("Voidling checkpoint: phase " + (num + 1) + " skipped."));
					return false;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("BeginEncounterPrefix: " + ex.Message));
			}
			return true;
		}

		private static bool RespawnCharacterPrefix(Stage __instance, CharacterMaster characterMaster)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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)
			//IL_00aa: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Restore restore = SaveSlotsPlugin.restore;
				if (!NetworkServer.active || restore == null || restore.done || !Object.op_Implicit((Object)(object)characterMaster) || !Object.op_Implicit((Object)(object)characterMaster.playerCharacterMasterController) || restore.spawned.Contains(characterMaster))
				{
					return true;
				}
				Checkpoint cp = restore.cp;
				Vector3 val;
				Vector3 to;
				switch (cp.kind)
				{
				case CpKind.Shrine:
				case CpKind.Teleporter:
				case CpKind.Mithrix:
				{
					string key = UserKey(characterMaster.playerCharacterMasterController);
					KeyValuePair<string, Vector3> keyValuePair = cp.players.FirstOrDefault((KeyValuePair<string, Vector3> p) => p.Key == key);
					val = ((keyValuePair.Key != null && Flat(keyValuePair.Value - cp.spot) <= 60f) ? keyValuePair.Value : Ring(cp.spot, restore.spawnCount));
					to = cp.anchor;
					break;
				}
				case CpKind.Voidling:
					TryOpenVoidGauntlets();
					if (!restore.voidOpened)
					{
						return true;
					}
					val = Ring(restore.voidSpawn, restore.spawnCount);
					to = restore.voidFace;
					break;
				default:
					return true;
				}
				restore.spawned.Add(characterMaster);
				restore.spawnCount++;
				RespawnArgs val2 = new RespawnArgs
				{
					spawnBodyArgs = new SpawnBodyArgs
					{
						spawnPointPosition = val,
						spawnPointRotation = Face(val, to),
						spawnPointIsFootPos = true
					},
					ignoreMetamorphosis = true
				};
				characterMaster.Respawn(ref val2);
				__instance.spawnedAnyPlayer = true;
				return false;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Checkpoint spawn: " + ex.Message));
				return true;
			}
		}

		internal static float Flat(Vector3 v)
		{
			v.y = 0f;
			return ((Vector3)(ref v)).magnitude;
		}

		internal static Vector3 Ring(Vector3 center, int index)
		{
			//IL_0028: 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)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (index <= 0)
			{
				return center;
			}
			float num = (float)index * 72f * ((float)Math.PI / 180f);
			float num2 = 2.5f + 1.5f * (float)((index - 1) / 5);
			return center + new Vector3(Mathf.Cos(num) * num2, 0.5f, Mathf.Sin(num) * num2);
		}

		internal static Quaternion Face(Vector3 from, Vector3 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0028: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			val.y = 0f;
			if (!(((Vector3)(ref val)).sqrMagnitude > 0.01f))
			{
				return Quaternion.identity;
			}
			return Quaternion.LookRotation(val);
		}

		internal static Vector3? NearestPlayer(Vector3 pos)
		{
			//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_0074: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			Vector3? result = null;
			float num = float.MaxValue;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody());
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
				{
					Vector3 val2 = val.footPosition - pos;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = val.footPosition;
					}
				}
			}
			return result;
		}

		internal static string UserKey(PlayerCharacterMasterController pc)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			if (!Object.op_Implicit((Object)(object)pc))
			{
				return null;
			}
			NetworkUser networkUser = pc.networkUser;
			if (!Object.op_Implicit((Object)(object)networkUser))
			{
				return "master:" + (Object.op_Implicit((Object)(object)pc.master) ? ((Object)pc.master).name : "?");
			}
			NetworkUserId id = networkUser.id;
			return id.value + "|" + id.strValue + "|" + id.subId;
		}

		private static void CaptureStageEffects(Checkpoint cp)
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (Object.op_Implicit((Object)(object)instance))
				{
					cp.shrineStacks = instance.shrineBonusStacks;
					cp.shopPortal = instance.shouldAttemptToSpawnShopPortal;
					cp.goldPortal = instance.shouldAttemptToSpawnGoldshoresPortal;
					cp.msPortal = instance.shouldAttemptToSpawnMSPortal;
					cp.hiddenPortal = instance.shouldAttemptToSpawnHiddenRealmsPortal;
					cp.accessDone = instance.showAccessCodesIndicator;
				}
				if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Run.instance.nextStageScene))
				{
					cp.nextScene = Run.instance.nextStageScene.cachedName ?? string.Empty;
				}
				PortalSpawner[] array = Object.FindObjectsOfType<PortalSpawner>();
				foreach (PortalSpawner val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && val.hasRegisteredToTeleporter)
					{
						cp.portals.Add(new KeyValuePair<string, Vector3>(Interactables.Clean(((Object)((Component)val).gameObject).name), ((Component)val).transform.position));
					}
				}
				AccessCodesMissionController instance2 = AccessCodesMissionController.instance;
				if (!Object.op_Implicit((Object)(object)instance2) || instance2.nodes == null)
				{
					return;
				}
				AccessCodesNodeData[] nodes = instance2.nodes;
				foreach (AccessCodesNodeData val2 in nodes)
				{
					EntityStateMachine val3 = ((!Object.op_Implicit((Object)(object)val2.node)) ? null : val2.node.GetComponent<EntityStateMachine>());
					if (Object.op_Implicit((Object)(object)val3) && (val3.state is NodeActive || val3.state is NodeAccessed || val3.state is Complete))
					{
						cp.accessNodes.Add(val2.id);
					}
				}
				if (cp.accessNodes.Count > 0 && cp.accessNodes.Count >= instance2.nodes.Length)
				{
					cp.accessDone = true;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stage effects: " + ex.Message));
			}
		}

		private static void RestoreStageEffects(Checkpoint cp)
		{
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Expected O, but got Unknown
			TeleporterInteraction instance = TeleporterInteraction.instance;
			bool flag = Object.op_Implicit((Object)(object)instance) && instance.isIdle;
			if (flag)
			{
				int num = 0;
				while (instance.shrineBonusStacks < cp.shrineStacks && num++ < 100)
				{
					instance.AddShrineStack();
				}
				if (num > 0)
				{
					Log.LogInfo((object)("Mountain Shrine stacks restored: " + instance.shrineBonusStacks + "."));
				}
				if (cp.shopPortal)
				{
					instance.shouldAttemptToSpawnShopPortal = true;
				}
				if (cp.goldPortal)
				{
					instance.shouldAttemptToSpawnGoldshoresPortal = true;
				}
				if (cp.msPortal)
				{
					instance.shouldAttemptToSpawnMSPortal = true;
				}
				if (cp.hiddenPortal)
				{
					instance.shouldAttemptToSpawnHiddenRealmsPortal = true;
				}
			}
			if (!string.IsNullOrEmpty(cp.nextScene) && Object.op_Implicit((Object)(object)Run.instance))
			{
				SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(cp.nextScene);
				if (Object.op_Implicit((Object)(object)sceneDefFromSceneName) && (Object)(object)Run.instance.nextStageScene != (Object)(object)sceneDefFromSceneName)
				{
					Run.instance.nextStageScene = sceneDefFromSceneName;
					Log.LogInfo((object)("Next stage restored: " + cp.nextScene + "."));
				}
			}
			if (cp.portals.Count > 0)
			{
				PortalSpawner[] array = Object.FindObjectsOfType<PortalSpawner>();
				foreach (KeyValuePair<string, Vector3> portal in cp.portals)
				{
					PortalSpawner val = null;
					float num2 = 2.25f;
					PortalSpawner[] array2 = array;
					foreach (PortalSpawner val2 in array2)
					{
						if (Object.op_Implicit((Object)(object)val2) && Interactables.Clean(((Object)((Component)val2).gameObject).name) == portal.Key)
						{
							Vector3 val3 = ((Component)val2).transform.position - portal.Value;
							float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
							if (sqrMagnitude < num2)
							{
								num2 = sqrMagnitude;
								val = val2;
							}
						}
					}
					if (Object.op_Implicit((Object)(object)val) && !val.hasRegisteredToTeleporter)
					{
						if (!val.willSpawn)
						{
							val.NetworkwillSpawn = true;
						}
						if (val.registerSelfToPortalRemotelyOnActivation)
						{
							val.TryToRemotelyRegisterToPortal();
						}
						else if (Object.op_Implicit((Object)(object)instance))
						{
							instance.TryAddingPortal(val);
							val.hasRegisteredToTeleporter = true;
						}
						Log.LogInfo((object)("Portal restored: " + portal.Key + "."));
					}
				}
			}
			AccessCodesMissionController instance2 = AccessCodesMissionController.instance;
			if (!flag || !Object.op_Implicit((Object)(object)instance2) || instance2.nodes == null)
			{
				return;
			}
			if (cp.accessDone)
			{
				if (!instance.showAccessCodesIndicator)
				{
					instance2.ActivateCode();
					Log.LogInfo((object)"Access Nodes restored: complete.");
				}
			}
			else
			{
				if (cp.accessNodes.Count <= 0)
				{
					return;
				}
				int num3 = 0;
				AccessCodesNodeData[] nodes = instance2.nodes;
				foreach (AccessCodesNodeData val4 in nodes)
				{
					if (cp.accessNodes.Contains(val4.id) && Object.op_Implicit((Object)(object)val4.node))
					{
						EntityStateMachine component = val4.node.GetComponent<EntityStateMachine>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.SetNextState((EntityState)new NodeActive
							{
								Id = val4.id
							});
							num3++;
						}
					}
				}
				instance2.Network_currentCode = num3;
				Log.LogInfo((object)("Access Nodes restored: " + num3 + " accessed."));
			}
		}

		private static bool Saving_Allowed(ConfigEntry<bool> entry)
		{
			if (NetworkServer.active && entry.Value && activeSlot >= 0 && (restore == null || restore.done) && Object.op_Implicit((Object)(object)Run.instance))
			{
				return !Run.instance.isGameOverServer;
			}
			return false;
		}

		private static void ShrinePrefix(HalcyoniteShrineInteractable __instance)
		{
			//IL_002f: 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)
			try
			{
				if (Object.op_Implicit((Object)(object)__instance) && __instance.interactions == 0 && Saving_Allowed(CpShrine))
				{
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.Shrine,
						anchor = ((Component)__instance).transform.position,
						exclude = ((Component)__instance).gameObject
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Shrine checkpoint: " + ex));
			}
		}

		private static void TeleporterPrefix(Interactor activator)
		{
			//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)
			//IL_0062: 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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (Object.op_Implicit((Object)(object)instance) && instance.isIdle && Saving_Allowed(CpTeleporter))
				{
					CharacterBody val = ((!Object.op_Implicit((Object)(object)activator)) ? null : ((Component)activator).GetComponent<CharacterBody>());
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.Teleporter,
						anchor = ((Component)instance).transform.position,
						spot = ((!Object.op_Implicit((Object)(object)val)) ? Vector3.zero : val.footPosition),
						exclude = ((Component)instance).gameObject
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Teleporter checkpoint: " + ex));
			}
		}

		private static void MithrixPostfix(PreEncounter __instance)
		{
			//IL_0036: 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)
			try
			{
				if (__instance != null && Object.op_Implicit((Object)(object)((EntityState)__instance).outer) && Saving_Allowed(CpMithrix))
				{
					Transform transform = ((Component)((EntityState)__instance).outer).transform;
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.Mithrix,
						anchor = transform.position,
						objectPath = PathOf(transform)
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Mithrix checkpoint: " + ex));
			}
		}

		private static void FalseSonPrefix(MeridianEventTriggerInteraction __instance)
		{
			//IL_002f: 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)
			try
			{
				if (Object.op_Implicit((Object)(object)__instance) && !__instance.isTriggered && Saving_Allowed(CpFalseSon))
				{
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.FalseSon,
						anchor = ((Component)__instance).transform.position
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("False Son checkpoint: " + ex));
			}
		}

		private static void GauntletPostfix(VoidRaidGauntletController __instance, bool __result)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (__result && Object.op_Implicit((Object)(object)__instance) && Saving_Allowed(CpVoidling))
				{
					int gauntletIndex = __instance.gauntletIndex;
					if (gauntletIndex == 1 || gauntletIndex == 2)
					{
						SaveCheckpoint(new Checkpoint
						{
							kind = CpKind.Voidling,
							phase = gauntletIndex + 1,
							anchor = Vector3.zero
						});
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Voidling checkpoint: " + ex));
			}
		}

		private static void VoidlingP4Postfix()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Saving_Allowed(CpVoidling))
				{
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.Voidling,
						phase = 4,
						anchor = Vector3.zero
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Voidling phase 4 checkpoint: " + ex));
			}
		}

		private static void VoidlingP12Postfix()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (Saving_Allowed(CpVoidling))
				{
					SaveCheckpoint(new Checkpoint
					{
						kind = CpKind.Voidling,
						phase = 5,
						anchor = Vector3.zero
					});
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Voidling phase 12 checkpoint: " + ex));
			}
		}

		private static void GameEndPostfix(GameEndReportPanelController __instance, DisplayData newDisplayData)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			try
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)__instance.continueButton))
				{
					return;
				}
				Transform parent = ((Component)__instance.continueButton).transform.parent;
				Transform val = parent.Find("SaveSlotsLoadButton");
				RunReport runReport = newDisplayData.runReport;
				if (!DeathButton.Value || Chainloader.PluginInfos.ContainsKey("Gorakh.RespawnButton") || !NetworkServer.active || runReport == null || !Object.op_Implicit((Object)(object)runReport.gameEnding) || runReport.gameEnding.isWin || activeSlot < 0 || !SlotStore.Exists(activeSlot) || !Object.op_Implicit((Object)(object)Run.instance) || !(((object)Run.instance).GetType() == typeof(Run)))
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						((Component)val).gameObject.SetActive(false);
					}
					return;
				}
				int slot = activeSlot;
				if (!Object.op_Implicit((Object)(object)val))
				{
					GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.continueButton).gameObject, parent);
					((Object)obj).name = "SaveSlotsLoadButton";
					obj.transform.SetAsLastSibling();
					Transform val2 = obj.transform.Find("GenericGlyph");
					if (Object.op_Implicit((Object)(object)val2))
					{
						((Component)val2).gameObject.SetActive(false);
					}
					val = obj.transform;
				}
				((Component)val).gameObject.SetActive(true);
				HGButton component = ((Component)val).GetComponent<HGButton>();
				if (Object.op_Implicit((Object)(object)component))
				{
					((Button)component).onClick = new ButtonClickedEvent();
					((UnityEvent)((Button)component).onClick).AddListener((UnityAction)delegate
					{
						LoadAfterRunEnd(slot);
					});
					((Selectable)component).interactable = true;
				}
				LanguageTextMeshController componentInChildren = ((Component)val).GetComponentInChildren<LanguageTextMeshController>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					componentInChildren.token = "Load slot " + (slot + 1);
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Game over button: " + ex.Message));
			}
		}

		internal static void LoadAfterRunEnd(int slot)
		{
			if (Object.op_Implicit((Object)(object)Run.instance) && NetworkServer.active && Object.op_Implicit((Object)(object)NetworkSession.instance))
			{
				overridePostRunToLobby = true;
				NetworkSession.instance.EndRun();
				((MonoBehaviour)Instance).StartCoroutine(WaitForLobbyThenLoad(slot));
			}
		}

		private static IEnumerator WaitForLobbyThenLoad(int slot)
		{
			float t0 = Time.unscaledTime;
			while (Time.unscaledTime - t0 < 30f && (!Object.op_Implicit((Object)(object)PreGameController.instance) || Object.op_Implicit((Object)(object)Run.instance)))
			{
				yield return null;
			}
			overridePostRunToLobby = false;
			if (!Object.op_Implicit((Object)(object)PreGameController.instance))
			{
				Log.LogWarning((object)("The lobby didn't open, so slot " + (slot + 1) + " wasn't loaded."));
				yield break;
			}
			t0 = Time.unscaledTime;
			while (Time.unscaledTime - t0 < 15f && !NetworkUser.AllParticipatingNetworkUsersReady())
			{
				yield return null;
			}
			yield return (object)new WaitForSeconds(0.5f);
			LoadSlot(slot);
		}

		private static bool PostRunPrefix()
		{
			if (!overridePostRunToLobby)
			{
				return true;
			}
			if (NetworkServer.active)
			{
				NetworkManager.singleton.ServerChangeScene("lobby");
			}
			return false;
		}

		internal static void Say(string text)
		{
			//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_006e: Expected O, but got Unknown
			if (string.IsNullOrEmpty(text) || !NetworkServer.active)
			{
				return;
			}
			if (ChatMessages != null && !ChatMessages.Value)
			{
				Log.LogInfo((object)text);
				return;
			}
			try
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<color=#9fd8ff>" + text.Replace("{", "(").Replace("}", ")") + "</color>"
				});
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("Chat: " + ex.Message));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCList(ConCommandArgs args)
		{
			for (int i = 0; i < 100; i++)
			{
				SlotInfo slotInfo = SlotStore.Read(i, withBlob: false);
				Debug.Log((object)("Slot " + (i + 1) + ": " + ((slotInfo == null || !slotInfo.exists) ? "empty" : slotInfo.OneLine())));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCLoad(ConCommandArgs args)
		{
			if (!LoadSlot(((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1))
			{
				Debug.Log((object)(SlotMenu.status ?? "Couldn't load."));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCNewRun(ConCommandArgs args)
		{
			int num = ((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1;
			if (num >= 0 && num < 100)
			{
				nextNewRunSlot = num;
				RefreshLobbyTooltip();
				Debug.Log((object)("The next new run saves into slot " + (num + 1) + "."));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCDelete(ConCommandArgs args)
		{
			int num = ((ConCommandArgs)(ref args)).TryGetArgInt(0).GetValueOrDefault() - 1;
			if (num >= 0 && num < 100)
			{
				SlotStore.Delete(num);
				Debug.Log((object)("Slot " + (num + 1) + " deleted."));
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCMenu(ConCommandArgs args)
		{
			SlotMenu.Open();
		}
	}
	internal enum CpKind
	{
		None,
		Shrine,
		Teleporter,
		Mithrix,
		FalseSon,
		Voidling
	}
	internal class Checkpoint
	{
		public CpKind kind;

		public string scene = string.Empty;

		public int phase;

		public Vector3 anchor;

		public Vector3 spot;

		public int shrineStacks;

		public bool shopPortal;

		public bool goldPortal;

		public bool msPortal;

		public bool hiddenPortal;

		public string objectPath = string.Empty;

		public List<KeyValuePair<string, Vector3>> players = new List<KeyValuePair<string, Vector3>>();

		public List<KeyValuePair<string, Vector3>> used = new List<KeyValuePair<string, Vector3>>();

		public string nextScene = string.Empty;

		public List<KeyValuePair<string, Vector3>> portals = new List<KeyValuePair<string, Vector3>>();

		public List<int> accessNodes = new List<int>();

		public bool accessDone;

		public GameObject exclude;

		public static int VoidlingPhaseNumber(int arena)
		{
			if (arena <= 2)
			{
				return 2;
			}
			return arena switch
			{
				4 => 9, 
				3 => 6, 
				_ => 12, 
			};
		}

		public string Label()
		{
			return kind switch
			{
				CpKind.Shrine => "Halcyon Shrine", 
				CpKind.Teleporter => "Teleporter", 
				CpKind.Mithrix => "Mithrix", 
				CpKind.FalseSon => "False Son", 
				CpKind.Voidling => "Voidling phase " + VoidlingPhaseNumber(phase), 
				_ => "Stage start", 
			};
		}

		public void Write(BinaryWriter w)
		{
			//IL_002f: 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)
			w.Write((int)kind);
			w.Write(scene ?? string.Empty);
			w.Write(phase);
			WriteV(w, anchor);
			WriteV(w, spot);
			w.Write(shrineStacks);
			w.Write((byte)((shopPortal ? 1u : 0u) | (uint)(goldPortal ? 2 : 0) | (uint)(msPortal ? 4 : 0) | (uint)(hiddenPortal ? 8 : 0)));
			w.Write(objectPath ?? string.Empty);
			WriteList(w, players);
			WriteList(w, used);
			w.Write(nextScene ?? string.Empty);
			WriteList(w, portals);
			w.Write(accessNodes.Count);
			foreach (int accessNode in accessNodes)
			{
				w.Write(accessNode);
			}
			w.Write(accessDone);
		}

		public static Checkpoint Read(BinaryReader r, int version)
		{
			//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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Checkpoint checkpoint = new Checkpoint();
			checkpoint.kind = (CpKind)r.ReadInt32();
			checkpoint.scene = r.ReadString();
			checkpoint.phase = r.ReadInt32();
			checkpoint.anchor = ReadV(r);
			checkpoint.spot = ReadV(r);
			checkpoint.shrineStacks = r.ReadInt32();
			byte b = r.ReadByte();
			checkpoint.shopPortal = (b & 1) != 0;
			checkpoint.goldPortal = (b & 2) != 0;
			checkpoint.msPortal = (b & 4) != 0;
			checkpoint.hiddenPortal = (b & 8) != 0;
			checkpoint.objectPath = r.ReadString();
			checkpoint.players = ReadList(r);
			checkpoint.used = ReadList(r);
			if (version >= 2)
			{
				checkpoint.nextScene = r.ReadString();
				checkpoint.portals = ReadList(r);
				int num = r.ReadInt32();
				for (int i = 0; i < num; i++)
				{
					checkpoint.accessNodes.Add(r.ReadInt32());
				}
				checkpoint.accessDone = r.ReadBoolean();
			}
			return checkpoint;
		}

		private static void WriteV(BinaryWriter w, Vector3 v)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			w.Write(v.x);
			w.Write(v.y);
			w.Write(v.z);
		}

		private static Vector3 ReadV(BinaryReader r)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
		}

		private static void WriteList(BinaryWriter w, List<KeyValuePair<string, Vector3>> list)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			w.Write(list.Count);
			foreach (KeyValuePair<string, Vector3> item in list)
			{
				w.Write(item.Key ?? string.Empty);
				WriteV(w, item.Value);
			}
		}

		private static List<KeyValuePair<string, Vector3>> ReadList(BinaryReader r)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			int num = r.ReadInt32();
			List<KeyValuePair<string, Vector3>> list = new List<KeyValuePair<string, Vector3>>(Mathf.Clamp(num, 0, 4096));
			for (int i = 0; i < num; i++)
			{
				string key = r.ReadString();
				list.Add(new KeyValuePair<string, Vector3>(key, ReadV(r)));
			}
			return list;
		}
	}
	internal class Restore
	{
		public Checkpoint cp;

		public Stage stage;

		public bool done;

		public readonly HashSet<CharacterMaster> spawned = new HashSet<CharacterMaster>();

		public int spawnCount;

		public bool voidOpened;

		public int voidGauntletTarget;

		public int voidEncounterIndex;

		public Vector3 voidSpawn;

		public Vector3 voidFace;
	}
	internal class SlotInfo
	{
		public int slot;

		public bool exists;

		public string error;

		public DateTime savedUtc;

		public string scene = string.Empty;

		public string sceneLabel = string.Empty;

		public int stage;

		public int time;

		public string difficulty = string.Empty;

		public string mode = string.Empty;

		public string kindLabel = string.Empty;

		public string contentHash = string.Empty;

		public List<string> players = new List<string>();

		public string hostBody = string.Empty;

		public string hostSurvivor = string.Empty;

		public Checkpoint checkpoint;

		public byte[] blob;

		public List<PlayerBackup> backups;

		public static SlotInfo FromCurrentRun(int slot, SaveFileHeader header, Checkpoint cp)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			SlotInfo slotInfo = new SlotInfo
			{
				slot = slot,
				exists = true,
				savedUtc = DateTime.UtcNow,
				scene = (header.SceneName ?? string.Empty),
				stage = header.StageClearCount + 1,
				time = header.Time,
				contentHash = (header.ContentHash ?? string.Empty),
				checkpoint = cp,
				kindLabel = ((cp == null) ? "Stage start" : cp.Label()),
				mode = SaveSlotsPlugin.ModeName(header.GameMode)
			};
			try
			{
				SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(slotInfo.scene);
				slotInfo.sceneLabel = ((!Object.op_Implicit((Object)(object)sceneDefFromSceneName)) ? slotInfo.scene : Language.GetString(sceneDefFromSceneName.nameToken));
				DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(header.Difficulty);
				slotInfo.difficulty = ((difficultyDef == null) ? string.Empty : Language.GetString(difficultyDef.nameToken));
			}
			catch
			{
			}
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master))
				{
					string text = (Object.op_Implicit((Object)(object)instance.networkUser) ? instance.networkUser.userName : "Player");
					string text2 = string.Empty;
					try
					{
						SurvivorDef val = SurvivorCatalog.FindSurvivorDefFromBody(instance.master.bodyPrefab);
						text2 = (((Object)(object)val == (Object)null) ? string.Empty : Language.GetString(val.displayNameToken));
					}
					catch
					{
					}
					slotInfo.players.Add(string.IsNullOrEmpty(text2) ? text : (text + " (" + text2 + ")"));
					bool flag = Object.op_Implicit((Object)(object)instance.networkUser) && ((NetworkBehaviour)instance.networkUser).isLocalPlayer;
					if ((flag || string.IsNullOrEmpty(slotInfo.hostBody)) && (flag || slotInfo.players.Count == 1))
					{
						slotInfo.hostBody = (Object.op_Implicit((Object)(object)instance.master.bodyPrefab) ? ((Object)instance.master.bodyPrefab).name : string.Empty);
						slotInfo.hostSurvivor = text2;
					}
				}
			}
			return slotInfo;
		}

		public static SlotInfo FromHeader(int slot, SaveFileHeader header, DateTime savedUtc)
		{
			//IL_0072: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Invalid comparison between Unknown and I4
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			SlotInfo slotInfo = new SlotInfo
			{
				slot = slot,
				exists = true,
				savedUtc = savedUtc,
				scene = (header.SceneName ?? string.Empty),
				stage = header.StageClearCount + 1,
				time = header.Time,
				contentHash = (header.ContentHash ?? string.Empty),
				checkpoint = null,
				kindLabel = "ProperSave save",
				mode = SaveSlotsPlugin.ModeName(header.GameMode)
			};
			try
			{
				SceneDef sceneDefFromSceneName = SceneCatalog.GetSceneDefFromSceneName(slotInfo.scene);
				slotInfo.sceneLabel = ((!Object.op_Implicit((Object)(object)sceneDefFromSceneName)) ? slotInfo.scene : Language.GetString(sceneDefFromSceneName.nameToken));
				DifficultyDef difficultyDef = DifficultyCatalog.GetDifficultyDef(header.Difficulty);
				slotInfo.difficulty = ((difficultyDef == null) ? string.Empty : Language.GetString(difficultyDef.nameToken));
			}
			catch
			{
			}
			HeaderUserData[] array = (HeaderUserData[])(((object)header.Users) ?? ((object)new HeaderUserData[0]));
			for (int i = 0; i < array.Length; i++)
			{
				HeaderUserData val = array[i];
				string text = string.Empty;
				string text2 = string.Empty;
				try
				{
					if (val != null && (int)val.Body != -1)
					{
						text2 = BodyCatalog.GetBodyName(val.Body) ?? string.Empty;
						SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(val.Body));
						text = (((Object)(object)survivorDef == (Object)null) ? string.Empty : Language.GetString(survivorDef.displayNameToken));
					}
				}
				catch
				{
				}
				string text3 = "Player " + (i + 1);
				slotInfo.players.Add(string.IsNullOrEmpty(text) ? text3 : (text3 + " (" + text + ")"));
				if (i == 0)
				{
					slotInfo.hostBody = text2;
					slotInfo.hostSurvivor = text;
				}
			}
			return slotInfo;
		}

		public static string Clock(int seconds)
		{
			seconds = Mathf.Max(0, seconds);
			if (seconds >= 3600)
			{
				return seconds / 3600 + ":" + (seconds / 60 % 60).ToString("00") + ":" + (seconds % 60).ToString("00");
			}
			return (seconds / 60).ToString("00") + ":" + (seconds % 60).ToString("00");
		}

		public string OneLine()
		{
			return sceneLabel + ", stage " + stage + ", " + Clock(time) + ", " + difficulty + ", " + kindLabel + ", " + string.Join(", ", players.ToArray()) + ", saved " + savedUtc.ToLocalTime().ToString("g");
		}
	}
	internal class PlayerBackup
	{
		internal struct EquipEntry
		{
			public uint slot;

			public uint set;

			public string name;

			public byte charges;
		}

		public string key = string.Empty;

		public string name = string.Empty;

		public uint money;

		public uint voidCoins;

		public uint infusion;

		public List<KeyValuePair<string, int>> items = new List<KeyValuePair<string, int>>();

		public List<EquipEntry> equipment = new List<EquipEntry>();

		public static List<PlayerBackup> CaptureAll()
		{
			List<PlayerBackup> list = new List<PlayerBackup>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master) && Object.op_Implicit((Object)(object)instance.master.inventory))
				{
					list.Add(Capture(instance));
				}
			}
			return list;
		}

		private static PlayerBackup Capture(PlayerCharacterMasterController pc)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_0117: Invalid comparison between Unknown and I4
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster master = pc.master;
			Inventory inventory = master.inventory;
			PlayerBackup playerBackup = new PlayerBackup
			{
				key = (SaveSlotsPlugin.UserKey(pc) ?? string.Empty),
				name = ((Object.op_Implicit((Object)(object)pc.networkUser) ? pc.networkUser.userName : ((Object)master).name) ?? string.Empty),
				money = master.money,
				voidCoins = master.voidCoins,
				infusion = inventory.infusionBonus
			};
			foreach (ItemIndex item in inventory.itemAcquisitionOrder)
			{
				int itemCountPermanent = inventory.GetItemCountPermanent(item);
				ItemDef itemDef = ItemCatalog.GetItemDef(item);
				if (itemCountPermanent > 0 && Object.op_Implicit((Object)(object)itemDef))
				{
					playerBackup.items.Add(new KeyValuePair<string, int>(((Object)itemDef).name, itemCountPermanent));
				}
			}
			int equipmentSlotCount = inventory.GetEquipmentSlotCount();
			int equipmentSetCount = inventory.GetEquipmentSetCount();
			for (uint num = 0u; num < equipmentSlotCount; num++)
			{
				for (uint num2 = 0u; num2 < equipmentSetCount; num2++)
				{
					EquipmentState val = inventory.GetEquipment(num, num2);
					EquipmentDef val2 = (((int)val.equipmentIndex == -1) ? null : EquipmentCatalog.GetEquipmentDef(val.equipmentIndex));
					if (Object.op_Implicit((Object)(object)val2))
					{
						playerBackup.equipment.Add(new EquipEntry
						{
							slot = num,
							set = num2,
							name = ((Object)val2).name,
							charges = val.charges
						});
					}
				}
			}
			return playerBackup;
		}

		public static void Verify(List<PlayerBackup> backups, string when)
		{
			if (backups == null || backups.Count == 0 || !NetworkServer.active)
			{
				return;
			}
			List<PlayerCharacterMasterController> list = PlayerCharacterMasterController.instances.Where((PlayerCharacterMasterController p) => Object.op_Implicit((Object)(object)p) && Object.op_Implicit((Object)(object)p.master) && Object.op_Implicit((Object)(object)p.master.inventory)).ToList();
			List<PlayerBackup> list2 = new List<PlayerBackup>(backups);
			List<KeyValuePair<PlayerCharacterMasterController, PlayerBackup>> list3 = new List<KeyValuePair<PlayerCharacterMasterController, PlayerBackup>>();
			Func<PlayerCharacterMasterController, PlayerBackup>[] array = new Func<PlayerCharacterMasterController, PlayerBackup>[2]
			{
				(PlayerCharacterMasterController p) => list2.FirstOrDefault((PlayerBackup b) => b.key.Length > 0 && b.key == SaveSlotsPlugin.UserKey(p)),
				(PlayerCharacterMasterController p) => list2.FirstOrDefault((PlayerBackup b) => Object.op_Implicit((Object)(object)p.networkUser) && b.name.Length > 0 && b.name == p.networkUser.userName)
			};
			foreach (Func<PlayerCharacterMasterController, PlayerBackup> func in array)
			{
				PlayerCharacterMasterController[] array2 = Enumerable.ToArray(list);
				foreach (PlayerCharacterMasterController val in array2)
				{
					PlayerBackup playerBackup = func(val);
					if (playerBackup != null)
					{
						list3.Add(new KeyValuePair<PlayerCharacterMasterController, PlayerBackup>(val, playerBackup));
						list2.Remove(playerBackup);
						list.Remove(val);
					}
				}
			}
			for (int num3 = 0; num3 < list.Count && num3 < list2.Count; num3++)
			{
				list3.Add(new KeyValuePair<PlayerCharacterMasterController, PlayerBackup>(list[num3], list2[num3]));
			}
			foreach (KeyValuePair<PlayerCharacterMasterController, PlayerBackup> item in list3)
			{
				try
				{
					string text = Differences(item.Key.master, item.Value);
					if (text != null)
					{
						Apply(item.Key.master, item.Value);
						string text2 = (Object.op_Implicit((Object)(object)item.Key.networkUser) ? item.Key.networkUser.userName : item.Value.name);
						SaveSlotsPlugin.Log.LogWarning((object)("Restored " + text2 + "'s items, equipment and money from SaveSlots' own copy (" + when + "; " + text + ")."));
					}
				}
				catch (Exception ex)
				{
					SaveSlotsPlugin.Log.LogError((object)("Restoring a player's items: " + ex));
				}
			}
		}

		private static Dictionary<ItemIndex, int> Wanted(PlayerBackup b, out int unknown)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ItemIndex, int> dictionary = new Dictionary<ItemIndex, int>();
			unknown = 0;
			foreach (KeyValuePair<string, int> item in b.items)
			{
				ItemIndex val = ItemCatalog.FindItemIndex(item.Key);
				if ((int)val == -1)
				{
					unknown++;
				}
				else
				{
					dictionary[val] = item.Value;
				}
			}
			return dictionary;
		}

		private static string Differences(CharacterMaster master, PlayerBackup b)
		{
			//IL_0028: 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_0071: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Invalid comparison between Unknown and I4
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = master.inventory;
			int unknown;
			Dictionary<ItemIndex, int> dictionary = Wanted(b, out unknown);
			int num = 0;
			foreach (KeyValuePair<ItemIndex, int> item in dictionary)
			{
				if (inventory.GetItemCountPermanent(item.Key) != item.Value)
				{
					num++;
				}
			}
			foreach (ItemIndex item2 in inventory.itemAcquisitionOrder)
			{
				if (!dictionary.ContainsKey(item2) && inventory.GetItemCountPermanent(item2) > 0)
				{
					num++;
				}
			}
			int num2 = 0;
		

SkillRemover.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using RoR2;
using RoR2.Skills;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace SkillRemover;

[BepInPlugin("custom.SkillRemover", "SkillRemover", "1.0.0")]
public class SkillRemoverPlugin : BaseUnityPlugin
{
	private const string DefaultList = "COMMANDO_SPECIAL_ALT2_NAME, HUNTRESS_SECONDARY_ALT_NAME, MAGE_UTILITY_ALT_NAME, TREEBOT_UTILITY_ALT2_NAME, CROCO_SPECIAL_ALT_NAME";

	internal static ManualLogSource Log;

	private static ConfigEntry<string> removedSkills;

	private static bool done;

	private void Awake()
	{
		Log = ((BaseUnityPlugin)this).Logger;
		removedSkills = ((BaseUnityPlugin)this).Config.Bind<string>("General", "RemovedSkills", "COMMANDO_SPECIAL_ALT2_NAME, HUNTRESS_SECONDARY_ALT_NAME, MAGE_UTILITY_ALT_NAME, TREEBOT_UTILITY_ALT2_NAME, CROCO_SPECIAL_ALT_NAME", "Skills that can't be selected, separated by commas. Use the skill's name token or its SkillDef name. Default: Sabotage (Commando), Laser Cyclone (Huntress), Tectonic Blast (Artificer), Proliferation (REX) and Cloying Breath (Acrid).");
		((ResourceAvailability)(ref BodyCatalog.availability)).CallWhenAvailable((Action)RemoveSkills);
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(RemoveSkills));
	}

	private static void RemoveSkills()
	{
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			HashSet<string> hashSet = new HashSet<string>(from x in (removedSkills.Value ?? "").Split(',')
				select x.Trim() into x
				where x.Length > 0
				select x, StringComparer.OrdinalIgnoreCase);
			if (hashSet.Count == 0)
			{
				return;
			}
			HashSet<SkillFamily> hashSet2 = new HashSet<SkillFamily>();
			foreach (GameObject allBodyPrefab in BodyCatalog.allBodyPrefabs)
			{
				if (!Object.op_Implicit((Object)(object)allBodyPrefab))
				{
					continue;
				}
				GenericSkill[] components = allBodyPrefab.GetComponents<GenericSkill>();
				foreach (GenericSkill val in components)
				{
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.skillFamily))
					{
						hashSet2.Add(val.skillFamily);
					}
				}
			}
			int num2 = 0;
			foreach (SkillFamily item2 in hashSet2)
			{
				if (item2.variants == null || item2.variants.Length < 2)
				{
					continue;
				}
				Variant item = item2.variants[Mathf.Clamp((int)item2.defaultVariantIndex, 0, item2.variants.Length - 1)];
				List<Variant> list = new List<Variant>();
				List<SkillDef> list2 = new List<SkillDef>();
				Variant[] variants = item2.variants;
				foreach (Variant val2 in variants)
				{
					SkillDef skillDef = val2.skillDef;
					if (Object.op_Implicit((Object)(object)skillDef) && (hashSet.Contains(skillDef.skillNameToken ?? "") || hashSet.Contains(skillDef.skillName ?? "") || hashSet.Contains(((Object)skillDef).name ?? "")))
					{
						list2.Add(skillDef);
					}
					else
					{
						list.Add(val2);
					}
				}
				if (list2.Count == 0 || list.Count == 0)
				{
					continue;
				}
				item2.variants = list.ToArray();
				item2.defaultVariantIndex = (uint)Mathf.Max(0, list.IndexOf(item));
				foreach (SkillDef item3 in list2)
				{
					Log.LogInfo((object)("Removed " + ((Object)item3).name + " (" + item3.skillNameToken + ") from " + ((Object)item2).name + "."));
					num2++;
				}
			}
			if (num2 > 0)
			{
				FixLoadedProfiles();
			}
			else if (!done)
			{
				Log.LogInfo((object)"No listed skills found to remove.");
			}
			done = true;
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Removing skills: " + ex));
		}
	}

	private static void FixLoadedProfiles()
	{
		try
		{
			if (PlatformSystems.saveSystem == null)
			{
				return;
			}
			foreach (UserProfile value in PlatformSystems.saveSystem.loadedUserProfiles.Values)
			{
				if (value != null && value.loadout != null)
				{
					value.loadout.EnforceValidity();
				}
			}
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("Checking loadouts: " + ex.Message));
		}
	}
}

Stage3AccessNodes.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.PointOfInterest;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace Stage3AccessNodes
{
	[BepInPlugin("custom.Stage3AccessNodes", "Stage3AccessNodes", "2.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Stage3AccessNodesPlugin : BaseUnityPlugin
	{
		private class Provider : IContentPackProvider
		{
			private readonly ContentPack pack = new ContentPack();

			public string identifier => "custom.Stage3AccessNodes";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.Stage3AccessNodes", null);
				}
				catch
				{
				}
				if (Object.op_Implicit((Object)(object)FxPrefab))
				{
					EffectDef val = new EffectDef(FxPrefab);
					try
					{
						FieldInfo fieldInfo = AccessTools.Field(typeof(EffectDef), "shouldPool");
						if (fieldInfo != null)
						{
							fieldInfo.SetValue(val, false);
						}
					}
					catch
					{
					}
					pack.effectDefs.Add((EffectDef[])(object)new EffectDef[1] { val });
				}
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(pack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__22_0;

			public static Action<Stage> <>9__22_1;

			public static UnityAction <>9__28_0;

			public static Func<AccessCodesNodeData, bool> <>9__28_1;

			public static Func<PointOfInterest, bool> <>9__38_0;

			public static Func<PointOfInterest, bool> <>9__38_1;

			public static Func<PortalStatueBehavior, bool> <>9__39_0;

			public static Func<PortalStatueBehavior, float> <>9__39_1;

			internal void <Awake>b__22_0(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new Provider());
			}

			internal void <Awake>b__22_1(Stage <p0>)
			{
				completed = false;
				listened = false;
				CustomNodes.Reset();
			}

			internal void <NodesComplete>b__28_0()
			{
				completed = true;
				Log.LogInfo((object)"Access nodes completed - teleporter unlocked.");
			}

			internal bool <NodesComplete>b__28_1(AccessCodesNodeData n)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)n.node))
				{
					return !n.node.activeInHierarchy;
				}
				return true;
			}

			internal bool <EnsurePointOfInterest>b__38_0(PointOfInterest p)
			{
				return Object.op_Implicit((Object)(object)p);
			}

			internal bool <EnsurePointOfInterest>b__38_1(PointOfInterest p)
			{
				return Object.op_Implicit((Object)(object)p);
			}

			internal bool <ServerNodes>b__39_0(PortalStatueBehavior a)
			{
				//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_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Invalid comparison between Unknown and I4
				if (Object.op_Implicit((Object)(object)a))
				{
					Scene scene = ((Component)a).gameObject.scene;
					if (((Scene)(ref scene)).IsValid())
					{
						return (int)a.portalType == 0;
					}
				}
				return false;
			}

			internal float <ServerNodes>b__39_1(PortalStatueBehavior a)
			{
				return Random.value;
			}
		}

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> ForceAll;

		internal static ConfigEntry<bool> LockTeleporter;

		internal static ConfigEntry<bool> ApplyOnLoops;

		internal static ConfigEntry<string> ForceScenes;

		internal static ConfigEntry<string> LockedText;

		internal static ConfigEntry<string> CustomScenes;

		internal static ConfigEntry<int> CustomCount;

		internal static ConfigEntry<float> CustomRadius;

		internal static Stage3AccessNodesPlugin Instance;

		internal static GameObject Holder;

		internal static GameObject FxPrefab;

		internal static GameObject OffTemplate;

		internal static GameObject OnTemplate;

		internal static GameObject SuccessVfx;

		internal const string GUID = "custom.Stage3AccessNodes";

		private static bool completed;

		private static bool listened;

		private float pollTimer;

		private string lastStates;

		private void Awake()
		{
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Expected O, but got Unknown
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Expected O, but got Unknown
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Expected O, but got Unknown
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the mod.");
			ForceAll = ((BaseUnityPlugin)this).Config.Bind<bool>("Spawn", "GuaranteeOnAllMaps", true, "Every map that can have the Access Node mission always has it.");
			ForceScenes = ((BaseUnityPlugin)this).Config.Bind<string>("Spawn", "GuaranteeScenes", "habitat;habitatfall", "Scenes (internal names) where the Access Node mission is always present even if GuaranteeOnAllMaps is off. habitat = Treeborn Colony, habitatfall = Golden Dieback.");
			LockTeleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter", "LockUntilNodesComplete", true, "On stage 3 (and any map with the Access Node mission) the teleporter cannot be activated until every Access Node has been hit and the code completed.");
			ApplyOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("Teleporter", "ApplyOnLoops", true, "Also lock on stages 8, 13, ...");
			LockedText = ((BaseUnityPlugin)this).Config.Bind<string>("Teleporter", "LockedPrompt", "Activate all the Access Nodes first", "Prompt shown on the locked teleporter.");
			CustomScenes = ((BaseUnityPlugin)this).Config.Bind<string>("CustomNodes", "Scenes", "habitat;habitatfall", "Maps without built-in Access Nodes that get one added (a real Access Node mission, exactly like the built-in ones: press the interact key, Solus Amalgamator boss fight; needs LocationsOfPrecipitation, otherwise a simple walk-up node). Placed at a Newt Altar spot or a random ground spot. habitat = Treeborn Colony, habitatfall = Golden Dieback.");
			CustomCount = ((BaseUnityPlugin)this).Config.Bind<int>("CustomNodes", "Count", 1, "Number of custom Access Nodes.");
			CustomRadius = ((BaseUnityPlugin)this).Config.Bind<float>("CustomNodes", "ActivationRadius", 6f, "Walk within this many metres of a custom node to activate it.");
			Instance = this;
			if (!Enabled.Value)
			{
				return;
			}
			try
			{
				MakeAssets();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Assets: " + ex));
			}
			object obj = <>c.<>9__22_0;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
				{
					add.Invoke((IContentPackProvider)(object)new Provider());
				};
				<>c.<>9__22_0 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			Stage.onStageStartGlobal += OnStageStart;
			Harmony val2 = new Harmony("custom.Stage3AccessNodes");
			val2.Patch((MethodBase)AccessTools.Method(typeof(AccessCodesMissionController), "OnEnable", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ForcePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(AccessCodesMissionController), "OnStartServer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ForcePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo = AccessTools.Method(typeof(AccessCodesMissionController), "ActivateCode", (Type[])null, (Type[])null);
			HarmonyMethod val3 = new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ActivateCodePostfix", (Type[])null);
			val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetInteractability", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "InteractPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetContextString", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ContextPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			if (ForceAll.Value)
			{
				AccessCodesMissionController.forceAccessNode = true;
			}
			Stage.onStageStartGlobal += delegate
			{
				completed = false;
				listened = false;
				CustomNodes.Reset();
			};
		}

		private static void ActivateCodePostfix()
		{
			if (!completed)
			{
				Log.LogInfo((object)"Access code activated - teleporter unlocked.");
			}
			completed = true;
		}

		private void Update()
		{
			//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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			pollTimer -= Time.deltaTime;
			if (pollTimer > 0f)
			{
				return;
			}
			pollTimer = 0.25f;
			try
			{
				AccessCodesMissionController instance = AccessCodesMissionController.instance;
				if (!Object.op_Implicit((Object)(object)instance))
				{
					return;
				}
				NodesComplete(instance);
				string text = "code " + instance._currentCode + "/" + instance._finalCode + " nodes:";
				if (instance.nodes != null)
				{
					AccessCodesNodeData[] nodes = instance.nodes;
					foreach (AccessCodesNodeData val in nodes)
					{
						if (!Object.op_Implicit((Object)(object)val.node))
						{
							text += " (missing)";
							continue;
						}
						EntityStateMachine componentInChildren = val.node.GetComponentInChildren<EntityStateMachine>(true);
						text = text + " " + ((!((Object)(object)componentInChildren != (Object)null) || componentInChildren.state == null) ? "?" : ((object)componentInChildren.state).GetType().Name);
					}
				}
				if (text != lastStates)
				{
					lastStates = text;
					Log.LogInfo((object)("Access nodes: " + text + ((!completed) ? string.Empty : " [complete]")));
				}
			}
			catch
			{
			}
		}

		private static bool SceneForced(string scene)
		{
			if (ForceAll.Value)
			{
				return true;
			}
			if (string.IsNullOrEmpty(scene))
			{
				return false;
			}
			return (ForceScenes.Value ?? string.Empty).Split(new char[1] { ';' }).Any((string s) => s.Trim().Equals(scene, StringComparison.OrdinalIgnoreCase));
		}

		private static void ForcePrefix(AccessCodesMissionController __instance)
		{
			//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)
			try
			{
				object obj;
				if (Object.op_Implicit((Object)(object)__instance))
				{
					Scene scene = ((Component)__instance).gameObject.scene;
					obj = ((Scene)(ref scene)).name;
				}
				else
				{
					obj = null;
				}
				string text = (string)obj;
				if (string.IsNullOrEmpty(text) && Object.op_Implicit((Object)(object)SceneCatalog.mostRecentSceneDef))
				{
					text = SceneCatalog.mostRecentSceneDef.cachedName;
				}
				if (SceneForced(text))
				{
					AccessCodesMissionController.forceAccessNode = true;
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("ForcePrefix: " + ex.Message));
			}
		}

		private static bool LockStageAllowed()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return false;
			}
			if (Run.instance.stageClearCount >= 5 && !ApplyOnLoops.Value)
			{
				return false;
			}
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			if (Object.op_Implicit((Object)(object)mostRecentSceneDef))
			{
				return (int)mostRecentSceneDef.sceneType == 1;
			}
			return false;
		}

		private static bool NodesComplete(AccessCodesMissionController mc)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (completed)
			{
				return true;
			}
			if (NetworkServer.active && !listened && mc.onTriggerAlternateFightServer != null)
			{
				listened = true;
				UnityEvent onTriggerAlternateFightServer = mc.onTriggerAlternateFightServer;
				object obj = <>c.<>9__28_0;
				if (obj == null)
				{
					UnityAction val = delegate
					{
						completed = true;
						Log.LogInfo((object)"Access nodes completed - teleporter unlocked.");
					};
					<>c.<>9__28_0 = val;
					obj = (object)val;
				}
				onTriggerAlternateFightServer.AddListener((UnityAction)obj);
			}
			try
			{
				if (mc._finalCode != 0 && mc._currentCode == mc._finalCode)
				{
					completed = true;
					Log.LogInfo((object)("Access code complete (" + mc._currentCode + ") - teleporter unlocked."));
					return true;
				}
			}
			catch
			{
			}
			if (mc.nodes == null)
			{
				return true;
			}
			if (mc.nodes.All((AccessCodesNodeData n) => !Object.op_Implicit((Object)(object)n.node) || !n.node.activeInHierarchy))
			{
				return true;
			}
			int num = 0;
			AccessCodesNodeData[] nodes = mc.nodes;
			foreach (AccessCodesNodeData val2 in nodes)
			{
				if (!Object.op_Implicit((Object)(object)val2.node))
				{
					continue;
				}
				num++;
				EntityStateMachine[] componentsInChildren = val2.node.GetComponentsInChildren<EntityStateMachine>(true);
				foreach (EntityStateMachine val3 in componentsInChildren)
				{
					if (val3.state != null && ((object)val3.state).GetType().Name == "Complete")
					{
						completed = true;
						return true;
					}
				}
			}
			return num == 0;
		}

		internal static bool Locked()
		{
			if (!LockTeleporter.Value || completed || !LockStageAllowed())
			{
				return false;
			}
			AccessCodesMissionController instance = AccessCodesMissionController.instance;
			if (IsCustomScene() && !Object.op_Implicit((Object)(object)instance))
			{
				return !CustomNodes.AllActive();
			}
			if (!Object.op_Implicit((Object)(object)instance) || !((Behaviour)instance).isActiveAndEnabled)
			{
				return false;
			}
			try
			{
				if (!instance.RunHasRequiredExpansion())
				{
					return false;
				}
			}
			catch
			{
			}
			return !NodesComplete(instance);
		}

		private static bool InteractPrefix(ref Interactability __result)
		{
			try
			{
				if (Locked())
				{
					__result = (Interactability)1;
					return false;
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			return true;
		}

		private static bool ContextPrefix(ref string __result)
		{
			try
			{
				if (Locked())
				{
					__result = LockedText.Value;
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		internal static bool IsCustomScene()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			string n = ((!Object.op_Implicit((Object)(object)mostRecentSceneDef)) ? null : mostRecentSceneDef.cachedName);
			if (string.IsNullOrEmpty(n))
			{
				return false;
			}
			return (CustomScenes.Value ?? string.Empty).Split(new char[1] { ';' }).Any((string x) => x.Trim().Equals(n, StringComparison.OrdinalIgnoreCase));
		}

		private static GameObject StripCopy(GameObject prefab, string name)
		{
			if (!Object.op_Implicit((Object)(object)prefab))
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, Holder.transform);
			((Object)val).name = name;
			MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
			}
			NetworkIdentity[] componentsInChildren2 = val.GetComponentsInChildren<NetworkIdentity>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			return val;
		}

		private static void MakeAssets()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0077: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			Holder = new GameObject("Stage3AccessNodesPrefabs");
			Holder.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)Holder);
			FxPrefab = new GameObject("S3NodeFx");
			FxPrefab.transform.SetParent(Holder.transform, false);
			EffectComponent obj = FxPrefab.AddComponent<EffectComponent>();
			obj.applyScale = false;
			obj.positionAtReferencedTransform = false;
			obj.parentToReferencedTransform = false;
			VFXAttributes obj2 = FxPrefab.AddComponent<VFXAttributes>();
			obj2.vfxPriority = (VFXPriority)2;
			obj2.vfxIntensity = (VFXIntensity)0;
			FxPrefab.AddComponent<S3NodeFx>();
			try
			{
				OffTemplate = StripCopy(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/AccessCodesNode/AccessCodesNodeOFF.prefab").WaitForCompletion(), "S3NodeOff");
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Node OFF model: " + ex.Message));
			}
			try
			{
				OnTemplate = StripCopy(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/AccessCodesNode/AccessCodesNodeON.prefab").WaitForCompletion(), "S3NodeOn");
			}
			catch (Exception ex2)
			{
				Log.LogWarning((object)("Node ON model: " + ex2.Message));
			}
			try
			{
				SuccessVfx = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC3/AccessCodesNode/NodeSuccessVFX.prefab").WaitForCompletion();
			}
			catch
			{
			}
		}

		private void OnStageStart(Stage st)
		{
			if (NetworkServer.active && IsCustomScene() && LockStageAllowed())
			{
				((MonoBehaviour)this).StartCoroutine(ServerNodes());
			}
		}

		private static Vector3 Ground(Vector3 p)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//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_0015: 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_0029: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = p + Vector3.up * 30f;
			Vector3 down = Vector3.down;
			LayerIndex world = LayerIndex.world;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, down, ref val2, 200f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
			{
				return ((RaycastHit)(ref val2)).point;
			}
			return p;
		}

		private static bool SpawnRealMission(Vector3 position)
		{
			//IL_0060: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = AccessTools.TypeByName("LOP.SetupDLC3AccessNode");
				FieldInfo fieldInfo = ((type == null) ? null : AccessTools.Field(type, "accessNodeMissionController"));
				GameObject val = (GameObject)((fieldInfo == null) ? null : /*isinst with value type is only supported in some contexts*/);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Log.LogWarning((object)"LocationsOfPrecipitation's Access Node mission isn't available; using a simple walk-up node instead.");
					return false;
				}
				GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"383d1a1eefe41db4eb8708719f86fc03").WaitForCompletion();
				if (!Object.op_Implicit((Object)(object)val2))
				{
					Log.LogWarning((object)"Access Node prefab not found; using a simple walk-up node instead.");
					return false;
				}
				Quaternion val3 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f);
				EnsurePointOfInterest(position, val3);
				GameObject val4 = Object.Instantiate<GameObject>(val2, position, val3);
				NetworkServer.Spawn(val4);
				GameObject val5 = Object.Instantiate<GameObject>(val);
				val5.GetComponent<AccessCodesMissionController>().nodes = (AccessCodesNodeData[])(object)new AccessCodesNodeData[1]
				{
					new AccessCodesNodeData
					{
						node = val4,
						id = 0
					}
				};
				NetworkServer.Spawn(val5);
				Log.LogInfo((object)"Added a real Access Node mission to this map.");
				return true;
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Access Node mission: " + ex));
				return false;
			}
		}

		private static void EnsurePointOfInterest(Vector3 position, Quaternion rotation)
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			PointOfInterestManager singleton = PointOfInterestManager.Singleton;
			if (!Object.op_Implicit((Object)(object)singleton) || singleton.PointsOfInterest == null || singleton.PointsOfInterest.Count((PointOfInterest p) => Object.op_Implicit((Object)(object)p)) < 1 || !singleton.PointsOfInterest.All((PointOfInterest p) => Object.op_Implicit((Object)(object)p)))
			{
				GameObject val = new GameObject("S3AccessNodePointsOfInterest");
				GameObject val2 = new GameObject("S3AccessNodePoint");
				val2.transform.SetParent(val.transform, false);
				val2.transform.SetPositionAndRotation(position, rotation);
				PointOfInterest val3 = val2.AddComponent<PointOfInterest>();
				PointOfInterestManager val4 = val.AddComponent<PointOfInterestManager>();
				val4.PointsOfInterest = (PointOfInterest[])(object)new PointOfInterest[1] { val3 };
				PointOfInterestManager.Singleton = val4;
			}
		}

		private IEnumerator ServerNodes()
		{
			yield return (object)new WaitForSeconds(3f);
			int num = Mathf.Max(1, CustomCount.Value);
			List<Vector3> list = new List<Vector3>();
			List<PortalStatueBehavior> list2 = (from a in Resources.FindObjectsOfTypeAll<PortalStatueBehavior>().Where(delegate(PortalStatueBehavior a)
				{
					//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_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Invalid comparison between Unknown and I4
					if (Object.op_Implicit((Object)(object)a))
					{
						Scene scene = ((Component)a).gameObject.scene;
						if (((Scene)(ref scene)).IsValid())
						{
							return (int)a.portalType == 0;
						}
					}
					return false;
				})
				orderby Random.value
				select a).ToList();
			foreach (PortalStatueBehavior item in list2)
			{
				if (list.Count >= num)
				{
					break;
				}
				Vector3 forward = ((Component)item).transform.forward;
				forward.y = 0f;
				if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
				{
					forward = Vector3.forward;
				}
				list.Add(Ground(((Component)item).transform.position + ((Vector3)(ref forward)).normalized * 6f));
			}
			try
			{
				NodeGraph val = ((!Object.op_Implicit((Object)(object)SceneInfo.instance)) ? null : SceneInfo.instance.groundNodes);
				Array array = ((!Object.op_Implicit((Object)(object)val)) ? null : (AccessTools.Field(typeof(NodeGraph), "nodes")?.GetValue(val) as Array));
				if (array != null && array.Length > 0)
				{
					FieldInfo fieldInfo = null;
					int num2 = 0;
					while (list.Count < num && num2 < 400)
					{
						object value = array.GetValue(Random.Range(0, array.Length));
						if (fieldInfo == null)
						{
							fieldInfo = value.GetType().GetField("position");
						}
						Vector3 p = (Vector3)fieldInfo.GetValue(value);
						if (list.All((Vector3 q) => Vector3.Distance(q, p) > 60f))
						{
							list.Add(p);
						}
						num2++;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Ground nodes: " + ex.Message));
			}
			if (Object.op_Implicit((Object)(object)AccessCodesMissionController.instance))
			{
				Log.LogInfo((object)"This map already has an Access Node mission.");
			}
			else if (list.Count <= 0 || !SpawnRealMission(list[0]))
			{
				Log.LogInfo((object)("Placed " + list.Count + " custom Access Node(s) (" + Mathf.Min(list2.Count, num) + " at Newt Altars)."));
				CustomNodes.ServerInit(list);
				while (CustomNodes.ServerActive)
				{
					CustomNodes.ServerTick();
					yield return (object)new WaitForSeconds(0.25f);
				}
			}
		}
	}
	internal static class CustomNodes
	{
		private class Vis
		{
			public Vector3 pos;

			public bool on;

			public GameObject go;
		}

		private static readonly Dictionary<int, Vis> vis = new Dictionary<int, Vis>();

		private static int count;

		private static List<Vector3> sPts;

		private static bool[] sOn;

		private static float lastBroadcast;

		internal static bool ServerActive;

		internal static void Reset()
		{
			foreach (Vis value in vis.Values)
			{
				if (Object.op_Implicit((Object)(object)value.go))
				{
					Object.Destroy((Object)(object)value.go);
				}
			}
			vis.Clear();
			count = 0;
			sPts = null;
			sOn = null;
			ServerActive = false;
		}

		internal static bool AllActive()
		{
			if (NetworkServer.active && sOn != null)
			{
				return sOn.All((bool x) => x);
			}
			if (count <= 0)
			{
				return true;
			}
			if (vis.Count >= count)
			{
				return vis.Values.All((Vis v) => v.on);
			}
			return false;
		}

		internal static void ServerInit(List<Vector3> pts)
		{
			sPts = pts;
			sOn = new bool[pts.Count];
			ServerActive = pts.Count > 0;
			Broadcast();
		}

		internal static void ServerTick()
		{
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_0087: 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)
			if (sPts == null)
			{
				return;
			}
			float value = Stage3AccessNodesPlugin.CustomRadius.Value;
			bool flag = false;
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody());
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive)
				{
					continue;
				}
				for (int i = 0; i < sPts.Count; i++)
				{
					if (!sOn[i] && Vector3.Distance(val.footPosition, sPts[i]) <= value)
					{
						sOn[i] = true;
						flag = true;
					}
				}
			}
			if (flag)
			{
				int num = sOn.Count((bool x) => x);
				SimpleChatMessage val2 = new SimpleChatMessage();
				val2.baseToken = "<color=#8fd4ff>Access Node activated (" + num + "/" + sOn.Length + ")</color>";
				Chat.SendBroadcastChat((ChatMessageBase)(object)val2);
				if (num == sOn.Length)
				{
					val2 = new SimpleChatMessage();
					val2.baseToken = "<color=#8fd4ff>All Access Nodes activated - the teleporter is unlocked.</color>";
					Chat.SendBroadcastChat((ChatMessageBase)(object)val2);
				}
			}
			if (flag || Time.time - lastBroadcast > 1.5f)
			{
				Broadcast();
			}
		}

		private static void Broadcast()
		{
			//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)
			//IL_0061: 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_0078: Expected O, but got Unknown
			lastBroadcast = Time.time;
			if (!Object.op_Implicit((Object)(object)Stage3AccessNodesPlugin.FxPrefab) || sPts == null)
			{
				return;
			}
			for (int i = 0; i < sPts.Count; i++)
			{
				uint genericUInt = (uint)((i & 0xFF) | (sOn[i] ? 256 : 0) | ((sPts.Count & 0xFF) << 16));
				try
				{
					EffectManager.SpawnEffect(Stage3AccessNodesPlugin.FxPrefab, new EffectData
					{
						origin = sPts[i],
						genericUInt = genericUInt
					}, true);
				}
				catch
				{
				}
			}
		}

		internal static void ClientUpdate(int idx, Vector3 pos, bool on, int total)
		{
			//IL_001b: 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_00d1: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			count = total;
			if (!vis.TryGetValue(idx, out var value))
			{
				value = new Vis
				{
					pos = pos
				};
				vis[idx] = value;
			}
			if (Object.op_Implicit((Object)(object)value.go) && value.on == on)
			{
				return;
			}
			bool num = on && Object.op_Implicit((Object)(object)value.go) && !value.on;
			if (Object.op_Implicit((Object)(object)value.go))
			{
				Object.Destroy((Object)(object)value.go);
			}
			GameObject val = ((!on) ? Stage3AccessNodesPlugin.OffTemplate : (Stage3AccessNodesPlugin.OnTemplate ?? Stage3AccessNodesPlugin.OffTemplate));
			if (Object.op_Implicit((Object)(object)val))
			{
				value.go = Object.Instantiate<GameObject>(val, pos, Quaternion.identity);
				value.go.SetActive(true);
			}
			else
			{
				value.go = GameObject.CreatePrimitive((PrimitiveType)2);
				value.go.transform.position = pos + Vector3.up;
				value.go.transform.localScale = new Vector3(2f, 1f, 2f);
			}
			value.on = on;
			if (!num)
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)Stage3AccessNodesPlugin.SuccessVfx))
			{
				try
				{
					Object.Instantiate<GameObject>(Stage3AccessNodesPlugin.SuccessVfx, pos, Quaternion.identity);
				}
				catch
				{
				}
			}
			try
			{
				Util.PlaySound("Play_UI_artifactSelect", value.go);
			}
			catch
			{
			}
		}
	}
	public class S3NodeFx : MonoBehaviour
	{
		private void Start()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				EffectComponent component = ((Component)this).GetComponent<EffectComponent>();
				EffectData val = ((!Object.op_Implicit((Object)(object)component)) ? null : component.effectData);
				if (val != null)
				{
					CustomNodes.ClientUpdate((int)(val.genericUInt & 0xFF), val.origin, (val.genericUInt & 0x100) != 0, (int)((val.genericUInt >> 16) & 0xFF));
				}
			}
			catch (Exception ex)
			{
				Stage3AccessNodesPlugin.Log.LogWarning((object)("Node fx: " + ex.Message));
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}

StageBosses.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace StageBosses
{
	public class SanctumBossMarker : MonoBehaviour
	{
		public bool applied;
	}
	[BepInPlugin("custom.StageBosses", "StageBosses", "1.1.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class StageBossesPlugin : BaseUnityPlugin
	{
		private class StageRule
		{
			public string[] scenes;

			public ConfigEntry<bool> bossEnabled;

			public ConfigEntry<bool> dropsEnabled;

			public string cardPath;

			public CharacterSpawnCard card;

			public string[] items;

			public bool alternate;

			public int qualityTier = -1;

			public ConfigEntry<string> tierDrop;
		}

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

		internal static StageBossesPlugin Instance;

		internal static ManualLogSource Log;

		private static readonly List<StageRule> rules = new List<StageRule>();

		private static ConfigEntry<bool> noHordes;

		private static ConfigEntry<bool> sanctumDoubleReds;

		private static readonly string[] sanctumScavs = new string[3] { "ScavSanctum1Body", "ScavSanctum2Body", "ScavSanctum3Body" };

		private void Awake()
		{
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Expected O, but got Unknown
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Expected O, but got Unknown
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			noHordes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableHordeOfMany", true, "The teleporter boss is never a Horde of Many on any stage.");
			sanctumDoubleReds = ((BaseUnityPlugin)this).Config.Bind<bool>("LuridBasilica", "DoubleRedDrops", true, "The special scavenger boss in Lurid Basilica (sanctum) drops two red items per player instead of one.");
			AddRule("AbyssalDepths", new string[1] { "dampcavesimple" }, "RoR2/Base/MagmaWorm/cscMagmaWorm.asset", new string[1] { "FireballsOnHit" }, alternate: false, -1, "Magma Worm teleporter boss", "Molten Perforator teleporter drops");
			AddRule("SunderedGrove", new string[1] { "rootjungle" }, "RoR2/Base/Vagrant/cscVagrant.asset", new string[1] { "NovaOnLowHealth" }, alternate: false, 0, "Wandering Vagrant teleporter boss", "Genesis Loop teleporter drops (Uncommon quality if Quality is installed)");
			AddRule("RepurposedCrater", new string[1] { "repurposedcrater" }, "RoR2/Base/RoboBallBoss/cscRoboBallBoss.asset", new string[2] { "ExtraEquipment", "RoboBallBuddy" }, alternate: true, -1, "Solus Control Unit teleporter boss", "Functional Coupler and Empathy Cores teleporter drops (alternating)");
			AddRule("SunkenTombs", new string[1] { "sunkentombs_wormsworms" }, "RoR2/DLC1/VoidMegaCrab/cscVoidMegaCrab.asset", new string[3] { "ChainLightningVoid", "MissileVoid", "BearVoid" }, alternate: false, -1, "Void Devastator teleporter boss", "Polylute / Plasma Shrimp / Safer Spaces teleporter drops (random per drop)");
			AddRule("StagnantPipeworks", new string[1] { "swampybog_winslow" }, "RoR2/Base/Scav/cscScav.asset", new string[0], alternate: false, -1, "Scavenger teleporter boss (bag drop unchanged)", "Red (legendary) item teleporter drops");
			AddTierRule("StagnantPipeworks", "Tier3");
			AddRule("SirensCall", new string[1] { "shipgraveyard" }, null, new string[0], alternate: false, -1, null, "Meal item teleporter drops");
			AddTierRule("SirensCall", "FoodTier");
			AddRule("ConduitCanyon", new string[1] { "conduitcanyon" }, null, new string[0], alternate: false, -1, null, "Meal item teleporter drops");
			AddTierRule("ConduitCanyon", "Tier3");
			AddRule("LucidBasilica", new string[1] { "sanctum" }, null, new string[0], alternate: false, -1, null, "Hallowed item teleporter drops");
			AddTierRule("LucidBasilica", "Cursed");
			AddRule("Tropics", new string[2] { "tropics_wormsworms", "tropicsnight_wormsworms" }, "RoR2/Base/ElectricWorm/cscElectricWorm.asset", new string[1] { "LightningStrikeOnHit" }, alternate: false, -1, "Overloading Worm teleporter boss (Sunset and Midnight Tropics)", "Charged Perforator teleporter drops");
			Harmony val = new Harmony("custom.StageBosses");
			MethodInfo methodInfo = AccessTools.Method(typeof(CombatDirector), "SetNextSpawnAsBoss", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(StageBossesPlugin), "SetNextSpawnAsBossPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.Method(typeof(BossGroup), "DropRewards", (Type[])null, (Type[])null), new HarmonyMethod(typeof(StageBossesPlugin), "DropRewardsPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
		}

		private void AddRule(string section, string[] scenes, string cardPath, string[] items, bool alternate, int quality, string bossDesc, string dropDesc)
		{
			//IL_0098: 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)
			StageRule r = new StageRule
			{
				scenes = scenes,
				cardPath = cardPath,
				items = items,
				alternate = alternate,
				qualityTier = quality
			};
			r.bossEnabled = ((bossDesc == null) ? null : ((BaseUnityPlugin)this).Config.Bind<bool>(section, "GuaranteeBoss", true, bossDesc));
			r.dropsEnabled = ((dropDesc == null) ? null : ((BaseUnityPlugin)this).Config.Bind<bool>(section, "GuaranteeDrops", true, dropDesc));
			if (cardPath != null)
			{
				AsyncOperationHandle<CharacterSpawnCard> val = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)cardPath);
				val.Completed += delegate(AsyncOperationHandle<CharacterSpawnCard> hnd)
				{
					r.card = hnd.Result;
				};
			}
			rules.Add(r);
		}

		private void AddTierRule(string section, string tier)
		{
			StageRule stageRule = rules[rules.Count - 1];
			stageRule.tierDrop = ((BaseUnityPlugin)this).Config.Bind<string>(section, "DropTier", tier, "Item tier the teleporter drops (Tier1, Tier2, Tier3, Boss, Lunar, VoidTier1-3, FoodTier = meals, Cursed = hallowed, ...). Items not normally available in the run are only used if the tier has no available items.");
		}

		private static List<PickupIndex> TierPool(string tierName)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			List<PickupIndex> list = new List<PickupIndex>();
			ItemTier val;
			try
			{
				val = (ItemTier)Enum.Parse(typeof(ItemTier), tierName.Trim(), ignoreCase: true);
			}
			catch
			{
				Log.LogError((object)("Unknown item tier: " + tierName));
				return list;
			}
			if ((int)val == 2 && Run.instance.availableTier3DropList != null && Run.instance.availableTier3DropList.Count > 0)
			{
				return new List<PickupIndex>(Run.instance.availableTier3DropList);
			}
			List<PickupIndex> list2 = new List<PickupIndex>();
			Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemDef current = enumerator.Current;
					if (!Object.op_Implicit((Object)(object)current) || current.tier != val || current.hidden || (int)current.itemIndex == -1 || ((Object)current).name.IndexOf("Consumed", StringComparison.OrdinalIgnoreCase) >= 0 || string.IsNullOrEmpty(current.nameToken))
					{
						continue;
					}
					PickupIndex val2 = PickupCatalog.FindPickupIndex(current.itemIndex);
					if (!(val2 == PickupIndex.none))
					{
						list2.Add(val2);
						bool flag = true;
						try
						{
							flag = Run.instance.availableItems.Contains(current.itemIndex);
						}
						catch
						{
						}
						if (flag)
						{
							list.Add(val2);
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
			return (list.Count <= 0) ? list2 : list;
		}

		private static string SceneName()
		{
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			return (!Object.op_Implicit((Object)(object)mostRecentSceneDef)) ? string.Empty : mostRecentSceneDef.cachedName;
		}

		private static StageRule RuleForScene()
		{
			string n = SceneName();
			return rules.FirstOrDefault((StageRule r) => r.scenes.Contains(n));
		}

		private static bool IsChampion(DirectorCard card)
		{
			try
			{
				SpawnCard val = ((card == null) ? null : card.GetSpawnCard());
				if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.prefab))
				{
					return false;
				}
				CharacterMaster component = val.prefab.GetComponent<CharacterMaster>();
				if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.bodyPrefab))
				{
					return false;
				}
				CharacterBody component2 = component.bodyPrefab.GetComponent<CharacterBody>();
				return Object.op_Implicit((Object)(object)component2) && component2.isChampion;
			}
			catch
			{
				return false;
			}
		}

		private static void SetNextSpawnAsBossPostfix(CombatDirector __instance)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			try
			{
				if (!NetworkServer.active)
				{
					return;
				}
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (!Object.op_Implicit((Object)(object)instance) || (Object)(object)instance.bossDirector != (Object)(object)__instance)
				{
					return;
				}
				StageRule stageRule = RuleForScene();
				if (stageRule != null && stageRule.bossEnabled != null && stageRule.bossEnabled.Value && Object.op_Implicit((Object)(object)stageRule.card))
				{
					DirectorCard val = new DirectorCard();
					val.spawnCard = (SpawnCard)(object)stageRule.card;
					val.selectionWeight = 1;
					__instance.OverrideCurrentMonsterCard(val);
					EnsureAffordable(__instance, (SpawnCard)(object)stageRule.card);
					Log.LogInfo((object)("Teleporter boss forced to " + ((Object)stageRule.card).name));
				}
				else
				{
					if (!noHordes.Value || IsChampion((DirectorCard)/*isinst with value type is only supported in some contexts*/))
					{
						return;
					}
					WeightedSelection<DirectorCard> val2 = null;
					MethodInfo methodInfo = AccessTools.Method(typeof(CombatDirector), "GetFinalMonsterCardSelection", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						val2 = methodInfo.Invoke(__instance, null) as WeightedSelection<DirectorCard>;
					}
					if (val2 == null)
					{
						val2 = AccessTools.Field(typeof(CombatDirector), "monsterCardsSelection")?.GetValue(__instance) as WeightedSelection<DirectorCard>;
					}
					List<DirectorCard> list = new List<DirectorCard>();
					if (val2 != null)
					{
						for (int i = 0; i < val2.Count; i++)
						{
							DirectorCard value = val2.choices[i].value;
							if (value != null && IsChampion(value) && value.IsAvailable())
							{
								list.Add(value);
							}
						}
					}
					if (list.Count > 0)
					{
						DirectorCard val3 = list[Random.Range(0, list.Count)];
						__instance.OverrideCurrentMonsterCard(val3);
						EnsureAffordable(__instance, val3.GetSpawnCard());
						Log.LogInfo((object)("Horde of Many replaced with " + ((Object)val3.GetSpawnCard()).name));
					}
					else
					{
						Log.LogWarning((object)"Horde of Many could not be replaced: no champion available on this stage.");
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}

		private static void EnsureAffordable(CombatDirector director, SpawnCard card)
		{
			if (Object.op_Implicit((Object)(object)director) && Object.op_Implicit((Object)(object)card))
			{
				float num = (float)card.directorCreditCost * 1.1f;
				if (director.monsterCredit < num)
				{
					Log.LogInfo((object)("Boss director credit raised from " + director.monsterCredit + " to " + num + " for " + ((Object)card).name));
					director.monsterCredit = num;
				}
			}
		}

		private static PickupIndex ItemPickup(string name)
		{
			//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_0009: Invalid comparison between Unknown and I4
			//IL_0018: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			ItemIndex val = ItemCatalog.FindItemIndex(name);
			return ((int)val != -1) ? PickupCatalog.FindPickupIndex(val) : PickupIndex.none;
		}

		private static PickupIndex ToQuality(PickupIndex idx, int tier)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if (tier < 0 || !Chainloader.PluginInfos.ContainsKey("com.Gorakh.ItemQualities") || idx == PickupIndex.none)
			{
				return idx;
			}
			try
			{
				Type type = Type.GetType("ItemQualities.QualityCatalog, ItemQualities");
				Type type2 = Type.GetType("ItemQualities.QualityTier, ItemQualities");
				MethodInfo methodInfo = type?.GetMethod("GetPickupIndexOfQuality", new Type[2]
				{
					typeof(PickupIndex),
					type2
				});
				return (PickupIndex)((!(methodInfo != null)) ? idx : ((PickupIndex)methodInfo.Invoke(null, new object[2]
				{
					idx,
					Enum.ToObject(type2, tier)
				})));
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return idx;
			}
		}

		private static int PlayerCount()
		{
			try
			{
				PropertyInfo propertyInfo = AccessTools.Property(typeof(Run), "participatingPlayerCount");
				if (propertyInfo != null)
				{
					return Math.Max(1, (int)propertyInfo.GetValue(Run.instance, null));
				}
			}
			catch
			{
			}
			return Math.Max(1, PlayerCharacterMasterController.instances.Count);
		}

		private static bool ScaleByPlayers(BossGroup g)
		{
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(BossGroup), "scaleRewardsByPlayerCount");
				if (fieldInfo != null)
				{
					return (bool)fieldInfo.GetValue(g);
				}
			}
			catch
			{
			}
			return true;
		}

		private static Transform DropPosition(BossGroup g)
		{
			try
			{
				FieldInfo fieldInfo = AccessTools.Field(typeof(BossGroup), "dropPosition");
				if (fieldInfo != null)
				{
					object? value = fieldInfo.GetValue(g);
					return (Transform)((value is Transform) ? value : null);
				}
			}
			catch
			{
			}
			return null;
		}

		private static bool DropRewardsPrefix(BossGroup __instance)
		{
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: 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)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)Run.instance))
				{
					return true;
				}
				SanctumBossMarker component = ((Component)__instance).GetComponent<SanctumBossMarker>();
				if (Object.op_Implicit((Object)(object)component) && !component.applied && sanctumDoubleReds.Value)
				{
					component.applied = true;
					int bonusRewardCount = __instance.bonusRewardCount;
					__instance.bonusRewardCount = 2 * (bonusRewardCount + 1) - 1;
					Log.LogInfo((object)"Lurid Basilica scavenger rewards doubled.");
					return true;
				}
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (!Object.op_Implicit((Object)(object)instance) || (Object)(object)instance.bossGroup != (Object)(object)__instance)
				{
					return true;
				}
				StageRule stageRule = RuleForScene();
				if (stageRule == null || stageRule.dropsEnabled == null || !stageRule.dropsEnabled.Value)
				{
					return true;
				}
				List<PickupIndex> list = ((stageRule.tierDrop == null) ? (from p in stageRule.items.Select(ItemPickup)
					where p != PickupIndex.none
					select p).ToList() : TierPool(stageRule.tierDrop.Value));
				if (list.Count == 0)
				{
					Log.LogWarning((object)("No items for teleporter drop pool on " + SceneName()));
					return true;
				}
				int num = ((!ScaleByPlayers(__instance)) ? 1 : PlayerCount()) * (1 + Math.Max(0, __instance.bonusRewardCount));
				Transform val = DropPosition(__instance);
				Vector3 val2 = ((!Object.op_Implicit((Object)(object)val)) ? (((Component)instance).transform.position + Vector3.up * 3f) : val.position);
				float num2 = 360f / (float)num;
				Vector3 val3 = Vector3.up * 20f + ((!Object.op_Implicit((Object)(object)val)) ? Vector3.forward : val.forward) * 2f;
				Quaternion val4 = Quaternion.AngleAxis(num2, Vector3.up);
				int num3 = Random.Range(0, list.Count);
				for (int num4 = 0; num4 < num; num4++)
				{
					PickupIndex idx = ((!stageRule.alternate) ? list[Random.Range(0, list.Count)] : list[(num3 + num4) % list.Count]);
					idx = ToQuality(idx, stageRule.qualityTier);
					PickupDropletController.CreatePickupDroplet(new UniquePickup(idx), val2, val3, false, false);
					val3 = val4 * val3;
				}
				Log.LogInfo((object)("Teleporter dropped " + num + " guaranteed item(s) on " + SceneName()));
				return false;
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
				return true;
			}
		}

		private void OnBodyStart(CharacterBody body)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active && Object.op_Implicit((Object)(object)body))
			{
				object obj = BodyCatalog.GetBodyName(body.bodyIndex) as string;
				string text = default(string);
				if (obj != null)
				{
					text = (string)obj;
					obj = text;
				}
				if (obj != null && sanctumScavs.Contains(text))
				{
					((MonoBehaviour)this).StartCoroutine(MarkSanctumGroup(body));
				}
			}
		}

		private IEnumerator MarkSanctumGroup(CharacterBody body)
		{
			for (int i = 0; i < 20; i++)
			{
				if (!Object.op_Implicit((Object)(object)body))
				{
					break;
				}
				yield return (object)new WaitForSeconds(0.5f);
				if (!Object.op_Implicit((Object)(object)body))
				{
					break;
				}
				BossGroup g = null;
				try
				{
					MethodInfo methodInfo = AccessTools.Method(typeof(BossGroup), "FindBossGroup", (Type[])null, (Type[])null);
					if (methodInfo != null)
					{
						object? obj = methodInfo.Invoke(null, new object[1] { body });
						g = (BossGroup)((obj is BossGroup) ? obj : null);
					}
				}
				catch (Exception ex)
				{
					Log.LogError((object)ex);
					break;
				}
				if (Object.op_Implicit((Object)(object)g))
				{
					if (!Object.op_Implicit((Object)(object)((Component)g).GetComponent<SanctumBossMarker>()))
					{
						((Component)g).gameObject.AddComponent<SanctumBossMarker>();
					}
					Log.LogInfo((object)"Tracking Lurid Basilica scavenger boss group.");
					break;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

StageMountainShrines.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace StageMountainShrines
{
	[BepInPlugin("custom.StageMountainShrines", "StageMountainShrines", "1.0.2")]
	public class StageMountainShrinesPlugin : BaseUnityPlugin
	{
		internal static StageMountainShrinesPlugin Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<int>[] StageStacks = new ConfigEntry<int>[5];

		internal static ConfigEntry<bool> ExtraRewards;

		internal static ConfigEntry<bool> ApplyOnLoops;

		private static MethodInfo addShrineStack;

		private void Awake()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			int[] array = new int[5] { 6, 7, 8, 9, 10 };
			for (int i = 0; i < 5; i++)
			{
				StageStacks[i] = ((BaseUnityPlugin)this).Config.Bind<int>("Stacks", "Stage" + (i + 1), array[i], "Number of Mountain Shrine effects applied to the stage " + (i + 1) + " teleporter.");
			}
			ExtraRewards = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExtraRewards", false, "If true, the added Mountain Shrine effects also grant their extra boss item drops. Shrines you activate yourself always give rewards.");
			ApplyOnLoops = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ApplyOnLoops", false, "If true, stages 6-10, 11-15, ... use the Stage1-Stage5 values. If false, only the first loop is affected.");
			addShrineStack = AccessTools.Method(typeof(TeleporterInteraction), "AddShrineStack", (Type[])null, (Type[])null);
			Harmony val = new Harmony("custom.StageMountainShrines");
			MethodInfo methodInfo = AccessTools.Method(typeof(TeleporterInteraction), "Start", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(StageMountainShrinesPlugin), "TeleporterStartPostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			MethodInfo methodInfo2 = AccessTools.Method(typeof(BossGroup), "DropRewards", (Type[])null, (Type[])null);
			val2 = new HarmonyMethod(typeof(StageMountainShrinesPlugin), "DropRewardsPrefix", (Type[])null);
			val2.priority = 800;
			val.Patch((MethodBase)methodInfo2, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static int GetStacksForCurrentStage()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return 0;
			}
			int stageClearCount = Run.instance.stageClearCount;
			if (stageClearCount >= 5 && !ApplyOnLoops.Value)
			{
				return 0;
			}
			return Mathf.Max(0, StageStacks[stageClearCount % 5].Value);
		}

		private static void TeleporterStartPostfix(TeleporterInteraction __instance)
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)__instance))
			{
				int stacksForCurrentStage = GetStacksForCurrentStage();
				if (stacksForCurrentStage > 0)
				{
					((MonoBehaviour)Instance).StartCoroutine(ApplyStacks(__instance, stacksForCurrentStage));
				}
			}
		}

		private static IEnumerator ApplyStacks(TeleporterInteraction tp, int stacks)
		{
			yield return null;
			if (!Object.op_Implicit((Object)(object)tp) || addShrineStack == null)
			{
				yield break;
			}
			int applied = 0;
			for (int i = 0; i < stacks; i++)
			{
				try
				{
					addShrineStack.Invoke(tp, null);
					applied++;
				}
				catch (Exception ex)
				{
					Log.LogError((object)ex);
					break;
				}
			}
			AddedStacks marker = ((Component)tp).GetComponent<AddedStacks>() ?? ((Component)tp).gameObject.AddComponent<AddedStacks>();
			marker.count += applied;
			Log.LogInfo((object)("Applied " + applied + " Mountain Shrine stack(s) to teleporter."));
		}

		private static void DropRewardsPrefix(BossGroup __instance)
		{
			try
			{
				if (ExtraRewards.Value || !NetworkServer.active || !Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				TeleporterInteraction instance = TeleporterInteraction.instance;
				if (Object.op_Implicit((Object)(object)instance) && !((Object)(object)instance.bossGroup != (Object)(object)__instance))
				{
					AddedStacks component = ((Component)instance).GetComponent<AddedStacks>();
					if (Object.op_Implicit((Object)(object)component) && component.count > 0 && !component.consumed)
					{
						__instance.bonusRewardCount = Mathf.Max(0, __instance.bonusRewardCount - component.count);
						component.consumed = true;
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
		}
	}
	public class AddedStacks : MonoBehaviour
	{
		public int count;

		public bool consumed;
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

TeleporterExpansionPlus.dll

Decompiled 7 hours ago
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace TeleporterExpansionPlus
{
	[BepInPlugin("custom.TeleporterExpansionPlus", "TeleporterExpansionPlus", "1.0.0")]
	public class TeleporterExpansionPlusPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> AllowEclipse;

		internal static ConfigEntry<bool> BlockWithFocus;

		internal static ConfigEntry<float> SecondsTo8x;

		internal static ConfigEntry<float> MinCharge;

		internal static ConfigEntry<float> MaxMultiplier;

		internal static ConfigEntry<string> DisabledStages;

		private void Awake()
		{
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "After the teleporter boss is killed, the charging teleporter zone keeps expanding.");
			SecondsTo8x = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SecondsTo8x", 42.857143f, "Seconds for the zone to grow to 8x its size (original mod: 30; 30% slower: 42.86). Growth continues past that.");
			MaxMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxMultiplier", 0f, "Maximum size multiplier. 0 = no limit.");
			MinCharge = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumCharge", 0.05f, "Charge fraction required before expansion can start (original: 0.05).");
			DisabledStages = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DisabledStages", "2", "Comma-separated stage numbers (1-5, loop-independent) where the teleporter never expands.");
			AllowEclipse = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowInEclipse", false, "Allow expansion on Eclipse difficulties (original default: off).");
			BlockWithFocus = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableWithFocusedConvergence", true, "No expansion while the team has Focused Convergence (original behaviour).");
			Harmony val = new Harmony("custom.TeleporterExpansionPlus");
			MethodInfo methodInfo = AccessTools.Method(typeof(HoldoutZoneController), "OnEnable", (Type[])null, (Type[])null);
			HarmonyMethod val2 = new HarmonyMethod(typeof(TeleporterExpansionPlusPlugin), "OnEnablePostfix", (Type[])null);
			val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void OnEnablePostfix(HoldoutZoneController __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance) && !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ZoneExpander>()) && Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<TeleporterInteraction>()))
			{
				((Component)__instance).gameObject.AddComponent<ZoneExpander>();
			}
		}

		internal static bool StageAllowed()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return false;
			}
			int num = Run.instance.stageClearCount % 5 + 1;
			string[] array = (DisabledStages.Value ?? string.Empty).Split(new char[1] { ',' });
			foreach (string text in array)
			{
				if (int.TryParse(text.Trim(), out var result) && result == num)
				{
					return false;
				}
			}
			return true;
		}
	}
	public class ZoneExpander : MonoBehaviour
	{
		private HoldoutZoneController zone;

		private TeleporterInteraction tp;

		private bool started;

		private float startTime;

		private float startRadius;

		private static FieldInfo fCleared;

		private bool subscribed;

		private void Awake()
		{
			zone = ((Component)this).GetComponent<HoldoutZoneController>();
			tp = ((Component)this).GetComponent<TeleporterInteraction>();
			if (fCleared == null)
			{
				fCleared = AccessTools.Field(typeof(TeleporterInteraction), "monstersCleared");
			}
		}

		private void OnEnable()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)zone) && !subscribed)
			{
				zone.calcRadius += new CalcRadiusDelegate(CalcRadius);
				subscribed = true;
			}
		}

		private void OnDisable()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)zone) && subscribed)
			{
				zone.calcRadius -= new CalcRadiusDelegate(CalcRadius);
				subscribed = false;
			}
		}

		private bool BossCleared()
		{
			if (NetworkServer.active && fCleared != null)
			{
				try
				{
					return (bool)fCleared.GetValue(tp);
				}
				catch
				{
				}
			}
			try
			{
				return Object.op_Implicit((Object)(object)tp.bossGroup) && Object.op_Implicit((Object)(object)tp.bossGroup.combatSquad) && tp.bossGroup.combatSquad.memberCount == 0;
			}
			catch
			{
				return false;
			}
		}

		private void Update()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Invalid comparison between Unknown and I4
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			if (!started && TeleporterExpansionPlusPlugin.Enabled.Value && Object.op_Implicit((Object)(object)tp) && Object.op_Implicit((Object)(object)zone) && Object.op_Implicit((Object)(object)Run.instance) && tp.isCharging && !(tp.chargeFraction <= TeleporterExpansionPlusPlugin.MinCharge.Value) && TeleporterExpansionPlusPlugin.StageAllowed() && (TeleporterExpansionPlusPlugin.AllowEclipse.Value || (int)Run.instance.selectedDifficulty < 3) && (!TeleporterExpansionPlusPlugin.BlockWithFocus.Value || Util.GetItemCountForTeam(zone.chargingTeam, Items.FocusConvergence.itemIndex, true, true) <= 0) && BossCleared())
			{
				started = true;
				startTime = Time.time;
				startRadius = Mathf.Max(0.01f, zone.currentRadius);
			}
		}

		private void CalcRadius(ref float radius)
		{
			if (started)
			{
				float num = Time.time - startTime;
				float num2 = Mathf.Max(0.1f, TeleporterExpansionPlusPlugin.SecondsTo8x.Value);
				float num3 = Mathf.Exp(Mathf.Log(8f) * num / num2);
				float value = TeleporterExpansionPlusPlugin.MaxMultiplier.Value;
				if (value > 0f)
				{
					num3 = Mathf.Min(num3, value);
				}
				num3 = Mathf.Min(num3, 100000f);
				radius = Mathf.Max(radius, startRadius * num3);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}

UnifiedStagePool.dll

Decompiled 7 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using HarmonyLib;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace UnifiedStagePool
{
	[BepInPlugin("custom.UnifiedStagePool", "UnifiedStagePool", "2.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class UnifiedStagePoolPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private ConfigEntry<bool> addReformedAltar;

		private ConfigEntry<bool> addTreebornColony;

		private ConfigEntry<bool> addConduitCanyon;

		private ConfigEntry<bool> mergeLoopVariants;

		private ConfigEntry<bool> routeNormalExit;

		private ConfigEntry<float> addedWeight;

		private ConfigEntry<string> extraStages;

		private ConfigEntry<bool> stageFilter;

		private static readonly FieldInfo entriesField = typeof(SceneCollection).GetField("_sceneEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private void Awake()
		{
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			addReformedAltar = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "ReformedAltar", true, "Add Reformed Altar (lemuriantemple) to the stage 2 pool, before and after looping.");
			addTreebornColony = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "TreebornColony", true, "Add Treeborn Colony (habitat) and its loop variant (habitatfall) to the stage 3 pool, before and after looping.");
			addConduitCanyon = ((BaseUnityPlugin)this).Config.Bind<bool>("Stages", "ConduitCanyon", true, "Add Conduit Canyon (conduitcanyon) to the stage 4 pool, before and after looping.");
			extraStages = ((BaseUnityPlugin)this).Config.Bind<string>("Stages", "ExtraStages", string.Empty, "Extra scenes as name:stage pairs, comma separated (e.g. mymap:3).");
			mergeLoopVariants = ((BaseUnityPlugin)this).Config.Bind<bool>("Loops", "MergeLoopVariants", true, "Every stage pool contains both the normal and the loop-variant stages, before and after looping (villagenight, lakesnight, etc.).");
			addedWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Stages", "AddedStageWeight", 1f, "Selection weight for added stages (vanilla stages are 1).");
			routeNormalExit = ((BaseUnityPlugin)this).Config.Bind<bool>("Routes", "RouteStagesUseNormalExit", true, "Added route stages lead into the normal pool of the next stage instead of continuing their route.");
			stageFilter = ((BaseUnityPlugin)this).Config.Bind<bool>("Stage Filter", "Enabled", true, "Adds a Stages category to the lobby (Classic and Eclipse runs) where every player, host or not, can vote stages off. It lists every stage in the pools, including Reformed Altar, Treeborn Colony, Golden Dieback, Conduit Canyon, the loop variants and modded stages. Banned stages are skipped by normal stage picks, Random stage order, Bazaar seers and the Reincarnation ritual; if every option for a pick is banned, that pick ignores the bans. The pause menu gets a Banned Stages list. This replaces the StageFilter mod: while StageFilter is installed, this category is not added. All players need this mod.");
			try
			{
				Apply();
			}
			catch (Exception ex)
			{
				Log.LogError((object)ex);
			}
			try
			{
				StageBans.Init(stageFilter, new Harmony("custom.UnifiedStagePool"));
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Stage filter failed to start: " + ex2));
			}
		}

		private static SceneEntry[] Raw(SceneCollection c)
		{
			if ((Object)(object)c == (Object)null || entriesField == null)
			{
				return (SceneEntry[])(object)new SceneEntry[0];
			}
			return (SceneEntry[])(((object)(SceneEntry[])entriesField.GetValue(c)) ?? ((object)new SceneEntry[0]));
		}

		private static T Load<T>(string path) where T : Object
		{
			//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)
			try
			{
				return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Could not load " + path + ": " + ex.Message));
				return default(T);
			}
		}

		internal static SceneDef Scene(string name)
		{
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			if (new Dictionary<string, string>
			{
				{ "lemuriantemple", "RoR2/DLC2/lemuriantemple/lemuriantemple.asset" },
				{ "habitat", "RoR2/DLC2/habitat/habitat.asset" },
				{ "habitatfall", "RoR2/DLC2/habitatfall/habitatfall.asset" },
				{ "conduitcanyon", "RoR2/DLC3/conduitcanyon/conduitcanyon.asset" }
			}.TryGetValue(name, out var value))
			{
				SceneDef val = Load<SceneDef>(value);
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			SceneDef val2 = SceneCatalog.FindSceneDef(name);
			if (Object.op_Implicit((Object)(object)val2))
			{
				return val2;
			}
			string[] array = new string[5] { "Base", "DLC1", "DLC2", "DLC3", "DLC4" };
			foreach (string text in array)
			{
				SceneDef val3 = null;
				try
				{
					val3 = Addressables.LoadAssetAsync<SceneDef>((object)("RoR2/" + text + "/" + name + "/" + name + ".asset")).WaitForCompletion();
				}
				catch
				{
				}
				if (Object.op_Implicit((Object)(object)val3))
				{
					return val3;
				}
			}
			Log.LogWarning((object)("Scene not found: " + name));
			return null;
		}

		private void Apply()
		{
			SceneCollection[] array = (SceneCollection[])(object)new SceneCollection[6];
			SceneCollection[] array2 = (SceneCollection[])(object)new SceneCollection[6];
			for (int i = 1; i <= 5; i++)
			{
				array[i] = Load<SceneCollection>("RoR2/Base/SceneGroups/sgStage" + i + ".asset");
				array2[i] = Load<SceneCollection>("RoR2/Base/SceneGroups/loopSgStage" + i + ".asset");
			}
			StageBans.normalCollections = array;
			StageBans.loopCollections = array2;
			if (mergeLoopVariants.Value)
			{
				for (int j = 1; j <= 5; j++)
				{
					if (Object.op_Implicit((Object)(object)array[j]) && Object.op_Implicit((Object)(object)array2[j]))
					{
						SceneEntry[] source = Raw(array[j]).ToArray();
						SceneEntry[] source2 = Raw(array2[j]).ToArray();
						MergeEntries(array[j], source2);
						MergeEntries(array2[j], source);
					}
				}
			}
			List<KeyValuePair<SceneDef, int>> list = new List<KeyValuePair<SceneDef, int>>();
			if (addReformedAltar.Value)
			{
				list.Add(new KeyValuePair<SceneDef, int>(Scene("lemuriantemple"), 2));
			}
			if (addTreebornColony.Value)
			{
				list.Add(new KeyValuePair<SceneDef, int>(Scene("habitat"), 3));
				list.Add(new KeyValuePair<SceneDef, int>(Scene("habitatfall"), 3));
			}
			if (addConduitCanyon.Value)
			{
				list.Add(new KeyValuePair<SceneDef, int>(Scene("conduitcanyon"), 4));
			}
			string[] array3 = extraStages.Value.Split(new char[1] { ',' });
			for (int k = 0; k < array3.Length; k++)
			{
				string[] array4 = array3[k].Trim().Split(new char[1] { ':' });
				if (array4.Length == 2 && int.TryParse(array4[1], out var result) && result >= 1 && result <= 5)
				{
					SceneDef val = Scene(array4[0].Trim());
					list.Add(new KeyValuePair<SceneDef, int>(val, result));
					if (Object.op_Implicit((Object)(object)val))
					{
						StageBans.extraScenes.Add(new KeyValuePair<SceneDef, int>(val, result));
					}
				}
			}
			foreach (KeyValuePair<SceneDef, int> item in list)
			{
				if ((Object)(object)item.Key == (Object)null || !Object.op_Implicit((Object)(object)item.Key))
				{
					Log.LogWarning((object)"Skipping a stage that failed to load.");
					continue;
				}
				Add(item.Key, array[item.Value]);
				Add(item.Key, array2[item.Value]);
				if (!routeNormalExit.Value || item.Value >= 5)
				{
					continue;
				}
				if (Object.op_Implicit((Object)(object)array[item.Value + 1]))
				{
					item.Key.destinationsGroup = array[item.Value + 1];
				}
				if (Object.op_Implicit((Object)(object)array2[item.Value + 1]))
				{
					FieldInfo field = typeof(SceneDef).GetField("loopedDestinationsGroup", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field != null)
					{
						field.SetValue(item.Key, array2[item.Value + 1]);
					}
				}
			}
			for (int l = 1; l <= 5; l++)
			{
				if (Object.op_Implicit((Object)(object)array[l]))
				{
					Log.LogInfo((object)("sgStage" + l + ": " + string.Join(", ", Raw(array[l]).Select(Describe))));
				}
				if (Object.op_Implicit((Object)(object)array2[l]))
				{
					Log.LogInfo((object)("loopSgStage" + l + ": " + string.Join(", ", Raw(array2[l]).Select(Describe))));
				}
			}
		}

		private void MergeEntries(SceneCollection collection, SceneEntry[] source)
		{
			//IL_0060: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)collection == (Object)null || entriesField == null || source == null)
			{
				return;
			}
			List<SceneEntry> list = (from e in Raw(collection)
				where (Object)(object)e.sceneDef != (Object)null
				select e).ToList();
			bool flag = false;
			for (int num = 0; num < source.Length; num++)
			{
				SceneEntry sourceEntry = source[num];
				if ((Object)(object)sourceEntry.sceneDef == (Object)null)
				{
					continue;
				}
				float weight = ((((SceneEntry)(ref sourceEntry)).weight > 0f) ? ((SceneEntry)(ref sourceEntry)).weight : addedWeight.Value);
				int num2 = list.FindIndex((SceneEntry e) => e.sceneDef == sourceEntry.sceneDef);
				if (num2 < 0)
				{
					SceneEntry item = sourceEntry;
					((SceneEntry)(ref item)).weight = weight;
					list.Add(item);
					flag = true;
					continue;
				}
				SceneEntry val = list[num2];
				if (((SceneEntry)(ref val)).weight <= 0f)
				{
					SceneEntry val2 = list[num2];
					((SceneEntry)(ref val2)).weight = weight;
					if ((Object)(object)val2.fallbackSceneDef == (Object)null)
					{
						val2.fallbackSceneDef = sourceEntry.fallbackSceneDef;
					}
					list[num2] = val2;
					flag = true;
				}
			}
			if (flag)
			{
				entriesField.SetValue(collection, list.ToArray());
			}
		}

		private static string Describe(SceneEntry e)
		{
			//IL_0000: 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)
			if ((Object)(object)e.sceneDef == (Object)null)
			{
				return "NULL";
			}
			string name = ((Object)e.sceneDef).name;
			if (Mathf.Approximately(((SceneEntry)(ref e)).weight, 1f))
			{
				return name;
			}
			return name + " (weight " + ((SceneEntry)(ref e)).weight.ToString("0.##") + ")";
		}

		private void Add(SceneDef scene, SceneCollection collection)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)scene == (Object)null || (Object)(object)collection == (Object)null || entriesField == null)
			{
				return;
			}
			SceneEntry[] array = (SceneEntry[])(((object)(SceneEntry[])entriesField.GetValue(collection)) ?? ((object)new SceneEntry[0]));
			SceneEntry[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				if (array2[i].sceneDef == scene)
				{
					if (((SceneEntry)(ref array2[i])).weight <= 0f)
					{
						((SceneEntry)(ref array2[i])).weight = addedWeight.Value;
						entriesField.SetValue(collection, array2);
					}
					return;
				}
			}
			SceneEntry val = new SceneEntry
			{
				sceneDef = scene
			};
			((SceneEntry)(ref val)).weight = addedWeight.Value;
			SceneEntry item = val;
			List<SceneEntry> list = array.Where((SceneEntry e) => (Object)(object)e.sceneDef != (Object)null).ToList();
			list.Add(item);
			entriesField.SetValue(collection, list.ToArray());
		}
	}
	public static class StageBans
	{
		public sealed class StageGroup
		{
			public string key;

			public string nameToken;

			public readonly List<SceneDef> scenes = new List<SceneDef>();

			public readonly SortedSet<int> tiers = new SortedSet<int>();

			public readonly SortedSet<int> loopTiers = new SortedSet<int>();

			public int stageOrder;

			public ExpansionDef expansion;

			public RuleDef rule;

			public RuleChoiceDef on;

			public RuleChoiceDef off;

			public bool LoopOnly
			{
				get
				{
					if (tiers.Count == 0)
					{
						return loopTiers.Count > 0;
					}
					return false;
				}
			}

			public int SortTier
			{
				get
				{
					if (tiers.Count > 0)
					{
						return tiers.Min;
					}
					if (loopTiers.Count > 0)
					{
						return loopTiers.Min;
					}
					return stageOrder;
				}
			}
		}

		private const string StageFilterGuid = "com.Yunull.StageFilter";

		private const string HeaderToken = "USP_RULE_HEADER_STAGES";

		private const string StageTokenPrefix = "USP_STAGE_";

		internal static SceneCollection[] normalCollections = (SceneCollection[])(object)new SceneCollection[6];

		internal static SceneCollection[] loopCollections = (SceneCollection[])(object)new SceneCollection[6];

		internal static readonly List<KeyValuePair<SceneDef, int>> extraScenes = new List<KeyValuePair<SceneDef, int>>();

		private static ConfigEntry<bool> enabled;

		private static RuleCategoryDef category;

		private static readonly List<StageGroup> groups = new List<StageGroup>();

		private static readonly Dictionary<string, StageGroup> groupsByKey = new Dictionary<string, StageGroup>(StringComparer.Ordinal);

		private static readonly Dictionary<SceneDef, StageGroup> groupByScene = new Dictionary<SceneDef, StageGroup>();

		private static readonly Dictionary<string, StageGroup> groupBySceneName = new Dictionary<string, StageGroup>(StringComparer.Ordinal);

		private static readonly Dictionary<string, string> staticStrings = new Dictionary<string, string>(StringComparer.Ordinal)
		{
			{ "USP_RULE_HEADER_STAGES", "Stages" },
			{ "USP_RULE_HEADER_STAGES_SUBTITLE", "Turn stages off to keep them out of the run." },
			{ "USP_RULE_HEADER_STAGES_EDIT", "Enable or disable stages." },
			{ "USP_STAGE_ON_DESC", "This stage <style=cArtifact><b>may</b></style> appear in this run." },
			{ "USP_STAGE_OFF_DESC", "This stage is <color=red><b>banned</b></color> from this run." },
			{ "USP_PAUSE_BANNED_STAGES", "Banned Stages" },
			{ "USP_BANLIST_HEADER", "Banned Stages" },
			{ "USP_BANLIST_NONE", "No stages are banned in this run." }
		};

		private static bool spritesBuilt;

		private static Sprite placeholderOn;

		private static Sprite placeholderOff;

		private static ManualLogSource Log => UnifiedStagePoolPlugin.Log;

		internal static void Init(ConfigEntry<bool> enabledEntry, Harmony harmony)
		{
			enabled = enabledEntry;
			if (Chainloader.PluginInfos.ContainsKey("com.Yunull.StageFilter"))
			{
				Log.LogWarning((object)"StageFilter is installed, so UnifiedStagePool's own Stages lobby category is not added. Remove StageFilter to use it (it also covers Reformed Altar, Treeborn Colony, Golden Dieback and Conduit Canyon, and works for every player, not only the host).");
				return;
			}
			Patch(harmony, AccessTools.Method(typeof(RuleCatalog), "Init", Type.EmptyTypes, (Type[])null), null, null, "RuleInitTranspiler");
			Patch(harmony, AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), "LanguagePrefix", null);
			Patch(harmony, AccessTools.Method(typeof(RuleCategoryController), "SetData", new Type[3]
			{
				typeof(RuleCategoryDef),
				typeof(RuleChoiceMask),
				typeof(RuleBook)
			}, (Type[])null), "SetDataPrefix", "SetDataPostfix");
			Patch(harmony, AccessTools.Method(typeof(Run), "PickNextStageScene", new Type[1] { typeof(WeightedSelection<SceneDef>) }, (Type[])null), "PickPrefix", "PickPostfix");
			Patch(harmony, AccessTools.Method(typeof(BazaarController), "SetUpSeerStations", Type.EmptyTypes, (Type[])null), null, "SeerPostfix", null, 0);
			Patch(harmony, AccessTools.Method(typeof(CursedBookSacrificeZone), "GetNextScene", Type.EmptyTypes, (Type[])null), null, "BookPostfix", null, 0);
			Patch(harmony, AccessTools.Method(typeof(PauseScreenController), "Awake", Type.EmptyTypes, (Type[])null), null, "PausePostfix");
		}

		private static void Patch(Harmony harmony, MethodBase target, string prefix, string postfix, string transpiler = null, int priority = -1)
		{
			string text = prefix ?? postfix ?? transpiler;
			if (target == null)
			{
				Log.LogError((object)("Stage filter: hook target missing for " + text + "; that part is off."));
				return;
			}
			try
			{
				harmony.Patch(target, Hm(prefix, priority), Hm(postfix, priority), Hm(transpiler, priority), (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter: could not hook " + target.DeclaringType?.Name + "." + target.Name + ": " + ex));
			}
		}

		private static HarmonyMethod Hm(string name, int priority)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			if (name == null)
			{
				return null;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(StageBans), name, (Type[])null);
			if (priority >= 0)
			{
				val.priority = priority;
			}
			return val;
		}

		private static IEnumerable<CodeInstruction> RuleInitTranspiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			MethodInfo methodInfo = AccessTools.Method(typeof(RuleCatalog), "AddRule", (Type[])null, (Type[])null);
			int num = -1;
			for (int i = 0; i < list.Count; i++)
			{
				if (CodeInstructionExtensions.Calls(list[i], methodInfo))
				{
					num = i;
				}
			}
			if (num < 0)
			{
				Log.LogError((object)"Stage filter: could not find where to add the Stages lobby category; the filter is off.");
				return list;
			}
			CodeInstruction val = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(StageBans), "CreateCategory", (Type[])null, (Type[])null));
			if (num + 1 < list.Count)
			{
				val.labels.AddRange(list[num + 1].labels);
				list[num + 1].labels.Clear();
			}
			list.Insert(num + 1, val);
			return list;
		}

		public static void CreateCategory()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				BuildGroups();
				placeholderOn = SolidSprite(new Color(0.42f, 0.42f, 0.46f, 1f));
				placeholderOff = SolidSprite(new Color(0.13f, 0.13f, 0.14f, 1f));
				category = RuleCatalog.AddCategory("USP_RULE_HEADER_STAGES", "USP_RULE_HEADER_STAGES_SUBTITLE", Color32.op_Implicit(new Color32((byte)196, (byte)143, (byte)51, byte.MaxValue)), (string)null, "USP_RULE_HEADER_STAGES_EDIT", (Func<bool>)CategoryHidden, (RuleCategoryType)1, (GridFormattingOverride)null);
				foreach (StageGroup group in groups)
				{
					string text = "USP_STAGE_" + group.key;
					RuleDef val = new RuleDef("USP.Stage." + group.key, text);
					RuleChoiceDef val2 = val.AddChoice("On", (object)group, false);
					val2.sprite = placeholderOn;
					val2.tooltipNameToken = text;
					val2.tooltipBodyToken = "USP_STAGE_ON_DESC";
					val2.tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)24));
					val2.selectionUISound = "Play_UI_artifactSelect";
					val2.onlyShowInGameBrowserIfNonDefault = true;
					if (Object.op_Implicit((Object)(object)group.expansion))
					{
						val2.requiredExpansionDef = group.expansion;
						val2.requiredEntitlementDef = group.expansion.requiredEntitlement;
					}
					val.MakeNewestChoiceDefault();
					RuleChoiceDef val3 = val.AddChoice("Off", (object)group, false);
					val3.sprite = placeholderOff;
					val3.tooltipNameToken = text;
					val3.getTooltipName = RuleChoiceDef.GetOffTooltipNameFromToken;
					val3.tooltipBodyToken = "USP_STAGE_OFF_DESC";
					val3.tooltipNameColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)10));
					val3.selectionUISound = "Play_UI_artifactDeselect";
					val3.onlyShowInGameBrowserIfNonDefault = true;
					group.rule = val;
					group.on = val2;
					group.off = val3;
					RuleCatalog.AddRule(val);
				}
				Log.LogInfo((object)("Stage filter: " + groups.Count + " stages in the Stages lobby category: " + string.Join(", ", groups.Select((StageGroup g) => g.key))));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter: could not build the Stages lobby category: " + ex));
			}
		}

		private static string SceneName(SceneDef scene)
		{
			if (!Object.op_Implicit((Object)(object)scene))
			{
				return null;
			}
			string text = scene.cachedName;
			if (string.IsNullOrEmpty(text))
			{
				text = ((Object)scene).name;
			}
			return text;
		}

		private static void BuildGroups()
		{
			//IL_0060: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Invalid comparison between Unknown and I4
			groups.Clear();
			groupsByKey.Clear();
			groupByScene.Clear();
			groupBySceneName.Clear();
			Dictionary<string, StageGroup> byIdentity = new Dictionary<string, StageGroup>(StringComparer.Ordinal);
			List<StageGroup> ordered = new List<StageGroup>();
			for (int i = 1; i <= 5; i++)
			{
				foreach (SceneEntry item in RawEntries(normalCollections, i))
				{
					SceneEntry current = item;
					Found(current.sceneDef, i, loop: false, ((SceneEntry)(ref current)).weight <= 0f);
				}
				foreach (SceneEntry item2 in RawEntries(loopCollections, i))
				{
					SceneEntry current2 = item2;
					Found(current2.sceneDef, i, loop: true, ((SceneEntry)(ref current2)).weight <= 0f);
				}
			}
			Found(UnifiedStagePoolPlugin.Scene("lemuriantemple"), 2, loop: false, catalogOnly: false);
			Found(UnifiedStagePoolPlugin.Scene("habitat"), 3, loop: false, catalogOnly: false);
			Found(UnifiedStagePoolPlugin.Scene("habitatfall"), 3, loop: false, catalogOnly: false);
			Found(UnifiedStagePoolPlugin.Scene("conduitcanyon"), 4, loop: false, catalogOnly: false);
			foreach (KeyValuePair<SceneDef, int> extraScene in extraScenes)
			{
				Found(extraScene.Key, extraScene.Value, loop: false, catalogOnly: false);
			}
			try
			{
				Enumerator<SceneDef> enumerator3 = SceneCatalog.allSceneDefs.GetEnumerator();
				try
				{
					while (enumerator3.MoveNext())
					{
						SceneDef current4 = enumerator3.Current;
						if (Object.op_Implicit((Object)(object)current4) && (int)current4.sceneType == 1 && current4.stageOrder >= 1 && current4.stageOrder <= 5 && !current4.isLockedBeforeLooping)
						{
							Found(current4, current4.stageOrder, loop: false, catalogOnly: true);
						}
					}
				}
				finally
				{
					((IDisposable)enumerator3/*cast due to .constrained prefix*/).Dispose();
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stage filter: could not read the scene catalog: " + ex.Message));
			}
			foreach (StageGroup item3 in ordered)
			{
				item3.scenes.Sort((SceneDef a, SceneDef b) => string.CompareOrdinal(SceneName(a), SceneName(b)));
				string text = SceneName(item3.scenes[0]);
				string text2 = text.TrimEnd('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
				string text3 = ((text2.Length > 0) ? text2 : text);
				if (groupsByKey.ContainsKey(text3))
				{
					text3 = text;
				}
				int num = 2;
				string text4 = text3;
				while (groupsByKey.ContainsKey(text3))
				{
					text3 = text4 + "_" + num++;
				}
				item3.key = text3;
				groupsByKey[text3] = item3;
				groups.Add(item3);
				foreach (SceneDef scene in item3.scenes)
				{
					groupByScene[scene] = item3;
					groupBySceneName[SceneName(scene)] = item3;
				}
			}
			groups.Sort(delegate(StageGroup a, StageGroup b)
			{
				int num2 = a.SortTier.CompareTo(b.SortTier);
				if (num2 != 0)
				{
					return num2;
				}
				num2 = a.LoopOnly.CompareTo(b.LoopOnly);
				return (num2 == 0) ? string.CompareOrdinal(a.key, b.key) : num2;
			});
			void Found(SceneDef scene, int tier, bool loop, bool catalogOnly)
			{
				string text5 = SceneName(scene);
				if (!string.IsNullOrEmpty(text5))
				{
					string key = (string.IsNullOrEmpty(scene.nameToken) ? ("#" + text5) : scene.nameToken);
					if (!byIdentity.TryGetValue(key, out var value))
					{
						value = new StageGroup
						{
							nameToken = scene.nameToken,
							stageOrder = scene.stageOrder,
							expansion = scene.requiredExpansion
						};
						byIdentity[key] = value;
						ordered.Add(value);
					}
					if (!value.scenes.Contains(scene))
					{
						value.scenes.Add(scene);
					}
					if (!Object.op_Implicit((Object)(object)value.expansion) && Object.op_Implicit((Object)(object)scene.requiredExpansion))
					{
						value.expansion = scene.requiredExpansion;
					}
					if (!catalogOnly && tier >= 1 && tier <= 5)
					{
						(loop ? value.loopTiers : value.tiers).Add(tier);
					}
				}
			}
		}

		private static IEnumerable<SceneEntry> RawEntries(SceneCollection[] collections, int index)
		{
			if (collections == null || index >= collections.Length || !Object.op_Implicit((Object)(object)collections[index]))
			{
				return Enumerable.Empty<SceneEntry>();
			}
			FieldInfo field = typeof(SceneCollection).GetField("_sceneEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			IEnumerable<SceneEntry> enumerable = ((field != null) ? ((SceneEntry[])field.GetValue(collections[index])) : null);
			return enumerable ?? Enumerable.Empty<SceneEntry>();
		}

		private static bool IsValidGameMode(GameModeIndex index)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			string gameModeName = GameModeCatalog.GetGameModeName(index);
			if (!(gameModeName == "ClassicRun"))
			{
				return gameModeName == "EclipseRun";
			}
			return true;
		}

		private static bool CategoryHidden()
		{
			//IL_0034: 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)
			try
			{
				if (enabled == null || !enabled.Value || groups.Count == 0)
				{
					return true;
				}
				if (Object.op_Implicit((Object)(object)PreGameController.instance))
				{
					return !IsValidGameMode(PreGameController.instance.gameModeIndex);
				}
				if (Object.op_Implicit((Object)(object)Run.instance))
				{
					return !IsValidGameMode(Run.instance.gameModeIndex);
				}
				return true;
			}
			catch
			{
				return true;
			}
		}

		private static bool LanguagePrefix(string token, ref string __result)
		{
			if (token == null || token.Length < 5 || token[0] != 'U' || !token.StartsWith("USP_", StringComparison.Ordinal))
			{
				return true;
			}
			try
			{
				if (staticStrings.TryGetValue(token, out var value))
				{
					__result = value;
					return false;
				}
				if (token.StartsWith("USP_STAGE_", StringComparison.Ordinal) && groupsByKey.TryGetValue(token.Substring("USP_STAGE_".Length), out var value2))
				{
					__result = DisplayName(value2) + " - " + TierLabel(value2);
					return false;
				}
			}
			catch (Exception)
			{
			}
			return true;
		}

		private static string DisplayName(StageGroup group)
		{
			if (string.IsNullOrEmpty(group.nameToken))
			{
				return group.key;
			}
			return Language.GetString(group.nameToken);
		}

		private static string TierLabel(StageGroup group)
		{
			if (group.tiers.Count > 1)
			{
				return "Stages " + string.Join("/", group.tiers);
			}
			if (group.tiers.Count == 1)
			{
				return "Stage " + group.tiers.Min;
			}
			if (group.loopTiers.Count > 0)
			{
				return "Stage " + string.Join("/", group.loopTiers) + " (after looping)";
			}
			return "Stage " + group.stageOrder;
		}

		private static void SetDataPrefix(RuleCategoryDef categoryDef)
		{
			if (categoryDef != null && categoryDef == category)
			{
				BuildSprites();
			}
		}

		private static void SetDataPostfix(RuleCategoryController __instance, RuleCategoryDef categoryDef)
		{
			if (categoryDef == null || categoryDef != category)
			{
				return;
			}
			try
			{
				if (Object.op_Implicit((Object)(object)__instance.popoutRandomButtonContainer))
				{
					__instance.popoutRandomButtonContainer.SetActive(false);
				}
				UIElementAllocator<RuleChoiceController> popoutButtonIconAllocator = __instance.popoutButtonIconAllocator;
				if (popoutButtonIconAllocator == null || popoutButtonIconAllocator.elements == null)
				{
					return;
				}
				foreach (RuleChoiceController element in popoutButtonIconAllocator.elements)
				{
					if (Object.op_Implicit((Object)(object)element) && element.choiceDef != null)
					{
						element.UpdateFromVotes();
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stage filter: lobby refresh: " + ex.Message));
			}
		}

		private static void BuildSprites()
		{
			if (spritesBuilt)
			{
				return;
			}
			spritesBuilt = true;
			foreach (StageGroup group in groups)
			{
				try
				{
					Texture val = null;
					foreach (SceneDef scene in group.scenes)
					{
						val = Preview(scene);
						if (Object.op_Implicit((Object)(object)val))
						{
							break;
						}
					}
					if (Object.op_Implicit((Object)(object)val) && group.on != null)
					{
						Texture2D val2 = SquareCopy(val, 128);
						group.on.sprite = MakeSprite(val2);
						group.off.sprite = MakeSprite(Darkened(val2, 0.3f));
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Stage filter: no preview picture for " + group.key + ": " + ex.Message));
				}
			}
		}

		private static Texture Preview(SceneDef scene)
		{
			//IL_0036: 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)
			Texture val = null;
			try
			{
				val = scene.previewTexture;
			}
			catch (Exception)
			{
			}
			if (!Object.op_Implicit((Object)(object)val) && scene.previewTextureReference != null && ((AssetReference)scene.previewTextureReference).RuntimeKeyIsValid())
			{
				try
				{
					val = Addressables.LoadAssetAsync<Texture>(((AssetReference)scene.previewTextureReference).RuntimeKey).WaitForCompletion();
				}
				catch (Exception)
				{
				}
			}
			return val;
		}

		private static Texture2D SquareCopy(Texture source, int size)
		{
			//IL_0034: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			int num = Mathf.Min(source.width, source.height);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)num / (float)source.width, (float)num / (float)source.height);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((1f - val.x) * 0.5f, (1f - val.y) * 0.5f);
			RenderTexture temporary = RenderTexture.GetTemporary(size, size, 0, (RenderTextureFormat)0);
			RenderTexture active = RenderTexture.active;
			try
			{
				Graphics.Blit(source, temporary, val, val2);
				RenderTexture.active = temporary;
				Texture2D val3 = new Texture2D(size, size, (TextureFormat)4, false);
				val3.ReadPixels(new Rect(0f, 0f, (float)size, (float)size), 0, 0);
				val3.Apply();
				return val3;
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
			}
		}

		private static Texture2D Darkened(Texture2D source, float factor)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//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_0029: 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_003d: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, false);
			Color32[] pixels = source.GetPixels32();
			for (int i = 0; i < pixels.Length; i++)
			{
				Color32 val2 = pixels[i];
				pixels[i] = new Color32((byte)((float)(int)val2.r * factor), (byte)((float)(int)val2.g * factor), (byte)((float)(int)val2.b * factor), val2.a);
			}
			val.SetPixels32(pixels);
			val.Apply();
			return val;
		}

		private static Sprite MakeSprite(Texture2D texture)
		{
			//IL_0019: 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)
			return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), new Vector2(0.5f, 0.5f), 100f);
		}

		private static Sprite SolidSprite(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0018: 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)
			Texture2D val = new Texture2D(8, 8, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[64];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			val.SetPixels(array);
			val.Apply();
			return MakeSprite(val);
		}

		private static bool Active(Run run)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (enabled != null && enabled.Value && groups.Count > 0 && Object.op_Implicit((Object)(object)run) && run.ruleBook != null)
			{
				return IsValidGameMode(run.gameModeIndex);
			}
			return false;
		}

		private static StageGroup FindGroup(SceneDef scene)
		{
			if (!Object.op_Implicit((Object)(object)scene))
			{
				return null;
			}
			if (groupByScene.TryGetValue(scene, out var value))
			{
				return value;
			}
			string text = SceneName(scene);
			if (text != null && groupBySceneName.TryGetValue(text, out value))
			{
				return value;
			}
			return null;
		}

		public static bool IsBanned(Run run, SceneDef scene)
		{
			StageGroup stageGroup = FindGroup(scene);
			if (stageGroup?.off == null || !Object.op_Implicit((Object)(object)run) || run.ruleBook == null)
			{
				return false;
			}
			return run.ruleBook.IsChoiceActive(stageGroup.off);
		}

		private static bool ExpansionOk(Run run, SceneDef scene)
		{
			if (Object.op_Implicit((Object)(object)scene.requiredExpansion))
			{
				return run.IsExpansionEnabled(scene.requiredExpansion);
			}
			return true;
		}

		private static void PickPrefix(Run __instance, WeightedSelection<SceneDef> choices, out SceneDef __state)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			__state = (Object.op_Implicit((Object)(object)__instance) ? __instance.nextStageScene : null);
			try
			{
				if (!NetworkServer.active || choices == null || choices.Count == 0 || !Active(__instance) || (int)__instance.ruleBook.stageOrder != 0)
				{
					return;
				}
				int num = 0;
				float num2 = 0f;
				for (int i = 0; i < choices.Count; i++)
				{
					if (IsBanned(__instance, choices.choices[i].value))
					{
						num++;
					}
					else
					{
						num2 += choices.choices[i].weight;
					}
				}
				if (num == 0)
				{
					return;
				}
				if (num >= choices.Count || num2 <= 0f)
				{
					Log.LogWarning((object)"Stage filter: every stage that could come next is banned; ignoring the bans for this pick.");
					return;
				}
				for (int num3 = choices.Count - 1; num3 >= 0; num3--)
				{
					if (IsBanned(__instance, choices.choices[num3].value))
					{
						choices.RemoveChoice(num3);
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter (next stage): " + ex));
			}
		}

		private static void PickPostfix(Run __instance, WeightedSelection<SceneDef> choices, SceneDef __state)
		{
			//IL_0020: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || choices == null || choices.Count == 0 || !Active(__instance) || (int)__instance.ruleBook.stageOrder == 0)
				{
					return;
				}
				SceneDef nextStageScene = __instance.nextStageScene;
				if (!Object.op_Implicit((Object)(object)nextStageScene) || !IsBanned(__instance, nextStageScene))
				{
					return;
				}
				List<SceneDef> list = new List<SceneDef>();
				Enumerator<SceneDef> enumerator = SceneCatalog.allStageSceneDefs.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						SceneDef current = enumerator.Current;
						if (Object.op_Implicit((Object)(object)current) && !IsBanned(__instance, current) && (!Object.op_Implicit((Object)(object)__state) || !(__state.baseSceneName == current.baseSceneName)) && current.hasAnyDestinations && current.validForRandomSelection && ExpansionOk(__instance, current) && (__instance.stageClearCount != 0 || __instance.blacklistedScenesForFirstScene == null || Array.IndexOf(__instance.blacklistedScenesForFirstScene, current) < 0))
						{
							list.Add(current);
						}
					}
				}
				finally
				{
					((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
				}
				if (list.Count == 0)
				{
					Log.LogWarning((object)("Stage filter: Random stage order picked banned " + SceneName(nextStageScene) + " and nothing else is allowed; keeping it."));
					return;
				}
				__instance.nextStageScene = list[__instance.nextStageRng.RangeInt(0, list.Count)];
				Log.LogInfo((object)("Stage filter: Random stage order picked banned " + SceneName(nextStageScene) + "; using " + SceneName(__instance.nextStageScene) + " instead."));
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter (random order): " + ex));
			}
		}

		private static void SeerPostfix(BazaarController __instance)
		{
			//IL_00b4: 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)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Invalid comparison between Unknown and I4
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Run instance = Run.instance;
				if (!NetworkServer.active || !Active(instance) || !Object.op_Implicit((Object)(object)__instance) || __instance.seerStations == null)
				{
					return;
				}
				SeerStationController[] seerStations = __instance.seerStations;
				SeerStationController[] array = seerStations;
				foreach (SeerStationController val in array)
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					int targetSceneDefIndex = val.targetSceneDefIndex;
					if (targetSceneDefIndex < 0 || targetSceneDefIndex >= SceneCatalog.sceneDefCount)
					{
						continue;
					}
					SceneDef sceneDef = SceneCatalog.GetSceneDef((SceneIndex)targetSceneDefIndex);
					if (!Object.op_Implicit((Object)(object)sceneDef) || !IsBanned(instance, sceneDef))
					{
						continue;
					}
					int num = (Object.op_Implicit((Object)(object)instance.nextStageScene) ? instance.nextStageScene.stageOrder : sceneDef.stageOrder);
					List<SceneDef> list = new List<SceneDef>();
					Enumerator<SceneDef> enumerator = SceneCatalog.allSceneDefs.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							SceneDef current = enumerator.Current;
							if (Object.op_Implicit((Object)(object)current) && !((Object)(object)current == (Object)(object)sceneDef) && !current.filterOutOfBazaar && (int)current.sceneType != 6 && current.stageOrder == num && ExpansionOk(instance, current) && (instance.stageClearCount >= 4 || !current.isLockedBeforeLooping || InPreLoopPool(current)) && !IsBanned(instance, current) && !SeerShows(seerStations, current))
							{
								list.Add(current);
							}
						}
					}
					finally
					{
						((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
					}
					if (list.Count > 0)
					{
						Xoroshiro128Plus val2 = (Xoroshiro128Plus)(((object)__instance.rng) ?? ((object)new Xoroshiro128Plus(instance.seed ^ (ulong)instance.stageClearCount)));
						SceneDef val3 = list[val2.RangeInt(0, list.Count)];
						val.SetTargetScene(val3);
						Log.LogInfo((object)("Stage filter: a Lunar Seer showed banned " + SceneName(sceneDef) + "; it now shows " + SceneName(val3) + "."));
					}
					else
					{
						PurchaseInteraction component = ((Component)val).GetComponent<PurchaseInteraction>();
						if (Object.op_Implicit((Object)(object)component))
						{
							component.SetAvailable(false);
						}
						Log.LogInfo((object)("Stage filter: a Lunar Seer showed banned " + SceneName(sceneDef) + " and no other stage is allowed; turned it off."));
					}
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter (seers): " + ex));
			}
		}

		private static bool InPreLoopPool(SceneDef scene)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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)
			for (int i = 1; i <= 5; i++)
			{
				foreach (SceneEntry item in RawEntries(normalCollections, i))
				{
					SceneEntry current = item;
					if (current.sceneDef == scene && ((SceneEntry)(ref current)).weight > 0f)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static bool SeerShows(SeerStationController[] seers, SceneDef scene)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between I4 and Unknown
			foreach (SeerStationController val in seers)
			{
				if (Object.op_Implicit((Object)(object)val) && val.targetSceneDefIndex == (int)scene.sceneDefIndex)
				{
					return true;
				}
			}
			return false;
		}

		private static void BookPostfix(CursedBookSacrificeZone __instance, ref SceneDef __result)
		{
			//IL_0075: 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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!NetworkServer.active || !Object.op_Implicit((Object)(object)__result) || !Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				Run instance = Run.instance;
				if (!Active(instance) || !IsBanned(instance, __result))
				{
					return;
				}
				SceneDef val = null;
				if (__instance.useRerollSceneInstead)
				{
					SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
					if (!Object.op_Implicit((Object)(object)mostRecentSceneDef))
					{
						return;
					}
					List<SceneDef> list = new List<SceneDef>();
					Enumerator<SceneDef> enumerator = SceneCatalog.allSceneDefs.GetEnumerator();
					try
					{
						while (enumerator.MoveNext())
						{
							SceneDef current = enumerator.Current;
							if (Object.op_Implicit((Object)(object)current) && !((Object)(object)current == (Object)(object)mostRecentSceneDef) && current.stageOrder == mostRecentSceneDef.stageOrder && ExpansionOk(instance, current) && !IsBanned(instance, current))
							{
								list.Add(current);
							}
						}
					}
					finally
					{
						((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
					}
					if (list.Count > 0)
					{
						val = list[instance.nextStageRng.RangeInt(0, list.Count)];
					}
				}
				else
				{
					if (__instance.useNextSceneInstead || __instance.useExplicitSceneInstead)
					{
						return;
					}
					SceneCollection val2 = (Object.op_Implicit((Object)(object)__instance.sceneTierCollection) ? __instance.sceneTierCollection.GetSceneCollection(instance.stageClearCountInCurrentLoop + 1) : __instance.sceneCollection);
					if (Object.op_Implicit((Object)(object)val2))
					{
						bool looped = instance.loopClearCount > 0;
						WeightedSelection<SceneDef> val3 = new WeightedSelection<SceneDef>(8);
						val2.AddToWeightedSelection(val3, (Func<SceneDef, bool>)((SceneDef s) => Object.op_Implicit((Object)(object)s) && ExpansionOk(instance, s) && !IsBanned(instance, (looped && Object.op_Implicit((Object)(object)s.loopedSceneDef)) ? s.loopedSceneDef : s)));
						if (val3.Count > 0 && val3.GetTotalWeight() > 0f)
						{
							SceneDef val4 = val3.Evaluate(instance.nextStageRng.nextNormalizedFloat);
							if (Object.op_Implicit((Object)(object)val4) && looped && Object.op_Implicit((Object)(object)val4.loopedSceneDef))
							{
								val4 = val4.loopedSceneDef;
							}
							val = val4;
						}
					}
				}
				if (Object.op_Implicit((Object)(object)val))
				{
					Log.LogDebug((object)("Stage filter: Reincarnation rolled banned " + SceneName(__result) + "; using " + SceneName(val) + "."));
					__result = val;
				}
				else
				{
					Log.LogDebug((object)("Stage filter: Reincarnation rolled banned " + SceneName(__result) + " and nothing else is allowed; keeping it."));
				}
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Stage filter (Reincarnation): " + ex));
			}
		}

		private static void PausePostfix(PauseScreenController __instance)
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			try
			{
				Run instance = Run.instance;
				if (!Object.op_Implicit((Object)(object)instance) || Object.op_Implicit((Object)(object)PreGameController.instance) || !Active(instance) || !groups.Any((StageGroup g) => g.off != null && instance.ruleBook.IsChoiceActive(g.off)) || !Object.op_Implicit((Object)(object)__instance.mainPanel) || ((Transform)__instance.mainPanel).childCount == 0)
				{
					return;
				}
				Transform child = ((Transform)__instance.mainPanel).GetChild(0);
				if (child.childCount < 2)
				{
					return;
				}
				Transform val = Object.Instantiate<Transform>(child.GetChild(1), child);
				((Object)val).name = "USP_BannedStagesButton";
				Button component = ((Component)val).GetComponent<Button>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)((Component)val).gameObject);
					return;
				}
				component.onClick = new ButtonClickedEvent();
				((UnityEvent)component.onClick).AddListener(new UnityAction(ShowBanList));
				string text = Language.GetString("USP_PAUSE_BANNED_STAGES");
				LanguageTextMeshController[] componentsInChildren = ((Component)val).GetComponentsInChildren<LanguageTextMeshController>(true);
				LanguageTextMeshController[] array = componentsInChildren;
				for (int num = 0; num < array.Length; num++)
				{
					array[num].token = "USP_PAUSE_BANNED_STAGES";
				}
				if (componentsInChildren.Length == 0)
				{
					TextMeshProUGUI[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<TextMeshProUGUI>(true);
					for (int num = 0; num < componentsInChildren2.Length; num++)
					{
						((TMP_Text)componentsInChildren2[num]).text = text;
					}
				}
				val.SetSiblingIndex(Mathf.Min(3, child.childCount - 1));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stage filter: could not add the Banned Stages pause button: " + ex.Message));
			}
		}

		private static void ShowBanList()
		{
			//IL_0028: 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)
			try
			{
				Run instance = Run.instance;
				if (Object.op_Implicit((Object)(object)instance))
				{
					EventSystem current = EventSystem.current;
					SimpleDialogBox obj = SimpleDialogBox.Create((MPEventSystem)(object)((current is MPEventSystem) ? current : null));
					obj.headerToken = new TokenParamsPair("USP_BANLIST_HEADER", Array.Empty<object>());
					obj.descriptionToken = new TokenParamsPair(BanListText(instance), Array.Empty<object>());
					obj.AddCancelButton(CommonLanguageTokens.ok, Array.Empty<object>());
				}
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Stage filter: could not show the Banned Stages list: " + ex.Message));
			}
		}

		private static string BanListText(Run run)
		{
			SortedDictionary<int, List<string>> sortedDictionary = new SortedDictionary<int, List<string>>();
			Dictionary<int, string> dictionary = new Dictionary<int, string>();
			foreach (StageGroup group in groups)
			{
				if (group.off != null && run.ruleBook.IsChoiceActive(group.off))
				{
					int key = group.SortTier * 2 + (group.LoopOnly ? 1 : 0);
					if (!sortedDictionary.TryGetValue(key, out var value))
					{
						List<string> list = (sortedDictionary[key] = new List<string>());
						value = list;
						dictionary[key] = "Stage " + group.SortTier + (group.LoopOnly ? " (after looping)" : "");
					}
					value.Add(DisplayName(group));
				}
			}
			if (sortedDictionary.Count == 0)
			{
				return Language.GetString("USP_BANLIST_NONE");
			}
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<int, List<string>> item in sortedDictionary)
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append('\n');
				}
				stringBuilder.Append("<style=cIsUtility>").Append(dictionary[item.Key]).Append(":</style> ")
					.Append(string.Join(", ", item.Value));
			}
			return stringBuilder.ToString();
		}
	}
}

VoidlingRework.dll

Decompiled 7 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.GameOver;
using EntityStates.NullifierMonster;
using EntityStates.VoidRaidCrab;
using HarmonyLib;
using RoR2;
using RoR2.AsyncManagement;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Navigation;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("RoR2")]
[assembly: IgnoresAccessChecksTo("HGCSharpUtils")]
[assembly: IgnoresAccessChecksTo("HGUnityUtils")]
[assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public string AssemblyName { get; }

		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
			AssemblyName = assemblyName;
		}
	}
}
namespace VoidlingRework
{
	public enum Atk
	{
		Disillusion,
		Transpose1,
		Transpose2,
		Transpose3,
		LaserBurst,
		SpinBeam,
		Vacuum,
		Crush,
		PortalBeams,
		Maze,
		GiantMeteor,
		LaserCircle,
		Maze2,
		Spiral,
		Pizza,
		SpinBeam2,
		GiantMeteor2,
		LaserCircle2,
		PortalBeams2,
		GiantLaserPizza,
		Pizza2,
		LaserGrid,
		LaserCircle3,
		SummonJailers,
		PortalBeams3,
		Pizza3,
		LaserBurst2,
		LaserBurst3,
		Vacuum2,
		Vacuum3,
		Crush2,
		Crush3,
		Maze3,
		SpinBeam3,
		Spiral2,
		Summon,
		GiantLaser,
		GiantLaser2,
		LaserGrid2,
		GiantLaserPizza2,
		SafeZone,
		RandomPizza,
		Singularity,
		NeedleBurst,
		SuperLaserBurst,
		QuadMeteors,
		RandomLasers,
		SpinBeamPizza,
		VanillaLaserBurst
	}
	public struct Arena
	{
		public Vector3 center;

		public float inner;

		public float outer;

		public float groundY;

		public float Mid => (inner + outer) * 0.5f;

		public float Rim => outer + VoidlingReworkPlugin.RimOffset.Value;

		public Vector3 CenterAt(float y)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(center.x, y, center.z);
		}
	}
	[BepInPlugin("custom.VoidlingRework", "VoidlingRework", "2.2.3")]
	public class VoidlingReworkPlugin : BaseUnityPlugin
	{
		private class Provider : IContentPackProvider
		{
			private readonly ContentPack pack = new ContentPack();

			public string identifier => "custom.VoidlingRework";

			public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
			{
				try
				{
					AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.VoidlingRework", null);
				}
				catch
				{
				}
				List<BuffDef> list = new List<BuffDef>();
				if (Object.op_Implicit((Object)(object)StageBuff))
				{
					list.Add(StageBuff);
				}
				if (Object.op_Implicit((Object)(object)AddBuff))
				{
					list.Add(AddBuff);
				}
				pack.buffDefs.Add(list.ToArray());
				List<EffectDef> list2 = new List<EffectDef>();
				GameObject[] array = (GameObject[])(object)new GameObject[5] { FxSpherePrefab, FxLaserPrefab, FxRockPrefab, FxTimerPrefab, FxScreenPrefab };
				foreach (GameObject val in array)
				{
					if (!Object.op_Implicit((Object)(object)val))
					{
						continue;
					}
					EffectDef val2 = new EffectDef(val);
					try
					{
						FieldInfo fieldInfo = AccessTools.Field(typeof(EffectDef), "shouldPool");
						if (fieldInfo != null)
						{
							fieldInfo.SetValue(val2, false);
						}
					}
					catch
					{
					}
					list2.Add(val2);
				}
				pack.effectDefs.Add(list2.ToArray());
				List<SkillFamily> list3 = new List<SkillFamily>();
				SkillFamily[] array2 = (SkillFamily[])(object)new SkillFamily[3] { MultiBeamFam, SpinBeamFam, VacuumFam };
				foreach (SkillFamily val3 in array2)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						list3.Add(val3);
					}
				}
				pack.skillFamilies.Add(list3.ToArray());
				pack.entityStateTypes.Add(stateTypes);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
			{
				ContentPack.Copy(pack, args.output);
				args.ReportProgress(1f);
				yield break;
			}

			public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
			{
				args.ReportProgress(1f);
				yield break;
			}
		}

		internal class ArenaZone : IZone
		{
			public bool IsInBounds(Vector3 position)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return InP3ArenaPos(position);
			}
		}

		public struct AddHealthState
		{
			public bool on;

			public float health;

			public float maxHealth;
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static CollectContentPackProvidersDelegate <>9__375_0;

			public static Action<Run> <>9__375_1;

			public static UnityAction<Scene, LoadSceneMode> <>9__375_2;

			public static Action<Stage> <>9__375_3;

			public static Func<ItemDefInfo, bool> <>9__396_0;

			public static Func<CharacterBody, bool> <>9__428_0;

			public static Func<Vector3, float> <>9__446_0;

			public static Func<float, float> <>9__446_1;

			public static Func<float, float> <>9__446_4;

			public static Func<float, float> <>9__446_7;

			public static Action<CharacterBody, float> <>9__462_0;

			public static Func<DonutInfo, string> <>9__474_0;

			public static Func<DonutInfo, string> <>9__474_1;

			internal void <Awake>b__375_0(AddContentPackProviderDelegate add)
			{
				add.Invoke((IContentPackProvider)(object)new Provider());
			}

			internal void <Awake>b__375_1(Run <p0>)
			{
				FightStage = 0;
				CheckpointStartPhase9 = false;
				CheckpointStartPhase12 = false;
			}

			internal void <Awake>b__375_2(Scene loadedScene, LoadSceneMode mode)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				if ((int)mode == 0)
				{
					FightStage = 0;
				}
			}

			internal void <Awake>b__375_3(Stage st)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				fightActive = false;
				fightFinished = false;
				sawP3 = false;
				FightStage = 0;
				CheckpointStartPhase9 = false;
				CheckpointStartPhase12 = false;
				bossBarHiders = 0;
				ForgetDarkMaterials();
				try
				{
					SceneDef val = ((!Object.op_Implicit((Object)(object)st)) ? null : st.sceneDef);
					if (VFIntro.Value && Object.op_Implicit((Object)(object)val) && val.cachedName == "arena")
					{
						VLScreen.Show(VFMessage.Value, Color.white, startBlack: true, 0f, VFBlack.Value, VFMessageTime.Value, VFFadeOut.Value);
						ProtectPlayers(VFBlack.Value + VFMessageTime.Value + VFFadeOut.Value + 2f);
					}
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("Void Fields intro: " + ex.Message));
				}
			}

			internal bool <SetupBodies>b__396_0(ItemDefInfo x)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return (Object)(object)x.itemDef == (Object)(object)OobItem;
			}

			internal bool <FogBodiesPostfix>b__428_0(CharacterBody b)
			{
				return !InP3Arena(b);
			}

			internal float <ComputeArena>b__446_0(Vector3 p)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				return p.y;
			}

			internal float <ComputeArena>b__446_1(float y)
			{
				return y;
			}

			internal float <ComputeArena>b__446_4(float x)
			{
				return x;
			}

			internal float <ComputeArena>b__446_7(float x)
			{
				return x;
			}

			internal void <Setter>b__462_0(CharacterBody <p0>, float <p1>)
			{
			}

			internal string <ShufflePostfix>b__474_0(DonutInfo d)
			{
				if (d != null && Object.op_Implicit((Object)(object)d.root))
				{
					return ((Object)d.root).name;
				}
				return "null";
			}

			internal string <ShufflePostfix>b__474_1(DonutInfo d)
			{
				if (d != null && Object.op_Implicit((Object)(object)d.root))
				{
					return ((Object)d.root).name;
				}
				return "null";
			}
		}

		public const string GUID = "custom.VoidlingRework";

		public const string SubtitleToken = "VOIDLINGREWORK_BODY_SUBTITLE";

		internal static ManualLogSource Log;

		internal static VoidlingReworkPlugin Instance;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> FatalAttacks;

		internal static ConfigEntry<bool> RemoveP3Fog;

		internal static ConfigEntry<bool> OldEnding;

		internal static ConfigEntry<bool> AllowOrbital;

		internal static ConfigEntry<bool> RecolorPizza;

		internal static ConfigEntry<bool> ArmorRecolor;

		internal static ConfigEntry<float> BaseHP;

		internal static ConfigEntry<float> LevelHP;

		internal static ConfigEntry<float> BaseDmg;

		internal static ConfigEntry<float> LevelDmg;

		internal static ConfigEntry<float> BaseArmor;

		internal static ConfigEntry<float> BaseAtkSpd;

		internal static ConfigEntry<float> BaseMoveSpd;

		internal static ConfigEntry<float> BaseAccel;

		internal static ConfigEntry<float> MissileTurn;

		internal static ConfigEntry<string> Subtitle;

		internal static ConfigEntry<float> AttackGap;

		internal static ConfigEntry<float> StartDelay;

		public const int StP1 = 10;

		public const int StT12 = 15;

		public const int StP2S1 = 20;

		public const int StP2S2 = 21;

		public const int StP2S3 = 22;

		public const int StP2S4 = 23;

		public const int StT23 = 25;

		public const int StP3S1 = 30;

		public const int StP3S2 = 31;

		public const int StP3S3 = 32;

		public const int StP4Out = 40;

		public const int StP4S1 = 41;

		public const int StP10 = 42;

		public const int StP11 = 43;

		public const int StP11Down = 44;

		public const int StP12 = 45;

		public const int StP12Seed = 46;

		public const int StDefeat = 50;

		public const string FinalNameToken = "VOIDLINGREWORK_FINAL_NAME";

		internal static BuffDef StageBuff;

		internal static BuffDef AddBuff;

		internal static SpawnCard HalcyoniteCard;

		internal static SpawnCard AlloyHunterCard;

		internal static SpawnCard DevastatorCard;

		internal static EquipmentDef VoidEliteEquip;

		internal static ConfigEntry<float> P2HealthMult;

		internal static ConfigEntry<float> P3HealthMult;

		internal static ConfigEntry<float> FinalHealthMult;

		internal static ConfigEntry<bool> SeedDoublesHealth;

		internal static ConfigEntry<float> FinalSeedHealthMult;

		internal static ConfigEntry<string> FinalName;

		internal static ConfigEntry<float> GapFinal;

		internal static ConfigEntry<string> FinalColor;

		internal static ConfigEntry<bool> ThresholdSummons;

		internal static ConfigEntry<float> AddHealthFraction;

		internal static ConfigEntry<float> MazePizzaInterval;

		internal static ConfigEntry<float> WaveInterval;

		internal static ConfigEntry<float> WaveDevastators;

		internal static ConfigEntry<float> WaveJailers;

		internal static ConfigEntry<float> WaveReavers;

		internal static ConfigEntry<float> P4BlackoutDelay;

		internal static ConfigEntry<float> P4FadeIn;

		internal static ConfigEntry<float> P4MessageDelay;

		internal static ConfigEntry<float> P4MessageTime;

		internal static ConfigEntry<float> P4FadeOut;

		internal static ConfigEntry<float> P4MeteorDelay;

		internal static ConfigEntry<string> P4Message;

		internal static ConfigEntry<string> P4MessageColor;

		internal static ConfigEntry<float> SurviveTime;

		internal static ConfigEntry<string> SurviveText;

		internal static ConfigEntry<float> P4MeteorTime;

		internal static ConfigEntry<float> P4Meteors;

		internal static ConfigEntry<float> P4MeteorRadiusMult;

		internal static ConfigEntry<float> P4MazeTime;

		internal static ConfigEntry<float> P10AddHealthFraction;

		internal static ConfigEntry<float> P10AddsEach;

		internal static ConfigEntry<float> P11HealthMult;

		internal static ConfigEntry<float> P10Delay;

		internal static ConfigEntry<float> P11Delay;

		internal static ConfigEntry<float> P12BlackoutDelay;

		internal static ConfigEntry<float> P12FadeIn;

		internal static ConfigEntry<float> P12MessageDelay;

		internal static ConfigEntry<string> P12Message;

		internal static ConfigEntry<string> P12MessageColor;

		internal static ConfigEntry<float> P12MessageSize;

		internal static ConfigEntry<float> P12MessageTime;

		internal static ConfigEntry<float> P12FadeOut;

		internal static ConfigEntry<float> P12ReturnDelay;

		internal static ConfigEntry<float> P12CheckpointDelay;

		internal static ConfigEntry<bool> P12Spirals;

		internal static ConfigEntry<float> FinalDarkness;

		internal static ConfigEntry<string> FinalObjective;

		internal static ConfigEntry<float> FinalBarrageRate;

		internal static ConfigEntry<float> T3Pizzas;

		internal static ConfigEntry<float> TPizzaDelay;

		internal static ConfigEntry<float> TPizzaInterval;

		internal static ConfigEntry<float> TPizzaLines;

		internal static ConfigEntry<float> LB1RadiusMult;

		internal static ConfigEntry<float> LB3RadiusMult;

		internal static ConfigEntry<string> MeteorText;

		internal static ConfigEntry<string> Meteor2Text;

		internal static ConfigEntry<bool> VFIntro;

		internal static ConfigEntry<string> VFMessage;

		internal static ConfigEntry<float> VFBlack;

		internal static ConfigEntry<float> VFMessageTime;

		internal static ConfigEntry<float> VFFadeOut;

		internal static ConfigEntry<float> MessageFontSize;

		internal static ConfigEntry<string> ArmorColor;

		internal static ConfigEntry<string> TelegraphColor;

		internal static ConfigEntry<string> PortalTelegraphColor;

		internal static ConfigEntry<string> PizzaColor;

		internal static ConfigEntry<string> TimerColor;

		internal static ConfigEntry<string> SafeText;

		internal static ConfigEntry<string> HideText;

		internal static ConfigEntry<float> SafeDarken;

		internal static ConfigEntry<float> SafeBeaconRadius;

		internal static ConfigEntry<float> ArenaInnerOverride;

		internal static ConfigEntry<float> ArenaOuterOverride;

		internal static ConfigEntry<float> ArenaFallbackInner;

		internal static ConfigEntry<float> ArenaFallbackOuter;

		internal static ConfigEntry<float> RimOffset;

		internal static ConfigEntry<float> BeamHeight;

		internal static Dictionary<Atk, ConfigEntry<bool>> AtkEnabled = new Dictionary<Atk, ConfigEntry<bool>>();

		internal static ConfigEntry<float> DisBaseDuration;

		internal static ConfigEntry<float> DisWaves;

		internal static ConfigEntry<float> DisMissiles;

		internal static ConfigEntry<float> DisBombInterval;

		internal static ConfigEntry<float> DisBombDamage;

		internal static ConfigEntry<float> THopTelegraph;

		internal static ConfigEntry<float> THopInterval;

		internal static ConfigEntry<float> TImplosionRadius;

		internal static ConfigEntry<float> TFarDistance;

		internal static ConfigEntry<float> TNearDistance;

		internal static ConfigEntry<float> RainDirectChance;

		internal static ConfigEntry<float> RainVariance;

		internal static ConfigEntry<float> LBShots;

		internal static ConfigEntry<float> LBTelegraph;

		internal static ConfigEntry<float> LBDelay;

		internal static ConfigEntry<float> LBRadius;

		internal static ConfigEntry<float> LBFinaleRadius;

		internal static ConfigEntry<bool> HideSafeZone;

		internal static ConfigEntry<bool> StationaryVoidling;

		internal static ConfigEntry<float> SpinScale;

		internal static ConfigEntry<float> SpinAimEnd;

		internal static ConfigEntry<float> CrushCharge;

		internal static ConfigEntry<float> CrushDuration;

		internal static ConfigEntry<float> CrushCount;

		internal static ConfigEntry<float> CrushTravel;

		internal static ConfigEntry<float> CrushRadius;

		internal static ConfigEntry<float> CrushSpread;

		internal static ConfigEntry<float> CrushRockScale;

		internal static ConfigEntry<float> RainCharge;

		internal static ConfigEntry<float> RainDuration;

		internal static ConfigEntry<float> RainRate;

		internal static ConfigEntry<float> RainDelay;

		internal static ConfigEntry<float> RainRadius;

		internal static ConfigEntry<float> MazeWaves;

		internal static ConfigEntry<float> MazeWarn;

		internal static ConfigEntry<float> MazeFire;

		internal static ConfigEntry<float> MazeRadius;

		internal static ConfigEntry<float> MazeSpread;

		internal static ConfigEntry<float> Maze2Spacing;

		internal static ConfigEntry<float> MeteorWarn;

		internal static ConfigEntry<float> MeteorRadius;

		internal static ConfigEntry<float> MeteorRockScale;

		internal static ConfigEntry<float> MeteorShake;

		internal static ConfigEntry<float> JailerCount;

		internal static ConfigEntry<bool> LBPuddle;

		internal static SpawnCard JailerCard;

		internal static GameObject PuddlePrefab;

		internal static ConfigEntry<float> CircleLapTime;

		internal static ConfigEntry<float> CircleLaps;

		internal static ConfigEntry<float> CircleWarn;

		internal static ConfigEntry<float> CirclePillarTime;

		internal static ConfigEntry<float> CircleMargin;

		internal static ConfigEntry<float> CircleSpacing;

		internal static ConfigEntry<float> SpiralCount;

		internal static ConfigEntry<float> SpiralDuration;

		internal static ConfigEntry<float> SpiralTurns;

		internal static ConfigEntry<float> SpiralSecondDelay;

		internal static ConfigEntry<float> SpiralRadius;

		internal static ConfigEntry<float> SpiralWarn;

		internal static ConfigEntry<float> PizzaBursts;

		internal static ConfigEntry<float> PizzaDuration;

		internal static ConfigEntry<float> PizzaLines;

		internal static ConfigEntry<float> PizzaCenters;

		internal static ConfigEntry<float> PizzaOffset;

		internal static ConfigEntry<float> PizzaDamage;

		internal static ConfigEntry<float> Pizza2Speed;

		internal static ConfigEntry<float> GPizzaWarn;

		internal static ConfigEntry<float> GPizzaRotationTime;

		internal static ConfigEntry<float> GPizzaDuration;

		internal static ConfigEntry<float> GPizzaRadius;

		internal static ConfigEntry<float> GPizzaCount;

		internal static ConfigEntry<float> GridWarn;

		internal static ConfigEntry<float> GridDuration;

		internal static ConfigEntry<float> GridWidth;

		internal static ConfigEntry<float> GridTravel;

		internal static ConfigEntry<float> GridSweeps;

		internal static ConfigEntry<float> CrushTargetChance;

		internal static ConfigEntry<float> CrushMissSpread;

		internal static ConfigEntry<float> Maze2ExtraWarn;

		internal static ConfigEntry<float> SpiralSets;

		internal static ConfigEntry<string> GridLayout;

		internal static GameObject Holder;

		internal static GameObject FxSpherePrefab;

		internal static GameObject FxLaserPrefab;

		internal static GameObject FxRockPrefab;

		internal static GameObject FxTimerPrefab;

		internal static GameObject SphereTemplate;

		internal static GameObject SphereTemplateGrey;

		internal static GameObject LaserTemplate;

		internal static GameObject WarnTemplate;

		internal static GameObject RockTemplate;

		internal static float SphereBaseDiameter = 1f;

		internal static Mesh BeamMesh;

		internal static Texture PurpleRemap;

		internal static GameObject TracerBig;

		internal static GameObject MultiBeamMuzzle;

		internal static Material BeamOuterMat;

		internal static Material BeamInnerMat;

		internal static Material WarnOuterMat;

		internal static Material WarnInnerMat;

		internal static GameObject ImplosionEffect;

		internal static GameObject PortalEffect;

		internal static GameObject SmallPortalEffect;

		internal static GameObject TracerEffect;

		internal static GameObject RainExplosion;

		internal static GameObject MeteorImpact;

		internal static GameObject BlinkEffect;

		internal static GameObject MissileMuzzle;

		internal static GameObject PortalBombMuzzle;

		internal static GameObject MissilePrefab;

		internal static GameObject BombPrefab;

		internal static GameObject UltStatic;

		internal static GameObject UltLeft;

		internal static GameObject UltRight;

		internal static Material DissolveMat;

		internal static Material KarmaMat;

		internal static Material ArmorOverlay;

		internal static SkillDef MultiBeamDef;

		internal static SkillDef SpinBeamDef;

		internal static SkillDef VacuumDef;

		internal static SkillFamily MultiBeamFam;

		internal static SkillFamily SpinBeamFam;

		internal static SkillFamily VacuumFam;

		internal static ItemDef OobItem;

		internal static BodyIndex[] PhaseBodies;

		private static readonly string[] BodyPaths;

		private static readonly string[] MasterPaths;

		private static Harmony harmony;

		private static Type[] stateTypes;

		internal static ConfigEntry<float> CircleSizeMult;

		internal static ConfigEntry<float> CirclePillars;

		internal static ConfigEntry<float> LB2RadiusMult;

		internal static ConfigEntry<float> LB2MinOff;

		internal static ConfigEntry<float> LB2MaxOff;

		internal static ConfigEntry<float> VacRainFactor;

		internal static ConfigEntry<float> SidePizzaLines;

		internal static ConfigEntry<float> Crush2Mult;

		internal static ConfigEntry<float> Crush3Mult;

		internal static ConfigEntry<float> Maze2Waves;

		internal static ConfigEntry<float> SummonCount;

		internal static ConfigEntry<float> GLWarn;

		internal static ConfigEntry<float> GLFire;

		internal static ConfigEntry<float> Spiral2Count;

		internal static ConfigEntry<float> Spiral2Sets;

		internal static ConfigEntry<float> Spiral2Delay;

		internal static ConfigEntry<float> GridLanes;

		internal static ConfigEntry<float> GridRotate;

		internal static ConfigEntry<float> SafeRadius;

		internal static ConfigEntry<float> SafeTime;

		internal static ConfigEntry<float> SingDuration;

		internal static ConfigEntry<float> NeedleWindup;

		internal static ConfigEntry<float> NeedleDuration;

		internal static ConfigEntry<float> NeedleRate;

		internal static ConfigEntry<float> NeedleSpread;

		internal static ConfigEntry<float> SuperLBTimer;

		internal static ConfigEntry<float> QuadRadiusMult;

		internal static ConfigEntry<float> QuadWarnReduce;

		internal static ConfigEntry<float> QuadSets;

		internal static ConfigEntry<float> QuadInterval;

		internal static ConfigEntry<float> SingSpeed;

		internal static ConfigEntry<float> SingCoreRadius;

		internal static ConfigEntry<float> RLCount;

		internal static ConfigEntry<float> RLDuration;

		internal static ConfigEntry<float> RLRadius;

		internal static ConfigEntry<float> UltPizzaFactor;

		internal static ConfigEntry<float> UltRainFactor;

		internal static ConfigEntry<float> UltMazeDowntime;

		internal static ConfigEntry<float> UltRandomLasers;

		internal static ConfigEntry<float> UltCrushFactor;

		internal static ConfigEntry<float> UltCircleFactor;

		internal static ConfigEntry<float> Meteor2Lead;

		internal static ConfigEntry<bool> WaitForPlayers;

		internal static ConfigEntry<float> WaitArenaMargin;

		internal static ConfigEntry<float> WaitMaxSeconds;

		internal static ConfigEntry<float> WaitExtraDelay;

		internal static ConfigEntry<float> UltCircleLap;

		internal static ConfigEntry<float> LB3FarOffset;

		internal static ConfigEntry<float> GPizzaRamp;

		internal static ConfigEntry<float> SingScale;

		internal static ConfigEntry<float> UltIntroDelay;

		internal static ConfigEntry<float> MeteorBoomCount;

		internal static GameObject DiabloImpact;

		internal static ConfigEntry<float> TimerFallbackY;

		internal static ConfigEntry<float> FightSpeed;

		internal static ConfigEntry<float> Maze2Warn;

		internal static ConfigEntry<float> Maze3Warn;

		internal static ConfigEntry<float> Pizza3Lines;

		internal static ConfigEntry<float> GridSizeMult;

		internal static ConfigEntry<float> TimerOffsetY;

		internal static SpawnCard SummonCard;

		internal static GameObject FxScreenPrefab;

		internal static GameObject CountdownPanelPrefab;

		internal static GameObject NeedlePrefab;

		internal static GameObject SingularityPrefab;

		internal static ConfigEntry<string> SummonCardPath;

		internal static ConfigEntry<string> PhaseDonutKeywords;

		internal static bool fightActive;

		internal static bool fightFinished;

		internal static bool sawP3;

		private float fightScan;

		internal static Arena P3Arena;

		internal static float P3ArenaTime;

		internal static readonly ArenaZone P3Zone;

		internal const float PillarTop = 300f;

		internal const float PillarBottom = -40f;

		private static Vector3 lastLoggedArena;

		private static readonly Dictionary<CharacterBody, int> curseSnap;

		private static FieldInfo fCurrentOverlays;

		private static FieldInfo fActiveOverlayCount;

		private static FieldInfo fMaterialsDirty;

		private static MethodInfo mUpdateOverlays;

		private static FieldInfo fArmorBuff;

		private static bool armorLookupDone;

		private static BuffDef cachedArmorBuff;

		private static PropertyInfo pBeamVfx;

		private static int idxStatic;

		private static int idxLeft;

		private static int idxRight;

		private static int idxNeedle;

		private static int idxSing;

		private static readonly HashSet<ScriptedCombatEncounter> waiting;

		private static ScriptedCombatEncounter bypass;

		private static readonly Dictionary<AnimationCurve, float> curvePeak;

		private static PropertyInfo pGhost;

		internal static float blackoutUntil;

		private float blackoutTick;

		private static FieldInfo fBarGroup;

		private static readonly Dictionary<Material, Material> darkOf;

		private static readonly HashSet<Material> darkMats;

		private static string finalColorText;

		private static Color finalColorValue;

		private static int bossBarHiders;

		private static Action<CharacterBody, float> setMaxHealth;

		private static Action<CharacterBody, float> setMaxBarrier;

		private static Action<CharacterBody, float> setMaxHull;

		public static int FightStage { get; private set; }

		public static bool CheckpointStartPhase9 { get; set; }

		public static bool CheckpointStartPhase12 { get; set; }

		public static bool ReworkEnabled
		{
			get
			{
				if (Enabled != null)
				{
					return Enabled.Value;
				}
				return false;
			}
		}

		public static string MusicPhase
		{
			get
			{
				switch (FightStage)
				{
				case 10:
					return "1";
				case 15:
					return "1-2";
				case 20:
					return "2";
				case 21:
					return "3";
				case 22:
					return "2.3";
				case 23:
					return "2.4";
				case 25:
					return "2-3";
				case 30:
					return "3.1";
				case 31:
					return "3.2";
				case 32:
					return "3.3";
				case 40:
					return "silence";
				case 41:
				case 42:
				case 43:
					return "4.1";
				case 44:
					return "silence";
				case 45:
				case 46:
					return "4.2";
				case 50:
					return "defeat";
				default:
					return null;
				}
			}
		}

		public static int MusicRank
		{
			get
			{
				int fightStage = FightStage;
				switch (fightStage)
				{
				case 40:
					return 35;
				case 41:
				case 42:
				case 43:
					return 40;
				case 44:
					return 41;
				case 45:
				case 46:
					return 42;
				case 50:
					return 101;
				default:
					return fightStage;
				}
			}
		}

		internal static BuffDef ArmorBuff
		{
			get
			{
				if (Object.op_Implicit((Object)(object)cachedArmorBuff))
				{
					return cachedArmorBuff;
				}
				if (!armorLookupDone)
				{
					armorLookupDone = true;
					try
					{
						Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
						for (int i = 0; i < assemblies.Length; i++)
						{
							Type type = assemblies[i].GetType("BossSuperArmor.BossSuperArmorPlugin", throwOnError: false);
							if (!(type == null))
							{
								fArmorBuff = type.GetField("ArmorBuff", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
								break;
							}
						}
					}
					catch
					{
					}
				}
				if (fArmorBuff != null)
				{
					try
					{
						object? value = fArmorBuff.GetValue(null);
						cachedArmorBuff = (BuffDef)((value is BuffDef) ? value : null);
					}
					catch
					{
					}
				}
				return cachedArmorBuff;
			}
		}

		internal static void NoteStage(int s)
		{
			if (s > FightStage)
			{
				FightStage = s;
			}
		}

		internal static string StageName(int s)
		{
			return s switch
			{
				10 => "phase 1", 
				15 => "phase 1 to 2", 
				20 => "phase 2", 
				21 => "phase 3 (ultimate)", 
				22 => "phase 4 (Halcyon Knight and Alloy Hunter)", 
				23 => "phase 5", 
				25 => "phase 5 to 6", 
				30 => "phase 6", 
				31 => "phase 7 (maze and pizzas)", 
				32 => "phase 8", 
				40 => "phase 9 (the voidling leaves)", 
				41 => "phase 9, survive", 
				42 => "phase 10 (Halcyon Knights and Alloy Hunters)", 
				43 => "phase 11", 
				44 => "phase 11 defeated (silence, then the blackout)", 
				45 => "phase 12, final battle", 
				46 => "phase 12, final battle (Halcyon Seed)", 
				50 => "defeated", 
				_ => "stage " + s, 
			};
		}

		internal static Material TransparentCopy(Material src, Color c, float alpha, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0040: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(src);
			((Object)val).name = name;
			string[] array = new string[3] { "_TintColor", "_Color", "_MainColor" };
			foreach (string text in array)
			{
				if (val.HasProperty(text))
				{
					val.SetColor(text, new Color(c.r, c.g, c.b, alpha));
				}
			}
			return val;
		}

		private void Awake()
		{
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			BindConfig();
			if (!Enabled.Value)
			{
				return;
			}
			try
			{
				LoadAssets();
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Asset load: " + ex));
			}
			try
			{
				CreateBuff();
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Buff: " + ex2));
			}
			try
			{
				CreateEffects();
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Effects: " + ex3));
			}
			try
			{
				SetupBodies();
			}
			catch (Exception ex4)
			{
				Log.LogError((object)("Bodies: " + ex4));
			}
			try
			{
				SetupMisc();
			}
			catch (Exception ex5)
			{
				Log.LogError((object)("Misc: " + ex5));
			}
			object obj = <>c.<>9__375_0;
			if (obj == null)
			{
				CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add)
				{
					add.Invoke((IContentPackProvider)(object)new Provider());
				};
				<>c.<>9__375_0 = val;
				obj = (object)val;
			}
			ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj;
			harmony = new Harmony("custom.VoidlingRework");
			Patch(AccessTools.Method(typeof(Language), "GetLocalizedStringByToken", new Type[1] { typeof(string) }, (Type[])null), "LanguagePrefix", null);
			MethodInfo target = AccessTools.Method(typeof(HealthComponent), "TakeDamageProcess", new Type[1] { typeof(DamageInfo) }, (Type[])null) ?? AccessTools.Method(typeof(HealthComponent), "TakeDamage", new Type[1] { typeof(DamageInfo) }, (Type[])null);
			Patch(target, "TakeDamagePrefix", "TakeDamagePostfix", 0);
			Patch(AccessTools.Method(typeof(CharacterModel), "UpdateOverlays", (Type[])null, (Type[])null), null, "OverlaysPostfix");
			Patch(AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null), null, "RecalcSpeedPostfix");
			Patch(AccessTools.Method(typeof(CharacterBody), "RecalculateStats", (Type[])null, (Type[])null), "RecalcAddPrefix", "RecalcAddPostfix");
			Patch(AccessTools.Method(typeof(HUDBossHealthBarController), "LateUpdate", (Type[])null, (Type[])null), null, "BossBarPostfix");
			Patch(AccessTools.Method(typeof(BossGroup), "UpdateObservations", (Type[])null, (Type[])null), "BossObservePrefix", null);
			Patch(AccessTools.Method(typeof(HealthBar), "UpdateBarInfos", (Type[])null, (Type[])null), null, "HealthBarPostfix");
			Patch(AccessTools.Method(typeof(ObjectiveTracker), "GetString", (Type[])null, (Type[])null), null, "ObjectiveStringPostfix");
			Run.onRunDestroyGlobal += delegate
			{
				FightStage = 0;
				CheckpointStartPhase9 = false;
				CheckpointStartPhase12 = false;
			};
			SceneManager.sceneLoaded += delegate(Scene loadedScene, LoadSceneMode mode)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				if ((int)mode == 0)
				{
					FightStage = 0;
				}
			};
			Stage.onStageStartGlobal += delegate(Stage st)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				fightActive = false;
				fightFinished = false;
				sawP3 = false;
				FightStage = 0;
				CheckpointStartPhase9 = false;
				CheckpointStartPhase12 = false;
				bossBarHiders = 0;
				ForgetDarkMaterials();
				try
				{
					SceneDef val2 = ((!Object.op_Implicit((Object)(object)st)) ? null : st.sceneDef);
					if (VFIntro.Value && Object.op_Implicit((Object)(object)val2) && val2.cachedName == "arena")
					{
						VLScreen.Show(VFMessage.Value, Color.white, startBlack: true, 0f, VFBlack.Value, VFMessageTime.Value, VFFadeOut.Value);
						ProtectPlayers(VFBlack.Value + VFMessageTime.Value + VFFadeOut.Value + 2f);
					}
				}
				catch (Exception ex6)
				{
					Log.LogWarning((object)("Void Fields intro: " + ex6.Message));
				}
			};
			Patch(AccessTools.Method(typeof(FogDamageController), "GetAffectedBodies", (Type[])null, (Type[])null), null, "FogBodiesPostfix");
			Patch(AccessTools.Method(typeof(FogDamageController), "GetAffectedBodiesOnTeam", (Type[])null, (Type[])null), null, "FogBodiesPostfix");
			Patch(AccessTools.Method(typeof(SpinBeamAttack), "FixedUpdate", (Type[])null, (Type[])null), "SpinFixedPrefix", "SpinFixedPostfix");
			Patch(AccessTools.Method(typeof(BaseSpinBeamAttackState), "UpdateBeamTransforms", (Type[])null, (Type[])null), null, "SpinBeamTransformsPostfix");
			Patch(AccessTools.Method(typeof(ProjectileController), "Start", (Type[])null, (Type[])null), null, "ProjectileStartPostfix");
			Patch(AccessTools.Method(typeof(VoidRaidGauntletController), "TryShuffleData", (Type[])null, (Type[])null), null, "ShufflePostfix");
			Patch(AccessTools.Method(typeof(ScriptedCombatEncounter), "BeginEncounter", (Type[])null, (Type[])null), "BeginEncounterPrefix", null);
			Patch(AccessTools.Method(typeof(VacuumAttack), "FixedUpdate", (Type[])null, (Type[])null), "VacuumFixedPrefix", null);
			CharacterBody.onBodyStartGlobal += OnBodyStart;
			GlobalEventManager.onCharacterDeathGlobal += OnDeath;
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnLoad));
		}

		private void Patch(MethodInfo target, string prefix, string postfix, int postfixPriority = -1)
		{
			//IL_0034: 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)
			if (target == null)
			{
				Log.LogWarning((object)("Patch target missing for " + (prefix ?? postfix)));
				return;
			}
			try
			{
				HarmonyMethod val = ((postfix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(VoidlingReworkPlugin), postfix, (Type[])null));
				if (val != null && postfixPriority >= 0)
				{
					val.priority = postfixPriority;
				}
				harmony.Patch((MethodBase)target, (prefix == null) ? ((HarmonyMethod)null) : new HarmonyMethod(typeof(VoidlingReworkPlugin), prefix, (Type[])null), val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Patch " + target.Name + ": " + ex));
			}
		}

		private void BindConfig()
		{
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the voidling rework.");
			FatalAttacks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FatalAttacks", true, "Every voidling attack deals fatal damage that ignores armor, block and other defensive items. Revive items still work. Protection that adds NonLethal (e.g. OneShotRework) still triggers.");
			RemoveP3Fog = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveLastArenaFog", true, "Disable void fog damage during phases 6 to 12 (while the last arena's voidling is alive). Parkour fog is untouched.");
			OldEnding = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "OldEndingCutscene", true, "Use the old void ending cutscene (voidoutro).");
			AllowOrbital = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowOrbitalSkills", true, "Allow orbital skills (Captain) in the voidling arena, as the old Fathomless Voidling did.");
			MissileTurn = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MissileTurnSpeed", 180f, "Turn speed of the voidling void missiles (old Fathomless default 180). Negative = leave vanilla.");
			AttackGap = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AttackGap", 1.5f, "Seconds between attacks.");
			StartDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "StartDelay", 1.5f, "Seconds after the voidling finishes spawning before its first attack.");
			Subtitle = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Subtitle", "Liberalio's Servant", "Boss subtitle.");
			FinalName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "FinalBattleName", "T H E     V O I D", "Name shown on the boss bar in the final battle (phase 12). Empty = Voidling.");
			ArmorRecolor = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "RecolorSuperArmor", true, "Recolour the karma super armor overlay on the voidling.");
			ArmorColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "SuperArmorColor", "C9A6FF", "Super armor overlay colour (hex).");
			TelegraphColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "TelegraphColor", "D7B8FF", "Sphere telegraph colour (hex).");
			PortalTelegraphColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "PortalBeamTelegraphColor", "D9D2E6", "Portal beam target sphere colour (hex).");
			PizzaColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "PizzaWaveColor", "9933FF", "Pizza wave colour (hex).");
			TimerColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "TimerColor", "B04DFF", "Colour of the on-screen timers (hex).");
			SafeText = ((BaseUnityPlugin)this).Config.Bind<string>("SafeZone", "TimerText", "Get Inside The Zone", "Safe zone timer text.");
			HideText = ((BaseUnityPlugin)this).Config.Bind<string>("SuperLaserBurst", "TimerText", "Hide", "Super laser burst timer text.");
			SafeDarken = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "MaxScreenDarkness", 0.75f, "Screen darkness reached at the end of the timer (0-1).");
			SafeBeaconRadius = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "BeaconRadius", 2f, "Radius of the light beacon above the safe zone.");
			RecolorPizza = ((BaseUnityPlugin)this).Config.Bind<bool>("Visuals", "RecolorPizzaWaves", true, "Tint the pizza wave projectiles purple.");
			BaseHP = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseMaxHealth", 6000f, "Phase 1 base max health. The other phases are multiples of it.");
			LevelHP = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "LevelMaxHealth", 1800f, "Phase 1 max health per level. The other phases are multiples of it.");
			P2HealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Phases2To5HealthMultiplier", 3f, "Health of the second arena (phases 2 to 5), in phase 1 healths.");
			P3HealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "Phases6To8HealthMultiplier", 3f, "Health of the last arena (phases 6 to 8), in phase 1 healths.");
			FinalHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "FinalBattleHealthMultiplier", 40f, "Final battle (phase 12) health, in phase 1 healths.");
			SeedDoublesHealth = ((BaseUnityPlugin)this).Config.Bind<bool>("Stats", "HalcyonSeedRaisesFinalHealth", true, "If a player carries a Halcyon Seed, the final battle (phase 12) uses FinalBattleSeedHealthMultiplier instead, and Aurelionite answers the seed at half of that health.");
			FinalSeedHealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "FinalBattleSeedHealthMultiplier", 80f, "Final battle health with a Halcyon Seed, in phase 1 healths.");
			BaseDmg = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseDamage", 15f, "Base damage.");
			LevelDmg = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "LevelDamage", 3f, "Damage per level.");
			BaseArmor = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseArmor", 30f, "Armor.");
			BaseAtkSpd = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseAttackSpeed", 1.25f, "Attack speed.");
			BaseMoveSpd = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseMoveSpeed", 90f, "Move speed.");
			BaseAccel = ((BaseUnityPlugin)this).Config.Bind<float>("Stats", "BaseAcceleration", 45f, "Acceleration.");
			GapFinal = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "FinalBattleAttackGap", 0f, "Seconds between attacks in the final battle (phase 12; AttackGap everywhere else).");
			FinalColor = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "FinalBattleColor", "6A1B9A", "Colour of the final battle (phase 12): the boss bar's name, subtitle and health, the health bar above the voidling, the objective's name and the voidling's glow (hex). Empty = unchanged.");
			ThresholdSummons = ((BaseUnityPlugin)this).Config.Bind<bool>("Fight", "HealthSummons", true, "Phase 1 summons Void Reavers at every 25% of health lost and phases 2 to 5 summon Void Jailers at every 20%, on top of the attacks.");
			AddHealthFraction = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "Phase4AddsHealth", 1f / 3f, "Health of the Voidtouched Halcyon Knight and Alloy Hunter in phase 4, as a fraction of phase 1's health.");
			MazePizzaInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "Phase7PizzaInterval", 3f, "Phase 7: seconds between pizzas while Maze 3 runs continuously.");
			WaveInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "VoidSpawnInterval", 30f, "Phases 8, 11 and 12: seconds between void spawns.");
			WaveDevastators = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "VoidSpawnDevastators", 1f, "Void Devastators per void spawn (also the most alive at once).");
			WaveJailers = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "VoidSpawnJailers", 2f, "Void Jailers per void spawn (also the most alive at once).");
			WaveReavers = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "VoidSpawnReavers", 4f, "Void Reavers per void spawn (also the most alive at once).");
			FinalBarrageRate = ((BaseUnityPlugin)this).Config.Bind<float>("Fight", "FinalBattleBarrageRate", 3f, "The ultimate's portal beams and crush meteors run alongside the attacks in phases 5, 8 and 11 (normal rate) and the final battle, phase 12 (this many times faster).");
			P4BlackoutDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "BlackoutDelay", 10f, "Seconds after the voidling's leaving animation finishes before the screen starts to fade to black (the music is silent from the end of phase 8).");
			P4FadeIn = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "BlackoutFadeIn", 2f, "Seconds for the screen to fade to black.");
			P4MessageDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "MessageDelay", 5f, "Seconds the screen stays black before the message fades in.");
			P4MessageTime = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "MessageTime", 10f, "Seconds the message stays on the black screen (it fades in and out).");
			P4FadeOut = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "BlackoutFadeOut", 2f, "Seconds for the black screen to fade away.");
			P4Message = ((BaseUnityPlugin)this).Config.Bind<string>("Phase 9", "Message", "You grow stronger than the Void...", "Message shown on the black screen.");
			P4MessageColor = ((BaseUnityPlugin)this).Config.Bind<string>("Phase 9", "MessageColor", "B04DFF", "Message colour (hex).");
			P4MeteorDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "SurviveDelay", 5f, "Seconds after the screen clears before the meteors start (and the music comes back).");
			SurviveTime = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "SurviveTimer", 90f, "Length of the on-screen timer once the meteors start. Phase 10 follows (see [Phase 10] StartDelay).");
			SurviveText = ((BaseUnityPlugin)this).Config.Bind<string>("Phase 9", "SurviveText", "Survive", "Timer text.");
			P4MeteorTime = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "MeteorTime", 30f, "Seconds of continuous giant meteors (each telegraph starts as the previous one lands).");
			P4Meteors = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "Meteors", 4f, "Giant meteors in that time (the last lands exactly at its end).");
			P4MeteorRadiusMult = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "MeteorSizeMultiplier", 2f, "Size of those meteors relative to Giant Meteor.");
			P4MazeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 9", "MazeTime", 60f, "Seconds of continuous Maze 3 and Pillar Spiral 2 (from the arena centre) after the meteors.");
			P10Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 10", "StartDelay", 5f, "Seconds between phase 9's timer running out and the phase 10 adds spawning.");
			P11Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 11", "StartDelay", 5f, "Seconds between the last phase 10 add dying and the voidling coming back for phase 11.");
			P10AddsEach = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 10", "AddsOfEachKind", 3f, "Phase 10 (after phase 9's timer runs out): this many Voidtouched Halcyon Knights and this many Voidtouched Alloy Hunters. Phase 10 ends when they are all dead.");
			P10AddHealthFraction = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 10", "AddsHealth", 1f / 3f, "Health of each phase 10 add, as a fraction of phase 1's health.");
			P11HealthMult = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 11", "HealthMultiplier", 3f, "Phase 11 (the voidling comes back with phase 8's attacks) health, in phase 1 healths. Emptying it plays the voidling's death animation and starts phase 12.");
			P12BlackoutDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "BlackoutDelay", 10f, "Seconds after phase 11's health runs out (the voidling's death animation plays and the music stops) before the screen fades to black.");
			P12FadeIn = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "BlackoutFadeIn", 2f, "Seconds for the screen to fade to black.");
			P12MessageDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "MessageDelay", 1f, "Seconds the screen stays black before the message fades in.");
			P12Message = ((BaseUnityPlugin)this).Config.Bind<string>("Phase 12", "Message", "T H I S   I S   I T ...", "Message shown on the black screen.");
			P12MessageColor = ((BaseUnityPlugin)this).Config.Bind<string>("Phase 12", "MessageColor", "6A1B9A", "Message colour (hex).");
			P12MessageSize = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "MessageSizeMultiplier", 3f, "Message size, relative to ScreenMessageSize.");
			P12MessageTime = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "MessageTime", 10f, "Seconds the message stays on the black screen (it fades in and out).");
			P12FadeOut = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "BlackoutFadeOut", 2f, "Seconds for the black screen to fade away.");
			P12ReturnDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "ReturnDelay", 10f, "Seconds after the screen clears before the voidling comes back as THE VOID and the final battle (and its music) starts.");
			P12CheckpointDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Phase 12", "CheckpointBlackoutDelay", 3f, "Loading the save made when phase 11 was defeated: seconds after the voidling blinks away before the blackout.");
			P12Spirals = ((BaseUnityPlugin)this).Config.Bind<bool>("Phase 12", "ContinuousSpirals", false, "Pillar Spiral 1 runs from the arena centre all through the final battle (one set every [Spiral] SetDelay seconds, alternating direction).");
			FinalDarkness = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "FinalBattleDarkness", 0.8f, "How much darker the voidling's body is in the final battle (0 = unchanged, 1 = black); its glow turns FinalBattleColor.");
			FinalObjective = ((BaseUnityPlugin)this).Config.Bind<string>("Visuals", "FinalBattleObjective", "Destroy {0}...", "Objective text in the final battle; {0} is FinalBattleName in FinalBattleColor.");
			VFIntro = ((BaseUnityPlugin)this).Config.Bind<bool>("Void Fields", "IntroMessage", true, "Entering the Void Fields starts on a black screen with a message, then the screen fades in.");
			VFMessage = ((BaseUnityPlugin)this).Config.Bind<string>("Void Fields", "Message", "You grow as strong as the Void...", "Message shown when entering the Void Fields.");
			VFBlack = ((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "BlackTimeBeforeMessage", 1f, "Seconds of black screen before the message.");
			VFMessageTime = ((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "MessageTime", 10f, "Seconds the message stays (it fades in and out).");
			VFFadeOut = ((BaseUnityPlugin)this).Config.Bind<float>("Void Fields", "FadeOut", 3f, "Seconds for the black screen to fade away after the message.");
			MessageFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Visuals", "ScreenMessageSize", 44f, "Font size of the black-screen messages (1080p reference).");
			ArenaInnerOverride = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "InnerRadiusOverride", 0f, "Donut inner radius. 0 = measured automatically.");
			ArenaOuterOverride = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "OuterRadiusOverride", 0f, "Donut outer radius. 0 = measured automatically.");
			ArenaFallbackInner = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "FallbackInnerRadius", 60f, "Inner radius used if measuring fails.");
			ArenaFallbackOuter = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "FallbackOuterRadius", 220f, "Outer radius used if measuring fails.");
			RimOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "PortalRimOffset", 20f, "Distance outside the outer edge where edge portals sit.");
			BeamHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "HorizontalLaserHeight", 8f, "Height above the ground of horizontal lasers.");
			foreach (Atk value in Enum.GetValues(typeof(Atk)))
			{
				AtkEnabled[value] = ((BaseUnityPlugin)this).Config.Bind<bool>("Attacks", value.ToString(), true, string.Concat("Enable ", value, "."));
			}
			DisBaseDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Disillusion", "BaseDuration", 4f, "Duration (divided by attack speed).");
			DisWaves = ((BaseUnityPlugin)this).Config.Bind<float>("Disillusion", "MissileWaves", 5f, "Missile waves.");
			DisMissiles = ((BaseUnityPlugin)this).Config.Bind<float>("Disillusion", "MissilesPerWave", 6f, "Missiles per wave.");
			DisBombInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Disillusion", "DeathBombInterval", 1f, "Seconds between tracking death bombs.");
			DisBombDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Disillusion", "DeathBombDamageCoefficient", 1f, "Death bomb damage coefficient (any damage is fatal).");
			THopTelegraph = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "ImplosionTelegraphSeconds", 6f, "Seconds the implosion sphere shows before the teleport.");
			THopInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "SecondsBetweenTeleports", 0.5f, "Seconds between teleports.");
			TPizzaDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "PizzaDelay", 1f, "Transpose 2 and 3: seconds after the teleport before the voidling spins a pizza around itself (like Mithrix).");
			TPizzaLines = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "PizzaLines", 6f, "Lines in that pizza.");
			T3Pizzas = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "Transpose3Pizzas", 3f, "Pizzas Transpose 3 spins (Transpose 2 spins one).");
			TPizzaInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "Transpose3PizzaInterval", 3f, "Seconds between Transpose 3's pizzas.");
			TImplosionRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "ImplosionKillRadius", 100f, "Implosion kill radius.");
			TFarDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "ReturnDistance", 100f, "Distance from a player where the voidling reappears after leaving, and where it goes for its continuous attacks. Kept on the donut.");
			TNearDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Transpose", "TeleportDistance", 30f, "Distance from the target of the teleport. Kept on the donut.");
			BindV14();
			RainDirectChance = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "DirectHitChance", 0.4f, "Chance (0-1) that a laser aims straight at the target. The rest land within the variance radius.");
			RainVariance = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "Variance", 50f, "Radius around the target where non-direct lasers land.");
			HideSafeZone = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideLastArenaSafeZoneSphere", true, "Hide the giant fog safe-zone sphere around the last arena's voidling (phases 6 to 12).");
			StationaryVoidling = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "StationaryVoidling", true, "The voidling does not walk/fly around; it only moves by teleporting and stays put during attacks.");
			SpinScale = ((BaseUnityPlugin)this).Config.Bind<float>("SpinBeam", "SizeMultiplier", 1f, "Spin beam size multiplier.");
			SpinAimEnd = ((BaseUnityPlugin)this).Config.Bind<float>("SpinBeam", "EndDownwardFactor", 0.35f, "Downward aim factor at the end of the spin beam (1 = vanilla, 0 = horizontal).");
			CrushCharge = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "ChargeTime", 2f, "Charge time.");
			CrushDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "Duration", 6f, "Meteor spawning duration.");
			CrushCount = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "MeteorCount", 18f, "Meteors.");
			CrushTravel = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "TelegraphSeconds", 4f, "Seconds between meteor spawn (telegraph) and impact.");
			CrushRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "ExplosionKillRadius", 37.5f, "Explosion radius.");
			CrushTargetChance = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "TargetedChance", 0.5f, "Chance (0-1) a meteor lands on the target; the rest land within CrushMissSpread.");
			CrushMissSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "MissSpread", 45f, "Landing spread of untargeted meteors.");
			CrushSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "TargetSpread", 12f, "Random spread around the target.");
			CrushRockScale = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "RockScale", 3.5f, "Meteor visual scale.");
			RainCharge = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "ChargeTime", 1f, "Charge time.");
			RainDuration = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "Duration", 6f, "Firing duration.");
			RainRate = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "VolleysPerSecond", 5.625f, "Volleys per second (Portal Beams 2 fires two lasers per volley).");
			RainDelay = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "TelegraphTime", 1.5f, "Telegraph time before each laser.");
			RainRadius = ((BaseUnityPlugin)this).Config.Bind<float>("PortalBeams", "BlastRadius", 6f, "Blast radius.");
			MazeWaves = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "Waves", 3f, "Maze waves.");
			MazeWarn = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "WarningTime", 5f, "Warning time.");
			MazeFire = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "FireTime", 3f, "Laser duration.");
			MazeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "LaserRadius", 24f, "Laser radius.");
			MazeSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "PizzaAngle", 120f, "Angle between the three Maze 1 portals.");
			Maze2Spacing = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "LineSpacing", 112.5f, "Spacing between parallel Maze 2 lasers.");
			Maze2ExtraWarn = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "Maze2ExtraWarningTime", 1f, "Extra warning time for Maze 2.");
			MeteorWarn = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "TelegraphSeconds", 9f, "Telegraph time.");
			MeteorText = ((BaseUnityPlugin)this).Config.Bind<string>("GiantMeteor", "WarningText", "A Meteor is Coming", "Giant Meteor timer text (counts down to the impact).");
			Meteor2Text = ((BaseUnityPlugin)this).Config.Bind<string>("GiantMeteor", "Meteor2WarningText", "Two Meteors are Coming", "Giant Meteor 2 timer text (counts down to the second impact).");
			MeteorRadius = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "ExplosionKillRadius", 240f, "Explosion radius.");
			LBShots = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "BurstCount", 5f, "Laser bursts (the last is the bigger finale).");
			LBTelegraph = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "TelegraphSeconds", 3f, "Telegraph before each burst.");
			LBDelay = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "DelayBetweenBursts", 1f, "Delay between bursts.");
			LBRadius = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "BlastRadius", 20f, "Blast radius of each burst.");
			LBFinaleRadius = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "FinaleBlastRadius", 40f, "Blast radius of the last burst.");
			JailerCount = ((BaseUnityPlugin)this).Config.Bind<float>("SummonJailers", "Count", 8f, "Void Jailers summoned, spaced evenly around the donut. They die with the voidling.");
			LBPuddle = ((BaseUnityPlugin)this).Config.Bind<bool>("LaserBurst", "FinaleVoidPuddle", true, "The last burst leaves a void puddle.");
			MeteorShake = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "ScreenShakeStrength", 30f, "Screen shake amplitude when the meteor lands.");
			MeteorRockScale = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "RockScale", 22f, "Meteor visual scale.");
			CircleLapTime = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "LapTimeV4", 24f, "Seconds per lap.");
			CircleLaps = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "RevolutionsV4", 1f, "Laps.");
			CircleWarn = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "WarningTime", 5f, "Warning time per pillar.");
			CirclePillarTime = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "PillarDuration", 1f, "Seconds each pillar lasts.");
			CircleMargin = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "WidthMargin", 8f, "Extra radius so the pillar covers the full donut width.");
			CircleSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "PillarDensity", 1f, "Pillars per lap relative to circumference / pillar diameter.");
			SpiralCount = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "LasersPerSet", 5f, "Lasers per set.");
			SpiralDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Duration", 16f, "Seconds to reach the edge.");
			SpiralTurns = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Turns", 1f, "Turns.");
			SpiralSecondDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "SetDelay", 8f, "Delay of the reversed second set.");
			SpiralRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "LaserRadius", 15f, "Laser radius.");
			SpiralWarn = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "WarningTime", 1.5f, "Warning time.");
			SpiralSets = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Sets", 3f, "Sets of lasers (each later set reverses direction).");
			PizzaBursts = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "Bursts", 6f, "Bursts.");
			PizzaDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "Duration", 8f, "Duration.");
			PizzaLines = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "LinesPerPizza", 3f, "Lines per pizza (Pizza 1/2/3).");
			PizzaCenters = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "PizzasPerBurst", 4f, "Pizzas per burst (placed at +-offset around a player).");
			PizzaOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "CenterOffset", 50f, "Pizza centre offset from the player.");
			PizzaDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "DamageCoefficient", 9f, "Damage coefficient (any damage is fatal).");
			Pizza2Speed = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "Pizza2RotationSpeed", 21f, "Rotation speed of Pizza 2 waves.");
			GPizzaWarn = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "WarningTime", 4f, "Warning time.");
			GPizzaRotationTime = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "SecondsPerFullRotation", 24f, "Seconds per full rotation (clockwise).");
			GPizzaDuration = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "LaserSeconds", 24f, "Laser duration.");
			GPizzaRadius = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "LaserRadius", 24f, "Laser radius.");
			GPizzaCount = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "Lasers", 4f, "Lasers.");
			GridWarn = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "WarningTime", 2f, "Warning time.");
			GridDuration = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "SecondsPerSweep", 15f, "Seconds for one sweep across the arena.");
			GridSweeps = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "Sweeps", 2f, "Sweeps (each sweep reverses direction).");
			GridWidth = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "PillarWidth", 75f, "Pillar diameter.");
			GridTravel = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "StartDistance", 1.4f, "Start/end distance from the centre, in outer radii.");
			GridLayout = ((BaseUnityPlugin)this).Config.Bind<string>("LaserGrid", "Layout", "T:-1.3,0.1,1.1;B:-0.65,0.75;R:1.2,0,-0.9;L:0.6,-0.65", "Pillar lanes in outer radii. T = from top (+Z) moving down, B = from bottom moving up, R = from right (+X) moving left, L = from left moving right.");
		}

		private void BindV14()
		{
			PhaseDonutKeywords = ((BaseUnityPlugin)this).Config.Bind<string>("Arena", "PhaseDonutKeywords", "RaidDC;RaidAL", "Object-name keywords identifying the second (phases 2 to 5) and last (phases 6 to 12) arenas (abyssal depths; aphelian sanctuary). Empty = vanilla random order.");
			CircleSizeMult = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "PillarSizeMultiplier", 1.5f, "Pillar size multiplier (covers the whole donut width).");
			CirclePillars = ((BaseUnityPlugin)this).Config.Bind<float>("LaserCircle", "PillarsPerRevolution", 16f, "Pillars per revolution.");
			LB1RadiusMult = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst1RadiusMultiplier", 2f, "Explosion size multiplier for Laser Burst (phase 1).");
			LB2RadiusMult = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst2RadiusMultiplier", 3f, "Explosion size multiplier for Laser Burst 2.");
			LB3RadiusMult = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst3RadiusMultiplier", 3f, "Explosion size multiplier for Laser Burst 3.");
			LB2MinOff = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst2MinOffset", 10f, "Laser Burst 2/3 land at least this far from the player.");
			LB2MaxOff = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst2MaxOffset", 20f, "Laser Burst 2/3 land at most this far from the player.");
			VacRainFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Vacuum", "PortalBeamRateFactor", 0.5f, "Portal beam rate during Vacuum 2/3, relative to Portal Beams 1.");
			SidePizzaLines = ((BaseUnityPlugin)this).Config.Bind<float>("Vacuum", "SidePizzaLines", 3f, "Lines per pizza during Spin Beam 3 / Vacuum 3.");
			Crush2Mult = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "Crush2DurationMultiplier", 2f, "Crush 2 duration multiplier.");
			Crush3Mult = ((BaseUnityPlugin)this).Config.Bind<float>("Crush", "Crush3DurationMultiplier", 3f, "Crush 3 duration multiplier.");
			Maze2Waves = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "Maze2And3Waves", 3f, "Waves of Maze 2 / Maze 3.");
			SummonCardPath = ((BaseUnityPlugin)this).Config.Bind<string>("Summon", "SpawnCard", "RoR2/Base/Nullifier/cscNullifier.asset", "Spawn card of the summoned enemy (default Void Reaver).");
			SummonCount = ((BaseUnityPlugin)this).Config.Bind<float>("Summon", "Count", 8f, "Enemies summoned, spaced evenly around the donut. They die with the voidling.");
			GLWarn = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaser", "WarningTime", 12f, "Warning time.");
			GLFire = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaser", "LaserTime", 8f, "Laser duration.");
			Spiral2Count = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Spiral2LasersPerSet", 8f, "Lasers per set in Pillar Spiral 2.");
			Spiral2Sets = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Spiral2Sets", 5f, "Sets in Pillar Spiral 2.");
			Spiral2Delay = ((BaseUnityPlugin)this).Config.Bind<float>("Spiral", "Spiral2SetDelay", 6f, "Delay between sets in Pillar Spiral 2.");
			GridLanes = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "LasersPerGroup", 3f, "Lasers in each of the 4 groups.");
			GridRotate = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "LaserGrid2Rotation", 180f, "Degrees Laser Grid 2 rotates around the centre over the whole attack.");
			SafeRadius = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "Radius", 30f, "Safe zone radius.");
			SafeTime = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "Time", 15f, "Seconds before everything outside the zone dies.");
			SingDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Singularity", "Duration", 15f, "Black hole duration (the voidling does nothing else meanwhile).");
			SingSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Singularity", "FollowSpeed", 9f, "Speed the black hole drifts toward the nearest enemy.");
			SingCoreRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Singularity", "KillRadius", 18f, "Anything this close to the black hole centre dies.");
			NeedleWindup = ((BaseUnityPlugin)this).Config.Bind<float>("NeedleBurst", "WindupTime", 2f, "Telegraph time.");
			NeedleDuration = ((BaseUnityPlugin)this).Config.Bind<float>("NeedleBurst", "Duration", 10f, "Firing duration.");
			NeedleRate = ((BaseUnityPlugin)this).Config.Bind<float>("NeedleBurst", "NeedlesPerSecond", 15f, "Needles per second.");
			NeedleSpread = ((BaseUnityPlugin)this).Config.Bind<float>("NeedleBurst", "Spread", 8f, "Spread in degrees.");
			SuperLBTimer = ((BaseUnityPlugin)this).Config.Bind<float>("SuperLaserBurst", "Time", 5f, "Seconds before the vanilla laser burst.");
			QuadRadiusMult = ((BaseUnityPlugin)this).Config.Bind<float>("QuadMeteors", "RadiusMultiplier", 0.4f, "Explosion radius relative to Giant Meteor.");
			QuadWarnReduce = ((BaseUnityPlugin)this).Config.Bind<float>("QuadMeteors", "TelegraphReduction", 0f, "Seconds shorter than the Giant Meteor telegraph.");
			QuadSets = ((BaseUnityPlugin)this).Config.Bind<float>("QuadMeteors", "Sets", 4f, "Sets of four meteors.");
			QuadInterval = ((BaseUnityPlugin)this).Config.Bind<float>("QuadMeteors", "SetInterval", 5f, "Seconds between sets.");
			RLCount = ((BaseUnityPlugin)this).Config.Bind<float>("RandomLasers", "Count", 5f, "Wandering lasers.");
			RLDuration = ((BaseUnityPlugin)this).Config.Bind<float>("RandomLasers", "Duration", 20f, "Attack duration.");
			RLRadius = ((BaseUnityPlugin)this).Config.Bind<float>("RandomLasers", "Radius", 18.75f, "Laser radius.");
			Meteor2Lead = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "Meteor2LeadTime", 1f, "Giant Meteor 2: the second telegraph starts this long before the first impact.");
			FightSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SurvivorWalkSpeedDuringFight", 30f, "Walking speed of every player survivor from the first voidling phase until the final phase dies (parkour included). Sprinting multiplies on top; items no longer change speed; acceleration and movement abilities scale to match. 0 = vanilla.");
			WaitForPlayers = ((BaseUnityPlugin)this).Config.Bind<bool>("Arena", "WaitForAllPlayers", true, "Phases 2 and 6 only start once every living player has come through the portal into the arena.");
			WaitArenaMargin = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "WaitArenaMargin", 60f, "Extra metres beyond the arena's outer radius that still count as being in the arena.");
			WaitMaxSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "WaitMaxSeconds", 0f, "Give up waiting after this many seconds (0 = wait forever).");
			WaitExtraDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Arena", "SpawnDelayAfterAllArrive", 1f, "Seconds after the last player arrives before the voidling spawns.");
			UltCircleLap = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "LaserCircleLapTime", 60f, "Seconds per laser circle revolution in the ultimate.");
			LB3FarOffset = ((BaseUnityPlugin)this).Config.Bind<float>("LaserBurst", "LaserBurst3FarOffset", 60f, "Laser Burst 3: one laser hits the player, the other lands about this far away.");
			GPizzaRamp = ((BaseUnityPlugin)this).Config.Bind<float>("GiantLaserPizza", "Pizza2ReverseRampSeconds", 4f, "Giant Laser Pizza 2: seconds to slow to a stop after the first revolution (and the same again to speed up the other way). Even numbers only.");
			SingScale = ((BaseUnityPlugin)this).Config.Bind<float>("Singularity", "SizeMultiplier", 2f, "Black hole size / pull radius multiplier.");
			UltIntroDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "IntroDelayPerAttack", 5f, "Ultimate attacks start one at a time, this many seconds apart.");
			MeteorBoomCount = ((BaseUnityPlugin)this).Config.Bind<float>("GiantMeteor", "DiabloImpactSounds", 2f, "Diablo Strike explosions played on Giant Meteor impact (2 = twice as loud).");
			Maze2Warn = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "Maze2WarningTime", 4f, "Maze 2 = Maze 1 with this warning time.");
			Maze3Warn = ((BaseUnityPlugin)this).Config.Bind<float>("Maze", "Maze3WarningTime", 3f, "Maze 3 = Maze 1 with this warning time.");
			Pizza3Lines = ((BaseUnityPlugin)this).Config.Bind<float>("Pizza", "Pizza3LinesPerPizza", 4f, "Lines per pizza for Pizza 3.");
			GridSizeMult = ((BaseUnityPlugin)this).Config.Bind<float>("LaserGrid", "LaserSizeMultiplier", 0.5f, "Laser Grid laser size multiplier.");
			TimerOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "CountdownOffsetFromTop", 260f, "Distance (HUD units, 1080 = screen height) from the top of the screen to the countdown panel. Raise it if it still overlaps the boss bar.");
			TimerFallbackY = ((BaseUnityPlugin)this).Config.Bind<float>("SafeZone", "CountdownFallbackOffset", 200f, "Only used if the HUD has no top-centre cluster: pixels from the top of the screen for the countdown panel (kept below the boss bar).");
			UltPizzaFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "PizzaRateDivisor", 6f, "Pizza rate divisor (relative to the pizza attack).");
			UltRainFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "PortalBeamRateDivisor", 8f, "Portal beam rate divisor (relative to Portal Beams 3).");
			UltMazeDowntime = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "MazeDowntime", 20f, "Seconds between maze lasers.");
			UltRandomLasers = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "RandomLasers", 2f, "Wandering lasers.");
			UltCrushFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "CrushRateDivisor", 10f, "Meteor rate divisor (relative to Crush).");
			UltCircleFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Ultimate", "LaserCircleSlowdown", 10f, "Laser circle revolution/pillar duration multiplier.");
		}

		internal static T Load<T>(string path) where T : Object
		{
			//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)
			try
			{
				return Addressables.LoadAssetAsync<T>((object)path).WaitForCompletion();
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Failed to load " + path + ": " + ex.Message));
				return default(T);
			}
		}

		private void LoadAssets()
		{
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			ImplosionEffect = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidMegaCrab/VoidMegaCrabDeathBombExplosion.prefab");
			BlinkEffect = ImplosionEffect;
			PortalEffect = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidMegaCrab/VoidMegaCrabSpawnEffect.prefab");
			SmallPortalEffect = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Nullifier/NullifierSpawnEffect.prefab");
			TracerEffect = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/TracerVoidRaidCrabTripleBeamSmall.prefab");
			RainExplosion = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabTripleBeamExplosion.prefab");
			MeteorImpact = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Meteor/MeteorStrikeImpact.prefab");
			MissileMuzzle = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabMuzzleflashEyeMissiles.prefab");
			MissilePrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabMissileProjectile.prefab");
			BombPrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidJailer/VoidJailerDeathBombProjectile.prefab");
			UltStatic = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/BrotherHaunt/BrotherUltLineProjectileStatic.prefab");
			UltLeft = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Brother/BrotherUltLineProjectileRotateLeft.prefab");
			UltRight = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Brother/BrotherUltLineProjectileRotateRight.prefab");
			if (!Object.op_Implicit((Object)(object)UltStatic))
			{
				UltStatic = UltRight;
			}
			DissolveMat = VoidlingReworkPlugin.Load<Material>("RoR2/Base/Imp/matImpDissolve.mat");
			KarmaMat = VoidlingReworkPlugin.Load<Material>("RoR2/Base/Brother/Karma/matKarmaOverlay.mat");
			MultiBeamDef = VoidlingReworkPlugin.Load<SkillDef>("RoR2/DLC1/VoidRaidCrab/RaidCrabMultiBeam.asset");
			SpinBeamDef = VoidlingReworkPlugin.Load<SkillDef>("RoR2/DLC1/VoidRaidCrab/RaidCrabSpinBeam.asset");
			VacuumDef = VoidlingReworkPlugin.Load<SkillDef>("RoR2/DLC1/VoidRaidCrab/RaidCrabVacuumAttack.asset");
			JailerCard = VoidlingReworkPlugin.Load<SpawnCard>("RoR2/DLC1/VoidJailer/cscVoidJailer.asset");
			PuddlePrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabMultiBeamDotZone.prefab");
			OobItem = VoidlingReworkPlugin.Load<ItemDef>("RoR2/Base/TeleportWhenOob/TeleportWhenOob.asset");
			SummonCard = VoidlingReworkPlugin.Load<SpawnCard>(SummonCardPath.Value);
			HalcyoniteCard = VoidlingReworkPlugin.Load<SpawnCard>("RoR2/DLC2/Halcyonite/cscHalcyonite.asset");
			AlloyHunterCard = VoidlingReworkPlugin.Load<SpawnCard>("RoR2/DLC3/VultureHunter/cscVultureHunter.asset");
			DevastatorCard = VoidlingReworkPlugin.Load<SpawnCard>("RoR2/DLC1/VoidMegaCrab/cscVoidMegaCrab.asset");
			VoidEliteEquip = VoidlingReworkPlugin.Load<EquipmentDef>("RoR2/DLC1/EliteVoid/EliteVoidEquipment.asset");
			DiabloImpact = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Captain/CaptainAirstrikeAltImpact.prefab");
			CountdownPanelPrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/UI/HudCountdownPanel.prefab");
			NeedlePrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Brother/LunarShardProjectile.prefab");
			SingularityPrefab = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Grandparent/GrandparentGravSphere.prefab");
			try
			{
				PortalBombMuzzle = FirePortalBomb.muzzleflashEffectPrefab;
			}
			catch
			{
			}
			Material val = ((!Object.op_Implicit((Object)(object)KarmaMat)) ? VoidlingReworkPlugin.Load<Material>("RoR2/Base/Common/matVoidDeathBombAreaIndicatorFront.mat") : KarmaMat);
			if (Object.op_Implicit((Object)(object)val))
			{
				ArmorOverlay = TintedCopy(val, ParseColor(ArmorColor.Value, new Color(0.79f, 0.65f, 1f)), "matVLArmorOverlay");
			}
		}

		internal static Color ParseColor(string hex, Color fallback)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Color result = default(Color);
			if (!string.IsNullOrEmpty(hex) && ColorUtility.TryParseHtmlString((!hex.StartsWith("#")) ? ("#" + hex) : hex, ref result))
			{
				return result;
			}
			return fallback;
		}

		internal static Material TintedCopy(Material src, Color c, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0015: Expected O, but got Unknown
			Material val = new Material(src)
			{
				name = name
			};
			TintMaterial(val, c);
			return val;
		}

		internal static void TintMaterial(Material m, Color c)
		{
			//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_0053: 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_005f: 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_006b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)m))
			{
				return;
			}
			string[] array = new string[5] { "_TintColor", "_Color", "_MainColor", "_EmColor", "_EmissionColor" };
			foreach (string text in array)
			{
				if (m.HasProperty(text))
				{
					Color color = m.GetColor(text);
					m.SetColor(text, new Color(c.r, c.g, c.b, color.a));
				}
			}
		}

		private void CreateBuff()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			StageBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)StageBuff).name = "bdVoidlingReworkStage";
			StageBuff.isHidden = true;
			StageBuff.canStack = true;
			StageBuff.isDebuff = false;
			StageBuff.isCooldown = false;
			StageBuff.buffColor = new Color(0.25f, 0.05f, 0.4f);
			AddBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)AddBuff).name = "bdVoidlingReworkAdd";
			AddBuff.isHidden = true;
			AddBuff.canStack = true;
			AddBuff.isDebuff = false;
			AddBuff.isCooldown = false;
			AddBuff.buffColor = new Color(0.25f, 0.05f, 0.4f);
		}

		private static void StripKillers(GameObject go)
		{
			Component[] componentsInChildren = go.GetComponentsInChildren<Component>(true);
			foreach (Component val in componentsInChildren)
			{
				if (!Object.op_Implicit((Object)(object)val) || val is Transform)
				{
					continue;
				}
				switch (((object)val).GetType().Name)
				{
				case "EffectComponent":
				case "NetworkIdentity":
				case "VfxKillBehavior":
				case "DestroyOnTimer":
				case "DestroyOnParticleEnd":
				case "EffectManagerHelper":
				case "ProjectileGhostController":
				case "VFXAttributes":
				case "ShakeEmitter":
				case "RayAttackIndicator":
					try
					{
						Object.DestroyImmediate((Object)(object)val);
					}
					catch
					{
					}
					break;
				}
			}
		}

		private static Transform FindDeep(Transform t, string name)
		{
			if (!Object.op_Implicit((Object)(object)t))
			{
				return null;
			}
			if (((Object)t).name == name)
			{
				return t;
			}
			for (int i = 0; i < t.childCount; i++)
			{
				Transform val = FindDeep(t.GetChild(i), name);
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			return null;
		}

		private void CreateEffects()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061a: Unknown result type (might be due to invalid IL or missing references)
			//IL_061c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_062a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			Holder = new GameObject("VoidlingReworkPrefabs");
			Holder.SetActive(false);
			Object.DontDestroyOnLoad((Object)(object)Holder);
			Material val = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/voidstage/matVoidBoostPath.mat");
			Material val2 = VoidlingReworkPlugin.Load<Material>("RoR2/Base/Common/matVoidDeathBombAreaIndicatorFront.mat");
			GameObject val3 = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabSpinBeamVFX.prefab");
			if (Object.op_Implicit((Object)(object)val3))
			{
				LaserTemplate = Object.Instantiate<GameObject>(val3, Holder.transform);
				((Object)LaserTemplate).name = "VLLaser";
				StripKillers(LaserTemplate);
				Transform val4 = LaserTemplate.transform.Find("Mesh, Additive");
				if (Object.op_Implicit((Object)(object)val4))
				{
					val4.localScale *= 3f;
					val4.localPosition = new Vector3(0f, 0f, 50.16f);
				}
				ParticleSystem[] componentsInChildren = LaserTemplate.GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val5 in componentsInChildren)
				{
					if (!(((Object)((Component)val5).gameObject).name == "MuzzleRayParticles"))
					{
						MainModule main = val5.main;
						((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * 3f;
					}
				}
				WarnTemplate = Object.Instantiate<GameObject>(val3, Holder.transform);
				((Object)WarnTemplate).name = "VLLaserWarning";
				for (int num = WarnTemplate.transform.childCount - 1; num >= 0; num--)
				{
					Transform child = WarnTemplate.transform.GetChild(num);
					if (((Object)child).name != "Mesh, Additive" && ((Object)child).name != "Mesh, Transparent")
					{
						Object.DestroyImmediate((Object)(object)((Component)child).gameObject);
					}
				}
				StripKillers(WarnTemplate);
				Transform val6 = WarnTemplate.transform.Find("Mesh, Additive");
				if (Object.op_Implicit((Object)(object)val6))
				{
					val6.localScale *= 3f;
					val6.localPosition = new Vector3(0f, 0f, 50.16f);
					MeshRenderer component = ((Component)val6).GetComponent<MeshRenderer>();
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)val))
					{
						((Renderer)component).sharedMaterial = val;
					}
					if (val6.childCount > 0)
					{
						MeshRenderer component2 = ((Component)val6.GetChild(0)).GetComponent<MeshRenderer>();
						if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)val2))
						{
							((Renderer)component2).sharedMaterial = val2;
						}
					}
				}
				Transform val7 = WarnTemplate.transform.Find("Mesh, Transparent");
				if (Object.op_Implicit((Object)(object)val7))
				{
					val7.localScale *= 3f;
					val7.localPosition = new Vector3(0f, 0f, 50.16f);
				}
			}
			BeamMesh = MakeCylinder(32);
			BeamOuterMat = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabSpinBeamCylinder2.mat");
			BeamInnerMat = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabSpinBeamCylinder1.mat");
			Color c = ParseColor(TelegraphColor.Value, new Color(0.84f, 0.72f, 1f));
			Material val8 = ((!Object.op_Implicit((Object)(object)val)) ? VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matWarningBeamOuterCylinder.mat") : val);
			Material val9 = ((!Object.op_Implicit((Object)(object)val2)) ? VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matWarningLaser.mat") : val2);
			WarnOuterMat = ((!Object.op_Implicit((Object)(object)val8)) ? null : TransparentCopy(val8, c, 0.35f, "matVLWarnOuter"));
			WarnInnerMat = ((!Object.op_Implicit((Object)(object)val9)) ? null : TransparentCopy(val9, c, 0.2f, "matVLWarnInner"));
			string[] array = new string[5] { "RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabTripleBeam1.mat", "RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabTripleBeam2.mat", "RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabSpinBeamCylinder1.mat", "RoR2/DLC1/VoidRaidCrab/matVoidRaidCrabTripleBeamSphere1.mat", "RoR2/DLC1/voidstage/matVoidBoostPath.mat" };
			for (int i = 0; i < array.Length; i++)
			{
				Material val10 = VoidlingReworkPlugin.Load<Material>(array[i]);
				if (Object.op_Implicit((Object)(object)val10) && val10.HasProperty("_RemapTex") && Object.op_Implicit((Object)(object)val10.GetTexture("_RemapTex")))
				{
					PurpleRemap = val10.GetTexture("_RemapTex");
					break;
				}
			}
			TracerBig = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/TracerVoidRaidCrabTripleBeam.prefab");
			MultiBeamMuzzle = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/VoidRaidCrabTripleBeamMuzzleflash.prefab");
			if (!Object.op_Implicit((Object)(object)BeamOuterMat))
			{
				BeamOuterMat = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matBeamOuterCylinder.mat");
			}
			if (!Object.op_Implicit((Object)(object)BeamInnerMat))
			{
				BeamInnerMat = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/VoidRaidCrab/matBeamInnerLine.mat");
			}
			Log.LogInfo((object)("Beam materials: " + ((!Object.op_Implicit((Object)(object)BeamOuterMat)) ? "null" : ((Object)BeamOuterMat).name) + ", " + ((!Object.op_Implicit((Object)(object)BeamInnerMat)) ? "null" : ((Object)BeamInnerMat).name) + ", " + ((!Object.op_Implicit((Object)(object)WarnOuterMat)) ? "null" : ((Object)WarnOuterMat).name) + ", " + ((!Object.op_Implicit((Object)(object)WarnInnerMat)) ? "null" : ((Object)WarnInnerMat).name)));
			Color c2 = ParseColor(TelegraphColor.Value, new Color(0.84f, 0.72f, 1f));
			Color c3 = ParseColor(PortalTelegraphColor.Value, new Color(0.85f, 0.82f, 0.9f));
			GameObject val11 = VoidlingReworkPlugin.Load<GameObject>("RoR2/DLC1/VoidRaidCrab/MultiBeamRayIndicator.prefab");
			Transform val12 = ((!Object.op_Implicit((Object)(object)val11)) ? null : FindDeep(val11.transform, "HitIndicator"));
			if (Object.op_Implicit((Object)(object)val12))
			{
				SphereTemplate = Object.Instantiate<GameObject>(((Component)val12).gameObject, Holder.transform);
				SphereTemplate.transform.localPosition = Vector3.zero;
				SphereTemplate.transform.localRotation = Quaternion.identity;
				StripKillers(SphereTemplate);
				MeshFilter componentInChildren = SphereTemplate.GetComponentInChildren<MeshFilter>(true);
				if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.sharedMesh))
				{
					Bounds bounds = componentInChildren.sharedMesh.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					float num2 = Mathf.Max(size.x, Mathf.Max(size.y, size.z));
					num2 *= Mathf.Max(((!((Object)(object)((Component)componentInChildren).transform == (Object)(object)SphereTemplate.transform)) ? Vector3.Scale(SphereTemplate.transform.localScale, ((Component)componentInChildren).transform.localScale) : SphereTemplate.transform.localScale).x, 0.0001f);
					if (num2 > 0.01f)
					{
						SphereBaseDiameter = num2;
					}
				}
				else
				{
					SphereTemplate = null;
				}
			}
			if (!Object.op_Implicit((Object)(object)SphereTemplate))
			{
				SphereTemplate = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)SphereTemplate).name = "VLSphere";
				Object.DestroyImmediate((Object)(object)SphereTemplate.GetComponent<Collider>());
				SphereTemplate.transform.SetParent(Holder.transform, false);
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Renderer)SphereTemplate.GetComponent<MeshRenderer>()).sharedMaterial = val2;
				}
				SphereBaseDiameter = 1f;
			}
			SphereTemplateGrey = Object.Instantiate<GameObject>(SphereTemplate, Holder.transform);
			TintRenderers(SphereTemplate, c2);
			TintRenderers(SphereTemplateGrey, c3);
			GameObject val13 = VoidlingReworkPlugin.Load<GameObject>("RoR2/Base/Grandparent/GrandparentBoulderGhost.prefab");
			if (Object.op_Implicit((Object)(object)val13))
			{
				RockTemplate = Object.Instantiate<GameObject>(val13, Holder.transform);
				((Object)RockTemplate).name = "VLRock";
				StripKillers(RockTemplate);
				Material val14 = VoidlingReworkPlugin.Load<Material>("RoR2/Base/Grandparent/matGrandparentBoulderProjectile.mat");
				Material val15 = VoidlingReworkPlugin.Load<Material>("RoR2/DLC1/EliteVoid/matEliteVoidOverlay.mat");
				MeshRenderer[] componentsInChildren2 = RockTemplate.GetComponentsInChildren<MeshRenderer>(true);
				foreach (MeshRenderer val16 in componentsInChildren2)
				{
					Material val17 = ((!Object.op_Implicit((Object)(object)val14)) ? ((Renderer)val16).sharedMaterial : val14);
					((Renderer)val16).sharedMaterials = (Material[])(object)((!Object.op_Implicit((Object)(object)val15)) ? new Material[1] { val17 } : new Material[2] { val17, val15 });
				}
			}
			FxSpherePrefab = MakeFxPrefab("VLFxSphere", 0);
			FxLaserPrefab = MakeFxPrefab("VLFxLaser", 1);
			FxRockPrefab = MakeFxPrefab("VLFxRock", 2);
			FxTimerPrefab = MakeFxPrefab("VLFxTimer", 3);
			FxScreenPrefab = MakeFxPrefab("VLFxScreen", 4);
		}

		private static Mesh MakeCylinder(int seg)
		{
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			//IL_006d: 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_0069: 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_0077: 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_0089: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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)
			//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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<Color> list4 = new List<Color>();
			List<int> list5 = new List<int>();
			Vector3 val = default(Vector3);
			for (int i = 0; i < 2; i++)
			{
				int count = list.Count;
				for (int j = 0; j <= seg; j++)
				{
					float num = (float)j * (float)Math.PI * 2f / (float)seg;
					((Vector3)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num), 0f);
					Vector3 item = ((i != 0) ? (-val) : val);
					list.Add(val * 0.5f);
					list2.Add(item);
					list3.Add(new Vector2((float)j / (float)seg, 0f));
					list4.Add(Color.white);
					list.Add(val * 0.5f + Vector3.forward);
					list2.Add(item);
					list3.Add(new Vector2((float)j / (float)seg, 1f));
					list4.Add(Color.white);
				}
				for (int k = 0; k < seg; k++)
				{
					int num2 = count + k * 2;
					int item2 = num2 + 1;
					int item3 = num2 + 2;
					int item4 = num2 + 3;
					if (i == 0)
					{
						list5.Add(num2);
						list5.Add(item3);
						list5.Add(item2);
						list5.Add(item2);
						list5.Add(item3);
						list5.Add(item4);
					}
					else
					{
						list5.Add(num2);
						list5.Add(item2);
						list5.Add(item3);
						list5.Add(item2);
						list5.Add(item4);
						list5.Add(item3);
					}
				}
			}
			Mesh val2 = new Mesh
			{
				name = "VLBeamCylinder"
			};
			val2.SetVertices(list);
			val2.SetNormals(list2);
			val2.SetUVs(0, list3);
			val2.SetColors(list4);
			val2.SetTriangles(list5, 0);
			val2.bounds = new Bounds(new Vector3(0f, 0f, 0.5f), new Vector3(1f, 1f, 1f));
			return val2;
		}

		internal static GameObject MakeBeamObject(bool warning)
		{
			//IL_000f: 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_0040: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0057: Expected O, but got Unknown
			GameObject val = new GameObject((!warning) ? "VLBeam" : "VLBeamWarning");
			Material mat = ((!warning) ? BeamOuterMat : WarnOuterMat);
			Material mat2 = ((!warning) ? BeamInnerMat : WarnInnerMat);
			AddCyl(val, mat, 1f);
			AddCyl(val, mat2, (!warning) ? 0.45f : 0.2f);
			return val;
		}

		private static void AddCyl(GameObject root, Material mat, float scale)
		{
			//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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)mat) && Object.op_Implicit((Object)(object)BeamMesh))
			{
				GameObject val = new GameObject("Cyl");
				val.transform.SetParent(root.transform, false);
				val.transform.localScale = new Vector3(scale, scale, 1f);
				val.AddComponent<MeshFilter>().sharedMesh = BeamMesh;
				MeshRenderer obj = val.AddComponent<MeshRenderer>();
				((Renderer)obj).sharedMaterial = mat;
				((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)obj).receiveShadows = false;
			}
		}

		private static void Measure(GameObject root, out float minZ, out float maxZ, out float half)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			minZ = float.MaxValue;
			maxZ = float.MinValue;
			half = 0f;
			Matrix4x4 worldToLocalMatrix = root.transform.worldToLocalMatrix;
			MeshFilter[] componentsInChildren = root.GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val.sharedMesh) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<Renderer>()))
				{
					Bounds bounds = val.sharedMesh.bounds;
					Matrix4x4 val2 = worldToLocalMatrix * ((Component)val).transfo