Decompiled source of LemurFusion v1.3.1

LemurFusion.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.AI.Walker;
using EntityStates.LemurianBruiserMonster;
using EntityStates.LemurianMonster;
using HG;
using HarmonyLib;
using IL.EntityStates.AI.Walker;
using IL.EntityStates.LemurianBruiserMonster;
using IL.EntityStates.LemurianMonster;
using IL.RoR2;
using IL.RoR2.CharacterAI;
using LemurFusion;
using LemurFusion.AI;
using LemurFusion.Config;
using LemurianNames;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On;
using On.RoR2;
using On.RoR2.UI;
using ProperSave;
using ProperSave.Data;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RiskyMod.Allies;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("LemurFusion")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+b7ace64cccc1446ebbc467279bcf64d189724f4f")]
[assembly: AssemblyProduct("LemurFusion")]
[assembly: AssemblyTitle("LemurFusion")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public class BetterLemurController : DevotedLemurianController
{
	[CompilerGenerated]
	private static class <>O
	{
		public static hook_InitializeDevotedLemurian <0>__DevotedLemurianController_InitializeDevotedLemurian;

		public static hook_OnDevotedBodyDead <1>__DevotedLemurianController_OnDevotedBodyDead;

		public static hook_PushItemTransformNotification <2>__CharacterMasterNotificationQueue_PushItemTransformNotification;
	}

	public SortedList<ItemIndex, int> _devotedItemList { get; set; } = new SortedList<ItemIndex, int>();


	public SortedList<ItemIndex, int> _untrackedItemList { get; set; } = new SortedList<ItemIndex, int>();


	public int FusionCount
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)((DevotedLemurianController)this).LemurianInventory))
			{
				return 0;
			}
			return ((DevotedLemurianController)this).LemurianInventory.GetItemCount(Items.LemurianHarness);
		}
		set
		{
			Utils.SetItem(_untrackedItemList, Items.LemurianHarness, value);
		}
	}

	public void ReturnItems()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)((DevotedLemurianController)this).LemurianInventory))
		{
			return;
		}
		if (_untrackedItemList != null)
		{
			foreach (KeyValuePair<ItemIndex, int> untrackedItem in _untrackedItemList)
			{
				((DevotedLemurianController)this).LemurianInventory.GiveItem(untrackedItem.Key, untrackedItem.Value);
			}
		}
		if (DevotionTweaks.EnableSharedInventory || _devotedItemList == null)
		{
			return;
		}
		foreach (KeyValuePair<ItemIndex, int> devotedItem in _devotedItemList)
		{
			((DevotedLemurianController)this).LemurianInventory.GiveItem(devotedItem.Key, devotedItem.Value);
		}
	}

	private PickupIndex FindPickupIndex(ItemIndex itemIndex, DevotionTweaks.DeathItem dropType)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: 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_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_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected I4, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Invalid comparison between Unknown and I4
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		if ((int)itemIndex != -1)
		{
			switch (dropType)
			{
			case DevotionTweaks.DeathItem.Scrap:
			{
				ItemTier tier = ItemCatalog.GetItemDef(itemIndex).tier;
				if (1 == 0)
				{
				}
				PickupIndex result = (PickupIndex)((int)tier switch
				{
					0 => PickupCatalog.FindPickupIndex("ItemIndex.ScrapWhite"), 
					1 => PickupCatalog.FindPickupIndex("ItemIndex.ScrapGreen"), 
					2 => PickupCatalog.FindPickupIndex("ItemIndex.ScrapRed"), 
					4 => PickupCatalog.FindPickupIndex("ItemIndex.ScrapYellow"), 
					_ => PickupIndex.none, 
				});
				if (1 == 0)
				{
				}
				return result;
			}
			case DevotionTweaks.DeathItem.Original:
				return PickupCatalog.FindPickupIndex(itemIndex);
			case DevotionTweaks.DeathItem.Custom:
			{
				if (ConfigExtended.DeathDrops_TierToItem_Map.TryGetValue(ItemCatalog.GetItemDef(itemIndex).tier, out var value) && (int)value != -1)
				{
					return PickupCatalog.FindPickupIndex(value);
				}
				break;
			}
			}
		}
		return PickupIndex.none;
	}

	private void DropScrapOnDeath()
	{
		//IL_0039: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ac: 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)
		DevotionTweaks.DeathItem value = ConfigExtended.DeathDrop_ItemType.Value;
		foreach (KeyValuePair<ItemIndex, int> devotedItem in _devotedItemList)
		{
			if (DevotionTweaks.EnableSharedInventory)
			{
				base._devotionInventoryController.RemoveItem(devotedItem.Key, devotedItem.Value);
			}
			if (value == DevotionTweaks.DeathItem.None)
			{
				continue;
			}
			PickupIndex val = FindPickupIndex(devotedItem.Key, value);
			if (val != PickupIndex.none)
			{
				int num = ((!ConfigExtended.DeathDrop_DropAll.Value) ? 1 : devotedItem.Value);
				for (int i = 0; i < num; i++)
				{
					PickupDropletController.CreatePickupDroplet(val, ((DevotedLemurianController)this).LemurianBody.corePosition, Vector2.op_Implicit(Random.insideUnitCircle * 15f));
				}
			}
		}
	}

	public static void InitHooks()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		object obj = <>O.<0>__DevotedLemurianController_InitializeDevotedLemurian;
		if (obj == null)
		{
			hook_InitializeDevotedLemurian val = DevotedLemurianController_InitializeDevotedLemurian;
			<>O.<0>__DevotedLemurianController_InitializeDevotedLemurian = val;
			obj = (object)val;
		}
		DevotedLemurianController.InitializeDevotedLemurian += (hook_InitializeDevotedLemurian)obj;
		object obj2 = <>O.<1>__DevotedLemurianController_OnDevotedBodyDead;
		if (obj2 == null)
		{
			hook_OnDevotedBodyDead val2 = DevotedLemurianController_OnDevotedBodyDead;
			<>O.<1>__DevotedLemurianController_OnDevotedBodyDead = val2;
			obj2 = (object)val2;
		}
		DevotedLemurianController.OnDevotedBodyDead += (hook_OnDevotedBodyDead)obj2;
		object obj3 = <>O.<2>__CharacterMasterNotificationQueue_PushItemTransformNotification;
		if (obj3 == null)
		{
			hook_PushItemTransformNotification val3 = CharacterMasterNotificationQueue_PushItemTransformNotification;
			<>O.<2>__CharacterMasterNotificationQueue_PushItemTransformNotification = val3;
			obj3 = (object)val3;
		}
		CharacterMasterNotificationQueue.PushItemTransformNotification += (hook_PushItemTransformNotification)obj3;
	}

	private static void CharacterMasterNotificationQueue_PushItemTransformNotification(orig_PushItemTransformNotification orig, CharacterMaster characterMaster, ItemIndex oldIndex, ItemIndex newIndex, TransformationType transformationType)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Invalid comparison between Unknown and I4
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(characterMaster, oldIndex, newIndex, transformationType);
		BetterLemurController betterLemurController = default(BetterLemurController);
		if (((NetworkBehaviour)characterMaster).hasAuthority || !(((Object)characterMaster).name == "BetterDevotedLemurianMaster(Clone)") || !((Component)characterMaster).TryGetComponent<BetterLemurController>(ref betterLemurController) || !Object.op_Implicit((Object)(object)((DevotedLemurianController)betterLemurController).LemurianInventory) || !betterLemurController._devotedItemList.TryGetValue(oldIndex, out var value))
		{
			return;
		}
		if ((int)transformationType == 1)
		{
			if (DevotionTweaks.EnableSharedInventory)
			{
				((DevotedLemurianController)betterLemurController)._devotionInventoryController.RemoveItem(oldIndex, value);
			}
			Utils.AddItem(betterLemurController._devotedItemList, newIndex, value);
			Utils.SetItem(betterLemurController._devotedItemList, oldIndex, 0);
		}
		else
		{
			if (DevotionTweaks.EnableSharedInventory)
			{
				((DevotedLemurianController)betterLemurController)._devotionInventoryController.RemoveItem(oldIndex, 1);
			}
			Utils.AddItem(betterLemurController._devotedItemList, newIndex);
			Utils.RemoveItem(betterLemurController._devotedItemList, oldIndex);
		}
		((DevotedLemurianController)betterLemurController)._devotionInventoryController.UpdateAllMinions(false);
	}

	private static void DevotedLemurianController_InitializeDevotedLemurian(orig_InitializeDevotedLemurian orig, DevotedLemurianController self, ItemIndex itemIndex, DevotionInventoryController devInvCtrl)
	{
		//IL_0003: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		orig.Invoke(self, itemIndex, devInvCtrl);
		if (!(self is BetterLemurController betterLemurController))
		{
			return;
		}
		((DevotedLemurianController)betterLemurController)._leashDistSq = PluginConfig.teleportDistance.Value * PluginConfig.teleportDistance.Value;
		if (PluginConfig.cloneReplacesRevive.Value)
		{
			if (itemIndex == Items.ExtraLife.itemIndex)
			{
				CreateTwin_ExtraLife(betterLemurController.FusionCount, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel, Items.ScrapRed.itemIndex, ((Component)self).gameObject.transform.position, ((Component)self).gameObject.transform.rotation, devInvCtrl);
				itemIndex = Items.ExtraLifeConsumed.itemIndex;
			}
			else if (itemIndex == Items.ExtraLifeVoid.itemIndex)
			{
				CreateTwin_ExtraLife(betterLemurController.FusionCount, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel, Items.BleedOnHitVoid.itemIndex, ((Component)self).gameObject.transform.position, ((Component)self).gameObject.transform.rotation, devInvCtrl);
				itemIndex = Items.ExtraLifeVoidConsumed.itemIndex;
			}
		}
		BetterLemurController betterLemurController2 = betterLemurController;
		if (betterLemurController2._devotedItemList == null)
		{
			SortedList<ItemIndex, int> sortedList2 = (betterLemurController2._devotedItemList = new SortedList<ItemIndex, int>());
		}
		Utils.AddItem(betterLemurController._devotedItemList, itemIndex);
		betterLemurController2 = betterLemurController;
		if (betterLemurController2._untrackedItemList == null)
		{
			SortedList<ItemIndex, int> sortedList2 = (betterLemurController2._untrackedItemList = new SortedList<ItemIndex, int>());
		}
		if (!betterLemurController._untrackedItemList.Any())
		{
			Utils.SetItem(betterLemurController._untrackedItemList, Items.LemurianHarness);
			Utils.SetItem(betterLemurController._untrackedItemList, Items.MinionLeash);
			Utils.SetItem(betterLemurController._untrackedItemList, Items.UseAmbientLevel);
			Utils.SetItem(betterLemurController._untrackedItemList, Items.TeleportWhenOob);
			if (LemurFusionPlugin.riskyInstalled)
			{
				betterLemurController.AddRiskyAllyItem();
			}
		}
	}

	[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
	private void AddRiskyAllyItem()
	{
		Utils.SetItem(_untrackedItemList, AllyItems.AllyMarkerItem);
	}

	private static void CreateTwin_ExtraLife(int fusionCount, int evoCount, ItemIndex devotedItem, Vector3 position, Quaternion rotation, DevotionInventoryController devotionInventoryController)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)devotionInventoryController))
		{
			return;
		}
		CharacterMaster summonerMaster = devotionInventoryController._summonerMaster;
		if (!Object.op_Implicit((Object)(object)summonerMaster))
		{
			return;
		}
		CharacterBody body = summonerMaster.GetBody();
		if (!Object.op_Implicit((Object)(object)body))
		{
			return;
		}
		MasterSummon val = new MasterSummon
		{
			masterPrefab = DevotionTweaks.masterPrefab,
			position = position,
			rotation = rotation,
			summonerBodyObject = ((Component)body).gameObject,
			ignoreTeamMemberLimit = true,
			useAmbientLevel = true
		};
		CharacterMaster val2 = val.Perform();
		BetterLemurController betterLemurController = default(BetterLemurController);
		if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).TryGetComponent<BetterLemurController>(ref betterLemurController))
		{
			((DevotedLemurianController)betterLemurController).InitializeDevotedLemurian(devotedItem, devotionInventoryController);
			if (fusionCount != 0)
			{
				betterLemurController.FusionCount = fusionCount;
			}
			((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel = evoCount;
			if (evoCount > 1)
			{
				((DevotedLemurianController)betterLemurController)._lemurianMaster.TransformBody("LemurianBruiserBody");
			}
			devotionInventoryController.UpdateAllMinions(false);
		}
	}

	private static void DevotedLemurianController_OnDevotedBodyDead(orig_OnDevotedBodyDead orig, DevotedLemurianController self)
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		if (!(self is BetterLemurController betterLemurController))
		{
			orig.Invoke(self);
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)betterLemurController) || !Object.op_Implicit((Object)(object)((DevotedLemurianController)betterLemurController)._lemurianMaster))
			{
				return;
			}
			if (!((MonoBehaviour)((DevotedLemurianController)betterLemurController)._lemurianMaster).IsInvoking("RespawnExtraLife") && !((MonoBehaviour)((DevotedLemurianController)betterLemurController)._lemurianMaster).IsInvoking("RespawnExtraLife"))
			{
				((DevotedLemurianController)betterLemurController)._lemurianMaster.destroyOnBodyDeath = true;
				betterLemurController.DropScrapOnDeath();
				if (ConfigExtended.DeathDrop_DropEgg.Value)
				{
					PlaceDevotionEgg(((DevotedLemurianController)betterLemurController).LemurianBody.footPosition);
				}
				Object.Destroy((Object)(object)((Component)((DevotedLemurianController)betterLemurController)._lemurianMaster).gameObject, 1f);
			}
			if (Object.op_Implicit((Object)(object)((DevotedLemurianController)betterLemurController)._devotionInventoryController))
			{
				((DevotedLemurianController)betterLemurController)._devotionInventoryController.UpdateAllMinions(false);
			}
		}
	}

	private static void PlaceDevotionEgg(Vector3 spawnLoc)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Expected O, but got Unknown
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)DirectorCore.instance))
		{
			Vector3 val = spawnLoc + Vector3.up * 1f;
			Vector3 down = Vector3.down;
			LayerIndex world = LayerIndex.world;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, down, ref val2, float.PositiveInfinity, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask)))
			{
				DirectorPlacementRule val3 = new DirectorPlacementRule
				{
					placementMode = (PlacementMode)0,
					position = ((RaycastHit)(ref val2)).point
				};
				DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(Addressables.LoadAssetAsync<SpawnCard>((object)"RoR2/CU8/LemurianEgg/iscLemurianEgg.asset").WaitForCompletion(), val3, new Xoroshiro128Plus(0uL)));
			}
		}
	}
}
namespace LemurFusion
{
	public class DevotionTweaks
	{
		public enum DeathItem
		{
			None,
			Scrap,
			Original,
			Custom
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static ArtifactStateChangeDelegate <0>__RunArtifactManager_onArtifactEnabledGlobal;

			public static ArtifactStateChangeDelegate <1>__RunArtifactManager_onArtifactDisabledGlobal;

			public static Manipulator <2>__LemurianEggController_SummonLemurian;

			public static hook_ActivateDevotedEvolution <3>__DevotionInventoryController_ActivateDevotedEvolution;

			public static hook_UpdateMinionInventory <4>__DevotionInventoryController_UpdateMinionInventory;

			public static Manipulator <5>__DevotionInventoryController_UpdateMinionInventory;

			public static Manipulator <6>__DevotionInventoryController_EvolveDevotedLumerian;

			public static Manipulator <7>__DevotionInventoryController_GenerateEliteBuff;

			public static hook_SetOptionsFromInteractor <8>__PickupPickerController_SetOptionsFromInteractor;

			public static hook_Perform <9>__MasterSummon_Perform;
		}

		public static DevotionTweaks instance;

		public static HashSet<EquipmentIndex> gigaChadLvl = new HashSet<EquipmentIndex>();

		public static HashSet<EquipmentIndex> lowLvl = new HashSet<EquipmentIndex>();

		public static HashSet<EquipmentIndex> highLvl = new HashSet<EquipmentIndex>();

		public static GameObject masterPrefab;

		public static GameObject bodyPrefab;

		public static GameObject bigBodyPrefab;

		public const string masterPrefabName = "BetterDevotedLemurianMaster";

		public const string masterCloneName = "BetterDevotedLemurianMaster(Clone)";

		public static bool EnableSharedInventory { get; private set; }

		private DevotionTweaks()
		{
		}

		public static void Init()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			if (instance != null)
			{
				return;
			}
			instance = new DevotionTweaks();
			EnableSharedInventory = PluginConfig.enableSharedInventory.Value;
			LoadAssets();
			object obj = <>O.<0>__RunArtifactManager_onArtifactEnabledGlobal;
			if (obj == null)
			{
				ArtifactStateChangeDelegate val = RunArtifactManager_onArtifactEnabledGlobal;
				<>O.<0>__RunArtifactManager_onArtifactEnabledGlobal = val;
				obj = (object)val;
			}
			RunArtifactManager.onArtifactEnabledGlobal += (ArtifactStateChangeDelegate)obj;
			object obj2 = <>O.<1>__RunArtifactManager_onArtifactDisabledGlobal;
			if (obj2 == null)
			{
				ArtifactStateChangeDelegate val2 = RunArtifactManager_onArtifactDisabledGlobal;
				<>O.<1>__RunArtifactManager_onArtifactDisabledGlobal = val2;
				obj2 = (object)val2;
			}
			RunArtifactManager.onArtifactDisabledGlobal += (ArtifactStateChangeDelegate)obj2;
			BetterLemurController.InitHooks();
			object obj3 = <>O.<2>__LemurianEggController_SummonLemurian;
			if (obj3 == null)
			{
				Manipulator val3 = LemurianEggController_SummonLemurian;
				<>O.<2>__LemurianEggController_SummonLemurian = val3;
				obj3 = (object)val3;
			}
			LemurianEggController.SummonLemurian += (Manipulator)obj3;
			object obj4 = <>O.<3>__DevotionInventoryController_ActivateDevotedEvolution;
			if (obj4 == null)
			{
				hook_ActivateDevotedEvolution val4 = DevotionInventoryController_ActivateDevotedEvolution;
				<>O.<3>__DevotionInventoryController_ActivateDevotedEvolution = val4;
				obj4 = (object)val4;
			}
			DevotionInventoryController.ActivateDevotedEvolution += (hook_ActivateDevotedEvolution)obj4;
			object obj5 = <>O.<4>__DevotionInventoryController_UpdateMinionInventory;
			if (obj5 == null)
			{
				hook_UpdateMinionInventory val5 = DevotionInventoryController_UpdateMinionInventory;
				<>O.<4>__DevotionInventoryController_UpdateMinionInventory = val5;
				obj5 = (object)val5;
			}
			DevotionInventoryController.UpdateMinionInventory += (hook_UpdateMinionInventory)obj5;
			object obj6 = <>O.<5>__DevotionInventoryController_UpdateMinionInventory;
			if (obj6 == null)
			{
				Manipulator val6 = DevotionInventoryController_UpdateMinionInventory;
				<>O.<5>__DevotionInventoryController_UpdateMinionInventory = val6;
				obj6 = (object)val6;
			}
			DevotionInventoryController.UpdateMinionInventory += (Manipulator)obj6;
			object obj7 = <>O.<6>__DevotionInventoryController_EvolveDevotedLumerian;
			if (obj7 == null)
			{
				Manipulator val7 = DevotionInventoryController_EvolveDevotedLumerian;
				<>O.<6>__DevotionInventoryController_EvolveDevotedLumerian = val7;
				obj7 = (object)val7;
			}
			DevotionInventoryController.EvolveDevotedLumerian += (Manipulator)obj7;
			object obj8 = <>O.<7>__DevotionInventoryController_GenerateEliteBuff;
			if (obj8 == null)
			{
				Manipulator val8 = DevotionInventoryController_GenerateEliteBuff;
				<>O.<7>__DevotionInventoryController_GenerateEliteBuff = val8;
				obj8 = (object)val8;
			}
			DevotionInventoryController.GenerateEliteBuff += (Manipulator)obj8;
			if (ConfigExtended.Blacklist_Enable.Value)
			{
				object obj9 = <>O.<8>__PickupPickerController_SetOptionsFromInteractor;
				if (obj9 == null)
				{
					hook_SetOptionsFromInteractor val9 = PickupPickerController_SetOptionsFromInteractor;
					<>O.<8>__PickupPickerController_SetOptionsFromInteractor = val9;
					obj9 = (object)val9;
				}
				PickupPickerController.SetOptionsFromInteractor += (hook_SetOptionsFromInteractor)obj9;
			}
		}

		private static void LoadAssets()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			LemurFusionPlugin.LogInfo("Adding Tags ItemTag.BrotherBlacklist, ItemTag.CannotSteal, ItemTag.CannotCopy to Lemurian Harness.");
			ItemDef val = Addressables.LoadAssetAsync<ItemDef>((object)"RoR2/CU8/Harness/LemurianHarness.asset").WaitForCompletion();
			if (Object.op_Implicit((Object)(object)val))
			{
				ItemTag[] tags = val.tags;
				ItemTag[] array = new ItemTag[3];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				val.tags = tags.Concat(new <>z__ReadOnlyArray<ItemTag>((ItemTag[])(object)array)).Distinct().ToArray();
			}
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Lemurian/LemurianBody.prefab").WaitForCompletion();
			bodyPrefab = PrefabAPI.InstantiateClone(val2, "DevotedLemurianBody", true);
			CharacterBody component = bodyPrefab.GetComponent<CharacterBody>();
			component.bodyFlags = (BodyFlags)(component.bodyFlags | 0x1000);
			component.baseMaxHealth = 360f;
			component.levelMaxHealth = 11f;
			component.baseMoveSpeed = 7f;
			GameObject val3 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/LemurianBruiser/LemurianBruiserBody.prefab").WaitForCompletion();
			bigBodyPrefab = PrefabAPI.InstantiateClone(val3, "DevotedLemurianBruiserBody", true);
			CharacterBody component2 = bigBodyPrefab.GetComponent<CharacterBody>();
			component2.bodyFlags = (BodyFlags)(component2.bodyFlags | 0x1000);
			component2.baseMaxHealth = 720f;
			component2.levelMaxHealth = 22f;
			component2.baseMoveSpeed = 10f;
			CharacterBody component3 = val2.GetComponent<CharacterBody>();
			component3.bodyFlags = (BodyFlags)(component3.bodyFlags & -4097);
			CharacterBody component4 = val3.GetComponent<CharacterBody>();
			component4.bodyFlags = (BodyFlags)(component4.bodyFlags & -4097);
			masterPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/CU8/LemurianEgg/DevotedLemurianMaster.prefab").WaitForCompletion(), "BetterDevotedLemurianMaster", true);
			Object.DestroyImmediate((Object)(object)masterPrefab.GetComponent<DevotedLemurianController>());
			masterPrefab.AddComponent<BetterLemurController>();
			masterPrefab.GetComponent<CharacterMaster>().bodyPrefab = bodyPrefab;
			ContentAddition.AddMaster(masterPrefab);
			ContentAddition.AddBody(bodyPrefab);
			ContentAddition.AddBody(bigBodyPrefab);
		}

		private static void RunArtifactManager_onArtifactEnabledGlobal(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (!((Object)(object)artifactDef != (Object)(object)Artifacts.Devotion))
			{
				object obj = <>O.<9>__MasterSummon_Perform;
				if (obj == null)
				{
					hook_Perform val = MasterSummon_Perform;
					<>O.<9>__MasterSummon_Perform = val;
					obj = (object)val;
				}
				MasterSummon.Perform += (hook_Perform)obj;
				StatHooks.instance.InitHooks();
				CreateEliteLists();
			}
		}

		private static void RunArtifactManager_onArtifactDisabledGlobal(RunArtifactManager runArtifactManager, ArtifactDef artifactDef)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			if (!((Object)(object)artifactDef != (Object)(object)Artifacts.Devotion))
			{
				object obj = <>O.<9>__MasterSummon_Perform;
				if (obj == null)
				{
					hook_Perform val = MasterSummon_Perform;
					<>O.<9>__MasterSummon_Perform = val;
					obj = (object)val;
				}
				MasterSummon.Perform -= (hook_Perform)obj;
				StatHooks.instance.RemoveHooks();
				lowLvl.Clear();
				highLvl.Clear();
				gigaChadLvl.Clear();
			}
		}

		private static void CreateEliteLists()
		{
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Invalid comparison between Unknown and I4
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			lowLvl.Clear();
			highLvl.Clear();
			gigaChadLvl.Clear();
			foreach (EliteTierDef item in EliteAPI.GetCombatDirectorEliteTiers().ToList())
			{
				if (item == null || item.eliteTypes.Length == 0 || item.eliteTypes.Any((EliteDef ed) => (Object)(object)ed != (Object)null && ((Object)ed).name.Contains("Honor")))
				{
					continue;
				}
				bool flag = false;
				bool flag2 = false;
				EliteDef[] eliteTypes = item.eliteTypes;
				foreach (EliteDef val in eliteTypes)
				{
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.eliteEquipmentDef))
					{
						if ((Object)(object)val.eliteEquipmentDef == (Object)(object)Equipment.AffixPoison || (Object)(object)val.eliteEquipmentDef == (Object)(object)Equipment.AffixLunar)
						{
							flag = true;
							break;
						}
						if ((Object)(object)val.eliteEquipmentDef == (Object)(object)Equipment.AffixBlue)
						{
							flag2 = true;
							break;
						}
					}
				}
				if (!(flag2 || flag))
				{
					continue;
				}
				EliteDef[] eliteTypes2 = item.eliteTypes;
				foreach (EliteDef val2 in eliteTypes2)
				{
					if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.eliteEquipmentDef) && (int)val2.eliteEquipmentDef.equipmentIndex != -1 && Object.op_Implicit((Object)(object)val2.eliteEquipmentDef.passiveBuffDef) && val2.eliteEquipmentDef.passiveBuffDef.isElite)
					{
						if (flag2)
						{
							lowLvl.Add(val2.eliteEquipmentDef.equipmentIndex);
							highLvl.Add(val2.eliteEquipmentDef.equipmentIndex);
						}
						if (flag)
						{
							highLvl.Add(val2.eliteEquipmentDef.equipmentIndex);
							gigaChadLvl.Add(val2.eliteEquipmentDef.equipmentIndex);
						}
					}
				}
			}
		}

		private static void PickupPickerController_SetOptionsFromInteractor(orig_SetOptionsFromInteractor orig, PickupPickerController self, Interactor activator)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00ac: 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)
			CharacterBody val = default(CharacterBody);
			if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<LemurianEggController>()) || !Object.op_Implicit((Object)(object)activator) || !((Component)activator).TryGetComponent<CharacterBody>(ref val) || !Object.op_Implicit((Object)(object)val.inventory))
			{
				orig.Invoke(self, activator);
				return;
			}
			List<Option> list = new List<Option>();
			foreach (ItemIndex item in val.inventory.itemAcquisitionOrder)
			{
				if (ConfigExtended.Blacklist_Filter(item))
				{
					PickupIndex val2 = PickupCatalog.FindPickupIndex(item);
					if (val2 != PickupIndex.none)
					{
						list.Add(new Option
						{
							available = true,
							pickupIndex = val2
						});
					}
				}
			}
			self.SetOptionsServer(list.ToArray());
		}

		private static CharacterMaster MasterSummon_Perform(orig_Perform orig, MasterSummon self)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = default(CharacterBody);
			if ((Object)(object)self?.masterPrefab == (Object)(object)masterPrefab && Object.op_Implicit((Object)(object)self.summonerBodyObject) && self.summonerBodyObject.TryGetComponent<CharacterBody>(ref val) && Object.op_Implicit((Object)(object)val))
			{
				CharacterMaster val2 = (self.ignoreTeamMemberLimit ? null : TrySummon(val.masterObjectId));
				self.ignoreTeamMemberLimit = true;
				if ((Object)(object)val2 != (Object)null)
				{
					return val2;
				}
			}
			return orig.Invoke(self);
		}

		private static CharacterMaster TrySummon(NetworkInstanceId summoner)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			List<BetterLemurController> list = new List<BetterLemurController>();
			MinionGroup obj = MinionGroup.FindGroup(summoner);
			MinionOwnership[] array = ((obj != null) ? obj.members : null) ?? Array.Empty<MinionOwnership>();
			BetterLemurController betterLemurController = default(BetterLemurController);
			foreach (MinionOwnership val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.TryGetComponent<BetterLemurController>(ref betterLemurController) && Object.op_Implicit((Object)(object)betterLemurController))
				{
					list.Add(betterLemurController);
				}
			}
			if (list.Count >= PluginConfig.maxLemurs.Value && list.Any())
			{
				BetterLemurController betterLemurController2 = list.OrderBy((BetterLemurController l) => l.FusionCount).FirstOrDefault();
				if (Object.op_Implicit((Object)(object)betterLemurController2) && Object.op_Implicit((Object)(object)((DevotedLemurianController)betterLemurController2)._lemurianMaster))
				{
					betterLemurController2.FusionCount++;
					return ((DevotedLemurianController)betterLemurController2)._lemurianMaster;
				}
			}
			return null;
		}

		private static void LemurianEggController_SummonLemurian(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0067: 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)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 0),
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<LemurianEggController>(i, "masterPrefab")
			}))
			{
				val.RemoveRange(2);
				val.Emit<DevotionTweaks>(OpCodes.Ldsfld, "masterPrefab");
			}
			else
			{
				LemurFusionPlugin.LogError("Hook failed for LemurianEggController_SummonLemurian # 1");
			}
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchStfld<MasterSummon>(i, "ignoreTeamMemberLimit")
			}))
			{
				val.Prev.OpCode = OpCodes.Ldc_I4_0;
			}
			else
			{
				LemurFusionPlugin.LogError("Hook failed for LemurianEggController_SummonLemurian # 2");
			}
		}

		private static void DevotionInventoryController_ActivateDevotedEvolution(orig_ActivateDevotedEvolution orig)
		{
			orig.Invoke();
			foreach (DevotionInventoryController instance in DevotionInventoryController.InstanceList)
			{
				instance.UpdateAllMinions(false);
			}
		}

		private static void DevotionInventoryController_UpdateMinionInventory(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num = default(int);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[6]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 0),
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<DevotionInventoryController>(i, "_devotionMinionInventory"),
				(Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 1),
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<DevotedLemurianController>(i, "get_DevotionItem"),
				(Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, ref num),
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<Inventory>(i, "GiveItem")
			}))
			{
				val.RemoveRange(6);
			}
			else
			{
				LemurFusionPlugin.LogError("IL Hook failed for DevotionInventoryController_UpdateMinionInventory #1");
			}
			ILCursor[] source = default(ILCursor[]);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCall<DevotionInventoryController>(i, "EvolveDevotedLumerian")
			}) && val.TryFindNext(ref source, new Func<Instruction, bool>[2]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<Inventory>(i, "GiveItem"),
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<Inventory>(i, "GiveItem")
			}))
			{
				val.MoveAfterLabels();
				val.RemoveRange(source.Last().Index + 1 - val.Index);
			}
			else
			{
				LemurFusionPlugin.LogError("IL Hook failed for DevotionInventoryController_UpdateMinionInventory #2");
			}
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallvirt<Inventory>(i, "AddItemsFrom")
			}))
			{
				if (ConfigExtended.Blacklist_Enable.Value && EnableSharedInventory)
				{
					val.Remove();
					val.Emit<ConfigExtended>(OpCodes.Ldsfld, "Blacklist_Filter");
					val.Emit(OpCodes.Callvirt, (MethodBase)typeof(Inventory).GetMethod("AddItemsFrom", new Type[2]
					{
						typeof(Inventory),
						typeof(Func<ItemIndex, bool>)
					}));
				}
				if (!EnableSharedInventory)
				{
					val.Remove();
					val.Emit(OpCodes.Pop);
					val.Emit(OpCodes.Pop);
				}
			}
			else
			{
				LemurFusionPlugin.LogError("IL Hook failed for DevotionInventoryController_UpdateMinionInventory #3");
			}
		}

		private static void DevotionInventoryController_UpdateMinionInventory(orig_UpdateMinionInventory orig, DevotionInventoryController self, DevotedLemurianController lem, bool shouldEvolve)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !(lem is BetterLemurController betterLemurController))
			{
				orig.Invoke(self, lem, shouldEvolve);
				return;
			}
			if (shouldEvolve && betterLemurController._devotedItemList.Any())
			{
				foreach (ItemIndex item in betterLemurController._devotedItemList.Keys.ToList())
				{
					if (EnableSharedInventory)
					{
						self.GiveItem(item, 1);
					}
					betterLemurController._devotedItemList[item]++;
				}
			}
			orig.Invoke(self, lem, shouldEvolve);
			betterLemurController.ReturnItems();
		}

		private static void DevotionInventoryController_EvolveDevotedLumerian(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0044: 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)
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "LemurianBruiserBody")
			}))
			{
				val.Remove();
				val.Emit(OpCodes.Ldstr, "DevotedLemurianBruiserBody");
			}
			else
			{
				LemurFusionPlugin.LogError("Hook failed for DevotionInventoryController_EvolveDevotedLumerian #1");
			}
			if (val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[2]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdstr(i, "shouldn't evolve!"),
				(Instruction i) => ILPatternMatchingExt.MatchCall<Debug>(i, "LogError")
			}))
			{
				val.Emit(OpCodes.Ldarg_1);
				val.EmitDelegate<Action<DevotedLemurianController>>((Action<DevotedLemurianController>)delegate(DevotedLemurianController lem)
				{
					//IL_0039: Unknown result type (might be due to invalid IL or missing references)
					List<EquipmentIndex> list = (PluginConfig.highTierElitesOnly.Value ? gigaChadLvl.ToList() : highLvl.ToList());
					int index = Random.Range(0, list.Count);
					lem.LemurianInventory.SetEquipmentIndex(list[index]);
				});
				val.RemoveRange(2);
			}
			else
			{
				LemurFusionPlugin.LogError("Hook failed for DevotionInventoryController_EvolveDevotedLumerian #2");
			}
		}

		private static void DevotionInventoryController_GenerateEliteBuff(ILContext ll)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(ll);
			ILLabel val3 = default(ILLabel);
			ILLabel val2 = default(ILLabel);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
			{
				(Instruction i) => ILPatternMatchingExt.MatchBrtrue(i, ref val3),
				(Instruction i) => ILPatternMatchingExt.MatchLdsfld<DevotionInventoryController>(i, "highLevelEliteBuffs"),
				(Instruction i) => ILPatternMatchingExt.MatchBr(i, ref val2),
				(Instruction i) => ILPatternMatchingExt.MatchLdsfld<DevotionInventoryController>(i, "lowLevelEliteBuffs")
			}))
			{
				val.RemoveRange(4);
				val.EmitDelegate<Func<bool, List<EquipmentIndex>>>((Func<bool, List<EquipmentIndex>>)((bool isLowLvl) => isLowLvl ? lowLvl.ToList() : highLvl.ToList()));
			}
			else
			{
				LemurFusionPlugin.LogError("Hook failed for DevotionInventoryController_GenerateEliteBuff");
			}
		}
	}
	[HarmonyPatch(typeof(LemurianNames), "UpdateNameFriend")]
	public class LemurianUpdateNameFriend
	{
		[HarmonyFinalizer]
		public static Exception Finalizer(Exception __exception)
		{
			if (__exception != null)
			{
				LemurFusionPlugin.LogWarning("Exception was thrown by dependency bouncyshield.LemurianNames!");
				LemurFusionPlugin.LogWarning(__exception.Message);
				LemurFusionPlugin.LogWarning(__exception.StackTrace);
			}
			return null;
		}
	}
	[HarmonyPatch(typeof(LemurianNames), "NameFriend")]
	public class LemurianNameFriend
	{
		[HarmonyFinalizer]
		public static Exception Finalizer(Exception __exception)
		{
			if (__exception != null)
			{
				LemurFusionPlugin.LogWarning("Exception was thrown by dependency bouncyshield.LemurianNames!");
				LemurFusionPlugin.LogWarning(__exception.Message);
				LemurFusionPlugin.LogWarning(__exception.StackTrace);
			}
			return null;
		}
	}
	[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.*/)]
	[BepInPlugin("com.score.LemurFusion", "LemurFusion", "1.3.1")]
	public class LemurFusionPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.score.LemurFusion";

		public const string PluginName = "LemurFusion";

		public const string PluginVersion = "1.3.1";

		public static LemurFusionPlugin instance;

		private static ManualLogSource _logger;

		public static bool rooInstalled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		public static bool lemNamesInstalled => Chainloader.PluginInfos.ContainsKey("bouncyshield.LemurianNames");

		public static bool properSaveInstalled => Chainloader.PluginInfos.ContainsKey("com.KingEnderBrine.ProperSave");

		public static bool riskyInstalled => Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod");

		public void Awake()
		{
			instance = this;
			_logger = ((BaseUnityPlugin)this).Logger;
			PluginConfig.myConfig = ((BaseUnityPlugin)this).Config;
			ConfigReader.Setup();
			DevotionTweaks.Init();
			StatHooks.Init();
			AITweaks.Init();
			CreateHarmonyPatches();
			CreateProperSaveCompat();
		}

		public static void LogInfo(string message)
		{
			Log((LogLevel)16, message);
		}

		public static void LogMessage(string message)
		{
			Log((LogLevel)8, message);
		}

		public static void LogWarning(string message)
		{
			Log((LogLevel)4, message);
		}

		public static void LogError(string message)
		{
			Log((LogLevel)2, message);
		}

		public static void LogFatal(string message)
		{
			Log((LogLevel)1, message);
		}

		public static void Log(LogLevel logLevel, string message)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (PluginConfig.enableDetailedLogs.Value)
			{
				_logger.Log(logLevel, (object)message);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void CreateHarmonyPatches()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			if (lemNamesInstalled)
			{
				Harmony val = new Harmony("com.score.LemurFusion");
				val.CreateClassProcessor(typeof(LemurianNameFriend)).Patch();
				val.CreateClassProcessor(typeof(LemurianUpdateNameFriend)).Patch();
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void CreateProperSaveCompat()
		{
			if (properSaveInstalled)
			{
				new ProperSaveManager();
			}
		}
	}
	public class BetterLemurianData
	{
		[DataMember(Name = "bldsi")]
		public UserIDData summonerId;

		[DataMember(Name = "bldid")]
		public ItemData[] itemData;

		[DataMember(Name = "bldfl")]
		public int fusionLevel;

		public BetterLemurianData()
		{
		}

		public BetterLemurianData(UserIDData userID, BetterLemurController lemCtrl)
		{
			summonerId = userID;
			fusionLevel = lemCtrl.FusionCount;
			itemData = ((IEnumerable<KeyValuePair<ItemIndex, int>>)lemCtrl._devotedItemList).Select((Func<KeyValuePair<ItemIndex, int>, ItemData>)((KeyValuePair<ItemIndex, int> kvp) => new ItemData
			{
				itemIndex = (int)kvp.Key,
				count = kvp.Value
			})).ToArray();
		}

		public void LoadData(BetterLemurController lemCtrl)
		{
			lemCtrl._devotedItemList = new SortedList<ItemIndex, int>();
			for (int i = 0; i < itemData.Length; i++)
			{
				ItemData val = itemData[i];
				Utils.SetItem(lemCtrl._devotedItemList, (ItemIndex)val.itemIndex, val.count);
			}
			lemCtrl._untrackedItemList = new SortedList<ItemIndex, int>();
			Utils.SetItem(lemCtrl._untrackedItemList, Items.LemurianHarness, fusionLevel);
			Utils.SetItem(lemCtrl._untrackedItemList, Items.MinionLeash);
			Utils.SetItem(lemCtrl._untrackedItemList, Items.UseAmbientLevel);
			Utils.SetItem(lemCtrl._untrackedItemList, Items.TeleportWhenOob);
		}
	}
	public class ProperSaveManager : MonoBehaviour
	{
		public ProperSaveManager()
		{
			SaveFile.OnGatherSaveData += SaveFile_OnGatherSaveData;
			Loading.OnLoadingEnded += Loading_OnLoadingEnded;
		}

		private void SaveFile_OnGatherSaveData(Dictionary<string, object> obj)
		{
			//IL_0046: 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_0052: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			List<BetterLemurianData> list = new List<BetterLemurianData>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (!Object.op_Implicit((Object)(object)instance.networkUser) || !Object.op_Implicit((Object)(object)instance.master))
				{
					continue;
				}
				UserIDData userID = new UserIDData(instance.networkUser.id);
				List<BetterLemurController> lemurControllers = GetLemurControllers(((NetworkBehaviour)instance.master).netId);
				foreach (BetterLemurController item in lemurControllers)
				{
					list.Add(new BetterLemurianData(userID, item));
				}
			}
			obj["com.score.LemurFusion"] = list;
		}

		private void Loading_OnLoadingEnded(SaveFile saveFile)
		{
			List<BetterLemurianData> lemurData;
			if (saveFile.ModdedData.TryGetValue("com.score.LemurFusion", out var value))
			{
				object obj = ((value != null) ? value.Value : null);
				lemurData = obj as List<BetterLemurianData>;
				if (lemurData != null && lemurData.Any())
				{
					CharacterMaster.onStartGlobal += SpawnMinion;
				}
			}
			void SpawnMinion(CharacterMaster master)
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				BetterLemurController lemCtrl = default(BetterLemurController);
				if (Object.op_Implicit((Object)(object)master) && ((Component)master).TryGetComponent<BetterLemurController>(ref lemCtrl))
				{
					MinionOwnership minionOwnership = master.minionOwnership;
					NetworkUserId? obj2;
					if (minionOwnership == null)
					{
						obj2 = null;
					}
					else
					{
						CharacterMaster ownerMaster = minionOwnership.ownerMaster;
						if (ownerMaster == null)
						{
							obj2 = null;
						}
						else
						{
							PlayerCharacterMasterController playerCharacterMasterController = ownerMaster.playerCharacterMasterController;
							if (playerCharacterMasterController == null)
							{
								obj2 = null;
							}
							else
							{
								NetworkUser networkUser = playerCharacterMasterController.networkUser;
								obj2 = ((networkUser != null) ? new NetworkUserId?(networkUser.id) : null);
							}
						}
					}
					NetworkUserId? netId = obj2;
					if (netId.HasValue)
					{
						BetterLemurianData betterLemurianData = lemurData.FirstOrDefault(delegate(BetterLemurianData lem)
						{
							//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)
							NetworkUserId val = lem.summonerId.Load();
							return ((object)(NetworkUserId)(ref val)).Equals((object?)netId);
						});
						if (betterLemurianData != null)
						{
							betterLemurianData.LoadData(lemCtrl);
							lemurData.Remove(betterLemurianData);
						}
						if (!lemurData.Any())
						{
							CharacterMaster.onStartGlobal -= SpawnMinion;
							foreach (DevotionInventoryController instance in DevotionInventoryController.InstanceList)
							{
								instance.UpdateAllMinions(false);
							}
						}
					}
				}
			}
		}

		private static List<BetterLemurController> GetLemurControllers(NetworkInstanceId masterID)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			List<BetterLemurController> list = new List<BetterLemurController>();
			MinionGroup obj = MinionGroup.FindGroup(masterID);
			MinionOwnership[] array = ((obj != null) ? obj.members : null) ?? Array.Empty<MinionOwnership>();
			BetterLemurController item = default(BetterLemurController);
			foreach (MinionOwnership val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.TryGetComponent<BetterLemurController>(ref item))
				{
					list.Add(item);
				}
			}
			return list;
		}
	}
	internal class StatHooks
	{
		public static StatHooks instance;

		private StatHooks()
		{
		}

		public static void Init()
		{
			if (instance == null)
			{
				instance = new StatHooks();
			}
		}

		public void InitHooks()
		{
			//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
			Util.GetBestMasterName += new hook_GetBestMasterName(Util_GetBestMasterName);
			CharacterBody.GetDisplayName += new hook_GetDisplayName(CharacterBody_GetDisplayName);
			ScoreboardController.Rebuild += new hook_Rebuild(ScoreboardController_Rebuild);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
			CharacterBody.onBodyStartGlobal += CharacterBody_onBodyStartGlobal;
		}

		public void RemoveHooks()
		{
			//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
			Util.GetBestMasterName -= new hook_GetBestMasterName(Util_GetBestMasterName);
			CharacterBody.GetDisplayName -= new hook_GetDisplayName(CharacterBody_GetDisplayName);
			ScoreboardController.Rebuild -= new hook_Rebuild(ScoreboardController_Rebuild);
			RecalculateStatsAPI.GetStatCoefficients -= new StatHookEventHandler(RecalculateStatsAPI_GetStatCoefficients);
			CharacterBody.onBodyStartGlobal -= CharacterBody_onBodyStartGlobal;
		}

		private string Util_GetBestMasterName(orig_GetBestMasterName orig, CharacterMaster characterMaster)
		{
			if (Object.op_Implicit((Object)(object)characterMaster) && ((Object)characterMaster).name == "BetterDevotedLemurianMaster(Clone)" && characterMaster.hasBody)
			{
				return characterMaster.GetBody().GetDisplayName();
			}
			return orig.Invoke(characterMaster);
		}

		private string CharacterBody_GetDisplayName(orig_GetDisplayName orig, CharacterBody self)
		{
			string text = orig.Invoke(self);
			if (!string.IsNullOrEmpty(text))
			{
				int? obj;
				if (self == null)
				{
					obj = null;
				}
				else
				{
					Inventory inventory = self.inventory;
					obj = ((inventory != null) ? new int?(inventory.GetItemCount(Items.LemurianHarness)) : null);
				}
				int? num = obj;
				if (num.HasValue && num.Value > 0)
				{
					return $"{text} <style=cStack>x{num}</style>";
				}
			}
			return text;
		}

		private void ScoreboardController_Rebuild(orig_Rebuild orig, ScoreboardController self)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!PluginConfig.enableMinionScoreboard.Value)
			{
				return;
			}
			List<CharacterMaster> list = new List<CharacterMaster>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				list.Add(instance.master);
			}
			CharacterMaster master = LocalUserManager.readOnlyLocalUsersList.First().cachedMasterController.master;
			List<BetterLemurController> list2 = new List<BetterLemurController>();
			if (Object.op_Implicit((Object)(object)master))
			{
				MinionGroup obj = MinionGroup.FindGroup(((NetworkBehaviour)master).netId);
				MinionOwnership[] array = ((obj != null) ? obj.members : null) ?? Array.Empty<MinionOwnership>();
				BetterLemurController item = default(BetterLemurController);
				foreach (MinionOwnership val in array)
				{
					if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.TryGetComponent<BetterLemurController>(ref item))
					{
						list2.Add(item);
						if (!PluginConfig.showPersonalInventory.Value)
						{
							break;
						}
					}
				}
			}
			self.SetStripCount(list.Count + list2.Count);
			for (int j = 0; j < list.Count; j++)
			{
				self.stripAllocator.elements[j].SetMaster(list[j]);
			}
			for (int k = 0; k < list2.Count; k++)
			{
				BetterLemurController betterLemurController = list2[k];
				ScoreboardStrip val2 = self.stripAllocator.elements[k + list.Count];
				val2.SetMaster(((DevotedLemurianController)betterLemurController)._lemurianMaster);
				if (!PluginConfig.showPersonalInventory.Value)
				{
					break;
				}
				((DevotedLemurianController)betterLemurController).LemurianInventory.onInventoryChanged -= val2.itemInventoryDisplay.OnInventoryChanged;
				val2.itemInventoryDisplay.itemOrderCount = betterLemurController._devotedItemList.Count;
				Array.Copy(((DevotedLemurianController)betterLemurController).LemurianInventory.itemStacks, val2.itemInventoryDisplay.itemStacks, val2.itemInventoryDisplay.itemStacks.Length);
				Array.Copy(betterLemurController._devotedItemList.Keys.ToArray(), val2.itemInventoryDisplay.itemOrder, val2.itemInventoryDisplay.itemOrderCount);
				foreach (KeyValuePair<ItemIndex, int> devotedItem in betterLemurController._devotedItemList)
				{
					val2.itemInventoryDisplay.itemStacks[devotedItem.Key] = devotedItem.Value;
				}
				val2.itemInventoryDisplay.RequestUpdateDisplay();
			}
		}

		private void CharacterBody_onBodyStartGlobal(CharacterBody body)
		{
			//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)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			int? obj;
			if (body == null)
			{
				obj = null;
			}
			else
			{
				Inventory inventory = body.inventory;
				obj = ((inventory != null) ? new int?(inventory.GetItemCount(Items.LemurianHarness)) : null);
			}
			int? num = obj;
			if (num.HasValue && num.Value > 0)
			{
				if (AITweaks.disableFallDamage.Value)
				{
					body.bodyFlags = (BodyFlags)(body.bodyFlags | 1);
				}
				if (AITweaks.immuneToVoidDeath.Value)
				{
					body.bodyFlags = (BodyFlags)(body.bodyFlags | 0x800);
				}
				ResizeBody(num.Value, body);
			}
		}

		private void RecalculateStatsAPI_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			int? obj;
			if (sender == null)
			{
				obj = null;
			}
			else
			{
				Inventory inventory = sender.inventory;
				obj = ((inventory != null) ? new int?(inventory.GetItemCount(Items.LemurianHarness)) : null);
			}
			int? num = obj;
			BetterLemurController betterLemurController = default(BetterLemurController);
			if (num.HasValue && num.Value > 0 && sender.masterObject.TryGetComponent<BetterLemurController>(ref betterLemurController))
			{
				if (PluginConfig.rebalanceHealthScaling.Value)
				{
					args.levelHealthAdd += sender.levelMaxHealth * Utils.GetLevelModifier(((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.levelRegenAdd += Utils.GetLevelModifier(((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.armorAdd += Utils.GetLevelModifier(((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.healthMultAdd += Utils.GetFusionStatMultiplier(PluginConfig.statMultHealth.Value, num.Value, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.damageMultAdd += Utils.GetFusionStatMultiplier(PluginConfig.statMultDamage.Value, num.Value, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.attackSpeedMultAdd += Utils.GetFusionStatMultiplier(PluginConfig.statMultAttackSpeed.Value, num.Value, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
				}
				else
				{
					args.healthMultAdd += Utils.GetVanillaStatModifier(PluginConfig.statMultHealth.Value, num.Value, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.damageMultAdd += Utils.GetVanillaStatModifier(PluginConfig.statMultHealth.Value, num.Value, ((DevotedLemurianController)betterLemurController).DevotedEvolutionLevel);
					args.attackSpeedMultAdd += Utils.GetVanillaStatModifier(PluginConfig.statMultHealth.Value, num.Value, 0);
				}
			}
		}

		private void ResizeBody(int meldCount, CharacterBody body)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkClient.active)
			{
				return;
			}
			object obj;
			if (body == null)
			{
				obj = null;
			}
			else
			{
				ModelLocator modelLocator = body.modelLocator;
				obj = ((modelLocator != null) ? modelLocator.modelTransform : null);
			}
			Transform val = (Transform)obj;
			if (Object.op_Implicit((Object)(object)val))
			{
				if (PluginConfig.miniElders.Value)
				{
					val.localScale = Vector3.one * 0.15f;
				}
				FootstepHandler val2 = default(FootstepHandler);
				if (((Component)val).gameObject.TryGetComponent<FootstepHandler>(ref val2))
				{
					val2.baseFootstepString = "";
				}
			}
		}
	}
	internal static class Utils
	{
		public static void AddItem(SortedList<ItemIndex, int> target, ItemDef itemDef, int count = 1)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)itemDef))
			{
				AddItem(target, itemDef.itemIndex, count);
			}
		}

		public static void AddItem(SortedList<ItemIndex, int> target, ItemIndex itemIndex, int count = 1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if ((int)itemIndex != -1)
			{
				if (target == null)
				{
					target = new SortedList<ItemIndex, int>();
				}
				if (target.ContainsKey(itemIndex))
				{
					target[itemIndex] += count;
				}
				else
				{
					target.Add(itemIndex, count);
				}
			}
		}

		public static void SetItem(SortedList<ItemIndex, int> target, ItemDef itemDef, int count = 1)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)itemDef))
			{
				SetItem(target, itemDef.itemIndex, count);
			}
		}

		public static void SetItem(SortedList<ItemIndex, int> target, ItemIndex itemIndex, int count = 1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0016: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if ((int)itemIndex == -1)
			{
				return;
			}
			if (target == null)
			{
				target = new SortedList<ItemIndex, int>();
			}
			if (target.ContainsKey(itemIndex))
			{
				if (count <= 0)
				{
					target.Remove(itemIndex);
				}
				else
				{
					target[itemIndex] = count;
				}
			}
			else
			{
				target.Add(itemIndex, count);
			}
		}

		public static void RemoveItem(SortedList<ItemIndex, int> target, ItemDef itemDef, int count = 1)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)itemDef))
			{
				RemoveItem(target, itemDef.itemIndex, count);
			}
		}

		public static void RemoveItem(SortedList<ItemIndex, int> target, ItemIndex itemIndex, int count = 1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_001d: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)itemIndex == -1 || target == null)
			{
				return;
			}
			if (target == null)
			{
				target = new SortedList<ItemIndex, int>();
			}
			if (target.TryGetValue(itemIndex, out var value))
			{
				int num = Math.Max(0, value - count);
				if (num == 0)
				{
					target.Remove(itemIndex);
				}
				else
				{
					target[itemIndex] = num;
				}
			}
		}

		public static Vector3 GetScaleFactor(int configValue, int meldCount)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (meldCount <= 1)
			{
				return Vector3.one;
			}
			return Vector3.one * ((float)(meldCount - 1) * ((float)configValue * 0.01f) * 0.5f);
		}

		public static float GetVanillaStatModifier(int configValue, int meldCount, int evolutionCount)
		{
			if (1 == 0)
			{
			}
			int num;
			switch (evolutionCount)
			{
			case 0:
			case 2:
				num = 10;
				break;
			case 1:
				num = 20;
				break;
			default:
				num = 17 + evolutionCount;
				break;
			}
			if (1 == 0)
			{
			}
			int num2 = num;
			return (float)meldCount * ((float)configValue * 0.01f) + (float)num2 * 0.1f;
		}

		public static float GetFusionStatMultiplier(int configValue, int meldCount, int evolutionCount)
		{
			int num = Mathf.Clamp(evolutionCount, 0, 4);
			float num2 = (float)PluginConfig.statMultEvo.Value * 0.01f;
			return (float)(meldCount - 1) * ((float)configValue * 0.01f) + (float)num * num2 * 0.1f;
		}

		public static float GetLevelModifier(int evolutionCount)
		{
			if (!Object.op_Implicit((Object)(object)Run.instance))
			{
				return 0f;
			}
			int num = Mathf.Clamp(Run.instance.stageClearCount + 1, 1, 4);
			int num2 = Mathf.Clamp(evolutionCount, 0, 4);
			float num3 = (float)PluginConfig.statMultEvo.Value * 0.01f;
			return (float)num * num3 + (float)num2 * num3;
		}

		public static Vector3 EstimateClosestPoint(Vector3 pos, Vector3 lossyScale, Quaternion rotation, Vector3 point)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			lossyScale *= 0.5f;
			Vector3 start = rotation * new Vector3(pos.x + lossyScale.x, pos.y, pos.z + lossyScale.z);
			Vector3 end = rotation * new Vector3(pos.x - lossyScale.x, pos.y, pos.z - lossyScale.z);
			Vector3 start2 = rotation * new Vector3(pos.x + lossyScale.x, pos.y, pos.z - lossyScale.z);
			Vector3 end2 = rotation * new Vector3(pos.x - lossyScale.x, pos.y, pos.z + lossyScale.z);
			Vector3 val = NearestPointOnLine(point, start, end);
			Vector3 val2 = NearestPointOnLine(point, start2, end2);
			if (Vector3.Distance(val, point) < Vector3.Distance(val2, point))
			{
				return val;
			}
			return val2;
		}

		public static Vector3 NearestPointOnLine(Vector3 point, Vector3 start, Vector3 end)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			start.y = point.y;
			end.y = point.y;
			Vector3 val = end - start;
			float magnitude = ((Vector3)(ref val)).magnitude;
			((Vector3)(ref val)).Normalize();
			float num = Vector3.Dot(point - start, val);
			num = Mathf.Clamp(num, 0f, magnitude);
			return start + val * num;
		}
	}
}
namespace LemurFusion.Config
{
	internal class ConfigExtended
	{
		public static ConfigEntry<bool> Blacklist_Enable;

		public static ConfigEntry<bool> Blacklist_Filter_CannotCopy;

		public static ConfigEntry<bool> Blacklist_Filter_Scrap;

		public static ConfigEntry<bool> DeathDrop_Enable;

		public static ConfigEntry<bool> DeathDrop_DropEgg;

		public static ConfigEntry<DevotionTweaks.DeathItem> DeathDrop_ItemType;

		public static ConfigEntry<bool> DeathDrop_DropAll;

		public static ConfigEntry<string> Blacklisted_ItemTiers_Raw;

		public static ConfigEntry<string> Blacklisted_Items_Raw;

		public static ConfigEntry<string> DeathDrops_TierToItem_Map_Raw;

		public static HashSet<ItemTier> Blacklisted_ItemTiers = new HashSet<ItemTier>();

		public static HashSet<ItemIndex> Blacklisted_Items = new HashSet<ItemIndex>();

		public static SortedList<ItemTier, ItemIndex> DeathDrops_TierToItem_Map = new SortedList<ItemTier, ItemIndex>();

		public static Func<ItemIndex, bool> Blacklist_Filter;

		internal static void PostLoad()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			Blacklist_Filter = Inventory.defaultItemCopyFilterDelegate;
			Blacklisted_Items = new HashSet<ItemIndex>();
			Blacklisted_ItemTiers = new HashSet<ItemTier>();
			DeathDrops_TierToItem_Map = new SortedList<ItemTier, ItemIndex>();
			DeathDrops_TierToItem_Map.Add((ItemTier)0, Items.ScrapWhite.itemIndex);
			DeathDrops_TierToItem_Map.Add((ItemTier)1, Items.ScrapGreen.itemIndex);
			DeathDrops_TierToItem_Map.Add((ItemTier)2, Items.ScrapRed.itemIndex);
			DeathDrops_TierToItem_Map.Add((ItemTier)4, Items.ScrapYellow.itemIndex);
			if (Blacklist_Enable.Value)
			{
				BLItemTiers();
				BLItems();
				CreateBlacklistFunction();
			}
			if (DeathDrop_Enable.Value)
			{
				CreateDeathDropMap();
			}
		}

		private static void CreateDeathDropMap()
		{
			//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_00be: 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_00dd: Invalid comparison between Unknown and I4
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(DeathDrops_TierToItem_Map_Raw.Value))
			{
				return;
			}
			try
			{
				string[] array = DeathDrops_TierToItem_Map_Raw.Value.Replace(" ", "").Split(new char[1] { ';' });
				foreach (string text in array)
				{
					string[] array2 = text.Split(new char[1] { ',' });
					if (array2.Length != 2)
					{
						LemurFusionPlugin.LogWarning("String parsing error for (TierDef, ItemDef) pair '(" + text + ")' for Custom Drop List.");
						continue;
					}
					ItemTierDef val = ItemTierCatalog.FindTierDef(array2[0]);
					ItemIndex val2 = ItemCatalog.FindItemIndex(array2[1]);
					if (PluginConfig.enableDetailedLogs.Value)
					{
						LemurFusionPlugin.LogInfo($"Attemping to add ({val}, {val2}) pair parsed from string'({text})' for Custom Drop List.");
					}
					if (Object.op_Implicit((Object)(object)val) && (int)val2 != -1)
					{
						if (DeathDrops_TierToItem_Map.ContainsKey(val.tier) && PluginConfig.enableDetailedLogs.Value)
						{
							LemurFusionPlugin.LogWarning($"Overwriting duplicate {((val != null) ? ((Object)val).name : null)} with '({((val != null) ? ((Object)val).name : null)},{val2})' for Custom Drop List.");
						}
						DeathDrops_TierToItem_Map[val.tier] = val2;
					}
					else
					{
						LemurFusionPlugin.LogWarning($"Could not find (TierDef, ItemDef) pair '({((val != null) ? ((Object)val).name : null)},{val2})' for Custom Drop List.");
					}
				}
			}
			catch (Exception ex)
			{
				LemurFusionPlugin.LogWarning(ex.Message);
				LemurFusionPlugin.LogWarning(ex.StackTrace);
			}
		}

		private static void BLItems()
		{
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			LemurFusionPlugin.LogInfo("Blacklisting items...");
			try
			{
				HashSet<ItemIndex> hashSet = new HashSet<ItemIndex>();
				foreach (ItemIndex item in from <>h__TransparentIdentifier0 in (Blacklisted_Items_Raw.Value?.Split(new char[1] { ',' }) ?? Array.Empty<string>()).Select((string item) => new
					{
						item = item,
						idx = ItemCatalog.FindItemIndex(item?.Trim())
					}).Where(<>h__TransparentIdentifier0 =>
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						//IL_0007: Invalid comparison between Unknown and I4
						//IL_000a: Unknown result type (might be due to invalid IL or missing references)
						//IL_000f: Unknown result type (might be due to invalid IL or missing references)
						int result;
						if ((int)<>h__TransparentIdentifier0.idx != -1)
						{
							ItemIndex idx = <>h__TransparentIdentifier0.idx;
							result = (ItemCatalog.IsIndexValid(ref idx) ? 1 : 0);
						}
						else
						{
							result = 0;
						}
						return (byte)result != 0;
					})
					select ItemCatalog.GetItemDef(<>h__TransparentIdentifier0.idx) into def
					where Object.op_Implicit((Object)(object)def)
					select def.itemIndex)
				{
					hashSet.Add(item);
				}
				Blacklisted_Items = hashSet;
				if (!PluginConfig.enableDetailedLogs.Value)
				{
					return;
				}
				foreach (ItemIndex blacklisted_Item in Blacklisted_Items)
				{
					LemurFusionPlugin.LogInfo(ItemCatalog.GetItemDef(blacklisted_Item)?.nameToken);
				}
			}
			catch (Exception ex)
			{
				LemurFusionPlugin.LogWarning(ex.Message);
				LemurFusionPlugin.LogWarning(ex.StackTrace);
			}
		}

		private static void BLItemTiers()
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			LemurFusionPlugin.LogInfo("Blacklisting tiers...");
			try
			{
				HashSet<ItemTier> hashSet = new HashSet<ItemTier>();
				foreach (ItemTier item in from tier in Blacklisted_ItemTiers_Raw.Value.Split(new char[1] { ',' }) ?? Array.Empty<string>()
					let def = ItemTierCatalog.FindTierDef(tier?.Trim() ?? string.Empty)
					where Object.op_Implicit((Object)(object)def)
					select def.tier)
				{
					hashSet.Add(item);
				}
				Blacklisted_ItemTiers = hashSet;
				if (!PluginConfig.enableDetailedLogs.Value)
				{
					return;
				}
				foreach (ItemTier blacklisted_ItemTier in Blacklisted_ItemTiers)
				{
					ItemTierDef itemTierDef = ItemTierCatalog.GetItemTierDef(blacklisted_ItemTier);
					LemurFusionPlugin.LogInfo((itemTierDef != null) ? ((Object)itemTierDef).name : null);
				}
			}
			catch (Exception ex)
			{
				LemurFusionPlugin.LogWarning(ex.Message);
				LemurFusionPlugin.LogWarning(ex.StackTrace);
			}
		}

		private static void CreateBlacklistFunction()
		{
			try
			{
				Blacklist_Filter = delegate(ItemIndex idx)
				{
					//IL_0001: Unknown result type (might be due to invalid IL or missing references)
					//IL_0003: Invalid comparison between Unknown and I4
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0043: Invalid comparison between Unknown and I4
					//IL_0065: Unknown result type (might be due to invalid IL or missing references)
					if ((int)idx == -1 || !ItemCatalog.IsIndexValid(ref idx))
					{
						return false;
					}
					ItemDef itemDef = ItemCatalog.GetItemDef(idx);
					if (!Object.op_Implicit((Object)(object)itemDef) || itemDef.hidden || !itemDef.canRemove || (int)itemDef.tier == 5)
					{
						return false;
					}
					bool flag = !Blacklisted_Items.Contains(idx) && !Blacklisted_ItemTiers.Contains(itemDef.tier);
					if (Blacklist_Filter_CannotCopy.Value)
					{
						flag &= itemDef.DoesNotContainTag((ItemTag)13);
					}
					if (Blacklist_Filter_Scrap.Value)
					{
						flag &= itemDef.DoesNotContainTag((ItemTag)10) && itemDef.DoesNotContainTag((ItemTag)14);
					}
					return flag;
				};
				TestFilter();
			}
			catch (Exception ex)
			{
				LemurFusionPlugin.LogWarning(ex.Message);
				LemurFusionPlugin.LogWarning(ex.StackTrace);
			}
		}

		internal static void TestFilter()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginConfig.enableDetailedLogs.Value)
			{
				return;
			}
			LemurFusionPlugin.LogInfo("Testing blacklist function...");
			try
			{
				foreach (ItemDef item in ((IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs).ToList())
				{
					if (!Object.op_Implicit((Object)(object)item))
					{
						break;
					}
					bool flag = Blacklist_Filter(item.itemIndex);
					if (Object.op_Implicit((Object)(object)item) && ((int)item.tier == 3 || (int)item.tier >= 5))
					{
						bool flag2 = false;
					}
					else
					{
						bool flag2 = Inventory.defaultItemCopyFilterDelegate(item.itemIndex);
					}
				}
			}
			catch (Exception ex)
			{
				LemurFusionPlugin.LogWarning(ex.Message);
				LemurFusionPlugin.LogWarning(ex.StackTrace);
			}
		}
	}
	internal static class ConfigReader
	{
		private const string GENERAL = "01 - General";

		private const string EXPERIMENTAL = "02 - Experimental";

		private const string STATS = "03 - Fusion Stats";

		private const string AI_CONFIG = "04 - AI Changes";

		private const string DEATH = "05 - Death Settings";

		private const string BLACKLIST = "06 - Item Blacklist";

		private const string Desc_Enable = "Enables changes for this section.";

		internal static void Setup()
		{
			ReadConfig();
			ReadAIConfig();
			ReadConfigExtended();
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(ConfigExtended.PostLoad));
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		internal static void ReadConfig()
		{
			if (LemurFusionPlugin.rooInstalled)
			{
				PluginConfig.InitRoO();
			}
			PluginConfig.maxLemurs = PluginConfig.BindOptionSlider("01 - General", "Max Lemurs", 1, "Max dudes", 1f);
			PluginConfig.teleportDistance = PluginConfig.BindOptionSlider("01 - General", "Teleport Distance", 100, "Sets the max distance a Lemurian can be from their owner before teleporting.", 50f, 400f);
			PluginConfig.enableMinionScoreboard = PluginConfig.BindOption("01 - General", "Enable Minion Scoreboard", defaultValue: true, "Devoted Lemurians will show up on the scoreboard.");
			PluginConfig.showPersonalInventory = PluginConfig.BindOption("01 - General", "Individual Scoreboard Inventories", defaultValue: true, "Enable to display a scoreboard entry for each lemurian you control. Scoreboard entry will show the items that each minion contributes to the shared inventory.\r\nPurely visual, does not change vanilla item sharing mechanics.");
			PluginConfig.highTierElitesOnly = PluginConfig.BindOption("01 - General", "High Tier Elites Only For Final Evolution", defaultValue: true, "When rerolling the fully evolved elite elder lemurian aspects, should it always be a lategame elite type?");
			PluginConfig.enableSharedInventory = PluginConfig.BindOption("02 - Experimental", "Enable Shared Inventory", defaultValue: true, "If set to false, the shared inventory will not be used and instead unique inventory will be used for every lemurian you control.\r\nDisabling this setting will make all lemurians visible on the scoreboard.", restartRequired: true);
			PluginConfig.cloneReplacesRevive = PluginConfig.BindOption("02 - Experimental", "Clone Replaces Revive", defaultValue: false, "Spawns a clone of the target lemurian when a Dio's or Larva is given.");
			PluginConfig.miniElders = PluginConfig.BindOption("02 - Experimental", "Mini Elder Lemurians", defaultValue: true, "Theyre so cute omg");
			PluginConfig.enableDetailedLogs = PluginConfig.BindOption("02 - Experimental", "Enable Detailed Logs", defaultValue: false, "For dev use/debugging. Keep this on if you want to submit a bug report.");
			PluginConfig.rebalanceHealthScaling = PluginConfig.BindOption("03 - Fusion Stats", "Rebalance Stat Scaling", defaultValue: true, "Rebalances base stats and stat scaling so that new summons on later stages have an easier time surviving and elder lemurians dont get buffed as much");
			PluginConfig.statMultHealth = PluginConfig.BindOptionSlider("03 - Fusion Stats", "Fusion Health Increase", 20, "Health multiplier for each lemur fusion, in percent.", 0f, 100f);
			PluginConfig.statMultDamage = PluginConfig.BindOptionSlider("03 - Fusion Stats", "Fusion Damage Increase", 20, "Damage multiplier for each lemur fusion, in percent.", 0f, 100f);
			PluginConfig.statMultAttackSpeed = PluginConfig.BindOptionSlider("03 - Fusion Stats", "Fusion Attack Speed Increase", 20, "Attack speed multiplier for each lemur fusion, in percent.", 0f, 100f);
			PluginConfig.statMultEvo = PluginConfig.BindOptionSlider("03 - Fusion Stats", "Evolution Stat Modifier", 100, "Additional Health and Damage Multiplier for per Evolution Stage, in percent. Vanilla is 100.", 0f, 200f);
		}

		internal static void ReadAIConfig()
		{
			AITweaks.disableFallDamage = PluginConfig.BindOption("04 - AI Changes", "Disable Fall Damage", defaultValue: true, "If true, prevents Lemurians from taking fall damage.");
			AITweaks.immuneToVoidDeath = PluginConfig.BindOption("04 - AI Changes", "Immune To Void Death", defaultValue: false, "If true, prevents Lemurians from dying to void insta-kill explosions.");
			AITweaks.improveAI = PluginConfig.BindOption("04 - AI Changes", "Improve AI", defaultValue: true, "Makes minions less likely to stand around and makes them better at not dying.", restartRequired: true);
			AITweaks.enablePredictiveAiming = PluginConfig.BindOption("04 - AI Changes", "Enable Predictive Aiming", defaultValue: true, "Requires \"Improve AI\". Predicts target movement based on velocity.");
			AITweaks.enableProjectileTracking = PluginConfig.BindOption("04 - AI Changes", "Enable Projectile Tracking", defaultValue: true, "Requires \"Improve AI\". Tracks and attempts to dodge most projectiles that come close.");
			AITweaks.visualizeProjectileTracking = PluginConfig.BindOption("04 - AI Changes", "Visualize Projectile Tracking", defaultValue: false, "Requires \"Enable Projectile Tracking\". Creates a line connecting the foot position to the tracked projectile.");
			AITweaks.excludeSurvivorProjectiles = PluginConfig.BindOption("04 - AI Changes", "Exclude Survivor Projectiles", defaultValue: true, "Requires \"Enable Projectile Tracking\". Excludes enemy survivor projectiles from the list of dodgable projectiles. Set to false if you commonly fight vanilla survivor Umbras.", restartRequired: true);
			AITweaks.updateFrequency = PluginConfig.BindOptionSlider("04 - AI Changes", "In Combat Update Frequency", 0.1f, "Requires \"Enable Projectile Tracking\". Controls how often to refresh the projectile targeting. Increasing this value may change how the AI pathing behaves but will result in getting hit more often.", 0.1f, 0.5f);
			AITweaks.detectionRadius = PluginConfig.BindOptionSlider("04 - AI Changes", "Detection Radius", 25, "Requires \"Enable Projectile Tracking\". Controls the size of the detection area to use when deciding whether running away is necessary. Distance from large AOE zones is estimated using the hitbox instead of center point to account for size and rotation.", 10f, 40f);
		}

		private static void ReadConfigExtended()
		{
			ConfigExtended.DeathDrop_Enable = PluginConfig.BindOption("05 - Death Settings", "Enable Death Changes", defaultValue: true, "Enables changes for this section.", restartRequired: true);
			ConfigExtended.DeathDrop_DropEgg = PluginConfig.BindOption("05 - Death Settings", "Egg On Death", defaultValue: false, "Should