Decompiled source of NewMoon v2.0.1

NewMoon.dll

Decompiled 2 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.AI.Walker;
using EntityStates.Mage;
using EntityStates.Missions.BrotherEncounter;
using EntityStates.Missions.GeodeSecretMission;
using EntityStates.Missions.Moon;
using EntityStates.MoonElevator;
using HG;
using HG.Reflection;
using MoreStats;
using NewMoon.Artifacts;
using NewMoon.Components;
using NewMoon.Items;
using NewMoon.Modules;
using On.EntityStates;
using On.EntityStates.Missions.BrotherEncounter;
using On.EntityStates.Missions.GeodeSecretMission;
using On.RoR2;
using ProcSolver;
using R2API;
using R2API.Utils;
using RainrotSharedUtils;
using RainrotSharedUtils.Shelters;
using RoR2;
using RoR2.Achievements;
using RoR2.Audio;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Items;
using RoR2.Navigation;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPaths;
using RoR2BepInExPack.GameAssetPaths.Version_1_39_0;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
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: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("NewMoon")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NewMoon")]
[assembly: AssemblyTitle("NewMoon")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: UnverifiableCode]
namespace NewMoon
{
	[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.NewMoon", "NewMoon", "2.0.0")]
	public class NewMoonPlugin : BaseUnityPlugin
	{
		public static int requiredPillarCt = 2;

		public static int maxPillarCt = 4;

		public static float pillarDropOffset = 2.5f;

		public static float pillarDropForce = 20f;

		public static int baseRewardCount = 1;

		public static bool scaleRewardsByPlayerCount = true;

		private static bool isBossRush = false;

		public static SpawnCard exploderCard = Resources.Load<SpawnCard>("spawncards/characterspawncards/cscLunarExploder");

		private List<DirectorCard> exploderCards = new List<DirectorCard>();

		public static ExploderDirector exploderDirector;

		internal static float phaseTwoRate = 0f;

		internal static float phaseThreeRate = 1f;

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

		public const string teamName = "RiskOfBrainrot";

		public const string modName = "NewMoon";

		public const string version = "2.0.0";

		public static NewMoonPlugin instance;

		public static ItemTag IsMoonRelic;

		public static bool DoPillarItemDrop = false;

		public static AssetBundle mainAssetBundle => CommonAssets.mainAssetBundle;

		public static bool procSolverInstalled => Tools.isLoaded("com.RiskOfBrainrot.ProcSolver");

		internal static event Action onLoaded;

		private void MakePillarsFun()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			MoonBatteryMissionController.Awake += new hook_Awake(ReduceRequiredPillars);
			MoonBatteryMissionController.OnEnable += new hook_OnEnable(MoonBossRush);
			MoonBatteryMissionController.OnBatteryCharged += new hook_OnBatteryCharged(ChangePillarRequirement);
			GeodeSecretMissionRewardState.DropRewards += new hook_DropRewards(ReplaceGeodeSecretMissionRewards);
			NewMoonPlugin.LoadAsync<GameObject>(RoR2_Base_moon2.MoonBatteryBlood_prefab, (Action<GameObject>)delegate(GameObject ctx)
			{
				AddPillarItemDrop(ctx, PillarItemDropper.PillarType.Blood);
			});
			NewMoonPlugin.LoadAsync<GameObject>(RoR2_Base_moon2.MoonBatteryDesign_prefab, (Action<GameObject>)delegate(GameObject ctx)
			{
				AddPillarItemDrop(ctx, PillarItemDropper.PillarType.Blood);
			});
			NewMoonPlugin.LoadAsync<GameObject>(RoR2_Base_moon2.MoonBatteryMass_prefab, (Action<GameObject>)delegate(GameObject ctx)
			{
				AddPillarItemDrop(ctx, PillarItemDropper.PillarType.Blood);
			});
			NewMoonPlugin.LoadAsync<GameObject>(RoR2_Base_moon2.MoonBatterySoul_prefab, (Action<GameObject>)delegate(GameObject ctx)
			{
				AddPillarItemDrop(ctx, PillarItemDropper.PillarType.Blood);
			});
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_moon2.MoonBatteryBlood_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> ctx)
			{
				AddPillarItemDrop(ctx.Result, PillarItemDropper.PillarType.Blood);
			};
			val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_moon2.MoonBatteryDesign_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> ctx)
			{
				AddPillarItemDrop(ctx.Result, PillarItemDropper.PillarType.Design);
			};
			val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_moon2.MoonBatteryMass_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> ctx)
			{
				AddPillarItemDrop(ctx.Result, PillarItemDropper.PillarType.Mass);
			};
			val = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_moon2.MoonBatterySoul_prefab);
			val.Completed += delegate(AsyncOperationHandle<GameObject> ctx)
			{
				AddPillarItemDrop(ctx.Result, PillarItemDropper.PillarType.Soul);
			};
			static void AddPillarItemDrop(GameObject pillarPrefab, PillarItemDropper.PillarType pillarType)
			{
				PillarItemDropper pillarItemDropper = pillarPrefab.AddComponent<PillarItemDropper>();
				pillarItemDropper.pillarType = pillarType;
			}
		}

		private void MoonBossRush(orig_OnEnable orig, MoonBatteryMissionController self)
		{
			orig.Invoke(self);
			if (TeamHasRelics((TeamIndex)1) && NetworkServer.active)
			{
				isBossRush = true;
				Chat.ServerAttemptBroadcastChat(Language.Styling.MithrixStyle("The King of Nothing welcomes you...") ?? "");
				ServerUpdatePillarsAndElevators(self, wasCharged: false, hasMetRequirement: true, hasMetMax: false);
			}
		}

		private void ReplaceGeodeSecretMissionRewards(orig_DropRewards orig, GeodeSecretMissionRewardState self)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00e6: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			int participatingPlayerCount = Run.instance.participatingPlayerCount;
			if (participatingPlayerCount > 0 && Object.op_Implicit((Object)(object)((EntityState)self).gameObject) && Object.op_Implicit((Object)(object)((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.rewardDropTable))
			{
				int num = ((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.numberOfRewardsSpawned;
				if (((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.increaseRewardPerPlayer)
				{
					num *= participatingPlayerCount;
				}
				float num2 = 360f / (float)num;
				Vector3 val = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * 40f + Vector3.forward * 5f);
				Quaternion val2 = Quaternion.AngleAxis(num2, Vector3.up);
				Vector3 position = ((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.rewardSpawnLocation.transform.position;
				int num3 = 0;
				while (num3 < num)
				{
					CreatePickupInfo val3 = default(CreatePickupInfo);
					((CreatePickupInfo)(ref val3)).pickupIndex = PickupCatalog.FindPickupIndex(((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.rewardDisplayTier);
					val3.pickerOptions = (Option[])(object)new Option[4]
					{
						TPkp(ItemBase<MassAnomaly>.instance.ItemsDef),
						TPkp(ItemBase<DesignAnomaly>.instance.ItemsDef),
						TPkp(ItemBase<BloodAnomaly>.instance.ItemsDef),
						TPkp(ItemBase<SoulAnomaly>.instance.ItemsDef)
					};
					val3.rotation = Quaternion.identity;
					val3.prefabOverride = ((GeodeSecretMissionEntityStates)self).geodeSecretMissionController.rewardPrefab;
					PickupDropletController.CreatePickupDroplet(val3, position, val);
					num3++;
					val = val2 * val;
				}
			}
			static Option TPkp(ItemDef itemDef)
			{
				//IL_0003: 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_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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)
				return new Option
				{
					available = true,
					pickup = new UniquePickup
					{
						pickupIndex = PickupCatalog.itemIndexToPickupIndex[itemDef.itemIndex]
					}
				};
			}
		}

		private void ServerUpdatePillarsAndElevators(MoonBatteryMissionController self, bool wasCharged, bool hasMetRequirement, bool hasMetMax)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			if (!hasMetRequirement)
			{
				return;
			}
			if (!wasCharged)
			{
				Chat.ServerAttemptBroadcastChat(Language.Styling.MithrixStyle("A path forward is cleared...") ?? "");
			}
			for (int i = 0; i < self.elevatorStateMachines.Length; i++)
			{
				self.elevatorStateMachines[i].SetNextState((EntityState)new InactiveToReady());
			}
			if (!hasMetMax)
			{
				return;
			}
			for (int j = 0; j < self.batteryHoldoutZones.Length; j++)
			{
				if (((Behaviour)self.batteryHoldoutZones[j]).enabled)
				{
					self.batteryHoldoutZones[j].FullyChargeHoldoutZone();
					((UnityEvent<HoldoutZoneController>)(object)self.batteryHoldoutZones[j].onCharged).RemoveListener((UnityAction<HoldoutZoneController>)self.OnBatteryCharged);
				}
			}
			self.batteryHoldoutZones = (HoldoutZoneController[])(object)new HoldoutZoneController[0];
			for (int k = 0; k < self.batteryStateMachines.Length; k++)
			{
				if (!(self.batteryStateMachines[k].state is MoonBatteryComplete))
				{
					self.batteryStateMachines[k].SetNextState((EntityState)new MoonBatteryDisabled());
				}
			}
		}

		private void ChangePillarRequirement(orig_OnBatteryCharged orig, MoonBatteryMissionController self, HoldoutZoneController holdoutZone)
		{
			int num = requiredPillarCt;
			int num2 = maxPillarCt;
			if (isBossRush)
			{
				num = 0;
				num2 -= requiredPillarCt;
			}
			bool wasCharged = self._numChargedBatteries >= requiredPillarCt;
			if ((Object)(object)holdoutZone != (Object)null)
			{
				self.Network_numChargedBatteries = self._numChargedBatteries + 1;
			}
			if (NetworkServer.active)
			{
				ServerUpdatePillarsAndElevators(self, wasCharged, self._numChargedBatteries >= num, self._numChargedBatteries >= num2);
			}
		}

		private void ReduceRequiredPillars(orig_Awake orig, MoonBatteryMissionController self)
		{
			isBossRush = false;
			orig.Invoke(self);
			GameObject[] moonBatteries = self.moonBatteries;
			foreach (GameObject val in moonBatteries)
			{
				PillarItemDropper pillarItemDropper = val.GetComponent<PillarItemDropper>();
				if (!Object.op_Implicit((Object)(object)pillarItemDropper))
				{
					pillarItemDropper = val.AddComponent<PillarItemDropper>();
					PillarItemDropper.PillarType pillarType = PillarItemDropper.PillarType.None;
					string name = ((Object)val).name;
					switch (name.Substring(11, 4))
					{
					case "Mass":
						pillarType = PillarItemDropper.PillarType.Mass;
						break;
					case "Desi":
						pillarType = PillarItemDropper.PillarType.Design;
						break;
					case "Bloo":
						pillarType = PillarItemDropper.PillarType.Blood;
						break;
					case "Soul":
						pillarType = PillarItemDropper.PillarType.Soul;
						break;
					}
					pillarItemDropper.pillarType = pillarType;
				}
				pillarItemDropper.shouldDropItem = true;
			}
		}

		private void PillarsDropItems(orig_OnBatteryCharged orig, MoonBatteryMissionController self, HoldoutZoneController holdoutZone)
		{
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			int participatingPlayerCount = Run.instance.participatingPlayerCount;
			if (participatingPlayerCount != 0)
			{
				DropPillarItemFromHoldout(holdoutZone, participatingPlayerCount);
			}
			self.Network_numChargedBatteries = self._numChargedBatteries + 1;
			if (self._numChargedBatteries < self._numRequiredBatteries || !NetworkServer.active)
			{
				return;
			}
			for (int i = 0; i < self.batteryHoldoutZones.Length; i++)
			{
				if (((Behaviour)self.batteryHoldoutZones[i]).enabled)
				{
					self.batteryHoldoutZones[i].FullyChargeHoldoutZone();
					((UnityEvent<HoldoutZoneController>)(object)self.batteryHoldoutZones[i].onCharged).RemoveListener((UnityAction<HoldoutZoneController>)self.OnBatteryCharged);
				}
			}
			for (int j = 0; j < self.elevatorStateMachines.Length; j++)
			{
				self.elevatorStateMachines[j].SetNextState((EntityState)new InactiveToReady());
			}
		}

		public static void DropPillarItemFromHoldout(HoldoutZoneController holdoutZone)
		{
			Log.Warning(((Object)((Component)holdoutZone).gameObject).name + "3");
			DropPillarItemFromHoldout(holdoutZone, Object.op_Implicit((Object)(object)Run.instance) ? Run.instance.participatingPlayerCount : 0);
		}

		public static void DropPillarItemFromHoldout(HoldoutZoneController holdoutZone, int participatingPlayerCount)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			Log.Warning(((Object)((Component)holdoutZone).gameObject).name + "4");
			if (participatingPlayerCount == 0)
			{
				return;
			}
			Vector3 val = ((Component)holdoutZone).gameObject.transform.position + Vector3.up * pillarDropOffset;
			PickupIndex pickupIndexFromPillarType = GetPickupIndexFromPillarType(((Component)holdoutZone).gameObject);
			if (pickupIndexFromPillarType != PickupIndex.none)
			{
				Log.Warning(((Object)((Component)holdoutZone).gameObject).name + "5");
				int num = baseRewardCount;
				if (scaleRewardsByPlayerCount)
				{
					num *= participatingPlayerCount;
				}
				float num2 = 360f / (float)num;
				Vector3 val2 = Quaternion.AngleAxis((float)Random.Range(0, 360), Vector3.up) * (Vector3.up * pillarDropForce + Vector3.forward * 5f);
				Quaternion val3 = Quaternion.AngleAxis(num2, Vector3.up);
				int num3 = 0;
				while (num3 < num)
				{
					Log.Warning(((Object)((Component)holdoutZone).gameObject).name + "6");
					PickupDropletController.CreatePickupDroplet(new UniquePickup(pickupIndexFromPillarType), val, val2, false);
					num3++;
					val2 = val3 * val2;
				}
			}
		}

		public static PickupIndex GetPickupIndexFromPillarType(GameObject pillar)
		{
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			ItemBase itemBase = null;
			string name = ((Object)pillar).name;
			switch (name.Substring(11, 4))
			{
			case "Mass":
				itemBase = ItemBase<MassAnomaly>.instance;
				break;
			case "Desi":
				itemBase = ItemBase<DesignAnomaly>.instance;
				break;
			case "Bloo":
				itemBase = ItemBase<BloodAnomaly>.instance;
				break;
			case "Soul":
				itemBase = ItemBase<SoulAnomaly>.instance;
				break;
			}
			if (itemBase != null)
			{
				ItemIndex itemIndex = itemBase.ItemsDef.itemIndex;
				return PickupCatalog.FindPickupIndex(itemIndex);
			}
			Debug.Log((object)"No pickup index found!");
			return PickupIndex.none;
		}

		public void LunarExplodersDuringBrother()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Phase1.OnEnter += new hook_OnEnter(InitializeExploderDirector);
			Phase2.OnEnter += new hook_OnEnter(DisableExploderDirector);
			Phase3.OnEnter += new hook_OnEnter(RestoreExploderDirector);
			Phase4.OnEnter += new hook_OnEnter(KillExploderDirector);
		}

		private void GetExploderCard(List<DirectorCardHolder> cardList, StageInfo currentStage)
		{
			//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_0017: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			Debug.Log((object)"jsd fjsn");
			if ((int)currentStage.stage != 65536)
			{
				return;
			}
			List<DirectorCardHolder> list = new List<DirectorCardHolder>();
			foreach (DirectorCardHolder card2 in cardList)
			{
				if ((int)card2.MonsterCategory == 2)
				{
					DirectorCard card = card2.Card;
					SpawnCard spawnCard = card.spawnCard;
					GameObject prefab = spawnCard.prefab;
					if (((Object)spawnCard).name == "cscLunarExploder")
					{
						exploderCards.Add(card);
					}
				}
			}
			foreach (DirectorCardHolder item in list)
			{
				cardList.Remove(item);
			}
		}

		private void InitializeExploderDirector(orig_OnEnter orig, Phase1 self)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if ((Object)(object)exploderDirector == (Object)null)
			{
				GameObject val = new GameObject("CommencementPerfected_ChimeraExploderDirector_OrTheCPCEDForShort");
				val.transform.position = new Vector3(-88f, 491.1f, 0f);
				exploderDirector = val.AddComponent<ExploderDirector>();
				exploderDirector.baseState = (BrotherEncounterBaseState)(object)self;
			}
		}

		private void DisableExploderDirector(orig_OnEnter orig, Phase2 self)
		{
			orig.Invoke(self);
			exploderDirector.SetDirectorRate(phaseTwoRate);
		}

		private void RestoreExploderDirector(orig_OnEnter orig, Phase3 self)
		{
			orig.Invoke(self);
			exploderDirector.SetDirectorRate(phaseThreeRate);
		}

		private void KillExploderDirector(orig_OnEnter orig, Phase4 self)
		{
			orig.Invoke(self);
			Object.Destroy((Object)(object)((Component)exploderDirector).gameObject);
		}

		public static bool TeamHasRelics(TeamIndex teamIndex)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!DoPillarItemDrop)
			{
				return false;
			}
			int num = 0;
			ReadOnlyCollection<CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
			int num2 = 0;
			int num3 = 0;
			int count = readOnlyInstancesList.Count;
			while (num2 < count)
			{
				CharacterMaster val = readOnlyInstancesList[num2];
				if (val.teamIndex == teamIndex && Object.op_Implicit((Object)(object)val.playerCharacterMasterController) && val.playerCharacterMasterController.isConnected)
				{
					num3++;
					num += val.inventory.GetItemCountEffective(ItemBase<SoulAnomaly>.instance.ItemsDef) + val.inventory.GetItemCountEffective(ItemBase<BloodAnomaly>.instance.ItemsDef) + val.inventory.GetItemCountEffective(ItemBase<DesignAnomaly>.instance.ItemsDef) + val.inventory.GetItemCountEffective(ItemBase<MassAnomaly>.instance.ItemsDef);
				}
				num2++;
				Debug.Log((object)("relics: " + num));
				if (num >= num3)
				{
					return true;
				}
			}
			return false;
		}

		public static float GetProcRate(DamageInfo damageInfo)
		{
			if (damageInfo.procCoefficient <= 0f || !procSolverInstalled)
			{
				return damageInfo.procCoefficient;
			}
			return _GetProcRate(damageInfo);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static float _GetProcRate(DamageInfo damageInfo)
		{
			return ProcSolverPlugin.GetProcRateMod(damageInfo);
		}

		private void Awake()
		{
			//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)
			instance = this;
			Config.Init();
			Log.Init(((BaseUnityPlugin)this).Logger);
			IsMoonRelic = ItemAPI.AddItemTag("IsMoonRelic");
			Language.Init();
			Hooks.Init();
			CommonAssets.Init();
			EliteModule.Init();
			DoPillarItemDrop = GetConfigBool(defaultValue: true, "Global : Endgame Items", "Setting to TRUE will enable the Moon Relic items, which drop from pillars, and all features that rely on these items.");
			if (DoPillarItemDrop)
			{
				MakePillarsFun();
			}
			if (GetConfigBool(defaultValue: true, "Global : Mithrix : Lunar Exploders Spawn On Ramps", "Setting to TRUE will cause Lunar Exploders to spawn on arena ramps during the fight."))
			{
				LunarExplodersDuringBrother();
			}
			InitializeContent();
			NewMoonPlugin.onLoaded();
			Config.Save();
			new ContentPacks().Initialize();
		}

		private void InitializeContent()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			BeginInitializing<ItemBase>(types, "NewMoonItems.txt");
			BeginInitializing<ArtifactBase>(types, "NewMoonArtifacts.txt");
		}

		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 = NewMoonPlugin.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)
		{
			NewMoonPlugin.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 class Log
	{
		public static bool enableDebugging;

		internal static ManualLogSource _logSource;

		public static void DebugBreakpoint(string methodName, int breakpointNumber = -1)
		{
			string text = "NewMoon: " + 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 = "NewMoon : ";
			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();
			NewMoonPlugin.onLoaded += 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 class ExploderDirector : MonoBehaviour
	{
		internal BrotherEncounterBaseState baseState;

		private bool isActive = false;

		private static float baseSpawnFrequency = 20f;

		private static float spawnRateModifier = 1f;

		private float spawnFrequency;

		private float exploderSpawnTimer = 0f;

		public const float rampHeight = 524.3f;

		public List<ExploderSpawnNode> SpawnNodes = new List<ExploderSpawnNode>();

		public void SetDirectorRate(float rate)
		{
			if (rate <= 0f)
			{
				exploderSpawnTimer = 0f;
				spawnRateModifier = 0f;
				isActive = false;
			}
			else
			{
				isActive = true;
				spawnRateModifier = rate;
				spawnFrequency = baseSpawnFrequency / spawnRateModifier;
			}
		}

		private void Start()
		{
			if (baseState != null)
			{
				CreateSpawnNodes();
				SetDirectorRate(1f);
				isActive = true;
			}
			else
			{
				Object.Destroy((Object)(object)this);
			}
		}

		private void CreateSpawnNodes()
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				Vector3[] array = (Vector3[])(object)new Vector3[4]
				{
					new Vector3(65f, 524.3f, 155f),
					new Vector3(65f, 524.3f, -145f),
					new Vector3(-240f, 524.3f, 155f),
					new Vector3(-240f, 524.3f, -145f)
				};
				for (int i = 0; i < array.Length; i++)
				{
					GameObject val = new GameObject($"CommencementPerfected_ExploderSpawnNode_{i}");
					val.transform.position = array[i];
					val.transform.parent = ((Component)this).transform;
					ExploderSpawnNode item = val.AddComponent<ExploderSpawnNode>();
					SpawnNodes.Add(item);
				}
			}
		}

		private void FixedUpdate()
		{
			if (NetworkServer.active && spawnFrequency != 0f)
			{
				exploderSpawnTimer += Time.fixedDeltaTime * spawnRateModifier;
				while (exploderSpawnTimer > spawnFrequency)
				{
					exploderSpawnTimer -= spawnFrequency;
					List<CharacterMaster> list = new List<CharacterMaster>();
					foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
					{
						if (instance.body.healthComponent.alive)
						{
							list.Add(instance.master);
						}
					}
					StartExploderWaveStacked(list.Count, list);
				}
			}
			else
			{
				Debug.Log((object)"uuu");
			}
			if (((EntityState)baseState).outer.destroying)
			{
				SetDirectorRate(0f);
				Debug.Log((object)"Destroying Exploder Director! Ahhhhhh!!!!!!");
				Object.Destroy((Object)(object)this);
			}
		}

		private void StartExploderWaveStacked(int spawnCount, List<CharacterMaster> playersList)
		{
			//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_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)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < playersList.Count; i++)
			{
				CharacterMaster val = playersList[i];
				Vector3 position = val.GetBody().transform.position;
				float num = float.PositiveInfinity;
				ExploderSpawnNode exploderSpawnNode = null;
				foreach (ExploderSpawnNode spawnNode in SpawnNodes)
				{
					float num2 = Vector3.Distance(((Component)spawnNode).transform.position, position);
					Vector2 zero = Vector2.zero;
					if (num2 < num)
					{
						exploderSpawnNode = spawnNode;
						num = num2;
					}
				}
				int num3 = playersList.Count - i;
				int num4 = spawnCount / num3;
				if (spawnCount % num3 != 0)
				{
					num4 = Mathf.CeilToInt((float)num4);
				}
				if ((Object)(object)exploderSpawnNode != (Object)null && num4 > 0)
				{
					exploderSpawnNode.QueueSpawns(num4);
				}
			}
		}

		private void StartExploderWaveDispersed(int spawnCount, List<CharacterMaster> playersList, Vector2 searchRange)
		{
			//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_000f: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if (searchRange.x >= searchRange.y && searchRange.y != 0f)
			{
				StartExploderWaveStacked(spawnCount, playersList);
				return;
			}
			for (int i = 0; i < playersList.Count; i++)
			{
				CharacterMaster val = playersList[i];
				float num = float.PositiveInfinity;
				ExploderSpawnNode exploderSpawnNode = null;
				foreach (ExploderSpawnNode spawnNode in SpawnNodes)
				{
					if ((float)spawnNode.spawnQueue <= searchRange.y)
					{
						float num2 = Vector3.Distance(((Component)spawnNode).transform.position, ((Component)val).transform.position);
						if (num2 < num)
						{
							exploderSpawnNode = spawnNode;
							num = num2;
						}
					}
					else
					{
						if (searchRange.x < (float)spawnNode.spawnQueue)
						{
							searchRange.x = searchRange.y;
						}
						searchRange.y = spawnNode.spawnQueue;
					}
				}
				int num3 = playersList.Count - i;
				int num4 = spawnCount / num3;
				if (spawnCount % num3 != 0)
				{
					num4 = Mathf.CeilToInt((float)num4);
				}
				if ((Object)(object)exploderSpawnNode != (Object)null && num4 > 0)
				{
					exploderSpawnNode.QueueSpawns(num4);
				}
			}
		}
	}
	public class ExploderSpawnNode : MonoBehaviour
	{
		internal int spawnQueue = 0;

		private static float spawnInterval = 1f;

		private float spawnTimer = 0f;

		private void Start()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			spawnQueue = 0;
			Debug.Log((object)((Component)this).transform.position);
		}

		public void QueueSpawns(int spawnCount, float delay = 0f)
		{
			spawnQueue += spawnCount;
			spawnTimer = 0f - delay;
		}

		private void FixedUpdate()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			if (spawnQueue > 0)
			{
				spawnTimer += Time.fixedDeltaTime;
				while (spawnTimer > spawnInterval && spawnQueue > 0)
				{
					spawnTimer -= spawnInterval;
					spawnQueue--;
					Debug.Log((object)$"Spawn {((Object)NewMoonPlugin.exploderCard).name} at position {((Component)this).transform.position}!. Remaining queue: {spawnQueue}");
					DirectorSpawnRequest val = new DirectorSpawnRequest(NewMoonPlugin.exploderCard, new DirectorPlacementRule
					{
						placementMode = (PlacementMode)1,
						minDistance = 0f,
						maxDistance = 10f,
						spawnOnTarget = ((Component)this).transform
					}, RoR2Application.rng);
					val.teamIndexOverride = (TeamIndex)2;
					val.ignoreTeamMemberLimit = true;
					DirectorCore instance = DirectorCore.instance;
					if ((Object)(object)instance == (Object)null)
					{
						break;
					}
					instance.TrySpawnObject(val);
				}
			}
			else
			{
				spawnTimer = 0f;
			}
		}
	}
	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 string AsPercent(this float d)
		{
			return d * 100f + "%";
		}

		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 + "%";
		}

		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;
		}

		public static RecipeIngredient[] GetAllBossKeyIngredients()
		{
			return GetAllIngredientsWithTags((ItemTag[])(object)new ItemTag[1] { (ItemTag)26 }, (ItemTag[])(object)new ItemTag[0], 4, 4);
		}

		public static RecipeIngredient[] GetAllIngredientsWithTags(ItemTag[] required, ItemTag[] forbidden, int minTier = 1, int maxTier = 3)
		{
			//IL_000d: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			List<RecipeIngredient> list = new List<RecipeIngredient>();
			for (int i = minTier; i <= maxTier; i++)
			{
				ItemTier itemTier = (ItemTier)0;
				switch (i)
				{
				case 1:
					itemTier = (ItemTier)0;
					break;
				case 2:
					itemTier = (ItemTier)1;
					break;
				case 3:
					itemTier = (ItemTier)2;
					break;
				case 4:
					itemTier = (ItemTier)4;
					break;
				case 5:
					itemTier = (ItemTier)10;
					break;
				}
				RecipeIngredient val = new RecipeIngredient();
				val.requiredTags = required;
				val.forbiddenTags = forbidden;
				val.type = (IngredientTypeIndex)1;
				val.itemTier = itemTier;
				list.Add(val);
			}
			return list.ToArray();
		}
	}
}
namespace NewMoon.Modules
{
	public static class CommonAssets
	{
		private static AssetBundle _mainAssetBundle;

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

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

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

		public static AssetBundle mainAssetBundle
		{
			get
			{
				if ((Object)(object)_mainAssetBundle == (Object)null)
				{
					_mainAssetBundle = Assets.LoadAssetBundle("fruityendings");
				}
				return _mainAssetBundle;
			}
			set
			{
				_mainAssetBundle = value;
			}
		}

		public static void Init()
		{
		}
	}
	public class CustomRendererInfo
	{
		public string childName;

		public Material material = null;

		public bool dontHotpoo = false;

		public bool ignoreOverlays = false;
	}
	internal static class Assets
	{
		internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();

		internal static AssetBundle LoadAssetBundle(string bundleName)
		{
			if (loadedBundles.ContainsKey(bundleName))
			{
				return loadedBundles[bundleName];
			}
			AssetBundle val = null;
			val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)NewMoonPlugin.instance).Info.Location), bundleName));
			loadedBundles[bundleName] = val;
			return val;
		}

		internal static GameObject CloneTracer(string originalTracerName, string newTracerName)
		{
			if ((Object)(object)LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName) == (Object)null)
			{
				return null;
			}
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/Tracers/" + originalTracerName), newTracerName, true);
			if (!Object.op_Implicit((Object)(object)val.GetComponent<EffectComponent>()))
			{
				val.AddComponent<EffectComponent>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<VFXAttributes>()))
			{
				val.AddComponent<VFXAttributes>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			val.GetComponent<Tracer>().speed = 250f;
			val.GetComponent<Tracer>().length = 50f;
			Content.CreateAndAddEffectDef(val);
			return val;
		}

		internal static void ConvertAllRenderersToHopooShader(GameObject objectToConvert)
		{
			if (!Object.op_Implicit((Object)(object)objectToConvert))
			{
				return;
			}
			MeshRenderer[] componentsInChildren = objectToConvert.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val in componentsInChildren)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Renderer)val).sharedMaterial))
				{
					((Renderer)val).sharedMaterial.ConvertDefaultShaderToHopoo();
				}
			}
			SkinnedMeshRenderer[] componentsInChildren2 = objectToConvert.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
			{
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Renderer)val2).sharedMaterial))
				{
					((Renderer)val2).sharedMaterial.ConvertDefaultShaderToHopoo();
				}
			}
		}

		internal static GameObject LoadCrosshair(string crosshairName)
		{
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/" + crosshairName + "Crosshair");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("could not load crosshair with the name " + crosshairName + ". defaulting to Standard");
				return LegacyResourcesAPI.Load<GameObject>("Prefabs/Crosshair/StandardCrosshair");
			}
			return val;
		}

		internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, bool parentToTransform)
		{
			return assetBundle.LoadEffect(resourceName, "", parentToTransform);
		}

		internal static GameObject LoadEffect(this AssetBundle assetBundle, string resourceName, string soundName = "", bool parentToTransform = false)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assetBundle.LoadAsset<GameObject>(resourceName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.ErrorAssetBundle(resourceName, ((Object)assetBundle).name);
				return null;
			}
			val.AddComponent<DestroyOnTimer>().duration = 12f;
			val.AddComponent<NetworkIdentity>();
			val.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
			EffectComponent val2 = val.AddComponent<EffectComponent>();
			val2.applyScale = false;
			val2.effectIndex = (EffectIndex)(-1);
			val2.parentToReferencedTransform = parentToTransform;
			val2.positionAtReferencedTransform = true;
			val2.soundName = soundName;
			Content.CreateAndAddEffectDef(val);
			return val;
		}

		internal static GameObject CreateProjectileGhostPrefab(this AssetBundle assetBundle, string ghostName)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(ghostName);
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Failed to load ghost prefab " + ghostName);
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<ProjectileGhostController>()))
			{
				val.AddComponent<ProjectileGhostController>();
			}
			ConvertAllRenderersToHopooShader(val);
			return val;
		}

		internal static GameObject CreateProjectileGhostPrefab(GameObject ghostObject, string newName)
		{
			if ((Object)(object)ghostObject == (Object)null)
			{
				Log.Error("Failed to load ghost prefab " + ((Object)ghostObject).name);
			}
			GameObject val = PrefabAPI.InstantiateClone(ghostObject, newName);
			if (!Object.op_Implicit((Object)(object)val.GetComponent<NetworkIdentity>()))
			{
				val.AddComponent<NetworkIdentity>();
			}
			if (!Object.op_Implicit((Object)(object)val.GetComponent<ProjectileGhostController>()))
			{
				val.AddComponent<ProjectileGhostController>();
			}
			return val;
		}

		internal static GameObject CloneProjectilePrefab(string prefabName, string newPrefabName)
		{
			return PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/" + prefabName), newPrefabName);
		}

		internal static GameObject LoadAndAddProjectilePrefab(this AssetBundle assetBundle, string newPrefabName)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(newPrefabName);
			if ((Object)(object)val == (Object)null)
			{
				Log.ErrorAssetBundle(newPrefabName, ((Object)assetBundle).name);
				return null;
			}
			Content.AddProjectilePrefab(val);
			return val;
		}
	}
	internal static class Prefabs
	{
		private static PhysicMaterial ragdollMaterial;

		public static GameObject CreateDisplayPrefab(AssetBundle assetBundle, string displayPrefabName, GameObject prefab)
		{
			GameObject val = assetBundle.LoadAsset<GameObject>(displayPrefabName);
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("could not load display prefab " + displayPrefabName + ". Make sure this prefab exists in assetbundle " + ((Object)assetBundle).name);
				return null;
			}
			CharacterModel val2 = val.GetComponent<CharacterModel>();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				val2 = val.AddComponent<CharacterModel>();
			}
			val2.baseRendererInfos = prefab.GetComponentInChildren<CharacterModel>().baseRendererInfos;
			Assets.ConvertAllRenderersToHopooShader(val);
			return val;
		}

		public static CharacterModel SetupCharacterModel(GameObject bodyPrefab, CustomRendererInfo[] customInfos = null)
		{
			CharacterModel val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.GetComponent<CharacterModel>();
			bool flag = (Object)(object)val != (Object)null;
			if (!flag)
			{
				val = ((Component)bodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject.AddComponent<CharacterModel>();
			}
			val.body = bodyPrefab.GetComponent<CharacterBody>();
			val.autoPopulateLightInfos = true;
			val.invisibilityCount = 0;
			val.temporaryOverlays = new List<TemporaryOverlayInstance>();
			if (!flag)
			{
				SetupCustomRendererInfos(val, customInfos);
			}
			else
			{
				SetupPreAttachedRendererInfos(val);
			}
			SetupHurtboxGroup(bodyPrefab, ((Component)val).gameObject);
			SetupAimAnimator(bodyPrefab, ((Component)val).gameObject);
			SetupFootstepController(((Component)val).gameObject);
			SetupRagdoll(((Component)val).gameObject);
			return val;
		}

		public static void SetupPreAttachedRendererInfos(CharacterModel characterModel)
		{
			for (int i = 0; i < characterModel.baseRendererInfos.Length; i++)
			{
				if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null)
				{
					characterModel.baseRendererInfos[i].defaultMaterial = characterModel.baseRendererInfos[i].renderer.sharedMaterial;
				}
				if ((Object)(object)characterModel.baseRendererInfos[i].defaultMaterial == (Object)null)
				{
					Log.Error($"no material for rendererinfo of this renderer: {characterModel.baseRendererInfos[i].renderer}");
				}
				characterModel.baseRendererInfos[i].defaultMaterial.ConvertDefaultShaderToHopoo();
			}
		}

		public static void SetupCustomRendererInfos(CharacterModel characterModel, CustomRendererInfo[] customInfos)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			ChildLocator component = ((Component)characterModel).GetComponent<ChildLocator>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				Log.Error("Failed CharacterModel setup: ChildLocator component does not exist on the model");
				return;
			}
			List<RendererInfo> list = new List<RendererInfo>();
			for (int i = 0; i < customInfos.Length; i++)
			{
				if (!Object.op_Implicit((Object)(object)component.FindChild(customInfos[i].childName)))
				{
					Log.Error("Trying to add a RendererInfo for a renderer that does not exist: " + customInfos[i].childName);
					continue;
				}
				Renderer component2 = ((Component)component.FindChild(customInfos[i].childName)).GetComponent<Renderer>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Material val = customInfos[i].material;
					if ((Object)(object)val == (Object)null)
					{
						val = ((!customInfos[i].dontHotpoo) ? component2.sharedMaterial.ConvertDefaultShaderToHopoo() : component2.sharedMaterial);
					}
					list.Add(new RendererInfo
					{
						renderer = component2,
						defaultMaterial = val,
						ignoreOverlays = customInfos[i].ignoreOverlays,
						defaultShadowCastingMode = (ShadowCastingMode)1
					});
				}
			}
			characterModel.baseRendererInfos = list.ToArray();
		}

		private static void SetupHurtboxGroup(GameObject bodyPrefab, GameObject model)
		{
			SetupMainHurtboxesFromChildLocator(bodyPrefab, model);
			SetHurtboxesHealthComponents(bodyPrefab);
		}

		private static void SetupMainHurtboxesFromChildLocator(GameObject bodyPrefab, GameObject model)
		{
			//IL_011e: 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)
			if ((Object)(object)bodyPrefab.GetComponent<HurtBoxGroup>() != (Object)null)
			{
				Log.Debug("Hitboxgroup already exists on model prefab. aborting code setup");
				return;
			}
			ChildLocator component = model.GetComponent<ChildLocator>();
			if (!Object.op_Implicit((Object)(object)component.FindChild("MainHurtbox")))
			{
				Log.Error("Could not set up main hurtbox: make sure you have a transform pair in your prefab's ChildLocator called 'MainHurtbox'");
				return;
			}
			HurtBoxGroup val = model.AddComponent<HurtBoxGroup>();
			HurtBox val2 = null;
			GameObject val3 = component.FindChildGameObject("HeadHurtbox");
			if (Object.op_Implicit((Object)(object)val3))
			{
				Log.Debug("HeadHurtboxFound. Setting up");
				val2 = val3.AddComponent<HurtBox>();
				((Component)val2).gameObject.layer = LayerIndex.entityPrecise.intVal;
				val2.healthComponent = bodyPrefab.GetComponent<HealthComponent>();
				val2.isBullseye = false;
				val2.isSniperTarget = true;
				val2.damageModifier = (DamageModifier)0;
				val2.hurtBoxGroup = val;
				val2.indexInGroup = 1;
			}
			HurtBox val4 = component.FindChildGameObject("MainHurtbox").AddComponent<HurtBox>();
			((Component)val4).gameObject.layer = LayerIndex.entityPrecise.intVal;
			val4.healthComponent = bodyPrefab.GetComponent<HealthComponent>();
			val4.isBullseye = true;
			val4.isSniperTarget = (Object)(object)val2 == (Object)null;
			val4.damageModifier = (DamageModifier)0;
			val4.hurtBoxGroup = val;
			val4.indexInGroup = 0;
			if (Object.op_Implicit((Object)(object)val2))
			{
				val.hurtBoxes = (HurtBox[])(object)new HurtBox[2] { val4, val2 };
			}
			else
			{
				val.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val4 };
			}
			val.mainHurtBox = val4;
			val.bullseyeCount = 1;
		}

		public static void SetHurtboxesHealthComponents(GameObject bodyPrefab)
		{
			HealthComponent component = bodyPrefab.GetComponent<HealthComponent>();
			HurtBoxGroup[] componentsInChildren = bodyPrefab.GetComponentsInChildren<HurtBoxGroup>();
			foreach (HurtBoxGroup val in componentsInChildren)
			{
				val.mainHurtBox.healthComponent = component;
				for (int j = 0; j < val.hurtBoxes.Length; j++)
				{
					val.hurtBoxes[j].healthComponent = component;
				}
			}
		}

		private static void SetupFootstepController(GameObject model)
		{
			FootstepHandler val = model.AddComponent<FootstepHandler>();
			val.baseFootstepString = "Play_player_footstep";
			val.sprintFootstepOverrideString = "";
			val.enableFootstepDust = true;
			val.footstepDustPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/GenericFootstepDust");
		}

		private static void SetupRagdoll(GameObject model)
		{
			RagdollController component = model.GetComponent<RagdollController>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			if ((Object)(object)ragdollMaterial == (Object)null)
			{
				ragdollMaterial = ((Component)LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterBodies/CommandoBody").GetComponentInChildren<RagdollController>().bones[1]).GetComponent<Collider>().material;
			}
			Transform[] bones = component.bones;
			foreach (Transform val in bones)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Component)val).gameObject.layer = LayerIndex.ragdoll.intVal;
					Collider component2 = ((Component)val).GetComponent<Collider>();
					if (Object.op_Implicit((Object)(object)component2))
					{
						component2.sharedMaterial = ragdollMaterial;
					}
					else
					{
						Log.Error($"Ragdoll bone {((Component)val).gameObject} doesn't have a collider. Ragdoll will break.");
					}
				}
			}
		}

		private static void SetupAimAnimator(GameObject prefab, GameObject model)
		{
			AimAnimator val = model.AddComponent<AimAnimator>();
			val.directionComponent = prefab.GetComponent<CharacterDirection>();
			val.pitchRangeMax = 60f;
			val.pitchRangeMin = -60f;
			val.yawRangeMin = -80f;
			val.yawRangeMax = 80f;
			val.pitchGiveupRange = 30f;
			val.yawGiveupRange = 10f;
			val.giveupDuration = 3f;
			val.inputBank = prefab.GetComponent<InputBankTest>();
		}

		public static void CreateGenericDoppelganger(GameObject bodyPrefab, string masterName, string masterToCopy)
		{
			CloneDopplegangerMaster(bodyPrefab, masterName, masterToCopy);
		}

		public static GameObject CloneDopplegangerMaster(GameObject bodyPrefab, string masterName, string masterToCopy)
		{
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/" + masterToCopy + "MonsterMaster"), masterName, true);
			val.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab;
			Content.AddMasterPrefab(val);
			return val;
		}

		public static GameObject CreateBlankMasterPrefab(GameObject bodyPrefab, string masterName)
		{
			GameObject val = PrefabAPI.InstantiateClone(LegacyResourcesAPI.Load<GameObject>("Prefabs/CharacterMasters/CommandoMonsterMaster"), masterName, true);
			ContentPacks.masterPrefabs.Add(val);
			CharacterMaster component = val.GetComponent<CharacterMaster>();
			component.bodyPrefab = bodyPrefab;
			AISkillDriver[] components = val.GetComponents<AISkillDriver>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)(object)components[i]);
			}
			return val;
		}

		public static GameObject LoadMaster(this AssetBundle assetBundle, GameObject bodyPrefab, string assetName)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = assetBundle.LoadAsset<GameObject>(assetName);
			BaseAI val2 = val.GetComponent<BaseAI>();
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = val.AddComponent<BaseAI>();
				val2.aimVectorDampTime = 0.1f;
				val2.aimVectorMaxSpeed = 360f;
			}
			val2.scanState = new SerializableEntityStateType(typeof(Wander));
			EntityStateMachine component = val.GetComponent<EntityStateMachine>();
			if ((Object)(object)component == (Object)null)
			{
				AddEntityStateMachine(val, "AI", typeof(Wander), typeof(Wander));
			}
			val2.stateMachine = component;
			CharacterMaster val3 = val.GetComponent<CharacterMaster>();
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val.AddComponent<CharacterMaster>();
			}
			val3.bodyPrefab = bodyPrefab;
			val3.teamIndex = (TeamIndex)2;
			Content.AddMasterPrefab(val);
			return val;
		}

		public static void ClearEntityStateMachines(GameObject bodyPrefab)
		{
			EntityStateMachine[] components = bodyPrefab.GetComponents<EntityStateMachine>();
			for (int num = components.Length - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)components[num]);
			}
			NetworkStateMachine component = bodyPrefab.GetComponent<NetworkStateMachine>();
			component.stateMachines = Array.Empty<EntityStateMachine>();
			CharacterDeathBehavior component2 = bodyPrefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.idleStateMachine = Array.Empty<EntityStateMachine>();
			}
			SetStateOnHurt component3 = bodyPrefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.idleStateMachine = Array.Empty<EntityStateMachine>();
			}
		}

		public static void AddMainEntityStateMachine(GameObject bodyPrefab, string machineName = "Body", Type mainStateType = null, Type initalStateType = null)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			EntityStateMachine val = EntityStateMachine.FindByCustomName(bodyPrefab, machineName);
			if ((Object)(object)val == (Object)null)
			{
				val = bodyPrefab.AddComponent<EntityStateMachine>();
			}
			else
			{
				Log.Message("An Entity State Machine already exists with the name " + machineName + ". replacing.");
			}
			val.customName = machineName;
			if (mainStateType == null)
			{
				mainStateType = typeof(GenericCharacterMain);
			}
			val.mainStateType = new SerializableEntityStateType(mainStateType);
			if (initalStateType == null)
			{
				initalStateType = typeof(SpawnTeleporterState);
			}
			val.initialStateType = new SerializableEntityStateType(initalStateType);
			NetworkStateMachine component = bodyPrefab.GetComponent<NetworkStateMachine>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.stateMachines = component.stateMachines.Append(val).ToArray();
			}
			CharacterDeathBehavior component2 = bodyPrefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.deathStateMachine = val;
			}
			SetStateOnHurt component3 = bodyPrefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.targetStateMachine = val;
			}
		}

		public static void AddEntityStateMachine(GameObject prefab, string machineName, Type mainStateType = null, Type initalStateType = null)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			EntityStateMachine val = EntityStateMachine.FindByCustomName(prefab, machineName);
			if ((Object)(object)val == (Object)null)
			{
				val = prefab.AddComponent<EntityStateMachine>();
			}
			else
			{
				Log.Message("An Entity State Machine already exists with the name " + machineName + ". replacing.");
			}
			val.customName = machineName;
			if (mainStateType == null)
			{
				mainStateType = typeof(Idle);
			}
			val.mainStateType = new SerializableEntityStateType(mainStateType);
			if (initalStateType == null)
			{
				initalStateType = typeof(Idle);
			}
			val.initialStateType = new SerializableEntityStateType(initalStateType);
			NetworkStateMachine component = prefab.GetComponent<NetworkStateMachine>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.stateMachines = component.stateMachines.Append(val).ToArray();
			}
			CharacterDeathBehavior component2 = prefab.GetComponent<CharacterDeathBehavior>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.idleStateMachine = component2.idleStateMachine.Append(val).ToArray();
			}
			SetStateOnHurt component3 = prefab.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.idleStateMachine = component3.idleStateMachine.Append(val).ToArray();
			}
		}

		public static void SetupHitBoxGroup(GameObject modelPrefab, string hitBoxGroupName, params string[] hitboxChildNames)
		{
			ChildLocator component = modelPrefab.GetComponent<ChildLocator>();
			Transform[] array = (Transform[])(object)new Transform[hitboxChildNames.Length];
			for (int i = 0; i < hitboxChildNames.Length; i++)
			{
				array[i] = component.FindChild(hitboxChildNames[i]);
				if ((Object)(object)array[i] == (Object)null)
				{
					Log.Error("missing hitbox for " + hitboxChildNames[i]);
				}
			}
			SetupHitBoxGroup(modelPrefab, hitBoxGroupName, array);
		}

		public static void SetupHitBoxGroup(GameObject prefab, string hitBoxGroupName, params Transform[] hitBoxTransforms)
		{
			List<HitBox> list = new List<HitBox>();
			foreach (Transform val in hitBoxTransforms)
			{
				if ((Object)(object)val == (Object)null)
				{
					Log.Error("Error setting up hitboxGroup for " + hitBoxGroupName + ": hitbox transform was null");
					continue;
				}
				HitBox item = ((Component)val).gameObject.AddComponent<HitBox>();
				((Component)val).gameObject.layer = LayerIndex.projectile.intVal;
				list.Add(item);
			}
			if (list.Count == 0)
			{
				Log.Error("No hitboxes were set up. aborting setting up hitboxGroup for " + hitBoxGroupName);
				return;
			}
			HitBoxGroup val2 = prefab.AddComponent<HitBoxGroup>();
			val2.hitBoxes = list.ToArray();
			val2.groupName = hitBoxGroupName;
		}
	}
	internal static class Materials
	{
		private static List<Material> cachedMaterials = new List<Material>();

		internal static Shader hotpoo = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/HGStandard");

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

		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()));
			}
		}

		public static void SwapShadersFromMaterialsInBundle(AssetBundle bundle)
		{
			SwapAllShaders(bundle);
		}

		internal static void SwapAllShaders(AssetBundle assetBundle)
		{
			Material[] array = assetBundle.LoadAllAssets<Material>();
			foreach (Material val in array)
			{
				Log.Debug("Trying to swap shader for " + ((Object)val).name);
				TrySwapShader(val);
			}
		}

		internal static void TrySwapShader(Material material)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			string name = ((Object)material.shader).name;
			if (name.Contains("Stubbed"))
			{
				name = name.Replace("Stubbed", string.Empty) + ".shader";
				Shader val = Addressables.LoadAssetAsync<Shader>((object)name).WaitForCompletion();
				if ((Object)(object)val != (Object)null)
				{
					material.shader = val;
				}
				else
				{
					Log.Error("Failed to load shader " + name);
				}
			}
			else if (name == "Standard")
			{
				Texture texture = material.GetTexture("_BumpMap");
				float num = material.GetFloat("_BumpScale");
				Texture texture2 = material.GetTexture("_EmissionMap");
				material.shader = Resources.Load<Shader>("Shaders/Deferred/HGStandard");
				material.SetTexture("_NormalMap", texture);
				material.SetFloat("_NormalStrength", num);
				material.SetTexture("_EmTex", texture2);
				material.SetColor("_EmColor", new Color(0.2f, 0.2f, 0.2f));
				material.SetFloat("_EmPower", 0.15f);
			}
		}

		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);
		}

		public static Material LoadMaterial(this AssetBundle assetBundle, string materialName)
		{
			return assetBundle.CreateHopooMaterialFromBundle(materialName);
		}

		public static Material CreateHopooMaterialFromBundle(this AssetBundle assetBundle, string materialName)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Material val = cachedMaterials.Find(delegate(Material mat)
			{
				materialName.Replace(" (Instance)", "");
				return ((Object)mat).name.Contains(materialName);
			});
			if (Object.op_Implicit((Object)(object)val))
			{
				Log.Debug(((Object)val).name + " has already been loaded. returning cached");
				return val;
			}
			val = assetBundle.LoadAsset<Material>(materialName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.ErrorAssetBundle(materialName, ((Object)assetBundle).name);
				return new Material(hotpoo);
			}
			return val.ConvertDefaultShaderToHopoo();
		}

		public static Material SetHopooMaterial(this Material tempMat)
		{
			return tempMat.ConvertDefaultShaderToHopoo();
		}

		public static Material ConvertDefaultShaderToHopoo(this Material tempMat)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (cachedMaterials.Contains(tempMat))
			{
				Log.Debug(((Object)tempMat).name + " has already been loaded. returning cached");
				return tempMat;
			}
			float? num = null;
			Color? val = null;
			if (tempMat.IsKeywordEnabled("_NORMALMAP"))
			{
				num = tempMat.GetFloat("_BumpScale");
			}
			if (tempMat.IsKeywordEnabled("_EMISSION"))
			{
				val = tempMat.GetColor("_EmissionColor");
			}
			tempMat.shader = hotpoo;
			tempMat.SetTexture("_EmTex", tempMat.GetTexture("_EmissionMap"));
			tempMat.EnableKeyword("DITHER");
			if (num.HasValue)
			{
				tempMat.SetFloat("_NormalStrength", num.Value);
				tempMat.SetTexture("_NormalTex", tempMat.GetTexture("_BumpMap"));
			}
			if (val.HasValue)
			{
				tempMat.SetColor("_EmColor", val.Value);
				tempMat.SetFloat("_EmPower", 1f);
			}
			if (tempMat.IsKeywordEnabled("NOCULL"))
			{
				tempMat.SetInt("_Cull", 0);
			}
			if (tempMat.IsKeywordEnabled("LIMBREMOVAL"))
			{
				tempMat.SetInt("_LimbRemovalOn", 1);
			}
			cachedMaterials.Add(tempMat);
			return tempMat;
		}

		public static Material MakeUnique(this Material material)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (cachedMaterials.Contains(material))
			{
				return new Material(material);
			}
			return material;
		}

		public static Material SetColor(this Material material, Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			material.SetColor("_Color", color);
			return material;
		}

		public static Material SetNormal(this Material material, float normalStrength = 1f)
		{
			material.SetFloat("_NormalStrength", normalStrength);
			return material;
		}

		public static Material SetEmission(this Material material)
		{
			return material.SetEmission(1f);
		}

		public static Material SetEmission(this Material material, float emission)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return material.SetEmission(emission, Color.white);
		}

		public static Material SetEmission(this Material material, float emission, Color emissionColor)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			material.SetFloat("_EmPower", emission);
			material.SetColor("_EmColor", emissionColor);
			return material;
		}

		public static Material SetCull(this Material material, bool cull = false)
		{
			material.SetInt("_Cull", cull ? 1 : 0);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength)
		{
			material.SetFloat("_SpecularStrength", strength);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength, float exponent)
		{
			material.SetFloat("_SpecularStrength", strength);
			material.SetFloat("SpecularExponent", exponent);
			return material;
		}
	}
	internal static class Particles
	{
		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[] componentsInChildren = model.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				Debug.Log((object)("Particle: " + ((Object)val2).name.ToString()));
			}
		}
	}
	internal class Content
	{
		internal static void AddExpansionDef(ExpansionDef expansion)
		{
			ContentPacks.expansionDefs.Add(expansion);
		}

		internal static void AddCharacterBodyPrefab(GameObject bprefab)
		{
			ContentPacks.bodyPrefabs.Add(bprefab);
		}

		internal static void AddMasterPrefab(GameObject prefab)
		{
			ContentPacks.masterPrefabs.Add(prefab);
		}

		internal static void AddProjectilePrefab(GameObject prefab)
		{
			ContentPacks.projectilePrefabs.Add(prefab);
		}

		internal static void AddSurvivorDef(SurvivorDef survivorDef)
		{
			ContentPacks.survivorDefs.Add(survivorDef);
		}

		internal static void AddVoidItemRelationship(ItemDef itemToCorrupt, ItemDef itemThatCorrupts)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			ItemRelationshipProvider val = ScriptableObject.CreateInstance<ItemRelationshipProvider>();
			((Object)val).name = ((Object)itemThatCorrupts).name + ((Object)itemToCorrupt).name + "Relationship";
			val.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion();
			val.relationships = (Pair[])(object)new Pair[1]
			{
				new Pair
				{
					itemDef1 = itemToCorrupt,
					itemDef2 = itemThatCorrupts
				}
			};
			ContentPacks.itemRelationships.Add(val);
		}

		internal static void AddItemDef(ItemDef itemDef)
		{
			ContentPacks.itemDefs.Add(itemDef);
		}

		internal static void AddCraftableDef(CraftableDef itemDef)
		{
			if (itemDef.recipes.Length != 0)
			{
				ContentPacks.craftableDefs.Add(itemDef);
			}
		}

		internal static void AddEliteDef(EliteDef eliteDef)
		{
			ContentPacks.eliteDefs.Add(eliteDef);
		}

		internal static void AddArtifactDef(ArtifactDef artifactDef)
		{
			ContentPacks.artifactDefs.Add(artifactDef);
		}

		internal static void AddNetworkedObjectPrefab(GameObject