RiskierRain.dll

Decompiled 4 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.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.BeetleQueenMonster;
using EntityStates.ClayBruiser.Weapon;
using EntityStates.Drone;
using EntityStates.Drone.DroneJunk;
using EntityStates.ExtractorUnit;
using EntityStates.GoldGat;
using EntityStates.Gup;
using EntityStates.ImpBossMonster;
using EntityStates.LunarWisp;
using EntityStates.Missions.Arena.NullWard;
using EntityStates.NullifierMonster;
using EntityStates.QuestVolatileBattery;
using EntityStates.RoboBallBoss.Weapon;
using EntityStates.ShrineHalcyonite;
using EntityStates.VagrantMonster;
using EntityStates.VagrantNovaItem;
using HG;
using IL.RoR2;
using IL.RoR2.Artifacts;
using IL.RoR2.Items;
using IL.RoR2.Orbs;
using IL.RoR2.Projectile;
using IL.RoR2.Skills;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MoreStats;
using On.EntityStates.CaptainSupplyDrop;
using On.EntityStates.ClayBruiser.Weapon;
using On.EntityStates.Drone;
using On.EntityStates.Drone.DroneJunk;
using On.EntityStates.ExtractorUnit;
using On.EntityStates.Gup;
using On.EntityStates.LunarWisp;
using On.EntityStates.Missions.Arena.NullWard;
using On.EntityStates.NullifierMonster;
using On.EntityStates.QuestVolatileBattery;
using On.EntityStates.RoboBallBoss.Weapon;
using On.EntityStates.ShrineHalcyonite;
using On.EntityStates.VagrantMonster;
using On.EntityStates.VagrantNovaItem;
using On.RoR2;
using On.RoR2.Items;
using On.RoR2.Orbs;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RainrotSharedUtils.Difficulties;
using RainrotSharedUtils.Shelters;
using RiskierRain.Changes;
using RiskierRain.Changes.Components;
using RiskierRain.Components;
using RiskierRain.CoreModules;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using RoR2BepInExPack.GameAssetPathsBetter;
using SwanSongExtended.Modules;
using SwanSongExtended.Storms;
using ThreeEyedGames;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[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 = "")]
[assembly: AssemblyCompany("RiskierRain")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RiskierRain")]
[assembly: AssemblyTitle("RiskierRain")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace RiskierRain
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.RiskOfBrainrot.RiskierRain", "RiskierRain", "2.0.0")]
	[R2APISubmoduleDependency(new string[] { "LanguageAPI", "PrefabAPI", "DirectorAPI", "ItemAPI", "RecalculateStatsAPI", "EliteAPI" })]
	internal class RiskierRainPlugin : BaseUnityPlugin
	{
		public static int sacrificeDropCount = 12;

		public static int sacrificeDropCountRestricted = 5;

		public static float sacrificeDropRate = 8f;

		public static float sacrificeDropRateLimited = 20f;

		public static int sonorousDropCountBase = 4;

		public static int sonorousDropCountStack = 2;

		public static int sonorousDropCountRestrictedBase = 5;

		public static int sonorousDropCountRestrictedStack = 1;

		public static float sonorousDropRateBase = 5f;

		public static float sonorousDropRateStack = 5f;

		public static float sonorousDropRateLimited = 20f;

		private static int serverSacrificeDropTally = 0;

		private static int serverSonorousDropTally = 0;

		public static int minSpikes = 3;

		public static int maxSpikes = 4;

		public static int baseSpikesPerBuff = 2;

		public static int stackSpikesPerBuff = 1;

		public static float minDamageCoefficient = 5f;

		public static float releaseSpeed = 2f;

		public static float spikeDamageCoefficient = 0.3f;

		public static float spikeProcCoefficient = 1f;

		public static int shatterspleenBleedChance = 20;

		public static GameObject impBleedSpikePrefab;

		public const string guid = "com.RiskOfBrainrot.RiskierRain";

		public const string teamName = "RiskOfBrainrot";

		public const string modName = "RiskierRain";

		public const string version = "2.0.0";

		public static bool isAELoaded = Tools.isLoaded("com.Borbo.ArtificerExtended");

		public static bool isHBULoaded = Tools.isLoaded("com.Borbo.HuntressBuffULTIMATE");

		public static bool isScepterLoaded = Tools.isLoaded("com.DestroyedClone.AncientScepter");

		public static bool autosprintLoaded = Tools.isLoaded("com.johnedwa.RTAutoSprintEx");

		public static bool acridLungeLoaded = Tools.isLoaded("Withor.AcridBiteLunge");

		public static bool ucrLoaded = Tools.isLoaded("HIFU.UltimateCustomRun");

		public static string drizzleDesc = "Simplifies difficulty for players new to the game. Weeping and gnashing is replaced by laughter and tickles.<style=cStack>\n\n>Player Health Regeneration: <style=cIsHealing>+50%</style> \n>Difficulty Scaling: <style=cIsHealing>-50%</style> \n>Player Damage Reduction: <style=cIsHealing>+38%</style>";

		public static string rainstormDesc = "This is the way the game is meant to be played! Test your abilities and skills against formidable foes.<style=cStack>\n\n>Player Health Regeneration: +0% \n>Difficulty Scaling: +0% ";

		public static string monsoonDesc = "For hardcore players. Every bend introduces pain and horrors of the planet. You will die.<style=cStack>\n\n>Player Health Regeneration: <style=cIsHealth>-40%</style> \n>Difficulty Scaling: <style=cIsHealth>+50%</style>";

		public static GameObject meatballNapalmPool;

		public static PluginInfo PInfo { get; private set; }

		public static string dropPrefabsPath => Assets.dropPrefabsPath;

		public static string iconsPath => Assets.iconsPath;

		public static string eliteMaterialsPath => Assets.eliteMaterialsPath;

		internal static ConfigFile CustomConfigFile { get; set; }

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

		public static void DoSacrificeDropLimit()
		{
			//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
			SacrificeArtifactManager.OnServerCharacterDeath += new Manipulator(DropLimitForSacrifice);
			GlobalEventManager.OnCharacterDeath += new Manipulator(DropLimitForSonorous);
			Stage.onServerStageBegin += ResetServerDropCount;
			LanguageAPI.Add("ITEM_ITEMDROPCHANCEONKILL_DESC", "On killing a large monster, it will <style=cIsDamage>always</style> drop an item. " + $"Elite monsters have a <style=cIsUtility>{sonorousDropRateBase}%</style> chance of " + $"dropping an item <style=cStack>(+{sonorousDropRateStack}% per stack)</style>.");
		}

		public static int GetDropCountForSacrifice()
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return 0;
			}
			if (UsingRestrictedSacrifice())
			{
				return sacrificeDropCountRestricted * Run.instance.participatingPlayerCount;
			}
			return sacrificeDropCount * Run.instance.participatingPlayerCount;
		}

		public static int GetDropCountForSonorous()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return 0;
			}
			int itemCountForTeam = Util.GetItemCountForTeam((TeamIndex)1, Items.ItemDropChanceOnKill.itemIndex, false, true);
			if (UsingRestrictedSacrifice())
			{
				return sonorousDropCountRestrictedBase + sonorousDropCountRestrictedStack * (itemCountForTeam - 1);
			}
			return sonorousDropCountBase + sonorousDropCountStack * (itemCountForTeam - 1);
		}

		internal static bool UsingRestrictedSacrifice()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			return (int)Stage.instance.sceneDef.sceneType == 2 || (int)Stage.instance.sceneDef.sceneType == 5;
		}

		private static void ResetServerDropCount(Stage obj)
		{
			serverSacrificeDropTally = 0;
			serverSonorousDropTally = 0;
		}

		private static void DropLimitForSacrifice(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			FixSacrificeDropChance(val);
			val.Index = 0;
			AddSacrificeDropTally(val);
		}

		private static void FixSacrificeDropChance(ILCursor c)
		{
			float num = default(float);
			if (!c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, "RoR2.Util", "GetExpAdjustedDropChancePercent")
			}) || !c.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num)
			}))
			{
				DebugBreakpoint("FixSacrificeDropChance");
				return;
			}
			c.EmitDelegate<Func<float, float>>((Func<float, float>)((float _) => (serverSacrificeDropTally >= GetDropCountForSacrifice() && !Util.CheckRoll(sacrificeDropRateLimited, 0f, (CharacterMaster)null)) ? 0f : sacrificeDropRate));
		}

		private static void AddSacrificeDropTally(ILCursor c)
		{
			if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropletController>(x, "CreatePickupDroplet")
			}))
			{
				DebugBreakpoint("AddSacrificeDropTally");
				return;
			}
			c.EmitDelegate<Action>((Action)delegate
			{
				serverSacrificeDropTally++;
			});
		}

		private static void DropLimitForSonorous(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			ILLabel val2 = val.DefineLabel();
			int masterLoc = 17;
			int itemCountLoc = 102;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.DLC2Content/Items", "ItemDropChanceOnKill")
			}) || !val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref masterLoc)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective")
			}))
			{
				DebugBreakpoint("DropLimitForSonorous", 1);
				return;
			}
			SonorousUseTeamItemCount(val, masterLoc);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref itemCountLoc)
			}))
			{
				DebugBreakpoint("DropLimitForSonorous", 2);
				return;
			}
			val2 = val.MarkLabel();
			FixSonorousDropChance(val, itemCountLoc, masterLoc);
			val.GotoLabel(val2, (MoveType)1, false);
			AddSonorousDropTally(val, itemCountLoc);
		}

		private static void SonorousUseTeamItemCount(ILCursor c, int masterLoc)
		{
			DoTheRoar();
			if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective")
			}))
			{
				DebugBreakpoint("SonorousUseTeamItemCount");
			}
			else
			{
				DoTheRoar();
			}
			void DoTheRoar()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldloc, masterLoc);
				c.EmitDelegate<Func<int, CharacterMaster, int>>((Func<int, CharacterMaster, int>)((int oldItemCount, CharacterMaster master) => Util.GetItemCountForTeam(master.teamIndex, Items.ItemDropChanceOnKill.itemIndex, true, true)));
			}
		}

		private static void FixSonorousDropChance(ILCursor c, int itemCountLoc, int masterLoc)
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (!c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_isElite")
			}) || !c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, itemCountLoc)
			}) || !c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, masterLoc)
			}))
			{
				DebugBreakpoint("FixSonorousDropChance");
				return;
			}
			c.Emit(OpCodes.Ldloc, itemCountLoc);
			c.EmitDelegate<Func<float, int, float>>((Func<float, int, float>)((float chanceIn, int stack) => (serverSonorousDropTally >= GetDropCountForSacrifice() && !Util.CheckRoll(sonorousDropRateLimited, 0f, (CharacterMaster)null)) ? 0f : (sonorousDropRateBase + sonorousDropRateStack * (float)(stack - 1))));
		}

		private static void AddSonorousDropTally(ILCursor c, int itemCountLoc)
		{
			if (!c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_isElite")
			}) || !c.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, itemCountLoc)
			}) || !c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupDropletController>(x, "CreatePickupDroplet")
			}))
			{
				DebugBreakpoint("AddSonorousDropTally");
				return;
			}
			c.EmitDelegate<Action>((Action)delegate
			{
				serverSonorousDropTally++;
			});
		}

		private void ReworkShatterspleen()
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			impBleedSpikePrefab = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("prefabs/projectiles/ImpVoidspikeProjectile"), "ShatterspleenBleedSpike", true);
			ProjectileController component = impBleedSpikePrefab.GetComponent<ProjectileController>();
			component.procCoefficient = 1f;
			ProjectileImpactExplosion component2 = impBleedSpikePrefab.GetComponent<ProjectileImpactExplosion>();
			((ProjectileExplosion)component2).blastRadius = 4f;
			Rigidbody component3 = impBleedSpikePrefab.GetComponent<Rigidbody>();
			component3.useGravity = true;
			AntiGravityForce val = impBleedSpikePrefab.AddComponent<AntiGravityForce>();
			val.antiGravityCoefficient = -1f;
			val.rb = component3;
			ProjectileDirectionalTargetFinder val2 = impBleedSpikePrefab.AddComponent<ProjectileDirectionalTargetFinder>();
			((Behaviour)val2).enabled = true;
			val2.lookRange = 50f;
			val2.lookCone = 10f;
			ProjectileSteerTowardTarget val3 = impBleedSpikePrefab.AddComponent<ProjectileSteerTowardTarget>();
			val3.yAxisOnly = false;
			val3.rotationSpeed = 50f;
			Assets.projectilePrefabs.Add(impBleedSpikePrefab);
			GlobalEventManager.ProcessHitEnemy += new Manipulator(RevokeShatterspleenBleedRights);
			GlobalEventManager.OnCharacterDeath += new Manipulator(RevokeShatterspleenDeathRights);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RemoveShatterspleenCrit);
			CharacterBody.RecalculateStats += new hook_RecalculateStats(ShatterspleenBleedChance);
			GlobalEventManager.ProcessHitEnemy += new hook_ProcessHitEnemy(NewShatterspleenFunctionality);
			CharacterBody.RemoveBuff_BuffIndex += new hook_RemoveBuff_BuffIndex(FireShatterspleenBleedSpike);
			LanguageAPI.Add("ITEM_BLEEDONHITANDEXPLODE_PICKUP", "Massive hits charge a volley of bleed spikes.");
			LanguageAPI.Add("ITEM_BLEEDONHITANDEXPLODE_DESC", $"Gain {shatterspleenBleedChance}% bleed chance. " + "Hits that deal <style=cIsDamage>more than " + Tools.ConvertDecimal(minDamageCoefficient) + " damage</style> also " + $"charge {minSpikes}-{maxSpikes} volleys of " + $"{baseSpikesPerBuff} void spikes (+{stackSpikesPerBuff} per stack). " + $"These spikes release {releaseSpeed} seconds at a time, " + "dealing " + Tools.ConvertDecimal(spikeDamageCoefficient) + " BASE damage and bleeding enemies hit for " + Tools.ConvertDecimal(2.4f * spikeProcCoefficient) + " base damage.");
		}

		private void ShatterspleenBleedChance(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			Inventory inventory = self.inventory;
			if (inventory != null && inventory.GetItemCountEffective(Items.BleedOnHitAndExplode) > 0)
			{
				self.bleedChance += (float)shatterspleenBleedChance;
			}
		}

		private void RemoveShatterspleenCrit(CharacterBody sender, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)sender.inventory))
			{
				Inventory inventory = sender.inventory;
				if (inventory.GetItemCountEffective(Items.BleedOnHitAndExplode) > 0)
				{
					args.critAdd -= 5f;
				}
			}
		}

		private void FireShatterspleenBleedSpike(orig_RemoveBuff_BuffIndex orig, CharacterBody self, BuffIndex buffType)
		{
			//IL_0001: 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_0150: 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_006e: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f5: Unknown result type (might be due to invalid IL or missing references)
			if (buffType == Assets.shatterspleenSpikeBuff.buffIndex)
			{
				int itemCountEffective = self.inventory.GetItemCountEffective(Items.BleedOnHitAndExplode);
				if (itemCountEffective > 0)
				{
					Util.PlaySound(FireVoidspikes.attackSoundString, ((Component)self).gameObject);
					EffectManager.SimpleMuzzleFlash(FireVoidspikes.swipeEffectPrefab, ((Component)self).gameObject, "Head", false);
					Ray val = default(Ray);
					((Ray)(ref val))..ctor(self.inputBank.aimOrigin, self.inputBank.aimDirection);
					int num = baseSpikesPerBuff + stackSpikesPerBuff * (itemCountEffective - 1);
					Debug.Log((object)num);
					for (int i = 0; i < num; i++)
					{
						float num2 = 0f;
						float num3 = FireVoidspikes.projectileSpeed * 0.3f * (float)(i + 1);
						Vector3 val2 = Util.ApplySpread(((Ray)(ref val)).direction, 0f, 0f, 1f, 1f, num2, 0f);
						ProjectileManager.instance.FireProjectile(impBleedSpikePrefab, ((Ray)(ref val)).origin, Util.QuaternionSafeLookRotation(val2), ((Component)self).gameObject, self.damage * spikeDamageCoefficient, 0f, Util.CheckRoll(self.crit, self.master), (DamageColorIndex)0, (GameObject)null, num3, (DamageTypeCombo?)null);
					}
				}
			}
			orig.Invoke(self, buffType);
		}

		private void NewShatterspleenFunctionality(orig_ProcessHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)damageInfo.attacker) && damageInfo.procCoefficient > 0f && !((ProcChainMask)(ref damageInfo.procChainMask)).HasProc((ProcType)5))
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					int num = 0;
					Inventory inventory = component.inventory;
					if (Object.op_Implicit((Object)(object)inventory))
					{
						num = inventory.GetItemCountEffective(Items.BleedOnHitAndExplode);
						if ((Object)(object)component2 != (Object)null && num > 0)
						{
							int num2 = Random.Range(minSpikes, maxSpikes + 1);
							int buffCount = component.GetBuffCount(Assets.shatterspleenSpikeBuff);
							if (damageInfo.damage / component.damage >= minDamageCoefficient && num2 > buffCount)
							{
								((ProcChainMask)(ref damageInfo.procChainMask)).AddProc((ProcType)5);
								for (int i = buffCount; i < num2; i++)
								{
									component.AddTimedBuffAuthority(Assets.shatterspleenSpikeBuff.buffIndex, releaseSpeed * (float)(i + 1));
								}
							}
						}
					}
				}
			}
			orig.Invoke(self, damageInfo, victim);
		}

		private void RevokeShatterspleenBleedRights(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_005b: 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)
			ILCursor val = new ILCursor(il);
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.RoR2Content/Items", "BleedOnHitAndExplode"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective")
			});
			val.Emit(OpCodes.Ldc_I4, 0);
			val.Emit(OpCodes.Mul);
		}

		private void RevokeShatterspleenDeathRights(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_005b: 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)
			ILCursor val = new ILCursor(il);
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, "RoR2.RoR2Content/Items", "BleedOnHitAndExplode"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective")
			});
			val.Emit(OpCodes.Ldc_I4, 0);
			val.Emit(OpCodes.Mul);
		}

		private bool IsCategoryEnabled(bool category)
		{
			return category;
		}

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			PInfo = ((BaseUnityPlugin)this).Info;
			InitializeCoreModules();
			InitializeConfig();
			InitializeEverything();
			CharacterBody.RemoveBuff_BuffDef += new hook_RemoveBuff_BuffDef(Gah);
			SaveConfig();
			new ContentPacks().Initialize();
		}

		public static void DebugBreakpoint(string methodName, int breakpointNumber = -1)
		{
			string text = "RiskierRain: " + methodName + " IL hook failed!";
			if (breakpointNumber >= 0)
			{
				text += $" (breakpoint {breakpointNumber})";
			}
			Debug.LogError((object)text);
		}

		private void Gah(orig_RemoveBuff_BuffDef orig, CharacterBody self, BuffDef buffType)
		{
			if (!NetworkServer.active)
			{
				Debug.Log((object)((Object)buffType).name);
			}
			orig.Invoke(self, buffType);
		}

		private void InitializeEverything()
		{
			ItemChanges.Initialize();
			EquipmentChanges.Initialize();
			DifficultyChanges.Initialize();
			AllyChanges.Initialize();
			EnemyChanges.Initialize();
			InteractableChanges.Initialize();
			DoSacrificeDropLimit();
			LanguageAPI.Add("DIFFICULTY_EASY_DESCRIPTION", drizzleDesc + "</style>");
			LanguageAPI.Add("DIFFICULTY_NORMAL_DESCRIPTION", rainstormDesc + "</style>");
			LanguageAPI.Add("DIFFICULTY_HARD_DESCRIPTION", monsoonDesc + "</style>");
		}

		public static AssetReferenceT<T> LoadAsync<T>(string guid, Action<T> callback) where T : Object
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceT<T> val = new AssetReferenceT<T>(guid);
			AsyncOperationHandle<T> handle = AssetAsyncReferenceManager<T>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			if (callback == null)
			{
				return val;
			}
			if (handle.IsDone)
			{
				onCompleted(handle);
				return val;
			}
			handle.Completed += onCompleted;
			return val;
			void onCompleted(AsyncOperationHandle<T> val2)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Invalid comparison between Unknown and I4
				if (val2.Result == null || (int)val2.Status != 1)
				{
					Debug.LogError((object)$"Failed to load asset [{val2.DebugName}] : {val2.OperationException}");
				}
				else
				{
					callback(val2.Result);
				}
			}
		}

		public static void RetierItemAsync(string itemGuid, ItemTier tier = (ItemTier)5, Action<ItemDef> callback = null)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//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)
			AssetReferenceT<ItemDef> val = new AssetReferenceT<ItemDef>(itemGuid);
			AsyncOperationHandle<ItemDef> val2 = AssetAsyncReferenceManager<ItemDef>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<ItemDef> ctx)
			{
				//IL_000b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				ItemDef result = ctx.Result;
				result.tier = tier;
				result.deprecatedTier = tier;
				if (callback != null)
				{
					callback(result);
				}
			};
		}

		public static void RemoveEquipmentAsync(string equipmentGuid, Action<EquipmentDef> callback = null)
		{
			//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)
			AssetReferenceT<EquipmentDef> val = new AssetReferenceT<EquipmentDef>(equipmentGuid);
			AsyncOperationHandle<EquipmentDef> val2 = AssetAsyncReferenceManager<EquipmentDef>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<EquipmentDef> ctx)
			{
				EquipmentDef result = ctx.Result;
				result.canDrop = false;
				result.canBeRandomlyTriggered = false;
				result.enigmaCompatible = false;
				result.dropOnDeathChance = 0f;
				if (callback != null)
				{
					callback(result);
				}
			};
		}

		public static void ChangeEquipmentEnigma(string equipName, bool canEnigma)
		{
			EquipmentDef val = LoadEquipDef(equipName);
			if ((Object)(object)val != (Object)null)
			{
				val.enigmaCompatible = canEnigma;
			}
		}

		public static void ChangeBuffStacking(string buffName, bool canStack)
		{
			BuffDef val = LoadBuffDef(buffName);
			if ((Object)(object)val != (Object)null)
			{
				val.canStack = canStack;
			}
		}

		public static ItemDef LoadItemDef(string name)
		{
			return LegacyResourcesAPI.Load<ItemDef>("ItemDefs/" + name);
		}

		public static EquipmentDef LoadEquipDef(string name)
		{
			return LegacyResourcesAPI.Load<EquipmentDef>("EquipmentDefs/" + name);
		}

		public static BuffDef LoadBuffDef(string name)
		{
			return LegacyResourcesAPI.Load<BuffDef>("BuffDefs/" + name);
		}

		public static void CreateMeatballNapalm()
		{
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_005f: 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_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_00f4: 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_0171: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			meatballNapalmPool = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("prefabs/projectiles/beetlequeenacid"), "NapalmFire", true);
			Color val = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)120, (byte)0, byte.MaxValue));
			Transform val2 = meatballNapalmPool.transform.Find("FX/Decal");
			Material val3 = new Material(((Component)val2).GetComponent<Decal>().Material);
			val3.SetColor("_Color", val);
			((Component)val2).GetComponent<Decal>().Material = val3;
			ProjectileDotZone component = meatballNapalmPool.GetComponent<ProjectileDotZone>();
			component.lifetime = 5f;
			component.fireFrequency = 2f;
			component.damageCoefficient = 0.5f;
			component.overlapProcCoefficient = 0.5f;
			component.attackerFiltering = (AttackerFiltering)0;
			meatballNapalmPool.GetComponent<ProjectileDamage>().damageType = DamageTypeCombo.op_Implicit((DamageType)128);
			meatballNapalmPool.GetComponent<ProjectileController>().procCoefficient = 1f;
			float num = 2.5f;
			meatballNapalmPool.GetComponent<Transform>().localScale = new Vector3(num, num, num);
			Transform val4 = meatballNapalmPool.transform.Find("FX");
			((Component)val4.Find("Spittle")).gameObject.SetActive(false);
			GameObject val5 = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("prefabs/FireTrail").GetComponent<DamageTrail>().segmentPrefab, ((Component)val4).transform);
			MainModule main = val5.GetComponent<ParticleSystem>().main;
			((MainModule)(ref main)).duration = 8f;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.075f);
			MinMaxCurve startSizeX = ((MainModule)(ref main)).startSizeX;
			((MinMaxCurve)(ref startSizeX)).constantMin = ((MinMaxCurve)(ref startSizeX)).constantMin * 0.6f;
			((MinMaxCurve)(ref startSizeX)).constantMax = ((MinMaxCurve)(ref startSizeX)).constantMax * 0.8f;
			MinMaxCurve startSizeY = ((MainModule)(ref main)).startSizeY;
			((MinMaxCurve)(ref startSizeY)).constantMin = ((MinMaxCurve)(ref startSizeY)).constantMin * 0.8f;
			((MinMaxCurve)(ref startSizeY)).constantMax = ((MinMaxCurve)(ref startSizeY)).constantMax * 1f;
			MinMaxCurve startSizeZ = ((MainModule)(ref main)).startSizeZ;
			((MinMaxCurve)(ref startSizeZ)).constantMin = ((MinMaxCurve)(ref startSizeZ)).constantMin * 0.6f;
			((MinMaxCurve)(ref startSizeZ)).constantMax = ((MinMaxCurve)(ref startSizeZ)).constantMax * 0.8f;
			MinMaxCurve startLifetime = ((MainModule)(ref main)).startLifetime;
			((MinMaxCurve)(ref startLifetime)).constantMin = 0.9f;
			((MinMaxCurve)(ref startLifetime)).constantMax = 1.1f;
			((Behaviour)val5.GetComponent<DestroyOnTimer>()).enabled = false;
			val5.transform.localPosition = Vector3.zero;
			val5.transform.localPosition = Vector3.zero;
			val5.transform.localScale = Vector3.one;
			ShapeModule shape = val5.GetComponent<ParticleSystem>().shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).scale = Vector3.one * 0.5f;
			GameObject gameObject = ((Component)val4.Find("Point Light")).gameObject;
			Light component2 = gameObject.GetComponent<Light>();
			component2.color = new Color(1f, 0.5f, 0f);
			component2.intensity = 6f;
			component2.range = 12f;
			Assets.projectilePrefabs.Add(meatballNapalmPool);
		}

		private bool GetConfigBool(bool defaultValue, string packetTitle, string desc = "")
		{
			if (desc != "")
			{
				return CustomConfigFile.Bind<bool>("Packets - See README For Details.", packetTitle + " Packet", defaultValue, "The changes in this Packet will be enabled if set to true.").Value;
			}
			return CustomConfigFile.Bind<bool>("Packets", packetTitle + " Packet", defaultValue, "(The following changes will be enabled if set to true) " + desc).Value;
		}

		private void InitializeConfig()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\RiskierRain.cfg", true);
			CustomConfigFile.SaveOnConfigSet = false;
			EnableConfig = CustomConfigFile.Bind<bool>("Allow Config Options", "Enable Config", false, "Set this to true to enable config options. Please keep in mind that it was not within my design intentions to play this way. This is primarily meant for modpack users with tons of mods installed. If you have any issues or feedback on my mod balance, please feel free to send in feedback with the contact info in the README or Thunderstore description.");
			Debug.Log((object)"Config initialized!");
		}

		private void SaveConfig()
		{
			CustomConfigFile.SaveOnConfigSet = true;
			CustomConfigFile.Save();
		}

		private void InitializeCoreModules()
		{
			IEnumerable<Type> enumerable = from type in Assembly.GetExecutingAssembly().GetTypes()
				where !type.IsAbstract && type.IsSubclassOf(typeof(CoreModule))
				select type;
			foreach (Type item in enumerable)
			{
				CoreModule coreModule = (CoreModule)Activator.CreateInstance(item);
				coreModule.Init();
				Debug.Log((object)("Core Module: " + coreModule?.ToString() + " Initialized!"));
			}
		}
	}
	public static class Extensions
	{
		public static string AsPercent(this float d)
		{
			return d * 100f + "%";
		}
	}
	public static class Tools
	{
		public static string modPrefix = string.Format("@{0}+{1}", "ArtificerExtended", "artiskillicons");

		public static AssetBundle LoadAssetBundle(byte[] resourceBytes)
		{
			if (resourceBytes == null)
			{
				throw new ArgumentNullException("resourceBytes");
			}
			return AssetBundle.LoadFromMemory(resourceBytes);
		}

		public static string GetModPrefix(this BaseUnityPlugin plugin, string bundleName)
		{
			return $"@{plugin.Info.Metadata.Name}+{bundleName}";
		}

		internal static bool isLoaded(string modguid)
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				string key = pluginInfo.Key;
				PluginInfo value = pluginInfo.Value;
				if (key == modguid)
				{
					return true;
				}
			}
			return false;
		}

		internal static string ConvertDecimal(float d)
		{
			return d.AsPercent();
		}

		internal static void GetMaterial(GameObject model, string childObject, Color color, ref Material material, float scaleMultiplier = 1f, bool replaceAll = false)
		{
			//IL_0030: 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_00aa: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				if (string.Equals(((Object)val).name, childObject))
				{
					if (color == Color.clear)
					{
						Object.Destroy((Object)(object)val);
						break;
					}
					if ((Object)(object)material == (Object)null)
					{
						material = new Material(val.material);
						material.mainTexture = val.material.mainTexture;
						material.shader = val.material.shader;
						material.color = color;
					}
					val.material = material;
					Transform transform = ((Component)val).transform;
					transform.localScale *= scaleMultiplier;
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugMaterial(GameObject model)
		{
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				Debug.Log((object)("Material: " + ((Object)val2).name.ToString()));
			}
		}

		internal static void GetParticle(GameObject model, string childObject, Color color, float sizeMultiplier = 1f, bool replaceAll = false)
		{
			//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_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			ParticleSystem[] componentsInChildren = model.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				MainModule main = val2.main;
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				ColorBySpeedModule colorBySpeed = val2.colorBySpeed;
				if (string.Equals(((Object)val2).name, childObject))
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color);
					((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * sizeMultiplier;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(color);
					((ColorBySpeedModule)(ref colorBySpeed)).color = MinMaxGradient.op_Implicit(color);
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugParticleSystem(GameObject model)
		{
			ParticleSystem[] components = model.GetComponents<ParticleSystem>();
			ParticleSystem[] array = components;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				Debug.Log((object)("Particle: " + ((Object)val2).name.ToString()));
			}
		}

		internal static void GetLight(GameObject model, string childObject, Color color, bool replaceAll = false)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Light[] componentsInChildren = model.GetComponentsInChildren<Light>();
			Light[] array = componentsInChildren;
			foreach (Light val in array)
			{
				Light val2 = val;
				if (string.Equals(((Object)val2).name, childObject))
				{
					val2.color = color;
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugLight(GameObject model)
		{
			Light[] componentsInChildren = model.GetComponentsInChildren<Light>();
			Light[] array = componentsInChildren;
			foreach (Light val in array)
			{
				Light val2 = val;
				Debug.Log((object)("Light: " + ((Object)val2).name.ToString()));
			}
		}

		public static void ClearDotStacksForType(this DotController dotController, DotIndex dotIndex)
		{
			//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)
			for (int num = dotController.dotStackList.Count - 1; num >= 0; num--)
			{
				if (dotController.dotStackList[num].dotIndex == dotIndex)
				{
					dotController.RemoveDotStackAtServer(num);
				}
			}
		}

		public static void LoadCharacterBodyAsync(string guid, Action<CharacterBody> callback)
		{
			//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)
			AssetReferenceT<GameObject> val = new AssetReferenceT<GameObject>(guid);
			AsyncOperationHandle<GameObject> val2 = AssetAsyncReferenceManager<GameObject>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<GameObject> ctx)
			{
				GameObject result = ctx.Result;
				CharacterBody obj = default(CharacterBody);
				if (!((Object)(object)result == (Object)null) && result.TryGetComponent<CharacterBody>(ref obj))
				{
					callback(obj);
				}
			};
		}
	}
}
namespace RiskierRain.CoreModules
{
	public class Assets : CoreModule
	{
		public static AssetBundle _retierAssetBundle;

		public static string dropPrefabsPath = "Assets/Models/DropPrefabs";

		public static string iconsPath = "Assets/Textures/Icons/";

		public static string eliteMaterialsPath = "Assets/Textures/Materials/Elite/";

		public static List<ArtifactDef> artifactDefs = new List<ArtifactDef>();

		public static List<BuffDef> buffDefs = new List<BuffDef>();

		public static List<EffectDef> effectDefs = new List<EffectDef>();

		public static List<SkillFamily> skillFamilies = new List<SkillFamily>();

		public static List<SkillDef> skillDefs = new List<SkillDef>();

		public static List<GameObject> projectilePrefabs = new List<GameObject>();

		public static List<GameObject> networkedObjectPrefabs = new List<GameObject>();

		public static List<Type> entityStates = new List<Type>();

		public static List<ItemDef> itemDefs = new List<ItemDef>();

		public static List<EquipmentDef> equipDefs = new List<EquipmentDef>();

		public static List<EliteDef> eliteDefs = new List<EliteDef>();

		public static List<GameObject> masterPrefabs = new List<GameObject>();

		public static List<GameObject> bodyPrefabs = new List<GameObject>();

		public static string shredKeywordToken = "DUCK_SHRED_KEYWORD";

		public static BuffDef soulShrineLuckBuff;

		public static BuffDef voidCradleCurse;

		public static BuffDef shockMarker;

		public static int shockMarkerDuration = 4;

		public static BuffDef shockHealCooldown;

		public static float survivorExecuteThreshold = 0.15f;

		public static float banditExecutionThreshold = 0.1f;

		public static float harvestExecutionThreshold = 0.2f;

		public static BuffDef shatterspleenSpikeBuff;

		public static BuffDef noRazorwire;

		public static AssetBundle retierAssetBundle
		{
			get
			{
				if ((Object)(object)_retierAssetBundle == (Object)null)
				{
					_retierAssetBundle = AssetBundle.LoadFromFile(GetAssetBundlePath("retier2"));
				}
				return _retierAssetBundle;
			}
			set
			{
				_retierAssetBundle = value;
			}
		}

		public static List<Material> MaterialsWithSwappedShaders { get; } = new List<Material>();

		public static string GetAssetBundlePath(string bundleName)
		{
			return Path.Combine(Path.GetDirectoryName(RiskierRainPlugin.PInfo.Location), bundleName);
		}

		public static bool RegisterEntityState(Type entityState)
		{
			if (entityStates.Contains(entityState) || !entityState.IsSubclassOf(typeof(EntityState)) || entityState.IsAbstract)
			{
				return false;
			}
			entityStates.Add(entityState);
			return true;
		}

		public static EffectDef CreateEffect(GameObject effect)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00a5: 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_00c0: Expected O, but got Unknown
			if ((Object)(object)effect == (Object)null)
			{
				Debug.LogError((object)"Effect prefab was null");
				return null;
			}
			EffectComponent component = effect.GetComponent<EffectComponent>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogErrorFormat("Effect prefab: \"{0}\" does not have an EffectComponent.", new object[1] { ((Object)effect).name });
				return null;
			}
			VFXAttributes component2 = effect.GetComponent<VFXAttributes>();
			if ((Object)(object)component2 == (Object)null)
			{
				Debug.LogErrorFormat("Effect prefab: \"{0}\" does not have a VFXAttributes component.", new object[1] { ((Object)effect).name });
				return null;
			}
			EffectDef val = new EffectDef
			{
				prefab = effect,
				prefabEffectComponent = component,
				prefabVfxAttributes = component2,
				prefabName = ((Object)effect).name,
				spawnSoundEventName = component.soundName
			};
			effectDefs.Add(val);
			return val;
		}

		public override void Init()
		{
			AddShatterspleenSpikeBuff();
			AddRazorwireCooldown();
			AddVoidCradleCurse();
			AddShockDebuff();
			AddShockCooldown();
			AddSoulShrineLuckBuff();
		}

		private void AddSoulShrineLuckBuff()
		{
			//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)
			//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)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			BuffDef val = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/DLC2/bdExtraLifeBuff.asset").WaitForCompletion();
			soulShrineLuckBuff = ScriptableObject.CreateInstance<BuffDef>();
			soulShrineLuckBuff.buffColor = val.buffColor;
			soulShrineLuckBuff.canStack = true;
			soulShrineLuckBuff.isDebuff = val.isDebuff;
			soulShrineLuckBuff.flags = val.flags;
			((Object)soulShrineLuckBuff).name = "bdExtraLuckBuff";
			soulShrineLuckBuff.iconSprite = val.iconSprite;
			buffDefs.Add(soulShrineLuckBuff);
			StatHooks.GetMoreStatCoefficients += new MoreStatHookEventHandler(SoulShrineLuck);
		}

		private void SoulShrineLuck(CharacterBody sender, MoreStatHookEventArgs args)
		{
			int buffCount = sender.GetBuffCount(soulShrineLuckBuff);
			if (buffCount > 0)
			{
				args.luckAdd += (float)(buffCount * InteractableChanges.soulShrineLuckIncrease);
			}
		}

		private void AddVoidCradleCurse()
		{
			//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)
			//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)
			voidCradleCurse = ScriptableObject.CreateInstance<BuffDef>();
			voidCradleCurse.buffColor = Color.black;
			voidCradleCurse.canStack = false;
			voidCradleCurse.isDebuff = false;
			((Object)voidCradleCurse).name = "VoidCradleCurse";
			voidCradleCurse.iconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/texBuffVoidFog.tif").WaitForCompletion();
			buffDefs.Add(voidCradleCurse);
		}

		private void AddShockDebuff()
		{
			//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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			shockMarker = ScriptableObject.CreateInstance<BuffDef>();
			((Object)shockMarker).name = "Shock";
			shockMarker.buffColor = new Color(0f, 0f, 0.6f);
			shockMarker.canStack = false;
			shockMarker.isDebuff = true;
			BuffDef obj = shockMarker;
			obj.flags = (Flags)(obj.flags | 1);
			shockMarker.isHidden = true;
			shockMarker.iconSprite = null;
			buffDefs.Add(shockMarker);
		}

		private void AddShockCooldown()
		{
			//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)
			shockHealCooldown = ScriptableObject.CreateInstance<BuffDef>();
			((Object)shockHealCooldown).name = "Shock";
			shockHealCooldown.buffColor = new Color(0f, 0f, 0.6f);
			shockHealCooldown.canStack = true;
			shockHealCooldown.isDebuff = false;
			shockHealCooldown.isCooldown = true;
			shockHealCooldown.iconSprite = null;
			buffDefs.Add(shockHealCooldown);
		}

		private void AddShatterspleenSpikeBuff()
		{
			//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)
			//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)
			shatterspleenSpikeBuff = ScriptableObject.CreateInstance<BuffDef>();
			shatterspleenSpikeBuff.buffColor = new Color(0.7f, 0f, 0.2f, 1f);
			shatterspleenSpikeBuff.canStack = true;
			shatterspleenSpikeBuff.isDebuff = false;
			((Object)shatterspleenSpikeBuff).name = "ShatterspleenSpikeCharge";
			shatterspleenSpikeBuff.iconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/LunarSkillReplacements/texBuffLunarDetonatorIcon.tif").WaitForCompletion();
			buffDefs.Add(shatterspleenSpikeBuff);
		}

		private void AddRazorwireCooldown()
		{
			//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_0036: 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)
			noRazorwire = ScriptableObject.CreateInstance<BuffDef>();
			noRazorwire.buffColor = Color.black;
			noRazorwire.canStack = false;
			noRazorwire.isDebuff = true;
			BuffDef obj = noRazorwire;
			obj.flags = (Flags)(obj.flags | 1);
			((Object)noRazorwire).name = "NoRazorwire";
			noRazorwire.iconSprite = null;
			buffDefs.Add(noRazorwire);
		}

		public static void SwapShadersFromMaterialsInBundle(AssetBundle bundle)
		{
			if (bundle.isStreamedSceneAssetBundle)
			{
				Debug.LogWarning((object)"Cannot swap material shaders from a streamed scene assetbundle.");
				return;
			}
			Material[] array = (from mat in bundle.LoadAllAssets<Material>()
				where ((Object)mat.shader).name.StartsWith("Stubbed")
				select mat).ToArray();
			foreach (Material val in array)
			{
				if (!((Object)val.shader).name.StartsWith("Stubbed"))
				{
					Debug.LogWarning((object)$"The material {val} has a shader which's name doesnt start with \"Stubbed\" ({((Object)val.shader).name}), this is not allowed for stubbed shaders for MSU. not swapping shader.");
					continue;
				}
				try
				{
					SwapShader(val);
				}
				catch (Exception arg)
				{
					Debug.LogError((object)$"Failed to swap shader of material {val}: {arg}");
				}
			}
		}

		private static void SwapShader(Material material)
		{
			//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)
			string text = ((Object)material.shader).name.Substring("Stubbed".Length);
			string text2 = text + ".shader";
			Shader shader = Addressables.LoadAssetAsync<Shader>((object)text2).WaitForCompletion();
			material.shader = shader;
			MaterialsWithSwappedShaders.Add(material);
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public string identifier => "RiskierRain";

		public void Initialize()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.artifactDefs.Add(Assets.artifactDefs.ToArray());
			contentPack.buffDefs.Add(Assets.buffDefs.ToArray());
			contentPack.effectDefs.Add(Assets.effectDefs.ToArray());
			contentPack.equipmentDefs.Add(Assets.equipDefs.ToArray());
			contentPack.itemDefs.Add(Assets.itemDefs.ToArray());
			contentPack.eliteDefs.Add(Assets.eliteDefs.ToArray());
			contentPack.projectilePrefabs.Add(Assets.projectilePrefabs.ToArray());
			contentPack.bodyPrefabs.Add(Assets.bodyPrefabs.ToArray());
			contentPack.masterPrefabs.Add(Assets.masterPrefabs.ToArray());
			contentPack.entityStateTypes.Add(Assets.entityStates.ToArray());
			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 abstract class CoreModule
	{
		public abstract void Init();
	}
	public class EliteModule : CoreModule
	{
		public class CustomEliteDef : ScriptableObject
		{
			public EliteDef eliteDef;

			public EliteTiers eliteTier;

			public Color lightColor = Color.clear;

			public Texture eliteRamp;

			public Material overlayMaterial;

			public GameObject spawnEffect;
		}

		public enum EliteTiers
		{
			Tier1,
			Tier2,
			Other
		}

		public static List<CustomEliteDef> Elites = new List<CustomEliteDef>();

		public static Texture defaultShaderRamp = null;

		public override void Init()
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(AddElites));
		}

		private static void AddElites()
		{
			foreach (CustomEliteDef elite in Elites)
			{
				switch (elite.eliteTier)
				{
				case EliteTiers.Tier1:
					ArrayUtils.ArrayAppend<EliteDef>(ref CombatDirector.eliteTiers[1].eliteTypes, ref elite.eliteDef);
					ArrayUtils.ArrayAppend<EliteDef>(ref CombatDirector.eliteTiers[2].eliteTypes, ref elite.eliteDef);
					break;
				case EliteTiers.Tier2:
					ArrayUtils.ArrayAppend<EliteDef>(ref CombatDirector.eliteTiers[3].eliteTypes, ref elite.eliteDef);
					break;
				}
			}
		}
	}
	public class Spawnlists : CoreModule
	{
		public override void Init()
		{
			SpawnCards.Init();
		}

		public static void AddMonsterCardToSpawnlist(DirectorCardCategorySelection categorySelection, DirectorCard directorCard, MonsterCategory monsterCategory)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected I4, but got Unknown
			categorySelection.AddCard((int)monsterCategory, directorCard);
		}
	}
	public static class SpawnCards
	{
		public static bool initialized;

		public static CharacterSpawnCard AlphaConstruct;

		public static CharacterSpawnCard Beetle;

		public static CharacterSpawnCard Lemurian;

		public static CharacterSpawnCard Larva;

		public static CharacterSpawnCard Wisp;

		public static CharacterSpawnCard Jellyfish;

		public static CharacterSpawnCard BlindPestSnowy;

		public static CharacterSpawnCard BlindVerminSnowy;

		public static CharacterSpawnCard Imp;

		public static CharacterSpawnCard Vulture;

		public static CharacterSpawnCard Golem;

		public static CharacterSpawnCard BeetleGuard;

		public static CharacterSpawnCard Mushrum;

		public static CharacterSpawnCard Bison;

		public static CharacterSpawnCard ClayApothecary;

		public static CharacterSpawnCard ElderLemurian;

		public static CharacterSpawnCard Parent;

		public static CharacterSpawnCard Gup;

		public static CharacterSpawnCard Bronzong;

		public static CharacterSpawnCard GreaterWisp;

		public static CharacterSpawnCard TitanBlackBeach;

		public static CharacterSpawnCard TitanDampCave;

		public static CharacterSpawnCard TitanGolemPlains;

		public static CharacterSpawnCard TitanGooLake;

		public static CharacterSpawnCard Vagrant;

		public static CharacterSpawnCard BeetleQueen;

		public static CharacterSpawnCard Dunestrider;

		public static CharacterSpawnCard MagmaWorm;

		public static CharacterSpawnCard ImpOverlord;

		public static CharacterSpawnCard Grovetender;

		public static CharacterSpawnCard RoboBall;

		public static CharacterSpawnCard XiConstruct;

		public static CharacterSpawnCard Grandparent;

		public static CharacterSpawnCard OverloadingWorm;

		public static CharacterSpawnCard solusInvalidator;

		public static CharacterSpawnCard solusScorcher;

		public static CharacterSpawnCard solusTransporter;

		public static CharacterSpawnCard solusExtractor;

		public static CharacterSpawnCard solusProspector;

		public static CharacterSpawnCard solusDistributor;

		public static CharacterSpawnCard solusAmalgamator;

		public static void Init()
		{
			//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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d7: 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_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_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_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_0205: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: 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_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				initialized = true;
				AlphaConstruct = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/MajorAndMinorConstruct/cscMinorConstruct.asset").WaitForCompletion();
				Beetle = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscbeetle");
				Lemurian = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csclemurian");
				Wisp = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csclesserwisp");
				Jellyfish = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscjellyfish");
				Imp = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscimp");
				Vulture = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscvulture");
				Golem = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/Golem/cscGolem.asset").WaitForCompletion();
				BeetleGuard = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscbeetleguard");
				Mushrum = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscminimushroom");
				Bison = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/Bison/cscBison.asset").WaitForCompletion();
				ElderLemurian = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/LemurianBruiser/cscLemurianBruiser.asset").WaitForCompletion();
				Parent = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/Parent/cscParent.asset").WaitForCompletion();
				Gup = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/Gup/cscGupBody.asset").WaitForCompletion();
				Bronzong = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscbell");
				GreaterWisp = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscgreaterwisp");
				TitanBlackBeach = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csctitanblackbeach");
				TitanDampCave = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csctitandampcave");
				TitanGolemPlains = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csctitangolemplains");
				TitanGooLake = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/csctitangoolake");
				Vagrant = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscvagrant");
				BeetleQueen = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscbeetlequeen");
				Dunestrider = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscclayboss");
				MagmaWorm = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscmagmaworm");
				ImpOverlord = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscimpboss");
				Grovetender = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscgravekeeper");
				RoboBall = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscroboballboss");
				Grandparent = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/Base/Grandparent/cscGrandparent.asset").WaitForCompletion();
				OverloadingWorm = LegacyResourcesAPI.Load<CharacterSpawnCard>("spawncards/characterspawncards/cscelectricworm");
				BlindVerminSnowy = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/Vermin/cscVerminSnowy.asset").WaitForCompletion();
				BlindPestSnowy = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/FlyingVermin/cscFlyingVerminSnowy.asset").WaitForCompletion();
				ClayApothecary = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/ClayGrenadier/cscClayGrenadier.asset").WaitForCompletion();
				Larva = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/AcidLarva/cscAcidLarva.asset").WaitForCompletion();
				XiConstruct = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC1/MajorAndMinorConstruct/cscMegaConstruct.asset").WaitForCompletion();
				solusDistributor = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/MinePod/cscMinePod.asset").WaitForCompletion();
				solusExtractor = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/ExtractorUnit/cscExtractorUnit.asset ").WaitForCompletion();
				solusInvalidator = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/DefectiveUnit/cscDefectiveUnit.asset").WaitForCompletion();
				solusProspector = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/WorkerUnit/cscWorkerUnit.asset").WaitForCompletion();
				solusScorcher = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/Tanker/cscTanker.asset").WaitForCompletion();
				solusTransporter = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/IronHauler/cscIronHauler.asset").WaitForCompletion();
				solusAmalgamator = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)"RoR2/DLC3/SolusAmalgamator/cscSolusAmalgamator.asset").WaitForCompletion();
				DirectorCards.Init();
			}
		}
	}
	public static class DirectorCards
	{
		public static bool initialized;

		public static DirectorCard AlphaConstruct;

		public static DirectorCard AlphaConstructNear;

		public static DirectorCard Beetle;

		public static DirectorCard Lemurian;

		public static DirectorCard Larva;

		public static DirectorCard Wisp;

		public static DirectorCard Jellyfish;

		public static DirectorCard BlindPestSnowy;

		public static DirectorCard BlindVerminSnowy;

		public static DirectorCard Imp;

		public static DirectorCard Vulture;

		public static DirectorCard Golem;

		public static DirectorCard BeetleGuard;

		public static DirectorCard Mushrum;

		public static DirectorCard ClayApothecary;

		public static DirectorCard Bison;

		public static DirectorCard BisonLoop;

		public static DirectorCard ElderLemurian;

		public static DirectorCard Parent;

		public static DirectorCard Gup;

		public static DirectorCard Bronzong;

		public static DirectorCard GreaterWisp;

		public static DirectorCard TitanBlackBeach;

		public static DirectorCard TitanDampCave;

		public static DirectorCard TitanGolemPlains;

		public static DirectorCard TitanGooLake;

		public static DirectorCard Vagrant;

		public static DirectorCard BeetleQueen;

		public static DirectorCard Dunestrider;

		public static DirectorCard MagmaWorm;

		public static DirectorCard ImpOverlord;

		public static DirectorCard Grovetender;

		public static DirectorCard RoboBall;

		public static DirectorCard Grandparent;

		public static DirectorCard OverloadingWorm;

		public static DirectorCard XiConstruct;

		public static DirectorCard LunarGolemSkyMeadow;

		public static DirectorCard LunarGolemSkyMeadowBasic;

		public static DirectorCard SolusInvalidator;

		public static DirectorCard SolusScorcher;

		public static DirectorCard SolusTransporter;

		public static DirectorCard SolusExtractor;

		public static DirectorCard SolusProspector;

		public static DirectorCard SolusDistributor;

		public static DirectorCard SolusAmalgamator;

		public static bool logCardInfo;

		public static void Init()
		{
			if (!initialized)
			{
				initialized = true;
				AlphaConstruct = BuildDirectorCard(SpawnCards.AlphaConstruct, 1, 1, (MonsterSpawnDistance)0);
				AlphaConstructNear = BuildDirectorCard(SpawnCards.AlphaConstruct, 1, 1, (MonsterSpawnDistance)1);
				Beetle = BuildDirectorCard(SpawnCards.Beetle);
				Lemurian = BuildDirectorCard(SpawnCards.Lemurian);
				Larva = BuildDirectorCard(SpawnCards.Larva);
				Wisp = BuildDirectorCard(SpawnCards.Wisp);
				Jellyfish = BuildDirectorCard(SpawnCards.Jellyfish, 1, 0, (MonsterSpawnDistance)2);
				BlindPestSnowy = BuildDirectorCard(SpawnCards.BlindPestSnowy);
				BlindVerminSnowy = BuildDirectorCard(SpawnCards.BlindVerminSnowy);
				Imp = BuildDirectorCard(SpawnCards.Imp);
				Vulture = BuildDirectorCard(SpawnCards.Vulture, 1, 3, (MonsterSpawnDistance)0);
				Golem = BuildDirectorCard(SpawnCards.Golem);
				BeetleGuard = BuildDirectorCard(SpawnCards.BeetleGuard);
				Mushrum = BuildDirectorCard(SpawnCards.Mushrum);
				ClayApothecary = BuildDirectorCard(SpawnCards.ClayApothecary);
				Bison = BuildDirectorCard(SpawnCards.Bison, 1, 2, (MonsterSpawnDistance)0);
				Bronzong = BuildDirectorCard(SpawnCards.Bronzong);
				GreaterWisp = BuildDirectorCard(SpawnCards.GreaterWisp);
				ElderLemurian = BuildDirectorCard(SpawnCards.ElderLemurian, 1, 3, (MonsterSpawnDistance)0);
				Parent = BuildDirectorCard(SpawnCards.Parent, 1, 3, (MonsterSpawnDistance)0);
				Gup = BuildDirectorCard(SpawnCards.Gup, 1, 3, (MonsterSpawnDistance)0);
				TitanBlackBeach = BuildDirectorCard(SpawnCards.TitanBlackBeach);
				TitanDampCave = BuildDirectorCard(SpawnCards.TitanDampCave);
				TitanGolemPlains = BuildDirectorCard(SpawnCards.TitanGolemPlains);
				TitanGooLake = BuildDirectorCard(SpawnCards.TitanGooLake);
				Vagrant = BuildDirectorCard(SpawnCards.Vagrant);
				BeetleQueen = BuildDirectorCard(SpawnCards.BeetleQueen);
				Dunestrider = BuildDirectorCard(SpawnCards.Dunestrider);
				ImpOverlord = BuildDirectorCard(SpawnCards.ImpOverlord, 1, 1, (MonsterSpawnDistance)0);
				Grovetender = BuildDirectorCard(SpawnCards.Grovetender);
				RoboBall = BuildDirectorCard(SpawnCards.RoboBall, 1, 3, (MonsterSpawnDistance)0);
				MagmaWorm = BuildDirectorCard(SpawnCards.MagmaWorm, 1, 2, (MonsterSpawnDistance)0);
				Grandparent = BuildDirectorCard(SpawnCards.Grandparent, 1, 2, (MonsterSpawnDistance)0);
				OverloadingWorm = BuildDirectorCard(SpawnCards.OverloadingWorm);
				XiConstruct = BuildDirectorCard(SpawnCards.XiConstruct, 1, 2, (MonsterSpawnDistance)0);
				SolusInvalidator = BuildDirectorCard(SpawnCards.solusInvalidator);
				SolusScorcher = BuildDirectorCard(SpawnCards.solusScorcher);
				SolusTransporter = BuildDirectorCard(SpawnCards.solusTransporter);
				SolusExtractor = BuildDirectorCard(SpawnCards.solusExtractor);
				SolusProspector = BuildDirectorCard(SpawnCards.solusProspector);
				SolusDistributor = BuildDirectorCard(SpawnCards.solusDistributor);
				SolusAmalgamator = BuildDirectorCard(SpawnCards.solusAmalgamator);
			}
		}

		public static DirectorCard BuildDirectorCard(CharacterSpawnCard spawnCard)
		{
			return BuildDirectorCard(spawnCard, 1, 0, (MonsterSpawnDistance)0);
		}

		public static DirectorCard BuildDirectorCard(CharacterSpawnCard spawnCard, int weight, int minStages, MonsterSpawnDistance spawnDistance)
		{
			//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_0014: 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_0022: 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_002a: Expected O, but got Unknown
			return new DirectorCard
			{
				spawnCard = (SpawnCard)(object)spawnCard,
				selectionWeight = weight,
				preventOverhead = false,
				minimumStageCompletions = minStages,
				spawnDistance = spawnDistance
			};
		}

		public static DirectorCard BuildDirectorCard(InteractableSpawnCard spawnCard, int weight, int minStages)
		{
			//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_0014: 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_0023: Expected O, but got Unknown
			return new DirectorCard
			{
				spawnCard = (SpawnCard)(object)spawnCard,
				selectionWeight = weight,
				preventOverhead = false,
				minimumStageCompletions = minStages
			};
		}
	}
	public class StatHooks : CoreModule
	{
		public class BorboStatHookEventArgs : EventArgs
		{
			public float attackSpeedMultAdd = 1f;

			public float attackSpeedDivAdd = 1f;
		}

		public delegate void StatHookEventHandler(CharacterBody sender, BorboStatHookEventArgs args);

		public static event StatHookEventHandler BorboStatCoefficients;

		public static void ApplyCooldownScale(GenericSkill skillSlot, float cooldownScale)
		{
			if ((Object)(object)skillSlot != (Object)null)
			{
				skillSlot.cooldownScale *= cooldownScale;
			}
		}

		public override void Init()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			CharacterBody.RecalculateStats += new hook_RecalculateStats(AttackSpeedBs);
		}

		private void AttackSpeedBs(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			BorboStatHookEventArgs e = new BorboStatHookEventArgs();
			StatHooks.BorboStatCoefficients?.Invoke(self, e);
			float num = e.attackSpeedMultAdd / e.attackSpeedDivAdd;
			self.attackSpeed *= num;
		}
	}
}
namespace RiskierRain.Components
{
	internal class CopyInventoryFromOwner : MonoBehaviour
	{
		public Func<ItemIndex, bool> inventoryItemCopyFilter = Inventory.defaultItemCopyFilterDelegate.Invoke;

		public bool copyInventory = true;

		public bool copyEquipment = true;

		public void Start()
		{
			CharacterMaster component = ((Component)this).gameObject.GetComponent<CharacterMaster>();
			MinionOwnership component2 = ((Component)this).gameObject.GetComponent<MinionOwnership>();
			if (!((Object)(object)component2 != (Object)null) || !((Object)(object)component != (Object)null))
			{
				return;
			}
			CharacterMaster ownerMaster = component2.ownerMaster;
			Inventory val = ((ownerMaster != null) ? ownerMaster.inventory : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				if (copyEquipment)
				{
					component.inventory.CopyEquipmentFrom(val);
				}
				if (copyInventory)
				{
					component.inventory.CopyItemsFrom(val, inventoryItemCopyFilter);
				}
			}
		}
	}
	internal class InteractableBuffController : MonoBehaviour
	{
		private PurchaseInteraction _purchaseInteraction;

		public BuffDef buffDef;

		public float duration = -1f;

		public PurchaseInteraction purchaseInteraction
		{
			get
			{
				if (Object.op_Implicit((Object)(object)_purchaseInteraction))
				{
					return _purchaseInteraction;
				}
				_purchaseInteraction = ((Component)this).GetComponent<PurchaseInteraction>();
				return _purchaseInteraction;
			}
		}

		internal virtual void Start()
		{
			((UnityEvent<Interactor>)(object)purchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)OnPurchase);
		}

		private void OnPurchase(Interactor interactor)
		{
			if (!((Object)(object)buffDef == (Object)null))
			{
				CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component) && NetworkServer.active)
				{
					AddDebuff(component);
				}
			}
		}

		internal virtual void AddDebuff(CharacterBody interactorBody)
		{
			if (duration <= 0f)
			{
				interactorBody.AddBuff(buffDef);
			}
			else
			{
				interactorBody.AddTimedBuff(buffDef, duration);
			}
		}
	}
	internal class StatBuffer : MonoBehaviour
	{
		public int levelOffset = 0;

		public float levelDamage = 0f;

		public float levelAttackSpeed = 0f;

		public float levelMoveSpeed = 0f;

		public float levelShield = 0f;

		public float levelArmor = 0f;
	}
}
namespace RiskierRain.Changes
{
	public static class AllyChanges
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<GameObject> <>9__3_0;

			public static hook_OnEnter <>9__7_0;

			public static hook_OnEnter <>9__11_0;

			internal void <ChangeMegaDrone>b__3_0(GameObject prefab)
			{
				CharacterBody val = default(CharacterBody);
				if (prefab.TryGetComponent<CharacterBody>(ref val))
				{
					val.baseMaxHealth = megaDroneBaseMaxHealth;
					val.levelMaxHealth = val.baseMaxHealth * 0.3f;
					val.baseDamage = megaDroneBaseDamage;
					val.levelDamage = val.baseDamage * 0.2f;
					val.PerformAutoCalculateLevelStats();
				}
			}

			internal void <ChangeJunkDrone>b__7_0(orig_OnEnter orig, Surprise self)
			{
				Surprise.itemsToDropCoefficient = junkDroneDropCoefficient;
				Surprise.maxItemCount = junkDroneDropsMax;
				Surprise.extraItemsPerTier = junkDroneDropsPerTier;
			}

			internal void <ChangeCleanupDrone>b__11_0(orig_OnEnter orig, Cleanup self)
			{
				Cleanup.goldPackValue = cleanupValueGold;
				Cleanup.healthOrbFractionalHealing = cleanupValueHealFraction;
				Cleanup.healthOrbFlatHealing = cleanupValueHealFlat;
				orig.Invoke(self);
			}
		}

		public static float megaDroneBaseMaxHealth = 450f;

		public static float megaDroneBaseDamage = 10f;

		public static float junkDroneDropCoefficient = 1000f;

		public static int junkDroneDropsMax = 3;

		public static int junkDroneDropsPerTier = 1;

		public static int cleanupValueGold = 8;

		public static float cleanupValueHealFraction = 0.1f;

		public static float cleanupValueHealFlat = 0f;

		public static void Initialize()
		{
			ChangeCleanupDrone();
			ChangeJunkDrone();
			ChangeMegaDrone();
		}

		private static void ChangeMegaDrone()
		{
			RiskierRainPlugin.LoadAsync<GameObject>(RoR2_Base_Drones.MegaDroneBody_prefab, (Action<GameObject>)delegate(GameObject prefab)
			{
				CharacterBody val = default(CharacterBody);
				if (prefab.TryGetComponent<CharacterBody>(ref val))
				{
					val.baseMaxHealth = megaDroneBaseMaxHealth;
					val.levelMaxHealth = val.baseMaxHealth * 0.3f;
					val.baseDamage = megaDroneBaseDamage;
					val.levelDamage = val.baseDamage * 0.2f;
					val.PerformAutoCalculateLevelStats();
				}
			});
		}

		private static void ChangeJunkDrone()
		{
			//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__7_0;
			if (obj == null)
			{
				hook_OnEnter val = delegate
				{
					Surprise.itemsToDropCoefficient = junkDroneDropCoefficient;
					Surprise.maxItemCount = junkDroneDropsMax;
					Surprise.extraItemsPerTier = junkDroneDropsPerTier;
				};
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			Surprise.OnEnter += (hook_OnEnter)obj;
		}

		private static void ChangeCleanupDrone()
		{
			//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__11_0;
			if (obj == null)
			{
				hook_OnEnter val = delegate(orig_OnEnter orig, Cleanup self)
				{
					Cleanup.goldPackValue = cleanupValueGold;
					Cleanup.healthOrbFractionalHealing = cleanupValueHealFraction;
					Cleanup.healthOrbFlatHealing = cleanupValueHealFlat;
					orig.Invoke(self);
				};
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			Cleanup.OnEnter += (hook_OnEnter)obj;
		}
	}
	public static class DifficultyChanges
	{
		public delegate bool orig_getHasOneShotProtection(CharacterBody self);

		public delegate float get_oneShotProtectionFraction(CharacterBody self);

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

			public static hook_Start <>9__2_0;

			public static hook_OnControlEnd <>9__12_1;

			public static Manipulator <>9__80_0;

			public static Manipulator <>9__80_1;

			public static Manipulator <>9__80_2;

			public static Manipulator <>9__80_3;

			public static Func<Instruction, bool> <>9__86_0;

			public static Func<Instruction, bool> <>9__86_2;

			public static Func<Instruction, bool> <>9__88_0;

			public static Func<Instruction, bool> <>9__90_0;

			public static Func<Instruction, bool> <>9__90_1;

			public static Func<Instruction, bool> <>9__90_2;

			public static Func<Instruction, bool> <>9__104_0;

			public static Func<Instruction, bool> <>9__104_1;

			public static Func<Instruction, bool> <>9__104_2;

			public static Func<Instruction, bool> <>9__104_3;

			public static Func<Instruction, bool> <>9__104_4;

			public static Func<Instruction, bool> <>9__105_1;

			public static Func<Instruction, bool> <>9__105_2;

			public static Func<Instruction, bool> <>9__105_3;

			public static Func<Instruction, bool> <>9__105_4;

			public static Func<Instruction, bool> <>9__105_5;

			public static Func<Instruction, bool> <>9__105_6;

			public static Func<Instruction, bool> <>9__105_8;

			public static Func<Instruction, bool> <>9__105_9;

			public static Func<Instruction, bool> <>9__105_10;

			public static Func<Instruction, bool> <>9__105_11;

			public static Func<Instruction, bool> <>9__105_12;

			public static Func<Instruction, bool> <>9__105_13;

			public static Func<float, float> <>9__105_14;

			internal void <Initialize>b__2_0(orig_Start orig, MoneyPickup self)
			{
				if (NetworkServer.active)
				{
					self.goldReward = (self.shouldScale ? Run.instance.GetDifficultyScaledCost(self.baseGoldReward, Stage.instance.entryDifficultyCoefficient) : self.baseGoldReward);
				}
			}

			internal void <AddPotentialProtection>b__12_1(orig_OnControlEnd orig, NetworkUIPromptController self)
			{
				orig.Invoke(self);
				self.ClearParticipant();
			}

			internal void <ChangeEclipse>b__80_0(ILContext ctx)
			{
				RemoveEclipseEffect(ctx, "E1");
			}

			internal void <ChangeEclipse>b__80_1(ILContext ctx)
			{
				RemoveEclipseEffect(ctx, "E3");
			}

			internal void <ChangeEclipse>b__80_2(ILContext ctx)
			{
				RemoveEclipseEffect(ctx, "E5");
			}

			internal void <ChangeEclipse>b__80_3(ILContext ctx)
			{
				RemoveEclipseEffect(ctx, "E6");
			}

			internal bool <ChangeRequiredDifficultyLevelForStats>b__86_0(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "get_selectedDifficulty");
			}

			internal bool <ChangeRequiredDifficultyLevelForStats>b__86_2(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <RemoveEclipseEffect>b__88_0(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "get_selectedDifficulty");
			}

			internal bool <EclipseHoldoutScale>b__90_0(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<Run>(x, "get_selectedDifficulty");
			}

			internal bool <EclipseHoldoutScale>b__90_1(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchLdcI4(x, ref num);
			}

			internal bool <EclipseHoldoutScale>b__90_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "get_fullHealth");
			}

			internal bool <DirectorCreditGainChanges>b__104_0(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <DirectorCreditGainChanges>b__104_1(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <DirectorCreditGainChanges>b__104_2(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <DirectorCreditGainChanges>b__104_3(Instruction x)
			{
				int num = default(int);
				return ILPatternMatchingExt.MatchStloc(x, ref num);
			}

			internal bool <DirectorCreditGainChanges>b__104_4(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <AmbientLevelChanges>b__105_1(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <AmbientLevelChanges>b__105_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchMul(x);
			}

			internal bool <AmbientLevelChanges>b__105_3(Instruction x)
			{
				return ILPatternMatchingExt.MatchCallOrCallvirt<Mathf>(x, "Floor");
			}

			internal bool <AmbientLevelChanges>b__105_4(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <AmbientLevelChanges>b__105_5(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdarg(x, 0);
			}

			internal bool <AmbientLevelChanges>b__105_6(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdfld<Run>(x, "stageClearCount");
			}

			internal bool <AmbientLevelChanges>b__105_8(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <AmbientLevelChanges>b__105_9(Instruction x)
			{
				return ILPatternMatchingExt.MatchMul(x);
			}

			internal bool <AmbientLevelChanges>b__105_10(Instruction x)
			{
				float num = default(float);
				return ILPatternMatchingExt.MatchLdcR4(x, ref num);
			}

			internal bool <AmbientLevelChanges>b__105_11(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdarg(x, 0);
			}

			internal bool <AmbientLevelChanges>b__105_12(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdfld<Run>(x, "stageClearCount");
			}

			internal bool <AmbientLevelChanges>b__105_13(Instruction x)
			{
				return ILPatternMatchingExt.MatchLdsfld<Run>(x, "ambientLevelCap");
			}

			internal float <AmbientLevelChanges>b__105_14(float levelIn)
			{
				float ambientLevelBoost = GetAmbientLevelBoost();
				return levelIn + ambientLevelBoost;
			}
		}

		public static string Tier2EliteName = "Rare";

		public static bool potentialProtectionVisibility = true;

		public static bool potentialProtectionLimitedTime = false;

		public static float potentialProtectionDurationUnlimited = 0.5f;

		public static float potentialProtectionDurationLimited = 4f;

		public static bool pityChargeOn = false;

		public static float pityChargeShrinkDelta = 0f;

		public static float pityChargeRecolorDelta = 0f;

		public static float fastDirectorEliteBias = 0.75f;

		public static float fastDirectorCreditMultiplier = 0.75f;

		public static float slowDirectorEliteBias = 0.5f;

		public static float slowDirectorCreditMultiplier = 1f;

		public static float teleLesserEliteBias = 0.5f;

		public static float teleLesserCreditMultiplier = 0.8f;

		public static float teleBossEliteBias = 1f;

		public static float teleBossCreditMultiplier = 1f;

		public static float teleBossCreditMultiplierStage1 = 0.5f;

		public static float monsterCreditsMultiplier = 1f;

		public static float drizzleDifficultyBoost = 0f;

		public static float rainstormDifficultyBoost = 0f;

		public static float monsoonDifficultyBoost = 3f;

		public static float eclipseDifficultyBoost = 6f;

		public static int ambientLevelCapDrizzle = 99;

		public static int ambientLevelCap = 999;

		public static float easyTeleParticleRadius = 1f;

		public static float normalTeleParticleRadius = 0.8f;

		public static float hardTeleParticleRadius = 0.4f;

		public static float eclipseTeleParticleRadius = 0.4f;

		public static float defaultTeleParticleRadius = 0.9f;

		public static int Tier2EliteMinimumStageDefault = 6;

		public static int Tier2EliteMinimumStageDrizzle = 11;

		public static int Tier2EliteMinimumStageRainstorm = 6;

		public static int Tier2EliteMinimumStageMonsoon = 4;

		public static int Tier2EliteMinimumStageEclipse = 4;

		public static DifficultyIndex eclipseLevelBossElite = (DifficultyIndex)3;

		public static string eclipseOneDesc = "\n<mspace=0.5em>(1)</mspace> Boss Enemies: <style=cIsHealth>Always Elite</style>";

		public static DifficultyIndex eclipseLevelEnemyMspd = (DifficultyIndex)4;

		public static float eclipseEnemyMspd = 0.3f;

		public static string eclipseTwoDesc = "\n<mspace=0.5em>(2)</mspace> Enemy Speed: <style=cIsHealth>+" + eclipseEnemyMspd.AsPercent() + "</style>";

		public static DifficultyIndex eclipseLevelSmallHoldout = (DifficultyIndex)5;

		public static DifficultyIndex eclipseLevelHoldoutLoss = (DifficultyIndex)5;

		public static float eclipseHoldoutLossRate = 0.02f;

		public static float eclipseHoldoutScale = 0.6f;

		public static string eclipseThreeDesc = "\n<mspace=0.5em>(3)</mspace> All Holdout Zones are <style=cIsHealth>Eclipsed</style>";

		public static DifficultyIndex eclipseHealingLoss = (DifficultyIndex)6;

		public static float eclipseHealingMultiplier = 0.75f;

		public static string eclipseFourDesc = "\n<mspace=0.5em>(4)</mspace> Ally Healing: <style=cIsHealth>-" + (1f - eclipseHealingMultiplier).AsPercent() + "</style>";

		public static DifficultyIndex eclipseLevelEnemyCdr = (DifficultyIndex)7;

		public static float eclipseEnemyCooldownScale = 0.6f;

		public static string eclipseFiveDesc = "\n<mspace=0.5em>(5)</mspace> Enemy Cooldowns: <style=cIsHealth>-" + (1f - eclipseEnemyCooldownScale).AsPercent() + "</style>";

		public static DifficultyIndex eclipseLevelSpiteArtifact = (DifficultyIndex)8;

		public static string eclipseSixDesc = "\n<mspace=0.5em>(6)</mspace> On Kill: <style=cIsHealth>Enemies drop exploding bombs</style>";

		public static DifficultyIndex eclipseLevelItemTax = (DifficultyIndex)9;

		public static int eclipseItemTaxCount = 2;

		public static float eclipseItemTaxPercent = 0.2f;

		public static string eclipseSevenDesc = "\n<mspace=0.5em>(7)</mspace> Item Tax: <style=cIsHealth>" + eclipseItemTaxPercent.AsPercent() + " per Stage</style>";

		public static string eclipseEightDesc = "\n<mspace=0.5em>(8)</mspace> Allies recieve <style=cIsHealth>permanent damage</style>";

		public static float baseScalingMultiplier = 1f;

		public static float difficultyIncreasePerMinutePerDifficulty = 0.01f;

		public static float difficultyIncreasePerMinuteBase = 1f;

		public static float difficultyIncreasePerStage = -0.1f;

		public static float difficultyIncreasePerLoop = 1.2f;

		public static float playerBaseDifficultyFactor = 0.2f;

		public static float playerScalingDifficultyFactor = 0.2f;

		public static float playerSpawnRateFactor = 0.5f;

		public static float difficultySpawnRateFactor = 0.4f;

		public static float voidFieldsTimeCost = 120f;

		private static float goldRewardMultiplierGlobal = 0.35f;

		private static float expRewardMultiplierGlobal = 0.4f;

		private static float compensationForStartingLevel = 1f;

		internal static float GetAmbientLevelBoost()
		{
			return DifficultyUtilsModule.GetAmbientLevelBoost();
		}

		public static void Initialize()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			RemoveOspForever();
			AddPotentialProtection();
			AddPityCharge();
			FreezeDifficultyScalingOnFinalLevels();
			ChangeDifficultyCoefficientCalculation();
			ChangeEnemyRewards();
			DifficultyUtilsModule.EnableAll();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(AddDifficultyStats));
			AddMonsoonScalingStats();
			ChangeEclipse();
			ChangeDirectorStats();
			DirectorAPI.StageSettingsActions += IncreaseStageMonsterCredits;
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_Start val = delegate(orig_Start orig, MoneyPickup self)
				{
					if (NetworkServer.active)
					{
						self.goldReward = (self.shouldScale ? Run.instance.GetDifficultyScaledCost(self.baseGoldReward, Stage.instance.entryDifficultyCoefficient) : self.baseGoldReward);
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			MoneyPickup.Start += (hook_Start)obj;
		}

		public static void RemoveOspForever()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			Hook val = new Hook((MethodBase)typeof(CharacterBody).GetMethod("get_hasOneShotProtection", (BindingFlags)(-1)), typeof(DifficultyChanges).GetMethod("ReflectOnThatThang", (BindingFlags)(-1)));
			Hook val2 = new Hook((MethodBase)typeof(CharacterBody).GetMethod("get_oneShotProtectionFraction", (BindingFlags)(-1)), typeof(DifficultyChanges).GetMethod("ReflectOnThatThang2", (BindingFlags)(-1)));
		}

		public static bool ReflectOnThatThang(orig_getHasOneShotProtection orig, CharacterBody self)
		{
			return false;
		}

		public static float ReflectOnThatThang2(get_oneShotProtectionFraction orig, CharacterBody self)
		{
			return 0f;
		}

		public static void AddPotentialProtection()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			if (!potentialProtectionLimitedTime)
			{
				NetworkUIPromptController.SetParticipantMaster += new hook_SetParticipantMaster(PickupPickerPanelProtection);
				object obj = <>c.<>9__12_1;
				if (obj == null)
				{
					hook_OnControlEnd val = delegate(orig_OnControlEnd orig, NetworkUIPromptController self)
					{
						orig.Invoke(self);
						self.ClearParticipant();
					};
					<>c.<>9__12_1 = val;
					obj = (object)val;
				}
				NetworkUIPromptController.OnControlEnd += (hook_OnControlEnd)obj;
			}
			else
			{
				PickupPickerPanel.Awake += new hook_Awake(CommandOrPotentialArmor);
			}
			static void CommandOrPotentialArmor(orig_Awake orig, PickupPickerPanel self)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CharacterBody cachedBody = firstLocalUser.cachedBody;
				if (cachedBody.isPlayerControlled)
				{
					cachedBody.AddTimedBuffAuthority(GetBuffIndex(), potentialProtectionDurationLimited);
				}
				orig.Invoke(self);
			}
			static BuffIndex GetBuffIndex()
			{
				//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_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references)
				if (potentialProtectionVisibility)
				{
					return Buffs.Immune.buffIndex;
				}
				return Buffs.HiddenInvincibility.buffIndex;
			}
			static void PickupPickerPanelProtection(orig_SetParticipantMaster orig, NetworkUIPromptController self, CharacterMaster newParticipantMaster)
			{
				//IL_0046: 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_00c9: 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_00e5: 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_0084: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					if ((Object)(object)newParticipantMaster != (Object)(object)self.currentParticipantMaster && (Object)(object)self.currentParticipantMaster != (Object)null)
					{
						CharacterBody body = self.currentParticipantMaster.GetBody();
						if ((Object)(object)body != (Object)null && body.HasBuff(GetBuffIndex()))
						{
							body.ClearTimedBuffs(GetBuffIndex());
							while (body.HasBuff(GetBuffIndex()))
							{
								body.RemoveBuff(GetBuffIndex());
							}
							body.AddTimedBuff(GetBuffIndex(), potentialProtectionDurationUnlimited);
						}
					}
					if ((Object)(object)newParticipantMaster != (Object)null)
					{
						CharacterBody body2 = newParticipantMaster.GetBody();
						if ((Object)(object)body2 != (Object)null && body2.isPlayerControlled)
						{
							body2.ClearTimedBuffs(GetBuffIndex());
							while (body2.HasBuff(GetBuffIndex()))
							{
								body2.RemoveBuff(GetBuffIndex());
							}
							body2.AddBuff(GetBuffIndex());
						}
					}
				}
				orig.Invoke(self, newParticipantMaster);
			}
		}

		public static void AddPityCharge()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but

SwanSongExtended.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterSoulCost;
using BossDropRework;
using EntityStates;
using EntityStates.AI;
using EntityStates.AI.Walker;
using EntityStates.Bandit2;
using EntityStates.BrotherMonster;
using EntityStates.BrotherMonster.Weapon;
using EntityStates.Captain.Weapon;
using EntityStates.CaptainSupplyDrop;
using EntityStates.GrandParent;
using EntityStates.LaserTurbine;
using EntityStates.Mage.Weapon;
using EntityStates.NullifierMonster;
using EntityStates.TeleporterHealNovaController;
using EntityStates.VoidRaidCrab;
using FabricatorStandalone;
using HG;
using HG.BlendableTypes;
using HG.Reflection;
using HarmonyLib;
using IL.RoR2;
using IL.RoR2.Items;
using IL.RoR2.Orbs;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using MoreStats;
using On.EntityStates;
using On.EntityStates.AI.Walker;
using On.EntityStates.LaserTurbine;
using On.EntityStates.TeleporterHealNovaController;
using On.RoR2;
using On.RoR2.CharacterAI;
using On.RoR2.Items;
using On.RoR2.Orbs;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RainrotSharedUtils;
using RainrotSharedUtils.Components;
using RainrotSharedUtils.Difficulties;
using RainrotSharedUtils.MoreProjectiles;
using RainrotSharedUtils.Shelters;
using RainrotSharedUtils.Status;
using RoR2;
using RoR2.Achievements;
using RoR2.Artifacts;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Hologram;
using RoR2.Items;
using RoR2.Navigation;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPaths;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using RoR2BepInExPack.GameAssetPathsBetter;
using SwanSongExtended.Artifacts;
using SwanSongExtended.Changes;
using SwanSongExtended.Characters;
using SwanSongExtended.Components;
using SwanSongExtended.Elites;
using SwanSongExtended.Equipment;
using SwanSongExtended.Equipment.Zapinator;
using SwanSongExtended.Interactables;
using SwanSongExtended.Items;
using SwanSongExtended.Modules;
using SwanSongExtended.Scavengers;
using SwanSongExtended.Skills;
using SwanSongExtended.States;
using SwanSongExtended.States.AI;
using SwanSongExtended.Storms;
using ThreeEyedGames;
using Unity;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SwanSongExtended")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SwanSongExtended")]
[assembly: AssemblyTitle("SwanSongExtended")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
}
namespace RiskierRainContent.Interactables
{
	internal static class CombatEncounterHelper
	{
		public enum CustomDirectorType
		{
			GalleryDirector = 1,
			ConstructDirector
		}

		public static GameObject MethodOne(PurchaseInteraction purchaseInteraction, Interactor activator, int credits, CustomDirectorType directorType)
		{
			//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_000c: 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)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			Vector3 val = Vector3.zero;
			Quaternion rotation = Quaternion.identity;
			Transform transform = ((Component)purchaseInteraction).gameObject.transform;
			if (Object.op_Implicit((Object)(object)transform))
			{
				val = transform.position;
				rotation = transform.rotation;
			}
			GameObject val2 = LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/Encounters/MonstersOnShrineUseEncounter");
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val2, val, Quaternion.identity);
			NetworkServer.Spawn(val3);
			CombatDirector component = val3.GetComponent<CombatDirector>();
			ParseDirectorType(((Component)component).gameObject, directorType);
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)Stage.instance))
			{
				return null;
			}
			float num = (float)credits * Stage.instance.entryDifficultyCoefficient;
			DirectorCard val4 = component.SelectMonsterCardForCombatShrine(num);
			if (val4 != null)
			{
				component.CombatShrineActivation(activator, num, val4);
				EffectData val5 = new EffectData
				{
					origin = val,
					rotation = rotation
				};
				if (directorType == CustomDirectorType.ConstructDirector)
				{
					GameObject val6 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MonstersOnShrineUse");
					EffectManager.SpawnEffect(val6, val5, true);
				}
			}
			return val3;
		}

		public static void ParseDirectorType(GameObject obj, CustomDirectorType value)
		{
			switch (value)
			{
			case CustomDirectorType.GalleryDirector:
				obj.AddComponent<GalleryDirector>();
				break;
			case CustomDirectorType.ConstructDirector:
				obj.AddComponent<ConstructDirector>();
				break;
			default:
				obj.AddComponent<GalleryDirector>();
				break;
			}
		}
	}
	internal class GalleryDirector : MonoBehaviour
	{
	}
	internal class ConstructDirector : MonoBehaviour
	{
	}
}
namespace SwanSongExtended
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[R2APISubmoduleDependency(new string[] { "LanguageAPI", "PrefabAPI", "RecalculateStatsAPI", "DotAPI", "DifficultyAPI" })]
	[BepInPlugin("com.RiskOfBrainrot.SwanSongExtended", "SwanSongExtended", "0.2.0")]
	public class SwanSongPlugin : BaseUnityPlugin
	{
		public static int ignitionTankBurnChance = 15;

		public float ignitionBurnDamage = 2f;

		public float ignitionBurnDuration = 2f;

		private bool shouldIgnitionDamageAndDurationCompound = false;

		public static int stacheBurnChance = 25;

		public static int brandBurnChance = 30;

		public const string difficultyToken = "DIFFICULTYSWANSONG";

		public static float eclipseDifficultyBoost = 6f;

		public static DifficultyDef difficultyDefExtinction;

		public static DifficultyIndex difficultyIndexExtinction;

		public static string extinctionName = "Extinction";

		public static string extinctionDescBase = "For only the determined and truly masochistic.\nThe planet is alive and writhing with unspeakable hatred for what has been done to it. You, the subject of its fury, will be torn asunder and be made unrecognizable. <style=cStack>\n\n>Player Health Regeneration: <style=cArtifact>-40%</style></style> <style=cStack>\n>Difficulty Scaling: <style=cArtifact>+100%</style>";

		public static string extinctionDescStartingDifficulty = "<style=cStack>\n>Starting Difficulty: <style=cArtifact>Very Hard</style></style>";

		public static string extinctionDescExtra = "\n>Rare Elites: <style=cArtifact>Stage 4</style>\n>Teleporter Visuals: <style=cArtifact>OFF</style>\n>Enemies gain <style=cArtifact>enhanced scaling</style>\n>Enemies gain <style=cArtifact>tripled projectiles</style></style>";

		public static string extinctionDesc = extinctionDescBase + extinctionDescStartingDifficulty + extinctionDescExtra;

		private static List<string> swanSongDeathQuoteTokens = new List<string>();

		private static List<string> swanSongStormDeathQuoteTokens = new List<string>();

		public const string guid = "com.RiskOfBrainrot.SwanSongExtended";

		public const string teamName = "RiskOfBrainrot";

		public const string modName = "SwanSongExtended";

		public const string version = "0.2.0";

		public const string expansionName = "Swan Song";

		public const string expansionName2 = "Secrets of the Scug";

		public const string expansionToken = "EXPANSION2R4R";

		public const string expansionToken2 = "EXPANSIONSOTS";

		public const string DEVELOPER_PREFIX = "FRUIT";

		public static SwanSongPlugin instance;

		public static ExpansionDef expansionDefSS2;

		public static ExpansionDef expansionDefSOTS;

		public const string iconsPath = "";

		private GameObject meatballNapalmPool => CommonAssets.meatballNapalmPool;

		public static AssetBundle mainAssetBundle => CommonAssets.mainAssetBundle;

		public static AssetBundle retierAssetBundle => CommonAssets.retierAssetBundle;

		public static bool iabMissilesLoaded => ModLoaded("com.RiskOfBrainrot.IAmBecomeMissiles");

		public static bool isAELoaded => ModLoaded("com.Borbo.ArtificerExtended");

		public static bool is2R4RLoaded => ModLoaded("com.RiskOfBrainrot.RiskierRain");

		public static bool isBossDropLoaded => ModLoaded("com.RiskOfBrainrot.FruityBossDrops");

		public static bool isHBULoaded => ModLoaded("com.Borbo.HuntressBuffULTIMATE");

		public static bool isScepterLoaded => ModLoaded("com.DestroyedClone.AncientScepter");

		public static bool autosprintLoaded => ModLoaded("com.johnedwa.RTAutoSprintEx");

		public static bool acridLungeLoaded => ModLoaded("Withor.AcridBiteLunge");

		public static bool ucrLoaded => ModLoaded("HIFU.UltimateCustomRun");

		public static bool fabricatorsLoaded => ModLoaded("com.RiskOfBrainrot.Fabricators");

		internal static event Action onSwanSongLoaded;

		private void BurnReworks()
		{
			IgnitionTankRework();
		}

		private void IgnitionTankRework()
		{
			//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
			StatHooks.GetMoreStatCoefficients += new MoreStatHookEventHandler(IgniTankBurnChance);
			StrengthenBurnUtils.CheckDotForUpgrade += new hook_CheckDotForUpgrade(OverrideIgnitionBurn);
			LanguageAPI.Add("ITEM_STRENGTHENBURN_PICKUP", "Your ignite effects deal triple damage.");
			LanguageAPI.Add("ITEM_STRENGTHENBURN_DESC", $"Gain <style=cIsDamage>{ignitionTankBurnChance}% ignite chance</style>. " + "All ignition effects deal <style=cIsDamage>+" + Tools.ConvertDecimal(ignitionBurnDamage) + "</style> <style=cStack>(+" + Tools.ConvertDecimal(ignitionBurnDamage) + " per stack)</style> more damage and last <style=cIsUtility>+" + Tools.ConvertDecimal(ignitionBurnDuration) + "</style> <style=cStack>(+" + Tools.ConvertDecimal(ignitionBurnDuration) + " per stack)</style> longer.");
		}

		private void IgniTankBurnChance(CharacterBody sender, MoreStatHookEventArgs args)
		{
			Inventory inventory = sender.inventory;
			if (Object.op_Implicit((Object)(object)inventory) && inventory.GetItemCountEffective(Items.StrengthenBurn) > 0)
			{
				args.burnChanceOnHit += (float)ignitionTankBurnChance;
			}
		}

		private void OverrideIgnitionBurn(orig_CheckDotForUpgrade orig, Inventory inventory, ref InflictDotInfo dotInfo)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0038: 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)
			if ((int)dotInfo.dotIndex != 1 && (int)dotInfo.dotIndex != 2)
			{
				return;
			}
			int itemCountEffective = inventory.GetItemCountEffective(Items.StrengthenBurn);
			if (itemCountEffective > 0)
			{
				dotInfo.preUpgradeDotIndex = dotInfo.dotIndex;
				dotInfo.dotIndex = (DotIndex)7;
				float num = 1f + ignitionBurnDamage * (float)itemCountEffective;
				float num2 = 1f + ignitionBurnDuration * (float)itemCountEffective;
				if (shouldIgnitionDamageAndDurationCompound)
				{
					dotInfo.totalDamage *= num * num2;
					dotInfo.damageMultiplier *= num;
				}
				else
				{
					dotInfo.totalDamage *= num;
					dotInfo.damageMultiplier *= num / num2;
				}
			}
		}

		public static int GetBurnCount(CharacterBody victimBody)
		{
			return victimBody.GetBuffCount(Buffs.OnFire) + victimBody.GetBuffCount(Buffs.StrongerBurn);
		}

		public static bool EnableMoreProjectilesForExtinctionEnemies(CharacterBody sender)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//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)
			return (int)sender.teamComponent.teamIndex != 1 && Run.instance.selectedDifficulty == difficultyIndexExtinction;
		}

		private void CreateDifficultyDef()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//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_0070: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			difficultyDefExtinction = new DifficultyDef(4f, "DIFFICULTYSWANSONG_NAME", "", "DIFFICULTYSWANSONG_DESC", Color32.op_Implicit(new Color32((byte)115, (byte)81, (byte)151, byte.MaxValue)), "", true);
			difficultyDefExtinction.iconSprite = mainAssetBundle.LoadAsset<Sprite>("Assets/Textures/Icons/texIconDifficultyHardest.png");
			difficultyDefExtinction.foundIconSprite = true;
			difficultyIndexExtinction = DifficultyAPI.AddDifficulty(difficultyDefExtinction);
			MoreDifficultyStats moreDifficultyStats = DifficultyUtilsModule.GetMoreDifficultyStats(difficultyIndexExtinction);
			moreDifficultyStats.ambientLevelCap = 999;
			moreDifficultyStats.delayFirstStorm_ForSwanSong = false;
			moreDifficultyStats.desiredStormTime_ForSwanSong = 4f;
			moreDifficultyStats.desiredStormWarningTime_ForSwanSong = 1f;
			moreDifficultyStats.startingDifficultyCoefficientBoost = difficultyDefExtinction.scalingValue - 1f;
			moreDifficultyStats.startingDifficultyDisplay = 9f;
			moreDifficultyStats.startingLevelBoost = eclipseDifficultyBoost;
			moreDifficultyStats.stormIntensifyStrength_ForSwanSong = 0.70000005f;
			moreDifficultyStats.teleporterParticleRangeMultiplier = 0f;
			moreDifficultyStats.tier2EliteStage = 4;
			DifficultyUtilsModule.difficultyCustomStats[difficultyIndexExtinction] = moreDifficultyStats;
			LanguageAPI.Add("DIFFICULTYSWANSONG_NAME", extinctionName);
			LanguageAPI.Add("DIFFICULTYSWANSONG_DESC", extinctionDesc);
			RoR2Application.onLoadFinished = (Action)Delegate.Combine(RoR2Application.onLoadFinished, new Action(ExtinctionCustomHooks));
			MoreProjectilesModule.MoreProjectilesProvider += new MoreProjectilesEventHandler(EnableMoreProjectilesForExtinctionEnemies);
		}

		private void ExtinctionCustomHooks()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			if (is2R4RLoaded)
			{
				Log.Error("Extinction no custom hooks");
				return;
			}
			Log.Error("Extinction custom hooks");
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(MonsoonPlusStatBuffs2);
		}

		private void MonsoonPlusStatBuffs2(CharacterBody sender, StatHookEventArgs args)
		{
			//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_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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Invalid comparison between Unknown and I4
			DifficultyIndex selectedDifficulty = Run.instance.selectedDifficulty;
			if (selectedDifficulty != difficultyIndexExtinction)
			{
				return;
			}
			float num = eclipseDifficultyBoost;
			if ((int)sender.teamComponent.teamIndex != 1)
			{
				float num2 = sender.level - num;
				if (sender.baseNameToken != "JELLYFISH_BODY_NAME")
				{
					args.attackSpeedMultAdd += Mathf.Clamp01(num2 / 200f) * 4f;
				}
				if (sender.isChampion)
				{
					args.armorAdd += 3f * num2;
				}
				else
				{
					args.moveSpeedMultAdd += Mathf.Clamp01(num2 / 200f) * 2f;
				}
			}
		}

		public static void AddDeathMessages()
		{
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "You didn't go fast enough.", "{0} thought about uninstalling Swan Song.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "Was it worth it?", "{0} is wondering if it was worth it.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "Sending complaints about storms..", "{0} is sending complaints about storms..");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "Should've checked the forecast..", "{0} didn't check the forecast.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "Consider playing SUPERBUG instead?", "{0} is considering playing SUPERBUG instead.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "You were washed away.", "{0} was washed away.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "The storm blew you away.", "The storm blew {0} away.");
			AddDeathQuoteTokenToList(ref swanSongStormDeathQuoteTokens, "You'll get the hang of it!", "{0} is still learning!");
			AddDeathQuoteToken("RIPMGSGHBAB.", "{0} went KA-BOOM.");
			AddDeathQuoteToken("You have made a poor balancing decision.", "{0} has made a poor balancing decision.");
			AddDeathQuoteToken("You were splatted.", "{0} was splatted.");
			AddDeathQuoteToken("Get got.", "{0} got got.");
			AddDeathQuoteToken("Congratulations on the spontaneous lobotomy!", "{0} was spontaneously lobotomized.");
			AddDeathQuoteToken("Your innards became outards.", "{0}'s innards became outards.");
			AddDeathQuoteToken("Your plea for death is answered.", "{0}'s plea for death was answered.");
			AddDeathQuoteToken("Must've been the wind.", "{0} blames it on the weather.");
			AddDeathQuoteToken("Counting, or not counting Elite violence?", "{0} had embarrassing last words.");
			AddDeathQuoteToken("Flopped!", "{0} was a flop.");
			AddDeathQuoteToken("Maybe that's configurable?", "{0} wants to change the config.");
			AddDeathQuoteToken("Remember to take breaks.", "{0} suggests we should take a break.");
			AddDeathQuoteToken("Remember to drink water.", "{0} wants a water break.");
			AddDeathQuoteToken("Didn't account for that?", "{0} didn't account for that.");
			AddDeathQuoteToken("You were slain..", "{0} was slain..");
			AddDeathQuoteToken("You weren't green enough..", "{0} wasnt green enough..");
			GlobalEventManager.OnPlayerCharacterDeath += new Manipulator(GlobalEventManager_OnPlayerCharacterDeath);
			static void AddDeathQuoteToken(string defaultText, string? secondPlayerText)
			{
				AddDeathQuoteTokenToList(ref swanSongDeathQuoteTokens, defaultText, secondPlayerText);
			}
			static void AddDeathQuoteTokenToList(ref List<string> list, string secondPerson, string? thirdPerson)
			{
				string text = "PLAYER_DEATH_QUOTE_SWANSONG_" + swanSongDeathQuoteTokens.Count;
				LanguageAPI.Add(text + "_2P", secondPerson);
				LanguageAPI.Add(text, thirdPerson ?? secondPerson);
				list.Add(text);
			}
		}

		private static void GlobalEventManager_OnPlayerCharacterDeath(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num = default(int);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld<GlobalEventManager>(x, "standardDeathQuoteTokens")
			}) || !val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
			}))
			{
				DebugBreakpoint("GlobalEventManager_OnPlayerCharacterDeath");
				return;
			}
			val.Emit(OpCodes.Ldarg_1);
			val.EmitDelegate<Func<string, DamageReport, string>>((Func<string, DamageReport, string>)delegate(string tokenIn, DamageReport damageReport)
			{
				if (swanSongStormDeathQuoteTokens.Count > 0 && StormsCore.IsStormDamage(damageReport.damageInfo, damageReport.attackerBody))
				{
					return swanSongStormDeathQuoteTokens[Random.Range(0, swanSongStormDeathQuoteTokens.Count)];
				}
				num = GlobalEventManager.standardDeathQuoteTokens.Length;
				int num2 = Random.Range(0, num + swanSongDeathQuoteTokens.Count);
				return (num2 < num || num2 - num > swanSongDeathQuoteTokens.Count) ? tokenIn : swanSongDeathQuoteTokens[num2 - num];
			});
		}

		public static bool ModLoaded(string modGuid)
		{
			return modGuid != "" && Chainloader.PluginInfos.ContainsKey(modGuid);
		}

		private void Awake()
		{
			instance = this;
			Config.Init();
			Language.Init();
			Log.Init(((BaseUnityPlugin)this).Logger);
			CreateExpansionDef();
			CreateDifficultyDef();
			AddDeathMessages();
			ShockUtilsModule.UseShockSparks = true;
			Hooks.Init();
			CommonAssets.Init();
			EliteModule.Init();
			Spawnlists.Init();
			StormsCore.Init();
			Materials.SwapShadersFromMaterialsInBundle(mainAssetBundle);
			ConfigManager.HandleConfigAttributes(((object)this).GetType(), "SwanSong", Config.MyConfig);
			InitializeContent();
			InitializeChanges();
			SwanSongPlugin.onSwanSongLoaded();
			Config.Save();
			new ContentPacks().Initialize();
		}

		public static void DebugBreakpoint(string methodName, int breakpointNumber = -1)
		{
			Log.DebugBreakpoint(methodName, breakpointNumber);
		}

		private void CreateExpansionDef()
		{
			//IL_004c: 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)
			expansionDefSS2 = ScriptableObject.CreateInstance<ExpansionDef>();
			expansionDefSS2.nameToken = "EXPANSION2R4R_NAME";
			expansionDefSS2.descriptionToken = "EXPANSION2R4R_DESCRIPTION";
			expansionDefSS2.iconSprite = mainAssetBundle.LoadAsset<Sprite>("Assets/Textures/Icons/texIconExpansionSwanSong.png");
			expansionDefSS2.disabledIconSprite = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common_MiscIcons.texUnlockIcon_png).WaitForCompletion();
			LanguageAPI.Add("EXPANSION2R4R_NAME", "Swan Song");
			LanguageAPI.Add("EXPANSION2R4R_DESCRIPTION", "Adds content from the 'Swan Song' expansion to the game.");
			Content.AddExpansionDef(expansionDefSS2);
			expansionDefSOTS = ScriptableObject.CreateInstance<ExpansionDef>();
			expansionDefSOTS.nameToken = "EXPANSIONSOTS_NAME";
			expansionDefSOTS.descriptionToken = "EXPANSIONSOTS_DESCRIPTION";
			expansionDefSOTS.iconSprite = null;
			expansionDefSOTS.disabledIconSprite = null;
		}

		private void InitializeContent()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			BeginInitializing<ReworkBase>(types, "SwanSongReworks.txt");
			BeginInitializing<ItemBase>(types, "SwanSongItems.txt");
			BeginInitializing<EquipmentBase>(types, "SwanSongEquipment.txt");
			BeginInitializing<EliteEquipmentBase>(types, "SwanSongElites.txt");
			BeginInitializing<InteractableBase>(types, "SwanSongInteractables.txt");
			BeginInitializing<ArtifactBase>(types, "SwanSongArtifacts.txt");
			BeginInitializing<SkillBase>(types, "SwanSongSkills.txt");
			BeginInitializing<TwistedScavengerBase>(types, "SwanSongScavengers.txt");
		}

		private void InitializeChanges()
		{
			Secrets.AddSecrets();
		}

		private void BeginInitializing<T>(Type[] allTypes, string fileName = "") where T : SharedBase
		{
			Type baseType = typeof(T);
			if (!baseType.IsAbstract)
			{
				Log.Error(Log.Combine() + "Incorrect BaseType: " + baseType.Name);
				return;
			}
			IEnumerable<Type> source = allTypes.Where((Type type) => !type.IsAbstract && type.IsSubclassOf(baseType));
			if (source.Count() <= 0)
			{
				return;
			}
			IEnumerable<SharedBase> enumerable = from objType in source
				select (T)Activator.CreateInstance(objType) into sharedBase
				orderby sharedBase.loadOrder
				select sharedBase;
			Log.Debug(Log.Combine(baseType.Name) + "Initializing");
			foreach (SharedBase item in enumerable)
			{
				string text = Log.Combine(baseType.Name, item.ConfigName);
				if (ValidateBaseType(item))
				{
					Log.Debug(text + "Validated");
					InitializeBaseType(item);
					Log.Debug(text + "Initialized");
				}
			}
			if (!string.IsNullOrEmpty(fileName))
			{
				Language.TryPrintOutput(fileName);
			}
		}

		private bool ValidateBaseType(SharedBase obj)
		{
			bool isEnabled = obj.isEnabled;
			if (obj.forcePrerequisites)
			{
				return isEnabled && obj.GetPrerequisites();
			}
			return obj.Bind(isEnabled, "Should This Content Be Enabled") && obj.GetPrerequisites();
		}

		private void InitializeBaseType(SharedBase obj)
		{
			obj.Init();
		}

		public static bool GetConfigBool(bool defaultValue, string packetTitle, string desc = "")
		{
			return ConfigManager.DualBindToConfig(packetTitle, Config.MyConfig, "Should This Content Be Enabled", defaultValue, desc);
		}

		public static Sprite TryLoadSpriteFromBundle(string path, AssetBundle assetBundle = null, bool fallBackOnWrench = false)
		{
			//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)
			Sprite val = SwanSongPlugin.TryLoadFromBundle<Sprite>(path, assetBundle);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			return Addressables.LoadAssetAsync<Sprite>((object)(fallBackOnWrench ? RoR2_Base_Core.texNullIcon_png : RoR2_Base_Common_MiscIcons.texWIPIcon_png)).WaitForCompletion();
		}

		public static T TryLoadFromBundle<T>(string path, AssetBundle assetBundle = null) where T : Object
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				assetBundle = mainAssetBundle;
			}
			if (Object.op_Implicit((Object)(object)assetBundle) && !string.IsNullOrWhiteSpace(path) && assetBundle.Contains(path))
			{
				return assetBundle.LoadAsset<T>(path);
			}
			return default(T);
		}

		public static AssetReferenceT<T> LoadAsync<T>(string guid, Action<T> callback) where T : Object
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceT<T> val = new AssetReferenceT<T>(guid);
			AsyncOperationHandle<T> handle = AssetAsyncReferenceManager<T>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			if (callback == null)
			{
				return val;
			}
			if (handle.IsDone)
			{
				onCompleted(handle);
				return val;
			}
			handle.Completed += onCompleted;
			return val;
			void onCompleted(AsyncOperationHandle<T> val2)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Invalid comparison between Unknown and I4
				if (val2.Result == null || (int)val2.Status != 1)
				{
					Debug.LogError((object)$"Failed to load asset [{val2.DebugName}] : {val2.OperationException}");
				}
				else
				{
					callback(val2.Result);
				}
			}
		}

		public static void RemoveCraftingRecipe(string guid)
		{
			SwanSongPlugin.LoadAsync<CraftableDef>(guid, (Action<CraftableDef>)delegate(CraftableDef craftableDef)
			{
				craftableDef.recipes = (Recipe[])(object)new Recipe[0];
			});
		}

		public static void RetierItemAsync(string itemGuid, ItemTier tier = (ItemTier)5, Action<ItemDef> callback = null)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//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)
			AssetReferenceT<ItemDef> val = new AssetReferenceT<ItemDef>(itemGuid);
			AsyncOperationHandle<ItemDef> val2 = AssetAsyncReferenceManager<ItemDef>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<ItemDef> ctx)
			{
				//IL_000b: 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_001d: Unknown result type (might be due to invalid IL or missing references)
				ItemDef result = ctx.Result;
				result.tier = tier;
				result.deprecatedTier = tier;
				if (callback != null)
				{
					callback(result);
				}
			};
		}

		public static void RemoveEquipmentAsync(string equipmentGuid, Action<EquipmentDef> callback = null)
		{
			//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)
			AssetReferenceT<EquipmentDef> val = new AssetReferenceT<EquipmentDef>(equipmentGuid);
			AsyncOperationHandle<EquipmentDef> val2 = AssetAsyncReferenceManager<EquipmentDef>.LoadAsset(val, (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<EquipmentDef> ctx)
			{
				EquipmentDef result = ctx.Result;
				result.canDrop = false;
				result.canBeRandomlyTriggered = false;
				result.enigmaCompatible = false;
				result.dropOnDeathChance = 0f;
				if (callback != null)
				{
					callback(result);
				}
			};
		}

		internal static void BlacklistSingleItem(ItemDef itemDef, ItemTag itemTag = (ItemTag)4)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemDef != (Object)null)
			{
				List<ItemTag> list = new List<ItemTag>(itemDef.tags);
				list.Add(itemTag);
				itemDef.tags = list.ToArray();
			}
			else
			{
				Log.Error("ItemDef null - unable to blacklist");
			}
		}

		internal static void BlacklistSingleItem(string name, ItemTag itemTag = (ItemTag)4)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			ItemDef itemDef = LoadItemDef(name);
			BlacklistSingleItem(itemDef, itemTag);
		}

		public static void ChangeBuffStacking(string buffName, bool canStack)
		{
			BuffDef val = LoadBuffDef(buffName);
			if ((Object)(object)val != (Object)null)
			{
				val.canStack = canStack;
			}
		}

		private static ItemDef LoadItemDef(string name)
		{
			return LegacyResourcesAPI.Load<ItemDef>("ItemDefs/" + name);
		}

		private static EquipmentDef LoadEquipDef(string name)
		{
			return LegacyResourcesAPI.Load<EquipmentDef>("EquipmentDefs/" + name);
		}

		private static BuffDef LoadBuffDef(string name)
		{
			return LegacyResourcesAPI.Load<BuffDef>("BuffDefs/" + name);
		}
	}
	public static class Secrets
	{
		private const bool DEBUG = true;

		public static void AddSecrets()
		{
			//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_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_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_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_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_00a9: 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_00f3: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: 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_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//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_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_0568: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			if (SwanSongPlugin.fabricatorsLoaded)
			{
				AddDoubleChestSecrets();
			}
			InteractableSpawnCard val = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)RoR2_Base_ShrineCombat.iscShrineCombat_asset).WaitForCompletion();
			InteractableSpawnCard val2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)RoR2_Base_EquipmentBarrel.iscEquipmentBarrel_asset).WaitForCompletion();
			InteractableSpawnCard spawnCard = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/DuplicatorLarge/iscDuplicatorLarge.asset").WaitForCompletion();
			InteractableSpawnCard spawnCard2 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/Chest2/iscChest2.asset").WaitForCompletion();
			InteractableSpawnCard spawnCard3 = Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/Base/LunarChest/iscLunarChest.asset").WaitForCompletion();
			InteractableSpawnCard spawnCard4 = InteractableBase<ConstructConstruct>.instance.customInteractable.spawnCard;
			InteractableSpawnCard spawnCard5 = null;
			InteractableSpawnCard spawnCard6 = null;
			InteractableSpawnCard spawnCard7 = null;
			InteractableSpawnCard spawnCard8 = null;
			SpawnSecret("ancientloft", (SpawnCard)(object)spawnCard, new Vector3(-86f, 29f, 34f));
			SpawnSecret("ancientloft", (SpawnCard)(object)spawnCard2, new Vector3(-104f, 106f, 265f));
			SpawnSecret("ancientloft", (SpawnCard)(object)spawnCard, new Vector3(-68f, 40f, -59f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard, new Vector3(257f, 84f, -140f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard, new Vector3(145f, -75f, -75f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard, new Vector3(-108f, -104f, -138f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard, new Vector3(-86f, 29f, 34f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard2, new Vector3(-128f, -127f, 98f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard3, new Vector3(-137f, -356f));
			SpawnSecret("foggyswamp", (SpawnCard)(object)spawnCard4, new Vector3(258f, -150f, -170f), 0.3f);
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard2, new Vector3(22f, -158f, -371f));
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard, new Vector3(-7f, -81f, -174f));
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard, new Vector3(221f, -100f, 296f));
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard5, new Vector3(351f, -78f, 108f));
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard, new Vector3(118f, -91f, -7f));
			SpawnSecret("goolake", (SpawnCard)(object)spawnCard2, new Vector3(174f, -11f, -252f));
			SpawnSemiRandom("wispgraveyard", (SpawnCard)(object)spawnCard5, (Vector3[])(object)new Vector3[4]
			{
				new Vector3(-412f, 6f, -20f),
				new Vector3(-418f, 6f, -67f),
				new Vector3(-383f, 6f, -102f),
				new Vector3(-421f, 6f, -39f)
			});
			SpawnSecret("wispgraveyard", (SpawnCard)(object)spawnCard6, new Vector3(46f, 29f, -62f));
			SpawnSemiRandom("frozenwall", (SpawnCard)(object)spawnCard7, (Vector3[])(object)new Vector3[3]
			{
				new Vector3(74f, 121f, 147f),
				new Vector3(66f, 115f, 109f),
				new Vector3(54f, 111f, 72f)
			});
			SpawnSecret("frozenwall", (SpawnCard)(object)spawnCard8, new Vector3(0f, 34f, 5f));
			SpawnSecret("sulfurpools", (SpawnCard)(object)spawnCard6, new Vector3(9f, -7f, -51f), 0.5f);
			SpawnSecret("sulfurpools", (SpawnCard)(object)spawnCard6, new Vector3(-155f, 27f, 46f), 0.5f);
			SpawnSecret("sulfurpools", (SpawnCard)(object)spawnCard6, new Vector3(176f, 28f, 45f), 0.5f);
			SpawnSecret("sulfurpools", (SpawnCard)(object)spawnCard6, new Vector3(94f, 22f, -133f), 0.5f);
			SpawnSemiRandom("sulfurpools", (SpawnCard)(object)spawnCard4, (Vector3[])(object)new Vector3[3]
			{
				new Vector3(23f, -35f, 65f),
				new Vector3(26f, -34f, 99f),
				new Vector3(28f, -34f, 36f)
			});
			SpawnSemiRandom("sulfurpools", (SpawnCard)(object)spawnCard4, (Vector3[])(object)new Vector3[2]
			{
				new Vector3(173f, 2f, -154f),
				new Vector3(128f, 0f, -194f)
			}, 0.5f);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void AddDoubleChestSecrets()
		{
			//IL_001a: 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_006c: 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_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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_010e: 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_0129: 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_0162: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: 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_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0463: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: Unknown result type (might be due to invalid IL or missing references)
			SpawnSecret("golemplains", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-109f, -100f, 42f));
			SpawnSecret("golemplains", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(133f, -100f, 29f), 0.4f);
			SpawnSecret("golemplains", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(183f, -92f, -144f));
			SpawnSecret("golemplains", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(100f, -155f, -342f), 0.4f);
			SpawnSemiRandom(posList: (Vector3[])(object)new Vector3[5]
			{
				new Vector3(139f, -119f, 194f),
				new Vector3(156f, -120f, -196f),
				new Vector3(152f, -112f, -222f),
				new Vector3(120f, -112f, -209f),
				new Vector3(89f, -116f, -192f)
			}, scene: "golemplains", spawnCard: (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard);
			SpawnSecret("golemplains2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-33f, 61f, -57f));
			SpawnSecret("golemplains2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-77f, 54f, -102f));
			SpawnSecret("golemplains2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-214f, 42f, -29f), 0.8f);
			SpawnSecret("golemplains2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(141f, 60f, -4f), 0.4f);
			SpawnSecret("golemplains2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(151f, 14f, -230f));
			SpawnSecret("blackbeach", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-23f, -175f, -387f));
			SpawnSecret("blackbeach", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(93f, -125f, -299f));
			SpawnSecret("blackbeach", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(31f, -213f, -120f));
			SpawnSecret("blackbeach", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-288f, -16f, -181f), 0.3f);
			SpawnSecret("blackbeach", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-337f, -199f, -230f), 0.5f);
			SpawnSecret("blackbeach2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-101f, 28f, 11f), 0.8f);
			SpawnSecret("blackbeach2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-134f, 47f, -103f), 0.4f);
			SpawnSecret("blackbeach2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(12f, 88f, -126f));
			SpawnSecret("blackbeach2", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(117f, 65f, 151f));
			SpawnSecret("snowyforest", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-252f, 22f, 57f), 0.5f);
			SpawnSecret("snowyforest", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(24f, 67f, 2f));
			SpawnSecret("snowyforest", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-34f, 70f, -193f));
			SpawnSecret("snowyforest", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(38f, 42f, -27f), 0.5f);
			SpawnSemiRandom(posList: (Vector3[])(object)new Vector3[3]
			{
				new Vector3(136f, 53f, 191f),
				new Vector3(92f, 41f, -32f),
				new Vector3(110f, 79f, 19f)
			}, scene: "snowyforest", spawnCard: (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard);
			SpawnSecret("ancientloft", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(165f, 62f, -31f), 0.8f);
			SpawnSecret("wispgraveyard", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-22f, 59f, 286f));
			SpawnSecret("frozenwall", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(87f, 82f, -250f), 0.5f);
			SpawnSecret("frozenwall", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(-104f, 35f, 49f));
			SpawnSecret("frozenwall", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(196f, 25f, 32f));
			SpawnSecret("sulfurpools", (SpawnCard)(object)FabricatorPlugin.fabricatorCommonSpawnCard, new Vector3(11f, -19f, 37f));
		}

		public static void SpawnSecret(string scene, SpawnCard spawnCard, Vector3 pos, float chance = -1f)
		{
			//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)
			if ((Object)(object)spawnCard == (Object)null)
			{
				return;
			}
			Stage.onStageStartGlobal += delegate(Stage self)
			{
				//IL_0003: 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_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Expected O, but got Unknown
				//IL_00fc: 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_0102: 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_0122: Expected O, but got Unknown
				//IL_011d: 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_0159: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Invalid comparison between Unknown and I4
				Vector3 val = default(Vector3);
				SceneDef sceneDef = self.sceneDef;
				if (!((Object)(object)sceneDef == (Object)null) && !(self.sceneDef.cachedName != scene) && (chance == -1f || RollForSecret(chance)))
				{
					if (!CheckForGeometry(pos + new Vector3(0f, 2f, 0f)))
					{
						Debug.Log((object)"no floor!!");
					}
					else
					{
						DirectorPlacementRule val2 = new DirectorPlacementRule
						{
							placementMode = (PlacementMode)0
						};
						if ((Object)(object)spawnCard == (Object)null)
						{
							Debug.Log((object)"spawncardnullwtf");
						}
						if (val2 == null)
						{
							Debug.Log((object)"placementrulenulwtf");
						}
						GameObject spawnedInstance = spawnCard.DoSpawn(pos, Quaternion.Euler(val), new DirectorSpawnRequest(spawnCard, val2, Run.instance.runRNG)).spawnedInstance;
						spawnedInstance.transform.eulerAngles = val;
						if (Object.op_Implicit((Object)(object)spawnedInstance))
						{
							PurchaseInteraction component = spawnedInstance.GetComponent<PurchaseInteraction>();
							if (Object.op_Implicit((Object)(object)component) && (int)component.costType == 1)
							{
								component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost);
							}
						}
						NetworkServer.Spawn(spawnedInstance);
					}
				}
			};
		}

		public static void SpawnSemiRandom(string scene, SpawnCard spawnCard, Vector3[] posList, float chance = -1f)
		{
			if ((Object)(object)spawnCard == (Object)null)
			{
				return;
			}
			Stage.onStageStartGlobal += delegate(Stage self)
			{
				//IL_0003: 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_0067: Expected O, but got Unknown
				//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)
				//IL_0079: 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_0099: Expected O, but got Unknown
				//IL_0094: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Invalid comparison between Unknown and I4
				Vector3 val = default(Vector3);
				if (!(self.sceneDef.cachedName != scene) && (chance == -1f || RollForSecret(chance)))
				{
					DirectorPlacementRule val2 = new DirectorPlacementRule
					{
						placementMode = (PlacementMode)0
					};
					GameObject spawnedInstance = spawnCard.DoSpawn(SemiRandomLocation(posList), Quaternion.Euler(val), new DirectorSpawnRequest(spawnCard, val2, Run.instance.runRNG)).spawnedInstance;
					spawnedInstance.transform.eulerAngles = val;
					if (Object.op_Implicit((Object)(object)spawnedInstance))
					{
						PurchaseInteraction component = spawnedInstance.GetComponent<PurchaseInteraction>();
						if (Object.op_Implicit((Object)(object)component) && (int)component.costType == 1)
						{
							component.Networkcost = Run.instance.GetDifficultyScaledCost(component.cost);
						}
					}
					NetworkServer.Spawn(spawnedInstance);
				}
			};
		}

		public static Vector3 SemiRandomLocation(Vector3[] locations)
		{
			//IL_000f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			int num = locations.Length;
			int num2 = Random.RandomRangeInt(0, num);
			Vector3 result = locations[num2];
			bool flag = true;
			Debug.LogWarning((object)$"{num} spots, chose spot {num2}");
			return result;
		}

		public static bool RollForSecret(float chance)
		{
			return Random.RandomRange(0f, 1f) < chance;
		}

		public static bool CheckForGeometry(Vector3 cords)
		{
			//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)
			return Physics.Raycast(cords, Vector3.down, 5f);
		}
	}
	internal static class Log
	{
		public static bool enableDebugging;

		internal static ManualLogSource _logSource;

		public static void DebugBreakpoint(string methodName, int breakpointNumber = -1)
		{
			string text = "SwanSongExtended: " + methodName + " IL hook failed!";
			if (breakpointNumber >= 0)
			{
				text += $" (breakpoint {breakpointNumber})";
			}
			Error(text);
		}

		internal static void Init(ManualLogSource logSource)
		{
			enableDebugging = ConfigManager.DualBindToConfig("Swan Song", Config.MyConfig, "Enable Debugging", defaultValue: false, "Enable debug outputs to the log for troubleshooting purposes. Enabling this will slow down the game.");
			_logSource = logSource;
		}

		internal static string Combine(params string[] parameters)
		{
			string text = "SwanSongExtended : ";
			foreach (string text2 in parameters)
			{
				text = text + text2 + " : ";
			}
			return text;
		}

		internal static void Debug(object data)
		{
			if (enableDebugging)
			{
				_logSource.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void ErrorAssetBundle(string assetName, string bundleName)
		{
			Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public abstract class SharedBase
	{
		public virtual int loadOrder => 0;

		public virtual bool forcePrerequisites { get; } = false;

		public abstract string ConfigName { get; }

		public virtual bool isEnabled { get; } = true;

		public static ManualLogSource Logger => Log._logSource;

		public abstract AssetBundle assetBundle { get; }

		public abstract void Hooks();

		public abstract void Lang();

		public virtual bool GetPrerequisites()
		{
			return true;
		}

		public virtual void Init()
		{
			ConfigManager.HandleConfigAttributes(GetType(), ConfigName, Config.MyConfig);
			Hooks();
			Lang();
			SwanSongPlugin.onSwanSongLoaded += PostInit;
		}

		public T Bind<T>(T defaultValue, string configName, string configDesc = "")
		{
			return ConfigManager.DualBindToConfig(ConfigName, Config.MyConfig, configName, defaultValue, configDesc);
		}

		public virtual void PostInit()
		{
		}

		public static float GetHyperbolic(float firstStack, float cap, float chance)
		{
			if (firstStack >= cap)
			{
				return cap * (chance / firstStack);
			}
			float num = chance / firstStack;
			float num2 = 100f * firstStack / (cap - firstStack);
			return cap * (1f - 100f / (num * num2 + 100f));
		}

		public static ExpansionDef SotvExpansionDef()
		{
			//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)
			return Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
		}
	}
	public static class Extensions
	{
		public static bool InteractableIsPermittedForSpawn(this GameObject interactableObject, bool disallowPickups = true)
		{
			if ((Object)(object)interactableObject == (Object)null)
			{
				return false;
			}
			InteractionProcFilter val = default(InteractionProcFilter);
			if (interactableObject.TryGetComponent<InteractionProcFilter>(ref val))
			{
				return val.shouldAllowOnInteractionBeginProc;
			}
			PurchaseInteraction val2 = default(PurchaseInteraction);
			if (interactableObject.TryGetComponent<PurchaseInteraction>(ref val2))
			{
				return !val2.disableSpawnOnInteraction;
			}
			DelusionChestController val3 = default(DelusionChestController);
			if (interactableObject.TryGetComponent<DelusionChestController>(ref val3))
			{
				PickupPickerController val4 = default(PickupPickerController);
				if (interactableObject.TryGetComponent<PickupPickerController>(ref val4) && ((Behaviour)val4).enabled)
				{
					return false;
				}
				return true;
			}
			GenericPickupController val5 = default(GenericPickupController);
			if (interactableObject.TryGetComponent<GenericPickupController>(ref val5))
			{
				return disallowPickups || val5.Duplicated;
			}
			if (Object.op_Implicit((Object)(object)interactableObject.GetComponent<VehicleSeat>()))
			{
				return false;
			}
			if (Object.op_Implicit((Object)(object)interactableObject.GetComponent<NetworkUIPromptController>()))
			{
				return false;
			}
			PowerPedestal val6 = default(PowerPedestal);
			if (interactableObject.TryGetComponent<PowerPedestal>(ref val6))
			{
				return val6.CanTriggerFireworks;
			}
			AccessCodesNodeController val7 = default(AccessCodesNodeController);
			if (interactableObject.TryGetComponent<AccessCodesNodeController>(ref val7))
			{
				return val7.CheckInteractionOrder();
			}
			return true;
		}

		public static GameObject FixItemModel(this GameObject prefab)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//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_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)
			//IL_00e4: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)prefab == (Object)null)
			{
				prefab = Resources.Load<GameObject>("prefabs/NullModel");
			}
			ModelPanelParameters val = prefab.AddComponent<ModelPanelParameters>();
			val.minDistance = 1f;
			val.maxDistance = 15f;
			Transform val2 = prefab.transform.Find("FocusPos");
			if ((Object)(object)val2 == (Object)null)
			{
				GameObject val3 = new GameObject("FocusPos");
				val2 = val3.transform;
				val2.parent = prefab.transform;
				val2.localPosition = Vector3.zero;
			}
			val.focusPointTransform = val2;
			Transform val4 = prefab.transform.Find("CameraPos");
			if ((Object)(object)val4 == (Object)null)
			{
				GameObject val5 = new GameObject("CameraPos");
				val4 = val5.transform;
				val4.parent = prefab.transform;
				val4.SetPositionAndRotation(val2.position + Vector3.forward * -7f + Vector3.right * -1f, val4.rotation);
			}
			val.cameraPositionTransform = val4;
			return prefab;
		}

		public static bool IsStormElite(this CharacterBody body)
		{
			if (StormEliteEquipmentBase<SurgingAspect>.instance != null && body.HasBuff(StormEliteEquipmentBase<SurgingAspect>.instance.EliteBuffDef))
			{
				return true;
			}
			if (T1EliteEquipmentBase<WhirlwindAspect>.instance != null && body.HasBuff(T1EliteEquipmentBase<WhirlwindAspect>.instance.EliteBuffDef))
			{
				return true;
			}
			if (EliteEquipmentBase<DeuteriumAspect>.instance != null && body.HasBuff(EliteEquipmentBase<DeuteriumAspect>.instance.EliteBuffDef))
			{
				return true;
			}
			return false;
		}

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

		public static Sprite AsSprite(this Texture2D tex)
		{
			//IL_001a: 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)
			return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f));
		}

		public static void AddPersistentListener(this OnSpawnedServer unityEvent, UnityAction<GameObject> action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}

		public static void AddPersistentListener(this HoldoutZoneControllerChargedUnityEvent unityEvent, UnityAction<HoldoutZoneController> action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}

		public static void AddPersistentListener(this UnityEvent<Interactor> unityEvent, UnityAction<Interactor> action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}

		public static void AddPersistentListener(this UnityEvent<CharacterMaster> unityEvent, UnityAction<CharacterMaster> action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}

		public static void AddPersistentListener(this UnityEvent<GameObject> unityEvent, UnityAction<GameObject> action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}
	}
	public static class Tools
	{
		public static string modPrefix = string.Format("@{0}+{1}", "ArtificerExtended", "artiskillicons");

		public static AssetBundle LoadAssetBundle(byte[] resourceBytes)
		{
			if (resourceBytes == null)
			{
				throw new ArgumentNullException("resourceBytes");
			}
			return AssetBundle.LoadFromMemory(resourceBytes);
		}

		public static string GetModPrefix(this BaseUnityPlugin plugin, string bundleName)
		{
			return $"@{plugin.Info.Metadata.Name}+{bundleName}";
		}

		internal static bool isLoaded(string modguid)
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				string key = pluginInfo.Key;
				PluginInfo value = pluginInfo.Value;
				if (key == modguid)
				{
					return true;
				}
			}
			return false;
		}

		internal static string ConvertDecimal(float d)
		{
			return d * 100f + "%";
		}

		public static float GetAmbientLevelScalar(float scalar)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return 1f;
			}
			return 1f + scalar * Run.instance.ambientLevel;
		}

		public static bool IsEasyMode(DifficultyIndex minDifficultyIndex = (DifficultyIndex)0)
		{
			//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)(object)Run.instance == (Object)null)
			{
				return true;
			}
			return Run.instance.selectedDifficulty <= minDifficultyIndex;
		}

		internal static void GetMaterial(GameObject model, string childObject, Color color, ref Material material, float scaleMultiplier = 1f, bool replaceAll = false)
		{
			//IL_0030: 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_00aa: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				if (string.Equals(((Object)val).name, childObject))
				{
					if (color == Color.clear)
					{
						Object.Destroy((Object)(object)val);
						break;
					}
					if ((Object)(object)material == (Object)null)
					{
						material = new Material(val.material);
						material.mainTexture = val.material.mainTexture;
						material.shader = val.material.shader;
						material.color = color;
					}
					val.material = material;
					Transform transform = ((Component)val).transform;
					transform.localScale *= scaleMultiplier;
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugMaterial(GameObject model)
		{
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				Debug.Log((object)("Material: " + ((Object)val2).name.ToString()));
			}
		}

		internal static void GetParticle(GameObject model, string childObject, Color color, float sizeMultiplier = 1f, bool replaceAll = false)
		{
			//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_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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			ParticleSystem[] componentsInChildren = model.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				MainModule main = val2.main;
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				ColorBySpeedModule colorBySpeed = val2.colorBySpeed;
				if (string.Equals(((Object)val2).name, childObject))
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color);
					((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * sizeMultiplier;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(color);
					((ColorBySpeedModule)(ref colorBySpeed)).color = MinMaxGradient.op_Implicit(color);
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugParticleSystem(GameObject model)
		{
			ParticleSystem[] components = model.GetComponents<ParticleSystem>();
			ParticleSystem[] array = components;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				Debug.Log((object)("Particle: " + ((Object)val2).name.ToString()));
			}
		}

		internal static void GetLight(GameObject model, string childObject, Color color, bool replaceAll = false)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Light[] componentsInChildren = model.GetComponentsInChildren<Light>();
			Light[] array = componentsInChildren;
			foreach (Light val in array)
			{
				Light val2 = val;
				if (string.Equals(((Object)val2).name, childObject))
				{
					val2.color = color;
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugLight(GameObject model)
		{
			Light[] componentsInChildren = model.GetComponentsInChildren<Light>();
			Light[] array = componentsInChildren;
			foreach (Light val in array)
			{
				Light val2 = val;
				Debug.Log((object)("Light: " + ((Object)val2).name.ToString()));
			}
		}

		public static void ClearDotStacksForType(this DotController dotController, DotIndex dotIndex)
		{
			//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)
			for (int num = dotController.dotStackList.Count - 1; num >= 0; num--)
			{
				if (dotController.dotStackList[num].dotIndex == dotIndex)
				{
					dotController.RemoveDotStackAtServer(num);
				}
			}
		}

		public static void ApplyCooldownScale(GenericSkill skillSlot, float cooldownScale)
		{
			if ((Object)(object)skillSlot != (Object)null)
			{
				skillSlot.cooldownScale *= cooldownScale;
			}
		}

		public static int CountOverspillTriangular(float totalValue, float incrementor = 1f)
		{
			int num = 0;
			while (totalValue > 0f)
			{
				num++;
				totalValue -= incrementor * (float)num;
			}
			return num;
		}

		public static int CountOverspillFibonacci(float totalValue, float thresholdScale = 1f, int startingIndex = 1)
		{
			int num = 1;
			int num2 = 1;
			int num3 = 0;
			while (totalValue > (float)num2 * thresholdScale)
			{
				num2 += num;
				num = num2 - num;
				if (num3 > startingIndex)
				{
					num3++;
				}
			}
			return num3;
		}
	}
}
namespace SwanSongExtended.Storms
{
	public class CycloneController : MonoBehaviour
	{
		public enum CycloneState
		{
			Idle,
			PreparingCyclone,
			ElectingLeader,
			PreparingSquall,
			FiringSquall
		}

		internal abstract class BaseCycloneState : BaseState
		{
			public GameObject beamVfxInstance => instance.beamPreVfxInstance;

			internal AffixSquallBehavior leaderElite
			{
				get
				{
					if ((Object)(object)instance == (Object)null)
					{
						return null;
					}
					return instance.leaderElite;
				}
				set
				{
					if (!((Object)(object)instance == (Object)null))
					{
						instance.leaderElite = value;
					}
				}
			}

			public abstract CycloneState cycloneState { get; }

			public abstract BaseCycloneState GetNextState();

			public override void OnEnter()
			{
				Debug.LogError((object)cycloneState.ToString());
			}

			internal void UpdateTelegraphr(bool newValue)
			{
				if (newValue != instance.telegraphActive)
				{
					instance.telegraphActive = newValue;
					if (newValue)
					{
						instance.beamPreVfxInstance = Object.Instantiate<GameObject>(WhirlwindAspect.squallPreBeamVfxPrefab);
						instance.beamPreVfxInstance.transform.SetParent(((ItemBehavior)leaderElite).body.aimOriginTransform, true);
						instance.UpdatePreBeamTransform();
						RoR2Application.onLateUpdate += instance.UpdatePreBeamTransform;
					}
					else
					{
						RoR2Application.onLateUpdate -= instance.UpdatePreBeamTransform;
						EntityState.Destroy((Object)(object)instance.beamPreVfxInstance);
						VfxKillBehavior.KillVfxObject(instance.beamPreVfxInstance);
						instance.beamPreVfxInstance = null;
					}
				}
			}

			public override void OnExit()
			{
				((EntityState)this).OnExit();
			}

			public void ElectLeader(AffixSquallBehavior candidateElite)
			{
				if (!((Object)(object)leaderElite == (Object)(object)candidateElite) && !((Object)(object)candidateElite == (Object)null))
				{
					DemoteCurrentLeaderInternal();
					((ItemBehavior)candidateElite).body.AddBuff(StormsCore.CycloneLeader);
					leaderElite = candidateElite;
					EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)leaderElite).gameObject, "Body");
					if ((Object)(object)val != (Object)null)
					{
						val.SetNextStateToMain();
					}
				}
			}

			public void DemoteCurrentLeaderInternal()
			{
				DemoteCurrentLeader();
			}

			public static bool IsAnyEliteInCyclone()
			{
				return AffixSquallBehavior.readOnlyInstancesList.Any((AffixSquallBehavior x) => ((ItemBehavior)x).body.HasBuff(StormsCore.CycloneProtection));
			}
		}

		internal class PrepareCyclone : BaseCycloneState
		{
			private float refreshCountdown = 0f;

			private float refreshInterval = 3f;

			public override CycloneState cycloneState => CycloneState.PreparingCyclone;

			public override void OnEnter()
			{
				if (Object.op_Implicit((Object)(object)instance.primaryCycloneInstance))
				{
					EntityState.Destroy((Object)(object)instance.primaryCycloneInstance);
				}
				if (instance.defaultConvergePosition.HasValue)
				{
					instance.defaultConvergePosition = null;
				}
				ResetRefreshCountdown();
				DemoteCurrentLeaderInternal();
				if (instance.accumulatedSquallTime <= 0f)
				{
					instance.accumulatedSquallTime = 0f;
					instance.accumulatedSquallCharge = 0f;
					instance.squallTimeFired = 0f;
				}
				instance.squallContributorCountHighest = 0;
				base.OnEnter();
			}

			public override void FixedUpdate()
			{
				//IL_0181: 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)
				//IL_0191: 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_01a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_028f: 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_02b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f2: 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_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0274: Unknown result type (might be due to invalid IL or missing references)
				//IL_021b: Unknown result type (might be due to invalid IL or missing references)
				((EntityState)this).FixedUpdate();
				if (!NetworkServer.active)
				{
					return;
				}
				if (instance.accumulatedSquallTime > 0f)
				{
					instance.accumulatedSquallTime -= StormsCore.squallReelectionRallyTimeLoss * Time.fixedDeltaTime;
					if (instance.accumulatedSquallTime <= 0f)
					{
						instance.accumulatedSquallTime = 0f;
						instance.accumulatedSquallCharge = 0f;
					}
				}
				if (refreshCountdown > 0f)
				{
					refreshCountdown -= Time.fixedDeltaTime;
					return;
				}
				IEnumerable<AffixSquallBehavior> source = AffixSquallBehavior.readOnlyInstancesList.Where((AffixSquallBehavior x) => (int)((ItemBehavior)x).body.teamComponent.teamIndex != 1 && !ShelterUtilsModule.IsBodySheltered(((ItemBehavior)x).body, 0f));
				int num = source.Count();
				if (source.Any((AffixSquallBehavior x) => !ShelterUtilsModule.IsBodySheltered(((ItemBehavior)x).body, 0f)))
				{
					source.Where((AffixSquallBehavior x) => !ShelterUtilsModule.IsBodySheltered(((ItemBehavior)x).body, 0f));
					num = source.Count();
				}
				else if (num <= 0)
				{
					ResetRefreshCountdown();
					return;
				}
				AffixSquallBehavior affixSquallBehavior = source.ElementAt(Random.Range(0, num - 1));
				NodeGraph nodeGraph = SceneInfo.instance.GetNodeGraph((GraphType)0);
				NodeIndex val = nodeGraph.FindClosestNode(((Component)affixSquallBehavior).transform.position, (HullClassification)2, 50f);
				Vector3 val2 = default(Vector3);
				if (!nodeGraph.GetNodePosition(val, ref val2))
				{
					return;
				}
				if (ShelterUtilsModule.IsPositionSheltered(val2, 0f))
				{
					List<NodeIndex> list = nodeGraph.FindNodesInRange(val2, 0f, StormsCore.cycloneRadius * 1.5f, (HullMask)2);
					List<Vector3> list2 = new List<Vector3>();
					Vector3 val3 = default(Vector3);
					foreach (NodeIndex item in list)
					{
						if (nodeGraph.GetNodePosition(item, ref val3) && !ShelterUtilsModule.IsPositionSheltered(val3, 0f))
						{
							list2.Add(val3);
						}
					}
					if (list2.Count <= 0)
					{
						ResetRefreshCountdown();
						return;
					}
					val2 = list2[Random.Range(0, list2.Count - 1)];
				}
				Debug.LogError((object)"Electing leader and placing cyclone");
				ElectLeader(affixSquallBehavior);
				instance.defaultConvergePosition = val2;
				if (!Tools.IsEasyMode((DifficultyIndex)0))
				{
					GameObject val4 = Object.Instantiate<GameObject>(StormsCore.cycloneWardPrefab, val2, Quaternion.identity);
					val4.GetComponent<TeamFilter>().teamIndex = (TeamIndex)(-1);
					instance.primaryCycloneInstance = val4;
					NetworkServer.Spawn(val4);
				}
				((EntityState)this).outer.SetNextState((EntityState)(object)GetNextState());
			}

			private void ResetRefreshCountdown()
			{
				refreshCountdown = refreshInterval;
			}

			public override BaseCycloneState GetNextState()
			{
				BaseCycloneState baseCycloneState = new PrepareSquall();
				(baseCycloneState as PrepareSquall).leaderEliteObject = ((Component)base.leaderElite).gameObject;
				return baseCycloneState;
			}
		}

		internal class ElectLeader : BaseCycloneState
		{
			internal float attemptElectLeaderCountdown = 0f;

			private bool shouldMoveCyclone = false;

			public override CycloneState cycloneState => CycloneState.ElectingLeader;

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

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if (!NetworkServer.active)
				{
					return;
				}
				if (attemptElectLeaderCountdown > 0f)
				{
					attemptElectLeaderCountdown -= Time.fixedDeltaTime;
					return;
				}
				if (AffixSquallBehavior.readOnlyInstancesList.Count <= 0)
				{
					GetNextState();
				}
				List<AffixSquallBehavior> list = AffixSquallBehavior.readOnlyInstancesList.Where((AffixSquallBehavior x) => (int)((ItemBehavior)x).body.teamComponent.teamIndex != 1 && ((ItemBehavior)x).body.HasBuff(StormsCore.CycloneProtection)).ToList();
				int num = list.Count();
				if (num == 0)
				{
					instance.accumulatedSquallTime -= StormsCore.squallReelectionRallyTimeLoss * StormsCore.squallReelectionInterval;
					if (instance.accumulatedSquallTime <= 0f || instance.squallContributorCountCurrent <= 0)
					{
						FizzleOut();
					}
					else
					{
						attemptElectLeaderCountdown = StormsCore.squallReelectionInterval;
					}
				}
				else
				{
					ElectLeader(list[Random.Range(0, num - 1)]);
					((EntityState)this).outer.SetNextState((EntityState)(object)GetNextState());
				}
			}

			private void FizzleOut()
			{
				instance.accumulatedSquallCharge = 0f;
				instance.accumulatedSquallTime = 0f;
				shouldMoveCyclone = true;
				((EntityState)this).outer.SetNextState((EntityState)(object)GetNextState());
			}

			public override BaseCycloneState GetNextState()
			{
				if (((Object)(object)instance.primaryCycloneInstance == (Object)null && !instance.defaultConvergePosition.HasValue) || (Object)(object)instance.leaderElite == (Object)null || shouldMoveCyclone)
				{
					return new PrepareCyclone();
				}
				BaseCycloneState baseCycloneState = new PrepareSquall();
				(baseCycloneState as PrepareSquall).leaderEliteObject = ((Component)base.leaderElite).gameObject;
				return baseCycloneState;
			}
		}

		internal class PrepareSquall : BaseCycloneState
		{
			private CycloneState nextState = CycloneState.PreparingSquall;

			public GameObject leaderEliteObject;

			private float squallTimeCache = 0f;

			public override CycloneState cycloneState => CycloneState.PreparingSquall;

			public override void OnSerialize(NetworkWriter writer)
			{
				((EntityState)this).OnSerialize(writer);
				writer.Write(leaderEliteObject);
			}

			public override void OnDeserialize(NetworkReader reader)
			{
				((EntityState)this).OnDeserialize(reader);
				leaderEliteObject = reader.ReadGameObject();
				if ((Object)(object)leaderEliteObject != (Object)null)
				{
					base.leaderElite = leaderEliteObject.GetComponent<AffixSquallBehavior>();
				}
			}

			public override void OnEnter()
			{
				base.OnEnter();
				squallTimeCache = instance.accumulatedSquallTime;
			}

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

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if (NetworkServer.active)
				{
					bool flag = ((EntityState)this).fixedAge > 1f;
					bool flag2 = ((EntityState)this).fixedAge >= StormsCore.squallRallyTimeMax + 1f;
					if ((Object)(object)base.leaderElite == (Object)null || (flag && instance.accumulatedSquallTime <= squallTimeCache) || flag2)
					{
						Log.Debug("PrepareSquall: Entering reelection");
						((EntityState)this).outer.SetNextState((EntityState)(object)GetNextState());
					}
					else if ((Object)(object)squallTargetBody == (Object)null)
					{
						instance.accumulatedSquallTime = ((instance.squallContributorCountCurrent == 0) ? 0f : (squallTimeCache + 1f));
						instance.accumulatedSquallCharge = 0f;
					}
					else if (GetSquallThresholdMet())
					{
						Log.Debug("PrepareSquall: Beginning to fire");
						((EntityState)this).outer.SetNextState((EntityState)(object)new FireSquall());
					}
				}
			}

			private bool GetSquallThresholdMet()
			{
				if (instance.accumulatedSquallTime < StormsCore.squallRallyTimeMin)
				{
					return false;
				}
				if (instance.accumulatedSquallTime >= StormsCore.squallRallyTimeMax)
				{
					return true;
				}
				float num = StormsCore.squallRallyTimeMin * StormsCore.squallRallyContributorThreshold;
				float num2 = Util.Remap(instance.accumulatedSquallCharge, 0f, num, StormsCore.squallRallyTimeMax, StormsCore.squallRallyTimeMin);
				return instance.accumulatedSquallTime >= num2;
			}

			public override BaseCycloneState GetNextState()
			{
				BaseCycloneState baseCycloneState = new ElectLeader();
				if (instance.squallContributorCountCurrent <= 0)
				{
					(baseCycloneState as ElectLeader).attemptElectLeaderCountdown = 2f;
				}
				return baseCycloneState;
			}
		}

		internal class FireSquall : BaseCycloneState
		{
			private bool resetting = false;

			public override CycloneState cycloneState => CycloneState.FiringSquall;

			public override void OnEnter()
			{
				RefreshFiringState();
				base.OnEnter();
			}

			private void RefreshFiringState()
			{
				if (!((Object)(object)base.leaderElite == (Object)null))
				{
					if (((EntityState)this).fixedAge + instance.squallTimeFired >= WhirlwindAspect.squallPreFireTime)
					{
						base.leaderElite.firingState = AffixSquallBehavior.FiringState.Firing;
						return;
					}
					base.leaderElite.firingState = AffixSquallBehavior.FiringState.Aiming;
					base.leaderElite.OnTargetUpdated();
				}
			}

			public override void FixedUpdate()
			{
				((EntityState)this).FixedUpdate();
				if ((Object)(object)base.leaderElite == (Object)null)
				{
					Log.Debug("FireSquall: Beginning reelection");
					((EntityState)this).outer.SetNextState((EntityState)(object)new ElectLeader());
					return;
				}
				if (((EntityState)this).fixedAge + instance.squallTimeFired >= WhirlwindAspect.squallPreFireTime)
				{
					RefreshFiringState();
				}
				float num = StormsCore.squallFireDurationMin + StormsCore.squallFireDurationBonusPerOverspill * (float)Tools.CountOverspillTriangular(instance.squallContributorCountHighest);
				if (((EntityState)this).fixedAge + instance.squallTimeFired >= num + WhirlwindAspect.squallPreFireTime)
				{
					Log.Debug("End squall");
					((EntityState)this).outer.SetNextState((EntityState)(object)GetNextState());
				}
			}

			public override void OnExit()
			{
				if ((Object)(object)base.leaderElite != (Object)null)
				{
					base.leaderElite.firingState = AffixSquallBehavior.FiringState.Off;
				}
				squallTargetBody = null;
				base.OnExit();
				if (!resetting)
				{
					instance.squallTimeFired = 0f;
				}
				else
				{
					instance.squallTimeFired += ((EntityState)this).fixedAge;
				}
			}

			public override BaseCycloneState GetNextState()
			{
				resetting = true;
				instance.accumulatedSquallCharge = 0f;
				instance.accumulatedSquallTime = 0f;
				return new PrepareCyclone();
			}
		}

		internal class Idle : BaseCycloneState
		{
			public override CycloneState cycloneState => CycloneState.Idle;

			public override BaseCycloneState GetNextState()
			{
				return new PrepareSquall();
			}
		}

		public static CycloneController instance;

		public GameObject beamPreVfxInstance;

		public bool telegraphActive = false;

		public EntityStateMachine cycloneStateMachine;

		public AISkillDriver HowlSquallDriver;

		public Vector3? defaultConvergePosition;

		public static CharacterBody squallTargetBody;

		public static Vector3 convergePositionGround;

		public static Vector3 convergePositionAir;

		public float accumulatedSquallCharge = 0f;

		public float accumulatedSquallTime = 0f;

		public int squallContributorCountCurrent = 0;

		public int squallContributorCountHighest = 0;

		public float squallTimeFired = 0f;

		public CycloneState cycloneState
		{
			get
			{
				if (currentState == null)
				{
					return CycloneState.Idle;
				}
				return currentState.cycloneState;
			}
		}

		private BaseCycloneState currentState => cycloneStateMachine.state as BaseCycloneState;

		public AffixSquallBehavior leaderElite { get; private set; }

		public GameObject primaryCycloneInstance { get; private set; }

		internal void UpdatePreBeamTransform()
		{
			//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)
			//IL_003c: 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)
			if (!telegraphActive)
			{
				RoR2Application.onLateUpdate -= UpdatePreBeamTransform;
				return;
			}
			Ray beamRay = leaderElite.GetBeamRay();
			beamPreVfxInstance.transform.SetPositionAndRotation(((Ray)(ref beamRay)).origin, Quaternion.LookRotation(((Ray)(ref beamRay)).direction));
		}

		public static void DemoteCurrentLeader()
		{
			squallTargetBody = null;
			if (!((Object)(object)instance != (Object)null))
			{
				return;
			}
			if ((Object)(object)instance.leaderElite != (Object)null)
			{
				instance.leaderElite.firingState = AffixSquallBehavior.FiringState.Off;
				if (((ItemBehavior)instance.leaderElite).body.HasBuff(StormsCore.CycloneLeader))
				{
					((ItemBehavior)instance.leaderElite).body.RemoveBuff(StormsCore.CycloneLeader);
				}
			}
			instance.leaderElite = null;
		}

		public static bool GetShouldConverge()
		{
			return (Object)(object)instance != (Object)null && (instance.defaultConvergePosition.HasValue || (Object)(object)instance.leaderElite != (Object)null);
		}

		public static void AddSquallCharge(float charge)
		{
			if (!((Object)(object)instance == (Object)null) && instance.cycloneState != CycloneState.FiringSquall)
			{
				instance.accumulatedSquallCharge += charge;
			}
		}

		public static void AddSquallTime(float time)
		{
			if (!((Object)(object)instance == (Object)null) && instance.cycloneState != CycloneState.FiringSquall)
			{
				instance.accumulatedSquallTime += time;
			}
		}

		public static void SetContributorCount(int count)
		{
			if (!((Object)(object)instance == (Object)null) && instance.cycloneState != CycloneState.FiringSquall)
			{
				instance.squallContributorCountCurrent = count;
				if (count > instance.squallContributorCountHighest)
				{
					instance.squallContributorCountHighest = count;
				}
			}
		}

		private void Awake()
		{
			//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)
			//IL_0047: 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)
			cycloneStateMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Cyclone");
			HowlSquallDriver = ((Component)this).gameObject.AddComponent<AISkillDriver>();
			HowlSquallDriver.aimType = (AimType)2;
			HowlSquallDriver.buttonPressType = (ButtonPressType)1;
			HowlSquallDriver.movementType = (MovementType)0;
			HowlSquallDriver.moveTargetType = (TargetType)3;
			HowlSquallDriver.activationRequiresAimConfirmation = false;
			HowlSquallDriver.activationRequiresAimTargetLoS = false;
			HowlSquallDriver.activationRequiresTargetLoS = false;
			HowlSquallDriver.aimVectorDampTimeOverride = WhirlwindAspect.squallAimDamping;
			HowlSquallDriver.aimVectorMaxSpeedOverride = WhirlwindAspect.squallAimMaxSpeed;
			HowlSquallDriver.customName = "FireSquall";
			HowlSquallDriver.driverUpdateTimerOverride = 1f;
			HowlSquallDriver.maxDistance = float.PositiveInfinity;
			HowlSquallDriver.moveInputScale = 1f;
			HowlSquallDriver.shouldFireEquipment = true;
			HowlSquallDriver.selectionRequiresAimTarget = false;
			HowlSquallDriver.selectionRequiresOnGround = false;
			HowlSquallDriver.selectionRequiresTargetLoS = false;
			HowlSquallDriver.selectionRequiresTargetNonFlier = false;
		}

		private void OnEnable()
		{
			if ((Object)(object)instance != (Object)null)
			{
				Object.Destroy((Object)(object)this);
			}
			instance = this;
		}

		private void OnDisable()
		{
			instance = null;
		}

		private void FixedUpdate()
		{
			LocateConvergePosition();
		}

		private void LocateConvergePosition()
		{
			//IL_0080: 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_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_00b2: 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_00d7: 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_00df: 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_00c3: 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)
			if (!GetShouldConverge())
			{
				return;
			}
			NodeGraph nodeGraph = SceneInfo.instance.GetNodeGraph((GraphType)1);
			NodeGraph nodeGraph2 = SceneInfo.instance.GetNodeGraph((GraphType)0);
			Vector3? val = defaultConvergePosition;
			if ((Object)(object)leaderElite != (Object)null && (Object)(object)((Component)leaderElite).gameObject != (Object)null && ((ItemBehavior)le