Decompiled source of Megalomania v1.3.1

plugins/Megalomania/MegalomaniaPlugin.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG;
using IL.RoR2;
using JetBrains.Annotations;
using MegalomaniaPlugin.Buffs;
using MegalomaniaPlugin.Items;
using MegalomaniaPlugin.Skills;
using MegalomaniaPlugin.Skills.MinigunAbility;
using MegalomaniaPlugin.Utilities;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.Networking;

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

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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;
		}
	}
}
namespace MegalomaniaPlugin
{
	[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("A5TR0spud.Megalomania", "Megalomania", "1.3.1")]
	public class MegalomaniaPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__285_0;

			internal void <HookLunarSunStats>b__285_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (!Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.inventory))
				{
					return;
				}
				int num = ((!ConfigBombStacking.Value) ? sender.inventory.GetItemCount(Items.LunarSun) : sender.master.GetDeployableCount((DeployableSlot)16));
				if (num > 0)
				{
					float num2 = (float)ConfigMaxHealthInitialStack.Value;
					num2 += (float)num * (float)ConfigMaxHealthPerStack.Value;
					args.baseHealthAdd += num2;
					float num3 = (float)ConfigRegenInitialStack.Value;
					num3 += (float)num * (float)ConfigRegenPerStack.Value;
					args.baseRegenAdd += num3;
					float num4 = (float)ConfigMovementSpeedInitialStack.Value;
					num4 += (float)ConfigMovementSpeedPerStack.Value;
					args.baseMoveSpeedAdd += Utils.determineStatBoost(ConfigMovementSpeedType.Value, num4, (float)ConfigMovementSpeedBonusCap.Value, num);
					float num5 = (float)ConfigDamageInitialStack.Value;
					num5 += (float)num * (float)ConfigDamagePerStack.Value;
					args.baseDamageAdd += num5;
					float num6 = (float)ConfigAttackSpeedInitialStack.Value;
					num6 += (float)ConfigAttackSpeedPerStack.Value;
					args.attackSpeedMultAdd += Utils.determineStatBoost(ConfigAttackSpeedType.Value, num6, (float)ConfigAttackSpeedBonusCap.Value, num);
					float num7 = (float)ConfigCritChanceInitialStack.Value;
					num7 += (float)num * (float)ConfigCritChancePerStack.Value;
					args.critAdd += 100f * num7;
					float num8 = (float)ConfigArmorInitialStack.Value;
					num8 += (float)num * (float)ConfigArmorPerStack.Value;
					if (ConfigArmorMax.Value > 0.0)
					{
						num8 = Math.Min(num8, (float)ConfigArmorMax.Value);
					}
					args.armorAdd += num8;
				}
			}
		}

		public const string PluginGUID = "A5TR0spud.Megalomania";

		public const string PluginAuthor = "A5TR0spud";

		public const string PluginName = "Megalomania";

		public const string PluginVersion = "1.3.1";

		public static AssetBundle megalomaniaAssetBundle;

		public static Sprite EgoPrimarySprite;

		public static Sprite EgoMonopolizeSprite;

		public static Sprite EgoBombSprite;

		public static Sprite EgoTwinShotSprite;

		public static Sprite EgoShellSprite;

		public static Sprite EgoMinigunSprite;

		public static ItemDef transformToken;

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

		public static ConfigEntry<double> ConfigMaxHealthInitialStack { get; set; }

		public static ConfigEntry<double> ConfigMaxHealthPerStack { get; set; }

		public static ConfigEntry<double> ConfigRegenInitialStack { get; set; }

		public static ConfigEntry<double> ConfigRegenPerStack { get; set; }

		public static ConfigEntry<double> ConfigArmorInitialStack { get; set; }

		public static ConfigEntry<double> ConfigArmorPerStack { get; set; }

		public static ConfigEntry<double> ConfigArmorMax { get; set; }

		public static ConfigEntry<double> ConfigDamageInitialStack { get; set; }

		public static ConfigEntry<double> ConfigDamagePerStack { get; set; }

		public static ConfigEntry<double> ConfigCritChanceInitialStack { get; set; }

		public static ConfigEntry<double> ConfigCritChancePerStack { get; set; }

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

		public static ConfigEntry<double> ConfigAttackSpeedInitialStack { get; set; }

		public static ConfigEntry<double> ConfigAttackSpeedPerStack { get; set; }

		public static ConfigEntry<double> ConfigAttackSpeedBonusCap { get; set; }

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

		public static ConfigEntry<double> ConfigMovementSpeedInitialStack { get; set; }

		public static ConfigEntry<double> ConfigMovementSpeedPerStack { get; set; }

		public static ConfigEntry<double> ConfigMovementSpeedBonusCap { get; set; }

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

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

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

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

		public static ConfigEntry<Utils.OnHitBombAttackType> ConfigOnHitBombAttack { get; set; }

		public static ConfigEntry<Utils.BombDensity> ConfigBombFocused { get; set; }

		public static ConfigEntry<double> ConfigBombCreationRate { get; set; }

		public static ConfigEntry<double> ConfigBombCreationStackingMultiplier { get; set; }

		public static ConfigEntry<double> ConfigBombCreationStackingAdder { get; set; }

		public static ConfigEntry<double> ConfigBombDamage { get; set; }

		public static ConfigEntry<double> ConfigBombStackingDamage { get; set; }

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

		public static ConfigEntry<double> ConfigBombStackingCap { get; set; }

		public static ConfigEntry<double> ConfigBombRange { get; set; }

		public static ConfigEntry<double> ConfigBombStackingRange { get; set; }

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

		public static ConfigEntry<double> ConfigStageStartTransformStack { get; set; }

		public static ConfigEntry<double> ConfigTransformTime { get; set; }

		public static ConfigEntry<double> ConfigTransformTimePerStack { get; set; }

		public static ConfigEntry<double> ConfigTransformTimeDiminishing { get; set; }

		public static ConfigEntry<double> ConfigTransformTimeMin { get; set; }

		public static ConfigEntry<double> ConfigTransformTimeMax { get; set; }

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

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

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

		public static ConfigEntry<double> ConfigStackSizeMultiplier { get; set; }

		public static ConfigEntry<double> ConfigStackSizeAdder { get; set; }

		public static ConfigEntry<Utils.ConversionSelectionType> ConfigConversionSelectionType { get; set; }

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

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

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

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

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

		public static ConfigEntry<Utils.SkillEnum> ConfigPrimarySkill { get; set; }

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

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

		public static ConfigEntry<Utils.SkillEnum> ConfigSecondarySkill { get; set; }

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

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

		public static ConfigEntry<Utils.SkillEnum> ConfigUtilitySkill { get; set; }

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

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

		public static ConfigEntry<Utils.SkillEnum> ConfigSpecialSkill { get; set; }

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

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

		public static MegalomaniaEgoBehavior megalomaniaEgoBehavior { get; set; }

		public void Awake()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			megalomaniaEgoBehavior = new MegalomaniaEgoBehavior();
			LoadAssets();
			CreateConfig();
			HookLunarSunStats();
			InitBuffs();
			InitItems();
			Utils.ParseRarityPriorityList();
			InitSkills();
			Utils.initSkillsList();
			ItemCatalog.SetItemDefs += new hook_SetItemDefs(ItemCatalog_SetItemDefs);
			CharacterMaster.OnServerStageBegin += new hook_OnServerStageBegin(CharacterMaster_OnServerStageBegin);
			CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(CharacterBody_OnInventoryChanged);
			if (!ConfigCompatibilityMode.Value)
			{
				megalomaniaEgoBehavior.init();
				LanguageUtils.start();
			}
		}

		private void CharacterBody_OnInventoryChanged(orig_OnInventoryChanged orig, CharacterBody self)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			SkillLocator skillLocator = self.skillLocator;
			if (Object.op_Implicit((Object)(object)skillLocator) && Object.op_Implicit((Object)(object)self.master) && Object.op_Implicit((Object)(object)self.inventory))
			{
				SkillDef val = Utils.lookupSkill(ConfigPrimarySkill.Value);
				if (ConfigPrimaryReplacement.Value && Object.op_Implicit((Object)(object)val))
				{
					if (ConfigCorruptVisions.Value)
					{
						Utils.CorruptItem(self.inventory, Items.LunarPrimaryReplacement.itemIndex, self.master);
						self.ReplaceSkillIfItemPresent(skillLocator.primary, Items.LunarSun.itemIndex, val);
					}
					else if (self.inventory.GetItemCount(Items.LunarPrimaryReplacement) == 0)
					{
						self.ReplaceSkillIfItemPresent(skillLocator.primary, Items.LunarSun.itemIndex, val);
					}
				}
				SkillDef val2 = Utils.lookupSkill(ConfigSecondarySkill.Value);
				if (ConfigSecondaryReplacement.Value && Object.op_Implicit((Object)(object)val2))
				{
					if (ConfigCorruptHooks.Value)
					{
						Utils.CorruptItem(self.inventory, Items.LunarSecondaryReplacement.itemIndex, self.master);
						self.ReplaceSkillIfItemPresent(skillLocator.secondary, Items.LunarSun.itemIndex, val2);
					}
					else if (self.inventory.GetItemCount(Items.LunarSecondaryReplacement) == 0)
					{
						self.ReplaceSkillIfItemPresent(skillLocator.secondary, Items.LunarSun.itemIndex, val2);
					}
				}
				SkillDef val3 = Utils.lookupSkill(ConfigUtilitySkill.Value);
				if (ConfigUtilityReplacement.Value && Object.op_Implicit((Object)(object)val3))
				{
					if (ConfigCorruptStrides.Value)
					{
						Utils.CorruptItem(self.inventory, Items.LunarUtilityReplacement.itemIndex, self.master);
						self.ReplaceSkillIfItemPresent(skillLocator.utility, Items.LunarSun.itemIndex, val3);
					}
					else if (self.inventory.GetItemCount(Items.LunarUtilityReplacement) == 0)
					{
						self.ReplaceSkillIfItemPresent(skillLocator.utility, Items.LunarSun.itemIndex, val3);
					}
				}
				SkillDef val4 = Utils.lookupSkill(ConfigSpecialSkill.Value);
				if (ConfigSpecialReplacement.Value && Object.op_Implicit((Object)(object)val4))
				{
					if (ConfigCorruptEssence.Value)
					{
						Utils.CorruptItem(self.inventory, Items.LunarSpecialReplacement.itemIndex, self.master);
						self.ReplaceSkillIfItemPresent(skillLocator.special, Items.LunarSun.itemIndex, val4);
					}
					else if (self.inventory.GetItemCount(Items.LunarSpecialReplacement) == 0)
					{
						self.ReplaceSkillIfItemPresent(skillLocator.special, Items.LunarSun.itemIndex, val4);
					}
				}
			}
			orig.Invoke(self);
		}

		private void LoadAssets()
		{
			megalomaniaAssetBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "AssetBundles", "megalomaniaassets"));
			EgoPrimarySprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texConceitIcon");
			EgoMonopolizeSprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texMonopolizeIcon");
			EgoBombSprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texBombIcon");
			EgoTwinShotSprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texTwinShotIcon");
			EgoShellSprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texShellIcon");
			EgoMinigunSprite = megalomaniaAssetBundle.LoadAsset<Sprite>("texLunarMinigun");
		}

		private void ItemCatalog_SetItemDefs(orig_SetItemDefs orig, ItemDef[] newItemDefs)
		{
			orig.Invoke(newItemDefs);
			Utils.ParseItemPriorityList();
			Utils.ParseItemConvertToList();
		}

		private void InitItems()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			transformToken = ScriptableObject.CreateInstance<ItemDef>();
			((Object)transformToken).name = "MEGALOMANIA_TOKEN_NAME";
			transformToken.nameToken = "MEGALOMANIA_TOKEN_NAME";
			transformToken.pickupToken = "MEGALOMANIA_TOKEN_PICKUP";
			transformToken.descriptionToken = "MEGALOMANIA_TOKEN_DESC";
			transformToken.loreToken = "MEGALOMANIA_TOKEN_LORE";
			transformToken.deprecatedTier = (ItemTier)5;
			transformToken.canRemove = false;
			transformToken.hidden = true;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(transformToken, val));
		}

		private void InitBuffs()
		{
			EgoShelledBuff.initEgoShellBuff();
		}

		private void InitSkills()
		{
			ConceitAbility.initEgoPrimary(EgoPrimarySprite);
			MonopolizeAbility.initEgoMonopolize(EgoMonopolizeSprite);
			BombAbility.initBombAbility(EgoBombSprite);
			TwinShotAbility.initEgoTwinShot(EgoTwinShotSprite);
			ShellAbility.initEgoShell(EgoShellSprite);
			FireMinigun.initMinigunAbility(EgoMinigunSprite);
		}

		private void CreateConfig()
		{
			ConfigCompatibilityMode = ((BaseUnityPlugin)this).Config.Bind<bool>("0. Main", "Compatibility Mode", false, "Intended to be used when another Ego rework mod is installed.\nIf true, skips the hook to override Egocentrism in a couple of ways:\nDisables all bomb stat and transformation over time changes.\nDisables description override.\nOther features that still work:\nStacking owner stats, such as health and movement speed.\nTransformations on stage start.\nSkill replacements.");
			ConfigMaxHealthInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Initial Max Health", 0.0, "A flat amount added to max health on the initial stack.");
			ConfigMaxHealthPerStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Stacking Max Health", 5.0, "A flat amount added to max health per subsequent stack.");
			ConfigRegenInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Initial Regeneration", 0.3, "A flat amount added to base regeneration on the initial stack. Measured in health per second.");
			ConfigRegenPerStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Stacking Regeneration", 0.3, "A flat amount added to base regeneration per subsequent stack. Measured in health per second.");
			ConfigArmorInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Initial Armor", 2.0, "A flat amount added to armor on the initial stack.");
			ConfigArmorPerStack = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Stacking Armor", 2.0, "A flat amount added to armor per subsequent stack.");
			ConfigArmorMax = ((BaseUnityPlugin)this).Config.Bind<double>("1. Stats - Defensive", "Stacking Armor Cap", 200.0, "Used to determine maximum armor benefit from stacking.\nSet cap to a negative value to disable the cap.");
			ConfigDamageInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Initial Damage", 0.0, "A percentage increase to damage on the initial stack.\n0.02 = 2%");
			ConfigDamagePerStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Stacking Damage", 0.02, "A percentage increase to damage per subsequent stack.\n0.02 = 2%");
			ConfigCritChanceInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Initial Crit Chance", 0.01, "A percentage increase to critical hit chance on the initial stack.\n0.01 = 1%");
			ConfigCritChancePerStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Stacking Crit Chance", 0.01, "A percentage increase to critical hit chance per subsequent stack.\n0.01 = 1%");
			ConfigAttackSpeedType = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Stats - Offensive", "Attack Speed Diminishing Returns", false, "If true, attack speed will have diminishing returns, with the limit towards infinity approaching the bonus cap.\nIf false, attack speed will stack linearly and cap at the bonus cap.");
			ConfigAttackSpeedInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Initial Attack Speed", 0.0, "A percentage used to determine how much attack speed is given on the initial stack.");
			ConfigAttackSpeedPerStack = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Stacking Attack Speed", 0.028, "A percentage used to determine how much attack speed is given per subsequent stack.");
			ConfigAttackSpeedBonusCap = ((BaseUnityPlugin)this).Config.Bind<double>("2. Stats - Offensive", "Bonus Attack Speed Cap", -1.0, "A percentage used to determine the maximum attack speed boost from Egocentrism stacking.\nIn linear mode, set cap to a negative value to disable the cap.\nIn any mode, set cap to 0 to disable attack speed bonus entirely.");
			ConfigMovementSpeedType = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Stats - Movement Speed", "Movement Speed Diminishing Returns", true, "If true, movement speed will have diminishing returns, with the limit towards infinity approaching the bonus cap.\nIf false, movement speed will stack linearly and cap at the bonus cap.");
			ConfigMovementSpeedInitialStack = ((BaseUnityPlugin)this).Config.Bind<double>("3. Stats - Movement Speed", "Initial Movement Speed", 0.028, "A percentage used to determine how much speed is given on the initial stack.");
			ConfigMovementSpeedPerStack = ((BaseUnityPlugin)this).Config.Bind<double>("3. Stats - Movement Speed", "Stacking Movement Speed", 0.028, "A percentage used to determine how much speed is given per subsequent stack.");
			ConfigMovementSpeedBonusCap = ((BaseUnityPlugin)this).Config.Bind<double>("3. Stats - Movement Speed", "Bonus Movement Speed Cap", 9.0, "A percentage used to determine the maximum speed boost from Egocentrism stacking.\nIn linear mode, set cap to a negative value to disable the cap.\nIn any mode, set cap to 0 to disable speed bonus entirely.");
			ConfigEnableBombs = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Bombs - Toggles", "Enable Bomb Generation", true, "Should bombs be generated over time at all?");
			ConfigBombStacking = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Bombs - Toggles", "Bomb Stacking", false, "If true, the amount of bombs currently orbiting the player is used instead of the amount of Egocentrism, for stacking calculations of player stats.");
			ConfigPrimaryEnhancement = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Bombs - Toggles", "Egocentrism Primary Targetting", false, "If true, Egocentrism enhances your primary skill by firing Egocentrism bombs at enemies within 30 degrees of view.\nComparable in activation to Shuriken.");
			ConfigPassiveBombAttack = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Bombs - Toggles", "Passive Bomb Attack", true, "Whether the vanilla seeking behavior should apply. If a bomb collides with an enemy, it may still explode.");
			ConfigOnHitBombAttack = ((BaseUnityPlugin)this).Config.Bind<Utils.OnHitBombAttackType>("4. Bombs - Toggles", "On Hit: Bombs Attack", Utils.OnHitBombAttackType.none, "If \"proc\", then any damage done against an enemy will have a 100% chance to also target an Egocentrism bomb at that enemy.\nIf \"create\", then any damage done has a 30% chance to create a bomb and then immediately attempt to target a bomb to the struck enemy.\nIf \"none\", it will behave as usual (doing nothing special).");
			ConfigBombFocused = ((BaseUnityPlugin)this).Config.Bind<Utils.BombDensity>("4. Bombs - Toggles", "Bomb Density", Utils.BombDensity.asteroid_belt, "If \"normal\", bombs will orbit with vanilla density.\nIf \"oort_cloud\", bombs will be further spread out vertically.\nIf \"asteroid_belt\", bombs will remain close to the owner.");
			ConfigBombCreationRate = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Initial Bomb Creation Rate", 3.0, "How many seconds it takes to generate a bomb at stack size 1.");
			ConfigBombCreationStackingMultiplier = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Bomb Creation Stacking Multiplier", 0.5, "Scales the rate at which additional stacks decrease cooldown.\nLower values require more Egocentrism to reduce the cooldown by the same amount.\nFor example, 0.5 requires 2x as many stacks as 1 would to reduce the time by the same amount.");
			ConfigBombCreationStackingAdder = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Bomb Creation Stacking Adder", 0.0, "Time to add to bomb creation rate per stack. Can be negative.");
			ConfigBombDamage = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Initial Bomb Damage", 3.0, "A percentage of damage the bombs should do at stack size 1. Vanilla is 3.6 (360%).");
			ConfigBombStackingDamage = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Stacking Bomb Damage", 0.05, "How much damage to add to each bomb per stack.");
			ConfigBombCap = ((BaseUnityPlugin)this).Config.Bind<int>("5. Bombs - Stats", "Initial Bomb Cap", 3, "How many bombs can be generated at stack size 1.");
			ConfigBombStackingCap = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Stacking Bomb Cap", 1.0, "How many bombs to add to the bomb cap per stack.");
			ConfigBombRange = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Bomb Range", 17.5, "The distance at which bombs can target enemies.");
			ConfigBombStackingRange = ((BaseUnityPlugin)this).Config.Bind<double>("5. Bombs - Stats", "Stacking Bomb Range", 0.5, "The distance to add to bomb range per stack.");
			ConfigStageStartTransform = ((BaseUnityPlugin)this).Config.Bind<int>("5. Transform - When to Transform", "Stage Start Transformations", 5, "How many items to convert on stage start, similar to Benthic Bloom.\nIf this is set to 0 or a negative number, conversion on stage start is disabled.");
			ConfigStageStartTransformStack = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Stage Start Transformations Per Stack", 0.0, "How many items to convert on stage start per additional stack.\nRounded down after calculating.");
			ConfigTransformTime = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Default Transform Timer", -60.0, "The time it takes for Egocentrism to transform another item.\nIf this is set a negative number, conversion over time is disabled.\nMinimum allowed value is 1/60th of a second.");
			ConfigTransformTimePerStack = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Flat Time Per Stack", 0.0, "Time to add to transform timer per stack. Can be negative.\nIgnored if Default Transform Timer is 0");
			ConfigTransformTimeDiminishing = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Multiplier Per Stack", 1.0, "Every stack multiplies the transform timer by this value.");
			ConfigTransformTimeMin = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Min Time", 30.0, "The minimum time Egocentrism can take before transforming an item.\nAnything less than 1/60th of a second is forced back up to 1/60th of a second.");
			ConfigTransformTimeMax = ((BaseUnityPlugin)this).Config.Bind<double>("5. Transform - When to Transform", "Max Time", 120.0, "The maximum time Egocentrism can take before transforming an item.\nAnything less than 1/60th of a second is forced back up to 1/60th of a second.");
			ConfigMaxTransformationsPerStage = ((BaseUnityPlugin)this).Config.Bind<int>("5. Transform - When to Transform", "Max Transforms Per Stage", 10, "Caps how many transformations can happen per stage.\nSet negative to disable cap.");
			ConfigMaxTransformationsPerStageStacking = ((BaseUnityPlugin)this).Config.Bind<int>("5. Transform - When to Transform", "Max Transforms Per Stage Per Stack", 0, "How many transformations to add to the cap per stack.\nThe system is intelligent and won't count stacks added by conversion from the current stage.");
			ConfigStackSizeMatters = ((BaseUnityPlugin)this).Config.Bind<bool>("6. Transform - Rules", "Stack Size Matters", false, "If true, the weight of the item is multiplied by how many of that item you have.\nWeight Calculation: TierWeight + ItemWeight + Floor(SSMultiplier * ItemWeight * (StackSize - 1) + SSAdder * (StackSize - 1))");
			ConfigStackSizeMultiplier = ((BaseUnityPlugin)this).Config.Bind<double>("6. Transform - Rules", "Stack Size Multiplier", 0.2, "How much to multiply subsequent stacks' weight by when Stack Size Matters is enabled.\nWeight is rounded down after calculating.\nEg: A weighted item at 10 and a multiplier of 0.5 would stack 10 -> 15 -> 20 -> 25\nEg: A weighted item at 50 and a multiplier of 0.2 would stack 50 -> 60 -> 70 -> 80");
			ConfigStackSizeAdder = ((BaseUnityPlugin)this).Config.Bind<double>("6. Transform - Rules", "Stack Size Adder", 3.0, "How much to add to weight per subsequent stack when Stack Size Matters is enabled.\nWeight is rounded down after calculating.\nEg: A weighted item at 10 and an adder of 5 would stack 10 -> 15 -> 20 -> 25\nEg: A weighted item at 50 and an adder of 0.5 would stack 50 -> 50 (50.5) -> 51 -> 51 (51.5)");
			ConfigConversionSelectionType = ((BaseUnityPlugin)this).Config.Bind<Utils.ConversionSelectionType>("6. Transform - Rules", "Conversion Selection Type", Utils.ConversionSelectionType.weighted, "Determines method for choosing items. Case sensitive. Allowed values:\nweighted: tends towards higher weighted items and tiers but maintains randomness.\npriority: always chooses the highest priority item available. If there's a tie, selects one at random.");
			ConfigItemsToConvertTo = ((BaseUnityPlugin)this).Config.Bind<string>("6. Transform - Rules", "Items To Convert To", "LunarSun:1", "A list of item that Egocentrism can convert other items into. Items cannot be converted into themselves.\nIf this is empty, conversion is disabled completely.\nIf an item does not make an appearance in this list or has a value of 0, that item cannot be converted into.\nHigher numbers means Egocentrism is more conditioned to convert to that item, possibly instead of Egocentrism.\nFormat: item1:integer, item2:int, item3:i, etc\nCase sensitive, somewhat whitespace sensitive.\nThe diplay name might not always equal the codename of the item.\nEg: Egocentrism = LunarSun. To find the name out for yourself, download the DebugToolkit mod, open the console (ctrl + alt + backtick (`)) and type in \"list_item\"");
			ConfigRarityPriorityList = ((BaseUnityPlugin)this).Config.Bind<string>("6. Transform - Rules", "Rarity:Priority List", "voidyellow:100, voidred:70, voidgreen:60, red:50, yellow:40, voidwhite:35, green:30, white:15, blue:0", "A priority of 0 or a negative priority blacklists that tier from Egocentrism.\nIf a rarity is not listed here, it cannot be converted by Egocentrism.\nHigher numbers means Egocentrism is more conditioned to select that tier of item.\nFormat: tier1:integer, tier2:int, tier3:i, etc\nCase insensitive, mostly whitespace insensitive.\nValid Tiers:\nwhite, green, red, blue, yellow, voidwhite, voidgreen, voidred, voidyellow, \ncommon, uncommon, legendary, lunar, boss, voidcommon, voiduncommon, voidlegendary, voidboss");
			ConfigItemPriorityList = ((BaseUnityPlugin)this).Config.Bind<string>("6. Transform - Rules", "Item:Priority List", "BeetleGland:5, GhostOnKill:5, MinorConstructOnKill:5, RoboBallBuddy:10, ScrapGreen:30, ScrapWhite:10, ScrapYellow:60, ScrapRed:20, RegeneratingScrap:-20, ExtraStatsOnLevelUp:15, FreeChest:-20, ExtraShrineItem:10, CloverVoid:15, LowerPricedChests:-20, ResetChests:-5", "Egocentrism is always blacklisted and cannot be converted from.\nA priority of 0 blacklists that item from Egocentrism.\nCan be negative. If negative is of a greater magnitude than the rarity, the item is blacklisted.\nIf a rarity that an item is part of is blacklisted but the item shows up in this list with a positive value, that item won't be blacklisted.\nIf a rarity is not listed here, its priority is determined exclusively by its tier.\nHigher numbers means Egocentrism is more conditioned to select that item.\nFormat: item1:integer, item2:int, item3:i, etc\nCase sensitive, somewhat whitespace sensitive.\nThe diplay name might not always equal the codename of the item.\nFor example: Wax Quail = JumpBoost. To find the name out for yourself, download the DebugToolkit mod, open the console (ctrl + alt + backtick (`)) and type in \"list_item\"");
			ConfigRegenerateScrap = ((BaseUnityPlugin)this).Config.Bind<bool>("6. Transform - Rules", "Regenerate Scrap", false, "If true, then regenerating scrap that gets assimilated into Egocentrism is consumed instead of destroyed, allowing it to regenerate next stage.");
			ConfigSkillsInfo = ((BaseUnityPlugin)this).Config.Bind<string>("7.0 Skills - All", "Skill Info", ":)", "Ignored. This is for information on what skills do.\nConceit: Fire a burst of 3 lunar shards for 3x100% damage. Intended to be primary.\nLunar Minigun: Rapidly fire lunar needles for 80% damage. Finishes with a blast of 10 needles. Intended to be alt primary.\nChimera Bomb: Fire a tracking bomb for 450% damage. Intended to be secondary.\nTwin Shot: Fire 6 lunar helices for 6x180% damage. Intended to be alt secondary.\nChimera Shell: Immediately gain barrier equal to 25% of combined max health, and jumpstart shield recharge. Damage taken to health or shield is capped to 10% of combined max health, but speed and healing are halved for 7 seconds. Intended to be utility.\nMonopolize: Crush up to 5 items. Gain twice the items lost as Egocentrism. Always grants at least 1 Egocentrism. Cooldown 60s. Intended to be special.\n");
			string text = "conceit, minigun, bomb, twinshot, shell, monopolize";
			ConfigPrimarySkill = ((BaseUnityPlugin)this).Config.Bind<Utils.SkillEnum>("7.1 Skills - Primary", "Skill to Use", Utils.SkillEnum.conceit, "What skill to replace primary with.\nAllowed values: " + text);
			ConfigPrimaryReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("7.1 Skills - Primary", "Enable Primary Replacement", true, "If true, holding Egocentrism replaces the primary skill.");
			ConfigCorruptVisions = ((BaseUnityPlugin)this).Config.Bind<bool>("7.1 Skills - Primary", "Corrupt Visions of Heresy", true, "If true, Visions of Heresy is corrupted into Egocentrism when replacement is enabled.\nIf false, Visions of Heresy's \"Hungering Gaze\" skill overrides Ego skill replacement.");
			ConfigSecondarySkill = ((BaseUnityPlugin)this).Config.Bind<Utils.SkillEnum>("7.2 Skills - Secondary", "Skill to Use", Utils.SkillEnum.bomb, "What skill to replace secondary with.\nAllowed values: " + text);
			ConfigSecondaryReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("7.2 Skills - Secondary", "Enable Secondary Replacement", false, "If true, holding Egocentrism replaces the secondary skill.");
			ConfigCorruptHooks = ((BaseUnityPlugin)this).Config.Bind<bool>("7.2 Skills - Secondary", "Corrupt Hooks of Heresy", true, "If true, Hooks of Heresy is corrupted into Egocentrism when replacement is enabled.\nIf false, Hooks of Heresy's \"Slicing Maelstrom\" skill overrides Ego skill replacement.");
			ConfigUtilitySkill = ((BaseUnityPlugin)this).Config.Bind<Utils.SkillEnum>("7.3 Skills - Utility", "Skill to Use", Utils.SkillEnum.shell, "What skill to replace utility with.\nAllowed values: " + text);
			ConfigUtilityReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("7.3 Skills - Utility", "Enable Utility Replacement", false, "If true, holding Egocentrism replaces the utility skill.");
			ConfigCorruptStrides = ((BaseUnityPlugin)this).Config.Bind<bool>("7.3 Skills - Utility", "Corrupt Strides of Heresy", true, "If true, Strides of Heresy is corrupted into Egocentrism when replacement is enabled.\nIf false, Strides of Heresy's \"Shadowfade\" skill overrides Ego skill replacement.");
			ConfigSpecialSkill = ((BaseUnityPlugin)this).Config.Bind<Utils.SkillEnum>("7.4 Skills - Special", "Skill to Use", Utils.SkillEnum.monopolize, "What skill to replace special with.\nAllowed values: " + text);
			ConfigSpecialReplacement = ((BaseUnityPlugin)this).Config.Bind<bool>("7.4 Skills - Special", "Enable Special Replacement", false, "If true, holding Egocentrism replaces the special skill.");
			ConfigCorruptEssence = ((BaseUnityPlugin)this).Config.Bind<bool>("7.4 Skills - Special", "Corrupt Essence of Heresy", true, "If true, Essence of Heresy is corrupted into Egocentrism when replacement is enabled.\nIf false, Essence of Heresy's \"Ruin\" skill overrides Ego skill replacement.");
			ConfigCleanup();
		}

		private void ConfigCleanup()
		{
			Dictionary<ConfigDefinition, string> propertyValue = Reflection.GetPropertyValue<Dictionary<ConfigDefinition, string>>((object)((BaseUnityPlugin)this).Config, "OrphanedEntries");
			propertyValue.Clear();
			((BaseUnityPlugin)this).Config.Save();
		}

		private void HookLunarSunStats()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__285_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
					{
						int num = ((!ConfigBombStacking.Value) ? sender.inventory.GetItemCount(Items.LunarSun) : sender.master.GetDeployableCount((DeployableSlot)16));
						if (num > 0)
						{
							float num2 = (float)ConfigMaxHealthInitialStack.Value;
							num2 += (float)num * (float)ConfigMaxHealthPerStack.Value;
							args.baseHealthAdd += num2;
							float num3 = (float)ConfigRegenInitialStack.Value;
							num3 += (float)num * (float)ConfigRegenPerStack.Value;
							args.baseRegenAdd += num3;
							float num4 = (float)ConfigMovementSpeedInitialStack.Value;
							num4 += (float)ConfigMovementSpeedPerStack.Value;
							args.baseMoveSpeedAdd += Utils.determineStatBoost(ConfigMovementSpeedType.Value, num4, (float)ConfigMovementSpeedBonusCap.Value, num);
							float num5 = (float)ConfigDamageInitialStack.Value;
							num5 += (float)num * (float)ConfigDamagePerStack.Value;
							args.baseDamageAdd += num5;
							float num6 = (float)ConfigAttackSpeedInitialStack.Value;
							num6 += (float)ConfigAttackSpeedPerStack.Value;
							args.attackSpeedMultAdd += Utils.determineStatBoost(ConfigAttackSpeedType.Value, num6, (float)ConfigAttackSpeedBonusCap.Value, num);
							float num7 = (float)ConfigCritChanceInitialStack.Value;
							num7 += (float)num * (float)ConfigCritChancePerStack.Value;
							args.critAdd += 100f * num7;
							float num8 = (float)ConfigArmorInitialStack.Value;
							num8 += (float)num * (float)ConfigArmorPerStack.Value;
							if (ConfigArmorMax.Value > 0.0)
							{
								num8 = Math.Min(num8, (float)ConfigArmorMax.Value);
							}
							args.armorAdd += num8;
						}
					}
				};
				<>c.<>9__285_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}

		[Server]
		private void CharacterMaster_OnServerStageBegin(orig_OnServerStageBegin orig, CharacterMaster self, Stage stage)
		{
			orig.Invoke(self, stage);
			Inventory inventory = self.inventory;
			if (!Object.op_Implicit((Object)(object)inventory))
			{
				return;
			}
			int itemCount = inventory.GetItemCount(transformToken);
			if (itemCount > 0)
			{
				inventory.RemoveItem(transformToken, itemCount);
			}
			int itemCount2 = inventory.GetItemCount(Items.LunarSun);
			if (ConfigStageStartTransform.Value > 0 && itemCount2 > 0)
			{
				int num = ConfigStageStartTransform.Value + (int)((double)(itemCount2 - 1) * ConfigStageStartTransformStack.Value);
				if (ConfigMaxTransformationsPerStage.Value > 0)
				{
					num = Math.Min(num, ConfigMaxTransformationsPerStage.Value);
				}
				Utils.TransformItems(inventory, num, null, self);
			}
		}
	}
}
namespace MegalomaniaPlugin.Utilities
{
	public class LanguageUtils
	{
		private static bool bombsAreEnabled;

		private static double bombInitialGenerationTime;

		private static double bombGenerationTimeRateMult;

		private static double bombGenerationTimeAdder;

		private static bool bombgenAffectedByMult;

		private static bool bombgenAffectedByAdder;

		private static double bombInitDamage;

		private static double bombDamageAdd;

		private static int bombCapInit;

		private static double bombCapAdd;

		private static double transformTime;

		private static double transformTimeMult;

		private static double transformTimeAdd;

		private static double transformTimeMin;

		private static double transformTimeMax;

		private static bool transformsHappenOverTime;

		private static bool transformAffectedByMult;

		private static bool transformAffectedByAdder;

		private static int transformStageStart;

		private static double transformStageStartStacking;

		private static bool transformOnStageStartHappens;

		private static double initHealth;

		private static double health;

		private static double initRegen;

		private static double regen;

		private static double initArmor;

		private static double armor;

		private static double initDamage;

		private static double damage;

		private static double initCrit;

		private static double crit;

		private static double initATK;

		private static double attackSpeed;

		private static double initMove;

		private static double moveSpeed;

		private static bool doReplacePrimary;

		private static string primaryReplacementID;

		private static bool doReplaceSecondary;

		private static string secondaryReplacementID;

		private static bool doReplaceUtility;

		private static string utilityReplacementID;

		private static bool doReplaceSpecial;

		private static string specialReplacementID;

		private static int skillReplacementCount;

		private static bool benefitStats;

		private static bool harmStats;

		public static void start()
		{
			bombsAreEnabled = MegalomaniaPlugin.ConfigEnableBombs.Value;
			bombInitialGenerationTime = MegalomaniaPlugin.ConfigBombCreationRate.Value;
			bombGenerationTimeRateMult = 50.0 * MegalomaniaPlugin.ConfigBombCreationStackingMultiplier.Value;
			bombGenerationTimeAdder = MegalomaniaPlugin.ConfigBombCreationStackingAdder.Value;
			bombgenAffectedByMult = bombGenerationTimeRateMult != 1.0;
			bombgenAffectedByAdder = bombGenerationTimeAdder != 0.0;
			bombInitDamage = MegalomaniaPlugin.ConfigBombDamage.Value;
			bombDamageAdd = MegalomaniaPlugin.ConfigBombStackingDamage.Value;
			bombCapInit = MegalomaniaPlugin.ConfigBombCap.Value;
			bombCapAdd = MegalomaniaPlugin.ConfigBombStackingCap.Value;
			transformTime = MegalomaniaPlugin.ConfigTransformTime.Value;
			transformTimeMult = MegalomaniaPlugin.ConfigTransformTimeDiminishing.Value;
			transformTimeAdd = MegalomaniaPlugin.ConfigTransformTimePerStack.Value;
			transformTimeMin = MegalomaniaPlugin.ConfigTransformTimeMin.Value;
			transformTimeMax = MegalomaniaPlugin.ConfigTransformTimeMax.Value;
			transformsHappenOverTime = transformTime >= 0.0;
			transformAffectedByAdder = transformTime != 0.0;
			transformAffectedByMult = transformTimeMult != 1.0;
			transformStageStart = MegalomaniaPlugin.ConfigStageStartTransform.Value;
			transformStageStartStacking = MegalomaniaPlugin.ConfigStageStartTransformStack.Value;
			transformOnStageStartHappens = transformStageStart > 0;
			initHealth = MegalomaniaPlugin.ConfigMaxHealthInitialStack.Value;
			health = MegalomaniaPlugin.ConfigMaxHealthPerStack.Value;
			initRegen = MegalomaniaPlugin.ConfigRegenInitialStack.Value;
			regen = MegalomaniaPlugin.ConfigRegenPerStack.Value;
			initArmor = MegalomaniaPlugin.ConfigArmorInitialStack.Value;
			armor = MegalomaniaPlugin.ConfigArmorPerStack.Value;
			initDamage = MegalomaniaPlugin.ConfigDamageInitialStack.Value * 100.0;
			damage = MegalomaniaPlugin.ConfigDamagePerStack.Value * 100.0;
			initCrit = MegalomaniaPlugin.ConfigCritChanceInitialStack.Value * 100.0;
			crit = MegalomaniaPlugin.ConfigCritChancePerStack.Value * 100.0;
			initATK = MegalomaniaPlugin.ConfigAttackSpeedInitialStack.Value * 100.0;
			attackSpeed = MegalomaniaPlugin.ConfigAttackSpeedPerStack.Value * 100.0;
			initMove = MegalomaniaPlugin.ConfigMovementSpeedInitialStack.Value * 100.0;
			moveSpeed = MegalomaniaPlugin.ConfigMovementSpeedPerStack.Value * 100.0;
			primaryReplacementID = Utils.lookupSkill(MegalomaniaPlugin.ConfigPrimarySkill.Value).skillNameToken;
			doReplacePrimary = MegalomaniaPlugin.ConfigPrimaryReplacement.Value && !Utility.IsNullOrWhiteSpace(primaryReplacementID);
			secondaryReplacementID = Utils.lookupSkill(MegalomaniaPlugin.ConfigSecondarySkill.Value).skillNameToken;
			doReplaceSecondary = MegalomaniaPlugin.ConfigSecondaryReplacement.Value && !Utility.IsNullOrWhiteSpace(secondaryReplacementID);
			utilityReplacementID = Utils.lookupSkill(MegalomaniaPlugin.ConfigUtilitySkill.Value).skillNameToken;
			doReplaceUtility = MegalomaniaPlugin.ConfigUtilityReplacement.Value && !Utility.IsNullOrWhiteSpace(utilityReplacementID);
			specialReplacementID = Utils.lookupSkill(MegalomaniaPlugin.ConfigSpecialSkill.Value).skillNameToken;
			doReplaceSpecial = MegalomaniaPlugin.ConfigSpecialReplacement.Value && !Utility.IsNullOrWhiteSpace(specialReplacementID);
			skillReplacementCount = 0;
			if (doReplacePrimary)
			{
				skillReplacementCount++;
			}
			if (doReplaceSecondary)
			{
				skillReplacementCount++;
			}
			if (doReplaceUtility)
			{
				skillReplacementCount++;
			}
			if (doReplaceSpecial)
			{
				skillReplacementCount++;
			}
			benefitStats = health > 0.0 || initHealth > 0.0 || regen > 0.0 || initRegen > 0.0 || armor > 0.0 || initArmor > 0.0 || damage > 0.0 || initDamage > 0.0 || crit > 0.0 || initCrit > 0.0 || attackSpeed > 0.0 || initATK > 0.0 || moveSpeed > 0.0 || initMove > 0.0;
			harmStats = health < 0.0 || initHealth < 0.0 || regen < 0.0 || initRegen < 0.0 || armor < 0.0 || initArmor < 0.0 || damage < 0.0 || initDamage < 0.0 || crit < 0.0 || initCrit < 0.0 || attackSpeed < 0.0 || initATK < 0.0 || moveSpeed < 0.0 || initMove < 0.0;
			setTokens();
		}

		private static void setTokens()
		{
			string text = "";
			if (bombsAreEnabled)
			{
				string text2 = "";
				if (bombgenAffectedByMult)
				{
					text2 += $"-{bombGenerationTimeRateMult}% per stack";
				}
				if (bombgenAffectedByMult && bombgenAffectedByAdder)
				{
					text2 += ", ";
				}
				if (bombgenAffectedByAdder)
				{
					string text3 = "";
					if (bombGenerationTimeAdder > 0.0)
					{
						text3 = "+";
					}
					text2 = text2 + text3 + bombGenerationTimeAdder + "s per stack";
				}
				if (text2 != "")
				{
					text2 = "<style=cStack>(" + text2 + ")</style>";
				}
				string arg = "";
				if (bombDamageAdd != 0.0)
				{
					arg = $"<style=cStack>(+{bombDamageAdd * 100.0}% per stack)</style>";
				}
				string text4 = "";
				if (bombCapAdd != 0.0)
				{
					text4 = $"<style=cStack>(+{bombCapAdd} per stack)</style>";
				}
				text = $"Every <style=cIsUtility>{bombInitialGenerationTime}</style>{text2} seconds, " + $"gain an <style=cIsDamage>orbiting bomb</style> that detonates on impact for <style=cIsDamage>{bombInitDamage * 100.0}%</style>{arg} damage, " + "up to a maximum of <style=cIsUtility>" + bombCapInit + text4 + " bombs</style>. ";
			}
			string text5 = "";
			if (transformsHappenOverTime)
			{
				string text6 = "";
				if (transformAffectedByMult)
				{
					double num = 1.0 - transformTimeMult;
					string text7 = "";
					if (num >= 0.0)
					{
						text7 = "+";
					}
					text6 = text6 + text7 + num + "% per stack";
				}
				if (transformAffectedByMult && transformAffectedByAdder)
				{
					text6 += ", ";
				}
				if (transformAffectedByAdder)
				{
					string text8 = "";
					if (transformTimeMult >= 0.0)
					{
						text8 = "+";
					}
					text6 = text6 + text8 + transformTimeMult + "s per stack";
				}
				if (text6 != "")
				{
					text6 = "<style=cStack>(" + text6 + ")</style>";
				}
				string text9 = "random";
				switch (MegalomaniaPlugin.ConfigConversionSelectionType.Value)
				{
				case Utils.ConversionSelectionType.weighted:
					text9 = "weighted";
					break;
				case Utils.ConversionSelectionType.priority:
					text9 = "prioritized";
					break;
				}
				string text10 = "this";
				if (Utils.parsedItemConvertToList.Count > 1)
				{
					text10 = "an";
				}
				text5 = "Every <style=cIsUtility>" + transformTime + text6 + "</style> seconds, a " + text9 + " item is <style=cIsUtility>converted</style> into " + text10 + " item. ";
			}
			string text11 = "";
			if (transformOnStageStartHappens)
			{
				string text12 = "";
				if (transformStageStartStacking > 0.0)
				{
					text12 = "<style=cStack>(+" + transformStageStartStacking + " per stack)</style>";
				}
				text11 = "On the start of each stage, <style=cIsUtility>transform</style> " + transformStageStart + text12 + " items. ";
			}
			string text13 = "";
			if (health != 0.0 || initHealth != 0.0)
			{
				string arg2 = "";
				if (health != 0.0)
				{
					arg2 = $"<style=cStack>(+{health} per stack)</style>";
				}
				text13 += $"Gain <style=cIsHealing>{initHealth}{arg2} max health</style>. ";
			}
			if (regen != 0.0 || initRegen != 0.0)
			{
				string arg3 = "";
				if (regen != 0.0)
				{
					arg3 = $"<style=cStack>(+{regen} per stack)</style>";
				}
				text13 += $"Gain <style=cIsHealing>{initRegen}{arg3} health per second</style>. ";
			}
			if (armor != 0.0 || initArmor != 0.0)
			{
				string arg4 = "";
				if (armor != 0.0)
				{
					arg4 = $"<style=cStack>(+{armor} per stack)</style>";
				}
				text13 += $"Gain <style=cIsUtility>{initArmor}{arg4} armor</style>. ";
			}
			if (damage != 0.0 || initDamage != 0.0)
			{
				string arg5 = "";
				if (damage != 0.0)
				{
					arg5 = $"<style=cStack>(+{damage}% per stack)</style>";
				}
				text13 += $"Gain <style=cIsDamage>{initDamage}%{arg5} damage</style>. ";
			}
			if (crit != 0.0 || initCrit != 0.0)
			{
				string arg6 = "";
				if (crit != 0.0)
				{
					arg6 = $"<style=cStack>(+{crit}% per stack)</style>";
				}
				text13 += $"Gain <style=cIsDamage>{initCrit}%{arg6} critical strike chance.</style> ";
			}
			if (attackSpeed != 0.0 || initATK != 0.0)
			{
				string arg7 = "";
				if (attackSpeed != 0.0)
				{
					arg7 = $"<style=cStack>(+{attackSpeed}% per stack)</style>";
				}
				text13 += $"Gain <style=cIsDamage>{initATK}%{arg7} attack speed</style>. ";
			}
			if (moveSpeed != 0.0 || initMove != 0.0)
			{
				string arg8 = "";
				if (moveSpeed != 0.0)
				{
					arg8 = $"<style=cStack>(+{moveSpeed}% per stack)</style>";
				}
				text13 += $"Gain <style=cIsUtility>{initMove}%{arg8} movement speed</style>. ";
			}
			string text14 = "";
			if (doReplacePrimary)
			{
				string text15 = skillReplacementLookupEN(primaryReplacementID);
				text14 = text14 + "Replace primary skill with <style=cIsUtility>" + text15 + "</style>. ";
			}
			if (doReplaceSecondary)
			{
				string text16 = skillReplacementLookupEN(secondaryReplacementID);
				text14 = text14 + "Replace secondary skill with <style=cIsUtility>" + text16 + "</style>. ";
			}
			if (doReplaceUtility)
			{
				string text17 = skillReplacementLookupEN(utilityReplacementID);
				text14 = text14 + "Replace utility skill with <style=cIsUtility>" + text17 + "</style>. ";
			}
			if (doReplaceSpecial)
			{
				string text18 = skillReplacementLookupEN(specialReplacementID);
				text14 = text14 + "Replace special skill with <style=cIsUtility>" + text18 + "</style>. ";
			}
			LanguageAPI.AddOverlay("ITEM_LUNARSUN_DESC", text + text5 + text11 + text13 + text14, "en");
			string text19 = "";
			if (bombsAreEnabled)
			{
				text19 = "Gain multiple orbiting bombs. ";
			}
			string text20 = "";
			if (skillReplacementCount > 0)
			{
				if (skillReplacementCount != 1)
				{
					text20 = ((skillReplacementCount != 4) ? "Replaces some skills. " : "Replaces every skill. ");
				}
				else if (doReplacePrimary)
				{
					text20 = "Replace your primary skill with '" + skillReplacementLookupEN(primaryReplacementID) + "'. ";
				}
				else if (doReplaceSecondary)
				{
					text20 = "Replace your secondary with '" + skillReplacementLookupEN(secondaryReplacementID) + "'. ";
				}
				else if (doReplaceUtility)
				{
					text20 = "Replace your utility with '" + skillReplacementLookupEN(utilityReplacementID) + "'. ";
				}
				else if (doReplaceSpecial)
				{
					text20 = "Replace your special with '" + skillReplacementLookupEN(specialReplacementID) + "'. ";
				}
			}
			string text21 = "";
			if (benefitStats && harmStats)
			{
				text21 = "Increase some of your stats, <color=#FF7F7F>decrease some of your stats.</color> ";
			}
			else if (benefitStats)
			{
				text21 = "Increase some of your stats. ";
			}
			else if (harmStats)
			{
				text21 = "<color=#FF7F7F>Decrease some of your stats.</color> ";
			}
			string text22 = "";
			if (transformsHappenOverTime)
			{
				text22 = ((!(Math.Abs(transformTime - 60.0) < 1.0)) ? $"<color=#FF7F7F>Every {transformTime} seconds, assimilate another item into Egocentrism.</color>" : "<color=#FF7F7F>Every minute, assimilate another item into Egocentrism.</color>");
			}
			string text23 = "";
			if (transformOnStageStartHappens)
			{
				text23 = "<color=#FF7F7F>On the start of each stage, assimilate more items into Egocentrism.</color>";
			}
			LanguageAPI.AddOverlay("ITEM_LUNARSUN_PICKUP", text19 + text20 + text21 + text22 + text23, "en");
		}

		private static string skillReplacementLookupEN(string lookupID)
		{
			string result = lookupID;
			switch (lookupID)
			{
			case "MEGALOMANIA_PRIMARY_NAME":
				result = "Conceit";
				break;
			case "MEGALOMANIA_MONOPOLIZE_NAME":
				result = "Monopolize";
				break;
			case "MEGALOMANIA_BOMB_NAME":
				result = "Chimera Bomb";
				break;
			case "MEGALOMANIA_TWINSHOT_NAME":
				result = "Twin Shot";
				break;
			case "MEGALOMANIA_SHELL_NAME":
				result = "Chimera Shell";
				break;
			case "MEGALOMANIA_MINIGUN_NAME":
				result = "Chimera Minigun";
				break;
			}
			return result;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

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

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public class Utils
	{
		public enum ItemTierLookup
		{
			white = 0,
			common = 0,
			green = 1,
			uncommon = 1,
			red = 2,
			legendary = 2,
			blue = 3,
			lunar = 3,
			yellow = 4,
			boss = 4,
			voidwhite = 6,
			voidcommon = 6,
			voidgreen = 7,
			voiduncommon = 7,
			voidred = 8,
			voidlegendary = 8,
			voidyellow = 9,
			voidboss = 9
		}

		public enum ConversionSelectionType : uint
		{
			weighted,
			priority
		}

		public enum OnHitBombAttackType : uint
		{
			none,
			proc,
			create
		}

		public enum SkillEnum : uint
		{
			conceit,
			monopolize,
			bomb,
			twinshot,
			shell,
			minigun
		}

		public enum BombDensity : uint
		{
			normal,
			oort_cloud,
			asteroid_belt
		}

		public enum EgoDialogue : uint
		{
			none,
			mithrix,
			false_son
		}

		public static Dictionary<ItemTier, int> parsedRarityPriorityList;

		public static Dictionary<ItemIndex, int> parsedItemPriorityList;

		public static Dictionary<ItemIndex, int> parsedItemConvertToList;

		private static Dictionary<SkillEnum, SkillDef> SkillLookup { get; set; }

		public static void initSkillsList()
		{
			SkillLookup = new Dictionary<SkillEnum, SkillDef>();
			SkillLookup.Add(SkillEnum.conceit, ConceitAbility.ConceitSkill);
			SkillLookup.Add(SkillEnum.monopolize, MonopolizeAbility.MonopolizeSkill);
			SkillLookup.Add(SkillEnum.bomb, BombAbility.BombSkill);
			SkillLookup.Add(SkillEnum.twinshot, TwinShotAbility.TwinShotSkill);
			SkillLookup.Add(SkillEnum.shell, ShellAbility.ShellSkill);
			SkillLookup.Add(SkillEnum.minigun, FireMinigun.MinigunSkill);
		}

		public static SkillDef lookupSkill(SkillEnum toGetDef)
		{
			if (SkillLookup.TryGetValue(toGetDef, out var value))
			{
				return value;
			}
			return null;
		}

		public static void CorruptItem(Inventory inventory, ItemIndex toCorrupt, CharacterMaster master)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			int itemCount = inventory.GetItemCount(Items.LunarSun);
			if (itemCount >= 1)
			{
				int itemCount2 = inventory.GetItemCount(toCorrupt);
				if (itemCount2 > 0)
				{
					inventory.RemoveItem(toCorrupt, itemCount2);
					inventory.GiveItem(Items.LunarSun, itemCount2);
					CharacterMasterNotificationQueue.SendTransformNotification(master, toCorrupt, Items.LunarSun.itemIndex, (TransformationType)4);
				}
			}
		}

		public static List<ItemIndex> TransformItems(Inventory inventory, int amount, Xoroshiro128Plus transformRng, CharacterMaster master, bool ignoreCap = false, bool notifUI = true)
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: 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_00f5: Invalid comparison between Unknown and I4
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Invalid comparison between Unknown and I4
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			List<ItemIndex> list = new List<ItemIndex>();
			if (!NetworkServer.active)
			{
				Log.Warning("[Server] function 'TransformItems' called on client");
				return list;
			}
			if (!Object.op_Implicit((Object)(object)inventory) || !Object.op_Implicit((Object)(object)master))
			{
				return list;
			}
			if (amount < 1)
			{
				return list;
			}
			if (parsedItemConvertToList.Count < 1)
			{
				return list;
			}
			if (transformRng == null)
			{
				ulong num = Run.instance.seed ^ (ulong)Run.instance.stageClearCount;
				transformRng = new Xoroshiro128Plus(num);
			}
			Dictionary<ItemIndex, int> dictionary = weighInventory(inventory);
			int num2 = amount * dictionary.Count;
			int num3 = 0;
			while (amount > 0 && dictionary.Count > 0 && num2 > 0)
			{
				num2--;
				ItemIndex val = (ItemIndex)(-1);
				ConversionSelectionType value = MegalomaniaPlugin.ConfigConversionSelectionType.Value;
				ConversionSelectionType conversionSelectionType = value;
				val = ((conversionSelectionType != ConversionSelectionType.priority) ? getWeightedDictKey(dictionary, transformRng) : getPriorityDictKey(dictionary, transformRng));
				if ((int)val == -1)
				{
					Log.Error("Egocentrism tried to convert an item but something went wrong. Did you forget to add an enum or function?\n" + $"parsedConversionSelectionType: '{MegalomaniaPlugin.ConfigConversionSelectionType.Value}'");
					return list;
				}
				List<ItemIndex> weightedDictKeyAndBackup = getWeightedDictKeyAndBackup(parsedItemConvertToList, transformRng);
				ItemIndex val2 = (ItemIndex)(-1);
				foreach (ItemIndex item in weightedDictKeyAndBackup)
				{
					if (val != item)
					{
						val2 = item;
						break;
					}
				}
				if ((int)val2 == -1)
				{
					num3++;
					if (num3 >= dictionary.Count)
					{
						return list;
					}
					continue;
				}
				inventory.RemoveItem(val, 1);
				inventory.GiveItem(val2, 1);
				if (MegalomaniaPlugin.ConfigRegenerateScrap.Value && val == Items.RegeneratingScrap.itemIndex)
				{
					inventory.GiveItem(Items.RegeneratingScrapConsumed, 1);
				}
				if (!ignoreCap)
				{
					inventory.GiveItem(MegalomaniaPlugin.transformToken, 1 + MegalomaniaPlugin.ConfigMaxTransformationsPerStageStacking.Value);
				}
				list.Add(val);
				if (notifUI)
				{
					CharacterMasterNotificationQueue.SendTransformNotification(master, val, val2, (TransformationType)4);
				}
				if (inventory.GetItemCount(val) < 1)
				{
					dictionary.Remove(val);
				}
				else if (MegalomaniaPlugin.ConfigStackSizeMatters.Value)
				{
					dictionary[val] = weighSingleItem(val, inventory.GetItemCount(val));
				}
				amount--;
			}
			return list;
		}

		public static int weighSingleItem(ItemIndex itemIndex, int itemCount)
		{
			//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_001b: 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: Invalid comparison between Unknown and I4
			//IL_005a: 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)
			if (itemIndex == Items.LunarSun.itemIndex)
			{
				return -1;
			}
			ItemDef itemDef = ItemCatalog.GetItemDef(itemIndex);
			if (!Object.op_Implicit((Object)(object)itemDef))
			{
				return -1;
			}
			if ((int)itemDef.tier == 5)
			{
				return -1;
			}
			int value = 0;
			if (!parsedRarityPriorityList.TryGetValue(itemDef.tier, out value))
			{
				value = 0;
			}
			int value2 = 0;
			if (parsedItemPriorityList.TryGetValue(itemIndex, out value2) && value2 == 0)
			{
				return -1;
			}
			value += value2;
			if (value <= 0)
			{
				return -1;
			}
			if (MegalomaniaPlugin.ConfigStackSizeMatters.Value)
			{
				double num = 0.0;
				num += (double)value * ((double)itemCount - 1.0) * MegalomaniaPlugin.ConfigStackSizeMultiplier.Value;
				num += ((double)itemCount - 1.0) * MegalomaniaPlugin.ConfigStackSizeAdder.Value;
				value += (int)num;
			}
			return value;
		}

		public static Dictionary<ItemIndex, int> weighInventory(Inventory inventory)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			List<ItemIndex> list = new List<ItemIndex>(inventory.itemAcquisitionOrder);
			Dictionary<ItemIndex, int> dictionary = new Dictionary<ItemIndex, int>();
			foreach (ItemIndex item in list)
			{
				int num = weighSingleItem(item, inventory.GetItemCount(item));
				if (num > 0)
				{
					dictionary.Add(item, num);
				}
			}
			return dictionary;
		}

		public static List<T> getWeightedDictKeyAndBackup<T>(Dictionary<T, int> dict, Xoroshiro128Plus rng)
		{
			Dictionary<T, int> dictionary = new Dictionary<T, int>();
			foreach (KeyValuePair<T, int> item in dict)
			{
				dictionary.Add(item.Key, item.Value);
			}
			List<T> list = new List<T>();
			for (int i = 0; i < dict.Count && i < 2; i++)
			{
				T weightedDictKey = getWeightedDictKey(dictionary, rng);
				list.Add(weightedDictKey);
				dictionary.Remove(weightedDictKey);
			}
			list.Reverse();
			return list;
		}

		public static T getPriorityDictKey<T>(Dictionary<T, int> dict, Xoroshiro128Plus rng)
		{
			int num = 0;
			List<T> list = new List<T>();
			foreach (KeyValuePair<T, int> item in dict)
			{
				if (item.Value == num)
				{
					list.Add(item.Key);
				}
				else if (item.Value > num)
				{
					num = item.Value;
					list.Clear();
					list.Add(item.Key);
				}
			}
			return list[rng.RangeInt(0, list.Count)];
		}

		public static T getWeightedDictKey<T>(Dictionary<T, int> dict, Xoroshiro128Plus rng)
		{
			int num = 0;
			foreach (int value in dict.Values)
			{
				num += value;
			}
			int num2 = rng.RangeInt(0, num);
			foreach (KeyValuePair<T, int> item in dict)
			{
				num2 -= item.Value;
				if (num2 < 0)
				{
					return item.Key;
				}
			}
			Log.Error("Couldn't return a random weighted dictionary key! This shouldn't happen if all weights are positive. Returned FirstOrDefault() instead.");
			return dict.FirstOrDefault().Key;
		}

		public static float determineStatBoost(bool diminishing, float perStack, float max, float stacksize)
		{
			if (max == 0f)
			{
				return 0f;
			}
			if (diminishing)
			{
				return max - max * (float)Math.Pow(1f - perStack / max, stacksize);
			}
			if (max > 0f)
			{
				return Math.Min(perStack * stacksize, max);
			}
			return perStack * stacksize;
		}

		public static void ParseItemConvertToList()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			parsedItemConvertToList = new Dictionary<ItemIndex, int>();
			string[] array = MegalomaniaPlugin.ConfigItemsToConvertTo.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(":");
				if (array3.Length != 2)
				{
					Log.Warning("(ConvertTo) Invalid amount of colons: '" + text + "'");
					continue;
				}
				string text2 = array3[0].Trim();
				string text3 = array3[1].Trim();
				if (Utility.IsNullOrWhiteSpace(text2) || Utility.IsNullOrWhiteSpace(text3))
				{
					Log.Warning("(ConvertTo) Invalid empty item or priority: '" + text + "'");
					continue;
				}
				if (!int.TryParse(text3, out var result))
				{
					Log.Warning("(ConvertTo) Invalid priority: '" + text + "'");
					continue;
				}
				ItemIndex val = ItemCatalog.FindItemIndex(text2);
				if ((int)val == -1)
				{
					Log.Warning("(ConvertTo) Invalid item: '" + text + "'");
					continue;
				}
				if (parsedItemConvertToList.ContainsKey(val))
				{
					Log.Warning("(ConvertTo) Item already in list: '" + text + "'");
					continue;
				}
				parsedItemConvertToList.Add(val, result);
				Log.Info("(ConvertTo) Item:Priority added! '" + text + "'");
			}
		}

		public static void ParseRarityPriorityList()
		{
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			parsedRarityPriorityList = new Dictionary<ItemTier, int>();
			string[] array = MegalomaniaPlugin.ConfigRarityPriorityList.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(":");
				if (array3.Length != 2)
				{
					Log.Warning("(Rarity:Priority) Invalid amount of colons: '" + text + "'");
					continue;
				}
				string text2 = array3[0].Trim().ToLower();
				string text3 = array3[1].Trim();
				if (Utility.IsNullOrWhiteSpace(text2) || Utility.IsNullOrWhiteSpace(text3))
				{
					Log.Warning("(Rarity:Priority) Invalid empty tier or priority: '" + text + "'");
					continue;
				}
				if (!int.TryParse(text3, out var result) || result < 0)
				{
					Log.Warning("(Rarity:Priority) Invalid priority: '" + text + "'");
					continue;
				}
				if (!Enum.TryParse<ItemTierLookup>(text2, out var result2))
				{
					Log.Warning("(Rarity:Priority) Invalid rarity: '" + text + "'");
					continue;
				}
				if (result == 0)
				{
					Log.Info("(Rarity:Priority) Blacklisting Rarity:Priority! '" + text + "'");
					continue;
				}
				ItemTier key = (ItemTier)result2;
				if (parsedRarityPriorityList.ContainsKey(key))
				{
					Log.Warning("(Rarity:Priority) Rarity already in list: '" + text + "'");
					continue;
				}
				parsedRarityPriorityList.Add(key, result);
				Log.Info("(Rarity:Priority) Rarity:Priority added! '" + text + "'");
			}
		}

		public static void ParseItemPriorityList()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Invalid comparison between Unknown and I4
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			parsedItemPriorityList = new Dictionary<ItemIndex, int>();
			string[] array = MegalomaniaPlugin.ConfigItemPriorityList.Value.Split(',');
			string[] array2 = array;
			foreach (string text in array2)
			{
				string[] array3 = text.Split(":");
				if (array3.Length != 2)
				{
					Log.Warning("(Item:Priority) Invalid amount of colons: '" + text + "'");
					continue;
				}
				string text2 = array3[0].Trim();
				string text3 = array3[1].Trim();
				if (Utility.IsNullOrWhiteSpace(text2) || Utility.IsNullOrWhiteSpace(text3))
				{
					Log.Warning("(Item:Priority) Invalid empty item or priority: '" + text + "'");
					continue;
				}
				if (!int.TryParse(text3, out var result))
				{
					Log.Warning("(Item:Priority) Invalid priority: '" + text + "'");
					continue;
				}
				ItemIndex val = ItemCatalog.FindItemIndex(text2);
				if ((int)val == -1)
				{
					Log.Warning("(Item:Priority) Invalid item: '" + text + "'");
					continue;
				}
				if (parsedItemPriorityList.ContainsKey(val))
				{
					Log.Warning("(Item:Priority) Item already in list: '" + text + "'");
					continue;
				}
				parsedItemPriorityList.Add(val, result);
				Log.Info("(Item:Priority) Item:Priority added! '" + text + "'");
			}
		}
	}
}
namespace MegalomaniaPlugin.Skills
{
	public class BombAbility : BaseSkillState
	{
		public static readonly float baseDuration = 0.5f;

		private float duration;

		public static SkillDef BombSkill;

		private static readonly float damageCoefficient = 4.5f;

		private static readonly float force = 0.8f;

		public static GameObject projectilePrefab;

		public static GameObject muzzleFlashPrefab;

		public static float spreadBloomValue = 1f;

		public static void initBombAbility(Sprite Icon)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			projectilePrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/LunarWispTrackingBomb");
			muzzleFlashPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MuzzleFlashes/MuzzleflashLunarShard");
			BombSkill = (SkillDef)(object)ScriptableObject.CreateInstance<EgoSkillDef>();
			BombSkill.activationState = new SerializableEntityStateType(typeof(BombAbility));
			BombSkill.activationStateMachineName = "Weapon";
			BombSkill.canceledFromSprinting = false;
			BombSkill.cancelSprintingOnActivation = true;
			BombSkill.fullRestockOnAssign = false;
			BombSkill.isCombatSkill = true;
			BombSkill.mustKeyPress = false;
			BombSkill.baseMaxStock = 1;
			BombSkill.rechargeStock = 1;
			BombSkill.requiredStock = 1;
			BombSkill.stockToConsume = 1;
			BombSkill.baseRechargeInterval = 3f;
			BombSkill.interruptPriority = (InterruptPriority)1;
			BombSkill.autoHandleLuminousShot = true;
			BombSkill.icon = Icon;
			BombSkill.skillDescriptionToken = "MEGALOMANIA_BOMB_DESCRIPTION";
			BombSkill.skillName = "Chimera Bomb";
			BombSkill.skillNameToken = "MEGALOMANIA_BOMB_NAME";
			ContentAddition.AddSkillDef(BombSkill);
		}

		public override void OnEnter()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			Ray aimRay = ((BaseState)this).GetAimRay();
			((BaseState)this).StartAimMode(aimRay, 2f, false);
			fire();
			if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.characterMotor))
			{
				float num = (((EntityState)this).characterBody.characterMotor.isGrounded ? 0.5f : 1f);
				float num2 = (Object.op_Implicit((Object)(object)((EntityState)this).characterBody.characterMotor) ? ((EntityState)this).characterBody.characterMotor.mass : 1f);
				float acceleration = ((EntityState)this).characterBody.acceleration;
				float num3 = Trajectory.CalculateInitialYSpeedForHeight(num, 0f - acceleration);
				((EntityState)this).characterBody.characterMotor.velocity = new Vector3(0f, 0f, 0f);
				((EntityState)this).characterBody.characterMotor.ApplyForce((0f - num3) * num2 * ((Ray)(ref aimRay)).direction, true, false);
			}
		}

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

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public void fire()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_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)
			//IL_00b2: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			Ray aimRay = ((BaseState)this).GetAimRay();
			if (Object.op_Implicit((Object)(object)muzzleFlashPrefab))
			{
				EffectData val = new EffectData
				{
					origin = ((Ray)(ref aimRay)).origin + ((Ray)(ref aimRay)).direction,
					rotation = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction)
				};
				EffectManager.SpawnEffect(muzzleFlashPrefab, val, false);
			}
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				((EntityState)this).characterBody.AddSpreadBloom(spreadBloomValue);
			}
			Util.PlaySound("Play_lunar_wisp_attack2_launch", ((EntityState)this).gameObject);
			Vector3 direction = ((Ray)(ref aimRay)).direction;
			Vector3 normalized = ((Vector3)(ref direction)).normalized;
			Vector3 normalized2 = ((Vector3)(ref ((EntityState)this).characterMotor.velocity)).normalized;
			float num = normalized.x * normalized2.x + normalized.y * normalized2.y + normalized.z + normalized2.z;
			if (num < 0f)
			{
				num = 0f;
			}
			ProjectileManager.instance.FireProjectile(projectilePrefab, ((Ray)(ref aimRay)).origin + ((Ray)(ref aimRay)).direction * 1.8f + ((Ray)(ref aimRay)).direction * ((EntityState)this).characterBody.moveSpeed * num * 0.1423f, Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction), ((EntityState)this).gameObject, ((BaseState)this).damageStat * damageCoefficient, force, ((BaseState)this).RollCrit(), (DamageColorIndex)0, (GameObject)null, -1f);
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: 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)
			return (InterruptPriority)2;
		}
	}
	public class ConceitAbility : BaseSkillState
	{
		public static float baseDuration = 1f;

		public static float burstShotsPerSecond = 8f;

		public static int shotsPerBurst = 3;

		public static float baseBurstDuration = (float)shotsPerBurst / burstShotsPerSecond;

		private float burstDuration;

		private int shotsFiredInBurst = 0;

		private float duration;

		public static SkillDef ConceitSkill;

		private static float damageCoefficient = 1f;

		private static float force = 0.1f;

		public static GameObject projectilePrefab;

		public static float spreadBloomValue = 0.15f;

		public static void initEgoPrimary(Sprite Icon)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			projectilePrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/LunarExploderShardProjectile");
			ConceitSkill = (SkillDef)(object)ScriptableObject.CreateInstance<EgoSkillDef>();
			ConceitSkill.activationState = new SerializableEntityStateType(typeof(ConceitAbility));
			ConceitSkill.activationStateMachineName = "Weapon";
			ConceitSkill.canceledFromSprinting = false;
			ConceitSkill.cancelSprintingOnActivation = true;
			ConceitSkill.fullRestockOnAssign = true;
			ConceitSkill.isCombatSkill = true;
			ConceitSkill.mustKeyPress = false;
			ConceitSkill.baseMaxStock = 1;
			ConceitSkill.rechargeStock = 1;
			ConceitSkill.requiredStock = 1;
			ConceitSkill.stockToConsume = 1;
			ConceitSkill.baseRechargeInterval = 0f;
			ConceitSkill.interruptPriority = (InterruptPriority)0;
			ConceitSkill.autoHandleLuminousShot = true;
			ConceitSkill.icon = Icon;
			ConceitSkill.skillDescriptionToken = "MEGALOMANIA_PRIMARY_DESCRIPTION";
			ConceitSkill.skillName = "Conceit";
			ConceitSkill.skillNameToken = "MEGALOMANIA_PRIMARY_NAME";
			ContentAddition.AddSkillDef(ConceitSkill);
		}

		public override void OnEnter()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			burstDuration = baseBurstDuration / ((BaseState)this).attackSpeedStat;
			shotsFiredInBurst = 0;
			Ray aimRay = ((BaseState)this).GetAimRay();
			((BaseState)this).StartAimMode(aimRay, 2f, false);
		}

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

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			int num = Mathf.FloorToInt(((EntityState)this).fixedAge / burstDuration * (float)shotsPerBurst);
			if (shotsFiredInBurst <= num && shotsFiredInBurst < shotsPerBurst)
			{
				fire();
				shotsFiredInBurst++;
			}
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public void fire()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_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_0078: Unknown result type (might be due to invalid IL or missing references)
			Ray aimRay = ((BaseState)this).GetAimRay();
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
			{
				((EntityState)this).characterBody.AddSpreadBloom(spreadBloomValue);
			}
			Vector3 val = Util.ApplySpread(((Ray)(ref aimRay)).direction, 0f, 1f, 1f, 0.5f, 0f, 0f);
			Util.PlaySound("Play_lunar_exploder_m1_fire", ((EntityState)this).gameObject);
			ProjectileManager.instance.FireProjectile(projectilePrefab, ((Ray)(ref aimRay)).origin, Util.QuaternionSafeLookRotation(val), ((EntityState)this).gameObject, ((BaseState)this).damageStat * damageCoefficient, force, ((BaseState)this).RollCrit(), (DamageColorIndex)0, (GameObject)null, 150f);
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: 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)
			return (InterruptPriority)1;
		}
	}
	internal class EgoSkillDef : SkillDef
	{
		public bool requiresBombs = false;

		public override bool IsReady([NotNull] GenericSkill skillSlot)
		{
			if (!requiresBombs)
			{
				return ((SkillDef)this).IsReady(skillSlot);
			}
			int deployableCount = skillSlot.characterBody.master.GetDeployableCount((DeployableSlot)16);
			return ((SkillDef)this).IsReady(skillSlot) && deployableCount > 0;
		}

		public override bool CanExecute([NotNull] GenericSkill skillSlot)
		{
			if (!requiresBombs)
			{
				return ((SkillDef)this).CanExecute(skillSlot);
			}
			int deployableCount = skillSlot.characterBody.master.GetDeployableCount((DeployableSlot)16);
			return ((SkillDef)this).CanExecute(skillSlot) && deployableCount > 0;
		}

		public Deployable GetFreeLunarSunBomb(CharacterBody body)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0044: Invalid comparison between Unknown and I4
			//IL_004d: 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)
			int deployableCount = body.master.GetDeployableCount((DeployableSlot)16);
			if (deployableCount > 0)
			{
				List<DeployableInfo> deployablesList = body.master.deployablesList;
				foreach (DeployableInfo item in deployablesList)
				{
					if ((int)item.slot == 16)
					{
						ProjectileSphereTargetFinder component = ((Component)item.deployable).gameObject.GetComponent<ProjectileSphereTargetFinder>();
						if (Object.op_Implicit((Object)(object)component) && !component.hasTarget)
						{
							return item.deployable;
						}
					}
				}
			}
			return null;
		}
	}
	public class MonopolizeAbility : BaseSkillState
	{
		public static float baseDuration = 1f;

		private float duration;

		public static SkillDef MonopolizeSkill;

		public static GameObject muzzleFlashPrefab;

		public static void initEgoMonopolize(Sprite Icon)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			muzzleFlashPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MuzzleFlashes/MuzzleflashLunarShard");
			MonopolizeSkill = (SkillDef)(object)ScriptableObject.CreateInstance<EgoSkillDef>();
			MonopolizeSkill.activationState = new SerializableEntityStateType(typeof(MonopolizeAbility));
			MonopolizeSkill.activationStateMachineName = "Weapon";
			MonopolizeSkill.beginSkillCooldownOnSkillEnd = true;
			MonopolizeSkill.canceledFromSprinting = false;
			MonopolizeSkill.cancelSprintingOnActivation = true;
			MonopolizeSkill.fullRestockOnAssign = false;
			MonopolizeSkill.isCombatSkill = false;
			MonopolizeSkill.mustKeyPress = true;
			MonopolizeSkill.baseMaxStock = 1;
			MonopolizeSkill.rechargeStock = 1;
			MonopolizeSkill.requiredStock = 1;
			MonopolizeSkill.stockToConsume = 1;
			MonopolizeSkill.baseRechargeInterval = 60f;
			MonopolizeSkill.interruptPriority = (InterruptPriority)1;
			MonopolizeSkill.icon = Icon;
			MonopolizeSkill.skillDescriptionToken = "MEGALOMANIA_MONOPOLIZE_DESC";
			MonopolizeSkill.skillName = "Monopolize";
			MonopolizeSkill.skillNameToken = "MEGALOMANIA_MONOPOLIZE_NAME";
			MonopolizeSkill.autoHandleLuminousShot = true;
			ContentAddition.AddSkillDef(MonopolizeSkill);
		}

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = baseDuration;
			Util.PlaySound("Play_voidman_R_activate", ((EntityState)this).gameObject);
		}

		public override void OnExit()
		{
			((EntityState)this).OnExit();
			Trigger();
			Util.PlaySound("Play_voidman_R_pop", ((EntityState)this).gameObject);
		}

		public void Trigger()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			Ray aimRay = ((BaseState)this).GetAimRay();
			Vector3 val = ((Ray)(ref aimRay)).origin;
			GameObject gameObject = ((EntityState)this).gameObject;
			CharacterModel component = ((Component)((EntityState)this).characterBody.modelLocator.modelTransform).gameObject.GetComponent<CharacterModel>();
			List<ParentedPrefabDisplay> parentedPrefabDisplays = component.parentedPrefabDisplays;
			foreach (ParentedPrefabDisplay item in parentedPrefabDisplays)
			{
				ParentedPrefabDisplay current = item;
				if (current.itemIndex == Items.LunarSun.itemIndex)
				{
					val = ((Component)((Component)((ParentedPrefabDisplay)(ref current)).itemDisplay).transform).gameObject.transform.position;
					gameObject = ((Component)((Component)((ParentedPrefabDisplay)(ref current)).itemDisplay).transform).gameObject;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)muzzleFlashPrefab))
			{
				EffectData val2 = new EffectData
				{
					origin = val,
					rootObject = gameObject
				};
				EffectManager.SpawnEffect(muzzleFlashPrefab, val2, false);
			}
			List<ItemIndex> list = Utils.TransformItems(((EntityState)this).characterBody.inventory, 5, null, ((EntityState)this).characterBody.master, ignoreCap: true, notifUI: false);
			int count = list.Count;
			if (count < 1)
			{
				Vector3 val3 = val;
				ItemIndex itemIndex = Items.LunarSun.itemIndex;
				Action<ItemTransferOrb> obj = delegate
				{
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					((EntityState)this).characterBody.inventory.GiveItem(Items.LunarSun, 1);
					CharacterMasterNotificationQueue.PushItemNotification(((EntityState)this).characterBody.master, Items.LunarSun.itemIndex);
				};
				HurtBox mainHurtBox = ((EntityState)this).characterBody.mainHurtBox;
				ItemTransferOrb.DispatchItemTransferOrb(val3, (Inventory)null, itemIndex, 1, obj, Either<NetworkIdentity, HurtBox>.op_Implicit(ref mainHurtBox));
				return;
			}
			foreach (ItemIndex item2 in list)
			{
				Vector3 val4 = val;
				Action<ItemTransferOrb> obj2 = delegate
				{
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					((EntityState)this).characterBody.inventory.GiveItem(Items.LunarSun, 1);
					CharacterMasterNotificationQueue.PushItemNotification(((EntityState)this).characterBody.master, Items.LunarSun.itemIndex);
				};
				HurtBox mainHurtBox = ((EntityState)this).characterBody.mainHurtBox;
				ItemTransferOrb.DispatchItemTransferOrb(val4, (Inventory)null, item2, 1, obj2, Either<NetworkIdentity, HurtBox>.op_Implicit(ref mainHurtBox));
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: 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)
			return (InterruptPriority)2;
		}
	}
	public class ShellAbility : BaseSkillState
	{
		public static float baseDuration = 1f;

		private float duration;

		public static SkillDef ShellSkill;

		public static GameObject muzzleFlashPrefab;

		public static void initEgoShell(Sprite Icon)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			muzzleFlashPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MuzzleFlashes/MuzzleflashLunarShard");
			ShellSkill = (SkillDef)(object)ScriptableObject.CreateInstance<EgoSkillDef>();
			ShellSkill.activationState = new SerializableEntityStateType(typeof(ShellAbility));
			ShellSkill.activationStateMachineName = "Weapon";
			ShellSkill.beginSkillCooldownOnSkillEnd = true;
			ShellSkill.canceledFromSprinting = false;
			ShellSkill.cancelSprintingOnActivation = false;
			ShellSkill.fullRestockOnAssign = false;
			ShellSkill.isCombatSkill = false;
			ShellSkill.mustKeyPress = false;
			ShellSkill.baseMaxStock = 1;
			ShellSkill.rechargeStock = 1;
			ShellSkill.requiredStock = 1;
			ShellSkill.stockToConsume = 1;
			ShellSkill.baseRechargeInterval = 14f;
			ShellSkill.interruptPriority = (InterruptPriority)1;
			ShellSkill.icon = Icon;
			ShellSkill.skillDescriptionToken = "MEGALOMANIA_SHELL_DESCRIPTION";
			ShellSkill.skillName = "Chimera Shell";
			ShellSkill.skillNameToken = "MEGALOMANIA_SHELL_NAME";
			ShellSkill.autoHandleLuminousShot = true;
			ContentAddition.AddSkillDef(ShellSkill);
		}

		public override void OnEnter()
		{
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			((EntityState)this).characterBody.healthComponent.ForceShieldRegen();
			((EntityState)this).characterBody.healthComponent.AddBarrier(((EntityState)this).characterBody.healthComponent.fullCombinedHealth * 0.25f);
			Util.PlayAttackSpeedSound("Play_lunar_golem_attack2_buildUp", ((EntityState)this).gameObject, ((BaseState)this).attackSpeedStat + 1.4f);
		}

		public override void OnExit()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0052: Expected O, but got Unknown
			((EntityState)this).OnExit();
			((EntityState)this).characterBody.AddTimedBuff(EgoShelledBuff.EgoShellBuff, 7f);
			Util.PlaySound("Play_lunar_golem_attack2_shieldActivate", ((EntityState)this).gameObject);
			EffectData val = new EffectData
			{
				origin = ((EntityState)this).characterBody.footPosition,
				rotation = Quaternion.identity
			};
			EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MonstersOnShrineUse"), val, true);
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).fixedAge >= duration && ((EntityState)this).isAuthority)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			//IL_0002: 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)
			return (InterruptPriority)2;
		}
	}
	public class TwinShotAbility : BaseSkillState
	{
		public static float baseDuration = 2f;

		public static float burstShotsPerSecond = 6f;

		public static int shotsPerBurst = 6;

		public static float baseBurstDuration = (float)shotsPerBurst / burstShotsPerSecond;

		private float burstDuration;

		private int shotsFiredInBurst = 0;

		private float duration;

		public static SkillDef TwinShotSkill;

		private static float damageCoefficient = 1.8f;

		private static float force = 0.2f;

		public static GameObject projectilePrefab;

		public static GameObject muzzleFlashPrefab;

		public static float spreadBloomValue = 0.3f;

		public static void initEgoTwinShot(Sprite Icon)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			projectilePrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Projectiles/LunarGolemTwinShotProjectile");
			muzzleFlashPrefab = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MuzzleFlashes/MuzzleflashLunarGolemTwinShot");
			TwinShotSkill = (SkillDef)(object)ScriptableObject.CreateInstance<EgoSkillDef>();
			TwinShotSkill.activationState = new SerializableEntityStateType(typeof(TwinShotAbility));
			TwinShotSkill.activationStateMachineName = "Weapon";
			TwinShotSkill.canceledFromSprinting = false;
			TwinShotSkill.cancelSprintingOnActivation = true;
			TwinShotSkill.fullRestockOnAssign = false;
			TwinShotSkill.isCombatSkill = true;
			TwinShotSkill.mustKeyPress = false;
			TwinShotSkill.baseMaxStock = 1;
			TwinShotSkill.rechargeStock = 1;
			TwinShotSkill.requiredStock = 1;
			TwinShotSkill.stockToConsume = 1;
			TwinShotSkill.baseRechargeInterval = 6f;
			TwinShotSkill.interruptPriority = (InterruptPriority)1;
			TwinShotSkill.autoHandleLuminousShot = true;
			TwinShotSkill.beginSkillCooldownOnSkillEnd = true;
			TwinShotSkill.icon = Icon;
			TwinShotSkill.skillDescriptionToken = "MEGALOMANIA_TWINSHOT_DESCRIPTION";
			TwinShotSkill.skillName = "Twin Shot";
			TwinShotSkill.skillNameToken = "MEGALOMANIA_TWINSHOT_NAME";
			ContentAddition.AddSkillDef(TwinShotSkill);
		}

		public override void OnEnter()
		{
			//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_003b: Unknown result type (might be due to invalid IL or missing references)
			((BaseState)this).OnEnter();
			duration = baseDuration / ((BaseState)this).attackSpeedStat;
			burstDuration = base