Decompiled source of KarmaClimb v2.0.0

KarmaClimb.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 System.Text;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Artifacts;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Artifacts;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KarmaClimb")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+e1cb25acf6842ea4872ce7d6503658ba19090ba1")]
[assembly: AssemblyProduct("KarmaClimb")]
[assembly: AssemblyTitle("KarmaClimb")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.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]
	[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]
	[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 KarmaClimb
{
	internal static class EclipseKarmaLock
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_ModifyKarma <>9__0_0;

			internal void <Init>b__0_0(orig_ModifyKarma orig, KarmaManager self, int amount)
			{
				if (!(Run.instance is EclipseRun))
				{
					orig.Invoke(self, amount);
				}
			}
		}

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_ModifyKarma val = delegate(orig_ModifyKarma orig, KarmaManager self, int amount)
				{
					if (!(Run.instance is EclipseRun))
					{
						orig.Invoke(self, amount);
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			KarmaManager.ModifyKarma += (hook_ModifyKarma)obj;
		}
	}
	internal static class EclipseLadderHooks
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_GetEclipseDifficultyIndex <>9__4_0;

			public static hook_GetEclipseLevelFromRuleBook <>9__4_1;

			public static hook_OverrideRuleChoices <>9__4_2;

			public static hook_FindChoiceDef <>9__4_3;

			internal DifficultyIndex <Init>b__4_0(orig_GetEclipseDifficultyIndex orig, int eclipseLevel)
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				if (!KarmaClimbDifficulties.TryGetDifficultyIndex(eclipseLevel, out var index))
				{
					return orig.Invoke(eclipseLevel);
				}
				return index;
			}

			internal int <Init>b__4_1(orig_GetEclipseLevelFromRuleBook orig, RuleBook ruleBook)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				if (!KarmaClimbDifficulties.TryGetEclipseLevel(ruleBook.FindDifficulty(), out var eclipseLevel))
				{
					return orig.Invoke(ruleBook);
				}
				return eclipseLevel;
			}

			internal void <Init>b__4_2(orig_OverrideRuleChoices orig, EclipseRun self, RuleChoiceMask mustInclude, RuleChoiceMask mustExclude, ulong runSeed)
			{
				inEclipseOverride = true;
				try
				{
					orig.Invoke(self, mustInclude, mustExclude, runSeed);
				}
				finally
				{
					inEclipseOverride = false;
				}
			}

			internal RuleChoiceDef <Init>b__4_3(orig_FindChoiceDef orig, string globalName)
			{
				if (inEclipseOverride && TryRemap(orig, globalName, out var remapped))
				{
					return remapped;
				}
				return orig.Invoke(globalName);
			}
		}

		private const string DifficultyPrefix = "Difficulty.";

		private const string KarmaPrefix = "Karma.InitialLevel.";

		private const string KarmaDisabledChoice = "Karma.InitialLevel.KarmaDisabled";

		private static bool inEclipseOverride;

		internal static void Init()
		{
			//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_0026: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			EclipseRun.maxEclipseLevel = 16;
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				DifficultyIndex index;
				hook_GetEclipseDifficultyIndex val = (orig_GetEclipseDifficultyIndex orig, int eclipseLevel) => (!KarmaClimbDifficulties.TryGetDifficultyIndex(eclipseLevel, out index)) ? orig.Invoke(eclipseLevel) : index;
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			EclipseRun.GetEclipseDifficultyIndex += (hook_GetEclipseDifficultyIndex)obj;
			object obj2 = <>c.<>9__4_1;
			if (obj2 == null)
			{
				int eclipseLevel;
				hook_GetEclipseLevelFromRuleBook val2 = (orig_GetEclipseLevelFromRuleBook orig, RuleBook ruleBook) => (!KarmaClimbDifficulties.TryGetEclipseLevel(ruleBook.FindDifficulty(), out eclipseLevel)) ? orig.Invoke(ruleBook) : eclipseLevel;
				<>c.<>9__4_1 = val2;
				obj2 = (object)val2;
			}
			EclipseRun.GetEclipseLevelFromRuleBook += (hook_GetEclipseLevelFromRuleBook)obj2;
			object obj3 = <>c.<>9__4_2;
			if (obj3 == null)
			{
				hook_OverrideRuleChoices val3 = delegate(orig_OverrideRuleChoices orig, EclipseRun self, RuleChoiceMask mustInclude, RuleChoiceMask mustExclude, ulong runSeed)
				{
					inEclipseOverride = true;
					try
					{
						orig.Invoke(self, mustInclude, mustExclude, runSeed);
					}
					finally
					{
						inEclipseOverride = false;
					}
				};
				<>c.<>9__4_2 = val3;
				obj3 = (object)val3;
			}
			EclipseRun.OverrideRuleChoices += (hook_OverrideRuleChoices)obj3;
			object obj4 = <>c.<>9__4_3;
			if (obj4 == null)
			{
				RuleChoiceDef remapped;
				hook_FindChoiceDef val4 = (orig_FindChoiceDef orig, string globalName) => (inEclipseOverride && TryRemap(orig, globalName, out remapped)) ? remapped : orig.Invoke(globalName);
				<>c.<>9__4_3 = val4;
				obj4 = (object)val4;
			}
			RuleCatalog.FindChoiceDef += (hook_FindChoiceDef)obj4;
		}

		private static bool TryRemap(orig_FindChoiceDef orig, string globalName, out RuleChoiceDef remapped)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected I4, but got Unknown
			remapped = null;
			if (string.IsNullOrEmpty(globalName))
			{
				return false;
			}
			if (globalName.StartsWith("Difficulty."))
			{
				string text = globalName.Substring("Difficulty.".Length);
				foreach (KeyValuePair<int, DifficultyIndex> registeredLevel in KarmaClimbDifficulties.RegisteredLevels)
				{
					if (!(((object)registeredLevel.Value/*cast due to .constrained prefix*/).ToString() != text))
					{
						remapped = FindDifficultyChoice(registeredLevel.Value);
						if (remapped == null)
						{
							Log.Error($"No rule choice for DifficultyIndex {(int)registeredLevel.Value} (Eclipse {registeredLevel.Key}).");
						}
						return remapped != null;
					}
				}
				return false;
			}
			if (globalName.StartsWith("Karma.InitialLevel."))
			{
				if (!int.TryParse(globalName.Substring("Karma.InitialLevel.".Length), out var result))
				{
					return false;
				}
				int num = KarmaClimbLadder.KarmaLevelFor(result);
				remapped = orig.Invoke((num > 0) ? ("Karma.InitialLevel." + num) : "Karma.InitialLevel.KarmaDisabled");
				return remapped != null;
			}
			return false;
		}

		private static RuleChoiceDef FindDifficultyChoice(DifficultyIndex index)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			RuleDef val = RuleCatalog.FindRuleDef("Difficulty");
			if (val == null)
			{
				return null;
			}
			foreach (RuleChoiceDef choice in val.choices)
			{
				if (choice.difficultyIndex == index)
				{
					return choice;
				}
			}
			return null;
		}
	}
	internal static class EclipseMenuDump
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__2_0;

			internal void <Init>b__2_0(orig_Awake orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				Dump(self);
			}
		}

		private static bool enabled;

		private static bool logged;

		internal static void Init(bool logHierarchy)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			enabled = logHierarchy;
			if (!enabled)
			{
				return;
			}
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					Dump(self);
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			EclipseRunScreenController.Awake += (hook_Awake)obj;
		}

		private static void Dump(EclipseRunScreenController controller)
		{
			if (!logged)
			{
				logged = true;
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("Eclipse menu hierarchy:\n");
				Append(stringBuilder, ((Component)controller).transform, 0);
				Log.Info(stringBuilder.ToString());
			}
		}

		private static void Append(StringBuilder sb, Transform transform, int depth)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			sb.Append(' ', depth * 2).Append("- ").Append(((Object)transform).name);
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				StringBuilder stringBuilder = sb.Append("  rect=");
				Rect rect = val.rect;
				StringBuilder stringBuilder2 = stringBuilder.Append(Mathf.Round(((Rect)(ref rect)).width)).Append('x');
				rect = val.rect;
				stringBuilder2.Append(Mathf.Round(((Rect)(ref rect)).height));
			}
			LayoutElement component = ((Component)transform).GetComponent<LayoutElement>();
			if (Object.op_Implicit((Object)(object)component))
			{
				sb.Append("  LE(min=").Append(component.minHeight).Append(",pref=")
					.Append(component.preferredHeight)
					.Append(",flex=")
					.Append(component.flexibleHeight)
					.Append(",ignore=")
					.Append(component.ignoreLayout)
					.Append(')');
			}
			Component[] components = ((Component)transform).GetComponents<Component>();
			if (components.Length != 0)
			{
				sb.Append("  [");
				for (int i = 0; i < components.Length; i++)
				{
					if (i > 0)
					{
						sb.Append(", ");
					}
					sb.Append(Object.op_Implicit((Object)(object)components[i]) ? ((object)components[i]).GetType().Name : "null");
				}
				sb.Append(']');
			}
			sb.Append('\n');
			for (int j = 0; j < transform.childCount; j++)
			{
				Append(sb, transform.GetChild(j), depth + 1);
			}
		}
	}
	internal class EclipseMenuEscape : MonoBehaviour
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__1_0;

			internal void <Init>b__1_0(orig_Awake orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<EclipseMenuEscape>()))
				{
					((Component)self).gameObject.AddComponent<EclipseMenuEscape>();
				}
			}
		}

		private Button backButton;

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					if (!Object.op_Implicit((Object)(object)((Component)self).GetComponent<EclipseMenuEscape>()))
					{
						((Component)self).gameObject.AddComponent<EclipseMenuEscape>();
					}
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			EclipseRunScreenController.Awake += (hook_Awake)obj;
		}

		private void Start()
		{
			Transform val = ((Component)this).transform.Find("Main Panel/BackButton");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Button[] componentsInChildren = ((Component)this).GetComponentsInChildren<Button>(true);
				foreach (Button val2 in componentsInChildren)
				{
					if (((Object)val2).name.Contains("BackButton"))
					{
						val = ((Component)val2).transform;
						break;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Warning("No Back button in the Eclipse menu; Escape will not leave it.");
			}
			else
			{
				backButton = ((Component)val).GetComponent<Button>();
			}
		}

		private void Update()
		{
			if (Object.op_Implicit((Object)(object)backButton) && Input.GetKeyDown((KeyCode)27) && ((Selectable)backButton).interactable)
			{
				((UnityEvent)backButton.onClick).Invoke();
			}
		}
	}
	internal static class EclipseMenuKarmaPanel
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__4_0;

			internal void <Init>b__4_0(orig_Awake orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				Build(self);
			}
		}

		internal const string PanelName = "KarmaClimbKarmaPanel";

		internal const string BadgeRowName = "KarmaBadgeRow";

		private const float GapBelowParagraph = 32f;

		private const float BadgeSpacing = 6f;

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__4_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					Build(self);
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			EclipseRunScreenController.Awake += (hook_Awake)obj;
		}

		private static void Build(EclipseRunScreenController controller)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0186: Expected O, but got Unknown
			Transform val = ((Component)controller).transform.Find("Main Panel/GenericMenuButtonPanel");
			RectTransform val2 = (RectTransform)(Object.op_Implicit((Object)(object)val) ? /*isinst with value type is only supported in some contexts*/: null);
			EclipseDifficultyMedalDisplay componentInChildren = ((Component)controller).GetComponentInChildren<EclipseDifficultyMedalDisplay>(true);
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)componentInChildren))
			{
				Log.Warning("Eclipse menu is missing the left column, its description or a medal; skipping the Karma box.");
			}
			else if (!Object.op_Implicit((Object)(object)val.Find("KarmaClimbKarmaPanel")))
			{
				GameObject val3 = new GameObject("KarmaClimbKarmaPanel", new Type[1] { typeof(RectTransform) });
				val3.transform.SetParent(val, false);
				RectTransform val4 = (RectTransform)val3.transform;
				val4.anchorMin = new Vector2(0.5f, 0.5f);
				val4.anchorMax = new Vector2(0.5f, 0.5f);
				val4.pivot = new Vector2(0f, 1f);
				Rect rect = val2.rect;
				val4.sizeDelta = new Vector2(((Rect)(ref rect)).width, 0f);
				Transform val5 = ((Component)controller).transform.Find("Main Panel/RightPanel");
				CopyBackdrop(val5, val3);
				VerticalLayoutGroup obj = val3.AddComponent<VerticalLayoutGroup>();
				VerticalLayoutGroup val6 = (Object.op_Implicit((Object)(object)val5) ? ((Component)val5).GetComponent<VerticalLayoutGroup>() : null);
				((LayoutGroup)obj).padding = (Object.op_Implicit((Object)(object)val6) ? new RectOffset(((LayoutGroup)val6).padding.left, ((LayoutGroup)val6).padding.right, ((LayoutGroup)val6).padding.top, ((LayoutGroup)val6).padding.bottom) : new RectOffset(16, 16, 16, 16));
				((HorizontalOrVerticalLayoutGroup)obj).spacing = (Object.op_Implicit((Object)(object)val6) ? ((HorizontalOrVerticalLayoutGroup)val6).spacing : 8f);
				((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
				ContentSizeFitter obj2 = val3.AddComponent<ContentSizeFitter>();
				obj2.horizontalFit = (FitMode)0;
				obj2.verticalFit = (FitMode)2;
				AddText(controller.eclipseDifficultyName, val3.transform, "KarmaHeading", "KARMACLIMB_MENU_KARMA_HEADING", sizeToText: false);
				AddBadgeRow(val3.transform, componentInChildren);
				AddText(controller.eclipseDifficultyDescription, val3.transform, "KarmaHint", "KARMACLIMB_MENU_KARMA_HINT", sizeToText: true);
				KarmaPanelPlacer karmaPanelPlacer = val3.AddComponent<KarmaPanelPlacer>();
				karmaPanelPlacer.anchor = val2;
				karmaPanelPlacer.gap = 32f;
				Log.Info("Built the Karma box in the Eclipse menu's left column.");
			}
		}

		private static void CopyBackdrop(Transform rightPanel, GameObject panel)
		{
			//IL_002c: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)rightPanel))
			{
				return;
			}
			Image component = ((Component)rightPanel).GetComponent<Image>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Image obj = panel.AddComponent<Image>();
				obj.sprite = component.sprite;
				obj.type = component.type;
				((Graphic)obj).color = ((Graphic)component).color;
				((Graphic)obj).material = ((Graphic)component).material;
				obj.pixelsPerUnitMultiplier = component.pixelsPerUnitMultiplier;
				((Graphic)obj).raycastTarget = false;
			}
			string[] array = new string[2] { "BlurPanel", "BorderImage" };
			foreach (string text in array)
			{
				Transform val = rightPanel.Find(text);
				if (Object.op_Implicit((Object)(object)val))
				{
					GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, panel.transform);
					((Object)val2).name = text;
					RectTransform val3 = (RectTransform)val2.transform;
					val3.anchorMin = Vector2.zero;
					val3.anchorMax = Vector2.one;
					val3.offsetMin = Vector2.zero;
					val3.offsetMax = Vector2.zero;
					LayoutElement val4 = val2.GetComponent<LayoutElement>();
					if (!Object.op_Implicit((Object)(object)val4))
					{
						val4 = val2.AddComponent<LayoutElement>();
					}
					val4.ignoreLayout = true;
				}
			}
		}

		private static LanguageTextMeshController AddText(LanguageTextMeshController template, Transform parent, string name, string token, bool sizeToText)
		{
			if (!Object.op_Implicit((Object)(object)template))
			{
				Log.Warning("No text template for " + name + "; it will be missing from the Karma box.");
				return null;
			}
			LanguageTextMeshController val = Object.Instantiate<LanguageTextMeshController>(template, parent);
			((Object)((Component)val).gameObject).name = name;
			val.token = token;
			if (sizeToText)
			{
				LayoutElement[] components = ((Component)val).GetComponents<LayoutElement>();
				foreach (LayoutElement obj in components)
				{
					obj.minHeight = -1f;
					obj.preferredHeight = -1f;
					obj.flexibleHeight = -1f;
				}
			}
			return val;
		}

		private static void AddBadgeRow(Transform parent, EclipseDifficultyMedalDisplay medalTemplate)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("KarmaBadgeRow", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)obj).childAlignment = (TextAnchor)4;
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 6f;
			RectTransform component = ((Component)medalTemplate).GetComponent<RectTransform>();
			float num;
			if (Object.op_Implicit((Object)(object)component))
			{
				Rect rect = component.rect;
				if (((Rect)(ref rect)).height > 0f)
				{
					rect = component.rect;
					num = ((Rect)(ref rect)).height;
					goto IL_0097;
				}
			}
			num = 64f;
			goto IL_0097;
			IL_0097:
			float num2 = num;
			LayoutElement obj2 = val.AddComponent<LayoutElement>();
			obj2.minHeight = num2;
			obj2.preferredHeight = num2;
			for (int i = 1; i <= 8; i++)
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)medalTemplate).gameObject, val.transform);
				((Object)val2).name = $"KarmaBadge{i}";
				val2.SetActive(true);
				EclipseDifficultyMedalDisplay component2 = val2.GetComponent<EclipseDifficultyMedalDisplay>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					((Behaviour)component2).enabled = false;
					Object.Destroy((Object)(object)component2);
				}
				Image component3 = val2.GetComponent<Image>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					Sprite val3 = FindKarmaSprite(i);
					if (Object.op_Implicit((Object)(object)val3))
					{
						component3.sprite = val3;
					}
					((Graphic)component3).color = Color.white;
					((Graphic)component3).raycastTarget = true;
				}
				TooltipProvider val4 = val2.GetComponent<TooltipProvider>();
				if (!Object.op_Implicit((Object)(object)val4))
				{
					val4 = val2.AddComponent<TooltipProvider>();
				}
				val4.titleToken = KarmaDescriptions.TitleToken(i);
				val4.titleColor = Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)12));
				val4.bodyToken = KarmaDescriptions.BodyToken(i);
			}
		}

		private static Sprite FindKarmaSprite(int karmaLevel)
		{
			RuleChoiceDef val = RuleCatalog.FindChoiceDef("Karma.InitialLevel." + karmaLevel);
			if (val == null)
			{
				Log.Warning($"No Karma.InitialLevel.{karmaLevel} rule choice; the badge keeps the medal artwork.");
				return null;
			}
			return val.sprite;
		}
	}
	internal static class EclipseMenuLayout
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__1_0;

			internal void <Init>b__1_0(orig_Awake orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				Apply(self);
			}
		}

		private static float extraWidth;

		internal static void Init(float rightPanelExtraWidth)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			extraWidth = rightPanelExtraWidth;
			object obj = <>c.<>9__1_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					Apply(self);
				};
				<>c.<>9__1_0 = val;
				obj = (object)val;
			}
			EclipseRunScreenController.Awake += (hook_Awake)obj;
		}

		private static void Apply(EclipseRunScreenController controller)
		{
			Widen(controller);
			FreeHeights(controller);
		}

		private static void Widen(EclipseRunScreenController controller)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if (extraWidth <= 0f)
			{
				return;
			}
			Transform val = ((Component)controller).transform.Find("Main Panel/RightPanel");
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Warning("No 'Main Panel/RightPanel'; leaving the Eclipse menu width alone.");
				return;
			}
			RectTransform component = ((Component)val).GetComponent<RectTransform>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Vector2 sizeDelta = component.sizeDelta;
				sizeDelta.x += extraWidth;
				component.sizeDelta = sizeDelta;
				Vector2 anchoredPosition = component.anchoredPosition;
				anchoredPosition.x -= (1f - component.pivot.x) * extraWidth;
				component.anchoredPosition = anchoredPosition;
				Log.Debug($"Widened the Eclipse right panel by {extraWidth}.");
			}
		}

		private static void FreeHeights(EclipseRunScreenController controller)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			LanguageTextMeshController eclipseDifficultyDescription = controller.eclipseDifficultyDescription;
			if (!Object.op_Implicit((Object)(object)eclipseDifficultyDescription))
			{
				return;
			}
			Release(((Component)eclipseDifficultyDescription).GetComponent<LayoutElement>());
			Transform parent = ((Component)eclipseDifficultyDescription).transform.parent;
			Transform val = ((Component)controller).transform.Find("Main Panel/RightPanel");
			if (Object.op_Implicit((Object)(object)parent))
			{
				Release(((Component)parent).GetComponent<LayoutElement>());
				SizeToChildren(((Component)parent).GetComponent<VerticalLayoutGroup>());
				ContentSizeFitter component = ((Component)parent).GetComponent<ContentSizeFitter>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)component);
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			foreach (Transform item in val)
			{
				Transform val2 = item;
				if (!((Object)val2).name.Contains("Border") && !((Object)val2).name.Contains("Blur"))
				{
					Release(((Component)val2).GetComponent<LayoutElement>());
					SizeToChildren(((Component)val2).GetComponent<VerticalLayoutGroup>());
				}
			}
			VerticalLayoutGroup component2 = ((Component)val).GetComponent<VerticalLayoutGroup>();
			SizeToChildren(component2);
			if (Object.op_Implicit((Object)(object)component2))
			{
				((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = true;
			}
			PinTopEdge((RectTransform)(object)((val is RectTransform) ? val : null));
			ContentSizeFitter val3 = ((Component)val).GetComponent<ContentSizeFitter>();
			if (!Object.op_Implicit((Object)(object)val3))
			{
				val3 = ((Component)val).gameObject.AddComponent<ContentSizeFitter>();
			}
			val3.horizontalFit = (FitMode)0;
			val3.verticalFit = (FitMode)2;
		}

		private static void PinTopEdge(RectTransform rect)
		{
			//IL_0009: 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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)rect) && !Mathf.Approximately(rect.pivot.y, 1f))
			{
				Vector3[] array = (Vector3[])(object)new Vector3[4];
				rect.GetWorldCorners(array);
				float y = array[1].y;
				rect.pivot = new Vector2(rect.pivot.x, 1f);
				rect.GetWorldCorners(array);
				((Transform)rect).position = ((Transform)rect).position + new Vector3(0f, y - array[1].y, 0f);
			}
		}

		private static void SizeToChildren(VerticalLayoutGroup layout)
		{
			if (Object.op_Implicit((Object)(object)layout))
			{
				((HorizontalOrVerticalLayoutGroup)layout).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)layout).childForceExpandHeight = false;
			}
		}

		private static void Release(LayoutElement layoutElement)
		{
			if (Object.op_Implicit((Object)(object)layoutElement))
			{
				layoutElement.preferredHeight = -1f;
				layoutElement.minHeight = -1f;
				layoutElement.flexibleHeight = -1f;
			}
		}
	}
	internal static class EclipseMenuMedals
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__0_0;

			public static hook_UpdateDisplayedSurvivor <>9__0_1;

			internal void <Init>b__0_0(orig_Awake orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				AddMedals(self);
			}

			internal void <Init>b__0_1(orig_UpdateDisplayedSurvivor orig, EclipseRunScreenController self)
			{
				orig.Invoke(self);
				RefreshAll(self);
			}
		}

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//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_0043: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					AddMedals(self);
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			EclipseRunScreenController.Awake += (hook_Awake)obj;
			object obj2 = <>c.<>9__0_1;
			if (obj2 == null)
			{
				hook_UpdateDisplayedSurvivor val2 = delegate(orig_UpdateDisplayedSurvivor orig, EclipseRunScreenController self)
				{
					orig.Invoke(self);
					RefreshAll(self);
				};
				<>c.<>9__0_1 = val2;
				obj2 = (object)val2;
			}
			EclipseRunScreenController.UpdateDisplayedSurvivor += (hook_UpdateDisplayedSurvivor)obj2;
		}

		private static void RefreshAll(EclipseRunScreenController controller)
		{
			EclipseDifficultyMedalDisplay[] componentsInChildren = ((Component)controller).GetComponentsInChildren<EclipseDifficultyMedalDisplay>(true);
			foreach (EclipseDifficultyMedalDisplay val in componentsInChildren)
			{
				Transform parent = ((Component)val).transform.parent;
				if (!Object.op_Implicit((Object)(object)parent) || !(((Object)parent).name == "KarmaBadgeRow"))
				{
					val.Refresh();
				}
			}
		}

		private static void AddMedals(EclipseRunScreenController controller)
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			EclipseDifficultyMedalDisplay val = null;
			EclipseDifficultyMedalDisplay[] componentsInChildren = ((Component)controller).GetComponentsInChildren<EclipseDifficultyMedalDisplay>(true);
			foreach (EclipseDifficultyMedalDisplay val2 in componentsInChildren)
			{
				if (val2.eclipseLevel > 8)
				{
					return;
				}
				if (!Object.op_Implicit((Object)(object)val) || val2.eclipseLevel > val.eclipseLevel)
				{
					val = val2;
				}
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.Warning("Eclipse menu has no medal displays; levels 9-16 will have no medals.");
				return;
			}
			Transform val3 = CreateSecondRow(((Component)val).transform.parent);
			int num = 0;
			for (int j = 9; j <= 16; j++)
			{
				Sprite val4 = KarmaClimbMedalArt.Active(j);
				Sprite val5 = KarmaClimbMedalArt.Inactive(j);
				Sprite val6 = KarmaClimbMedalArt.Complete(j);
				if (!Object.op_Implicit((Object)(object)val4) || !Object.op_Implicit((Object)(object)val5) || !Object.op_Implicit((Object)(object)val6))
				{
					Log.Warning($"Missing medal art for Eclipse {j}; skipping its medal.");
					continue;
				}
				GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, val3);
				((Object)obj).name = $"KarmaClimbMedal{j}";
				EclipseDifficultyMedalDisplay component = obj.GetComponent<EclipseDifficultyMedalDisplay>();
				component.eclipseLevel = j;
				component.unearnedSprite = val5;
				component.incompleteSprite = val4;
				component.completeSprite = val6;
				if (Object.op_Implicit((Object)(object)component.iconImage))
				{
					((Graphic)component.iconImage).color = Color.white;
				}
				num++;
			}
			Log.Info($"Added {num} Eclipse medals to the menu (levels {9}-{16}).");
		}

		private static Transform CreateSecondRow(Transform vanillaRow)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("KarmaClimbMedalRow", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(vanillaRow.parent, false);
			val.transform.SetSiblingIndex(vanillaRow.GetSiblingIndex() + 1);
			HorizontalLayoutGroup component = ((Component)vanillaRow).GetComponent<HorizontalLayoutGroup>();
			HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((LayoutGroup)val2).padding = ((LayoutGroup)component).padding;
				((HorizontalOrVerticalLayoutGroup)val2).spacing = ((HorizontalOrVerticalLayoutGroup)component).spacing;
				((LayoutGroup)val2).childAlignment = ((LayoutGroup)component).childAlignment;
				((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = ((HorizontalOrVerticalLayoutGroup)component).childControlWidth;
				((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = ((HorizontalOrVerticalLayoutGroup)component).childControlHeight;
				((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = ((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth;
				((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = ((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight;
				((HorizontalOrVerticalLayoutGroup)val2).childScaleWidth = ((HorizontalOrVerticalLayoutGroup)component).childScaleWidth;
				((HorizontalOrVerticalLayoutGroup)val2).childScaleHeight = ((HorizontalOrVerticalLayoutGroup)component).childScaleHeight;
				((HorizontalOrVerticalLayoutGroup)val2).reverseArrangement = ((HorizontalOrVerticalLayoutGroup)component).reverseArrangement;
			}
			return val.transform;
		}
	}
	internal static class KarmaBossShell
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_TakeDamageProcess <>9__6_0;

			public static hook_OnBuffFirstStackGained <>9__6_1;

			internal void <Init>b__6_0(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
			{
				if (Object.op_Implicit((Object)(object)self.body) && self.body.HasBuff(shellBuff))
				{
					damageInfo.damage *= 0.2f;
				}
				orig.Invoke(self, damageInfo);
			}

			internal void <Init>b__6_1(orig_OnBuffFirstStackGained orig, CharacterBody self, BuffDef buffDef)
			{
				orig.Invoke(self, buffDef);
				if ((Object)(object)buffDef == (Object)(object)shellBuff)
				{
					ShowOverlay(self);
				}
			}
		}

		private const int RequiredKarma = 4;

		private const float HealthThreshold = 0.33f;

		private const float Duration = 5f;

		private const float DamageTakenMult = 0.2f;

		private static readonly AnimationCurve OverlayAlpha = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
		{
			new Keyframe(0f, 0.5f),
			new Keyframe(0.8f, 0.5f),
			new Keyframe(1f, 0f)
		});

		private static BuffDef shellBuff;

		internal static void Init()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_009d: Expected O, but got Unknown
			shellBuff = ScriptableObject.CreateInstance<BuffDef>();
			((Object)shellBuff).name = "bdKarmaClimbShell";
			shellBuff.canStack = false;
			shellBuff.isDebuff = false;
			ContentAddition.AddBuffDef(shellBuff);
			CharacterBody.onBodyStartGlobal += AddShell;
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				hook_TakeDamageProcess val = delegate(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
				{
					if (Object.op_Implicit((Object)(object)self.body) && self.body.HasBuff(shellBuff))
					{
						damageInfo.damage *= 0.2f;
					}
					orig.Invoke(self, damageInfo);
				};
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			HealthComponent.TakeDamageProcess += (hook_TakeDamageProcess)obj;
			object obj2 = <>c.<>9__6_1;
			if (obj2 == null)
			{
				hook_OnBuffFirstStackGained val2 = delegate(orig_OnBuffFirstStackGained orig, CharacterBody self, BuffDef buffDef)
				{
					orig.Invoke(self, buffDef);
					if ((Object)(object)buffDef == (Object)(object)shellBuff)
					{
						ShowOverlay(self);
					}
				};
				<>c.<>9__6_1 = val2;
				obj2 = (object)val2;
			}
			CharacterBody.OnBuffFirstStackGained += (hook_OnBuffFirstStackGained)obj2;
		}

		private static void AddShell(CharacterBody body)
		{
			if (NetworkServer.active && KarmaRun.Level >= 4 && KarmaRun.IsFinalBoss(body) && !BrotherKarmaUtils.IsBrother(body))
			{
				GameObject val = BodyCatalog.FindBodyPrefab("BrotherBody");
				BrotherSuperArmorController val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<BrotherSuperArmorController>() : null);
				if (!Object.op_Implicit((Object)(object)shellBuff.iconSprite) && Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.buffToApply))
				{
					shellBuff.iconSprite = val2.buffToApply.iconSprite;
				}
				BrotherSuperArmorController obj = ((Component)body).gameObject.AddComponent<BrotherSuperArmorController>();
				obj.healthThreshold = 0.33f;
				obj.buffToApply = shellBuff;
				obj.buffDuration = 5f;
				obj.requiredKarma = 4;
				obj.applicationEffectPrefab = (Object.op_Implicit((Object)(object)val2) ? val2.applicationEffectPrefab : null);
			}
		}

		private static void ShowOverlay(CharacterBody body)
		{
			Transform val = (Object.op_Implicit((Object)(object)body.modelLocator) ? body.modelLocator.modelTransform : null);
			CharacterModel val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<CharacterModel>() : null);
			if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)CharacterModel.shieldBoosterOverlay))
			{
				TemporaryOverlayInstance obj = TemporaryOverlayManager.AddOverlay(((Component)body).gameObject);
				obj.duration = 5f;
				obj.animateShaderAlpha = true;
				obj.alphaCurve = OverlayAlpha;
				obj.destroyComponentOnEnd = true;
				obj.originalMaterial = CharacterModel.shieldBoosterOverlay;
				obj.AddToCharacterModel(val2);
			}
		}
	}
	internal static class KarmaClimbDifficulties
	{
		private static readonly Dictionary<int, DifficultyIndex> LevelToIndex = new Dictionary<int, DifficultyIndex>();

		private static readonly Dictionary<DifficultyIndex, int> IndexToLevel = new Dictionary<DifficultyIndex, int>();

		internal static IEnumerable<KeyValuePair<int, DifficultyIndex>> RegisteredLevels => LevelToIndex;

		internal static void Register()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected I4, but got Unknown
			for (int i = 9; i <= 16; i++)
			{
				DifficultyDef val = new DifficultyDef(3f, KarmaClimbLadder.NameToken(i), "Textures/DifficultyIcons/texDifficultyEclipse8Icon", KarmaClimbLadder.DescriptionToken(i), Color32.op_Implicit(ColorCatalog.GetColor((ColorIndex)17)), "mn", true);
				Sprite val2 = KarmaClimbMedalArt.Active(i);
				if (Object.op_Implicit((Object)(object)val2))
				{
					val.iconSprite = val2;
					val.foundIconSprite = true;
				}
				DifficultyIndex val3 = DifficultyAPI.AddDifficulty(val, true, true);
				if ((int)val3 == -1)
				{
					Log.Error($"R2API refused the difficulty for Eclipse {i}; the ladder will stop at {i - 1}.");
					break;
				}
				LevelToIndex[i] = val3;
				IndexToLevel[val3] = i;
				Log.Debug($"Eclipse {i} registered as DifficultyIndex {(int)val3} (Karma {KarmaClimbLadder.KarmaLevelFor(i)}).");
			}
		}

		internal static bool TryGetDifficultyIndex(int eclipseLevel, out DifficultyIndex index)
		{
			return LevelToIndex.TryGetValue(eclipseLevel, out index);
		}

		internal static bool TryGetEclipseLevel(DifficultyIndex index, out int eclipseLevel)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return IndexToLevel.TryGetValue(index, out eclipseLevel);
		}
	}
	internal static class KarmaClimbLadder
	{
		internal const int VanillaMaxLevel = 8;

		internal const int MaxLevel = 16;

		internal const int AddedLevelCount = 8;

		internal static bool IsKarmaClimbLevel(int eclipseLevel)
		{
			if (eclipseLevel > 8)
			{
				return eclipseLevel <= 16;
			}
			return false;
		}

		internal static int KarmaLevelFor(int eclipseLevel)
		{
			if (!IsKarmaClimbLevel(eclipseLevel))
			{
				return 0;
			}
			return eclipseLevel - 8;
		}

		internal static string NameToken(int eclipseLevel)
		{
			return $"KARMACLIMB_ECLIPSE_{eclipseLevel}_NAME";
		}

		internal static string DescriptionToken(int eclipseLevel)
		{
			return $"KARMACLIMB_ECLIPSE_{eclipseLevel}_DESCRIPTION";
		}

		internal static string UnlockableName(string survivorCachedName, int eclipseLevel)
		{
			return $"Eclipse.{survivorCachedName}.{eclipseLevel}";
		}

		internal static string UnlockableNameToken(int eclipseLevel)
		{
			return $"KARMACLIMB_UNLOCKABLE_ECLIPSE_{eclipseLevel}_NAME";
		}
	}
	internal static class KarmaClimbLanguage
	{
		private static readonly string[] InheritedEffects = new string[8] { "Ally Starting Health: <style=cIsHealth>-50%</style>", "Teleporter Radius: <style=cIsHealth>-50%</style>", "Ally Fall Damage: <style=cIsHealth>+100% and lethal</style>", "Enemy Speed: <style=cIsHealth>+40%</style>", "Ally Healing: <style=cIsHealth>-50%</style>", "Enemy Gold Drops: <style=cIsHealth>-20%</style>", "Enemy Cooldowns: <style=cIsHealth>-50%</style>", "Allies recieve <style=cIsHealth>permanent damage</style>" };

		internal static void Register()
		{
			LanguageAPI.Add("ECLIPSE_GAMEMODE_DESCRIPTION", "<style=cIsUtility>Eclipse</style> is a gamemode that adds stacking challenge modifiers to your run.\n\nEach time you <style=cIsUtility>beat the game</style>, your Eclipse level <style=cIsUtility>permanently increases</style> " + $"with that Survivor, up to a maximum of <style=cIsUtility>{16}</style> times.\n\n" + $"Levels <style=cIsUtility>{9}-{16}</style> keep every " + $"Eclipse {8} modifier and add <style=cIsUtility>Karma</style>, " + "which stays <style=cIsUtility>locked at its starting level</style> for the whole run.");
			for (int i = 9; i <= 16; i++)
			{
				int karma = KarmaClimbLadder.KarmaLevelFor(i);
				LanguageAPI.Add(KarmaClimbLadder.NameToken(i), $"Eclipse ({i})");
				LanguageAPI.Add(KarmaClimbLadder.DescriptionToken(i), BuildDescription(i, karma));
				LanguageAPI.Add(KarmaClimbLadder.UnlockableNameToken(i), $"Eclipse ({i})");
			}
		}

		private static string BuildDescription(int level, int karma)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("Starts at baseline Monsoon difficulty. <style=cSub>\n");
			for (int i = 0; i < InheritedEffects.Length; i++)
			{
				stringBuilder.Append("\n<mspace=0.5em>(").Append(i + 1).Append(")</mspace> ")
					.Append(InheritedEffects[i])
					.Append(' ');
			}
			stringBuilder.Append("\n<mspace=0.5em>(").Append(level).Append(")</mspace> Karma: <style=cIsHealth>locked at ")
				.Append(karma)
				.Append("</style></style>");
			return stringBuilder.ToString();
		}
	}
	internal static class KarmaClimbMedalArt
	{
		private static readonly Dictionary<string, Sprite> Cache = new Dictionary<string, Sprite>();

		internal static Sprite Active(int eclipseLevel)
		{
			return Load($"texKarmaClimbMedal{eclipseLevel}Active");
		}

		internal static Sprite Inactive(int eclipseLevel)
		{
			return Load($"texKarmaClimbMedal{eclipseLevel}Inactive");
		}

		internal static Sprite Complete(int eclipseLevel)
		{
			return Load($"texKarmaClimbMedal{eclipseLevel}Complete");
		}

		private static Sprite Load(string name)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (Cache.TryGetValue(name, out var value))
			{
				return value;
			}
			Sprite val = null;
			string text = "KarmaClimb.Medals." + name + ".png";
			using (Stream stream = typeof(KarmaClimbMedalArt).Assembly.GetManifestResourceStream(text))
			{
				if (stream == null)
				{
					Log.Error("Missing embedded medal art " + text + ".");
				}
				else
				{
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false)
					{
						name = name,
						wrapMode = (TextureWrapMode)1,
						filterMode = (FilterMode)1
					};
					if (ImageConversion.LoadImage(val2, memoryStream.ToArray()))
					{
						val = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
						((Object)val).name = name;
					}
					else
					{
						Log.Error("Could not decode embedded medal art " + text + ".");
					}
				}
			}
			Cache[name] = val;
			return val;
		}
	}
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("chen-ror2.KarmaClimb", "KarmaClimb", "2.0.0")]
	public class KarmaClimbPlugin : BaseUnityPlugin
	{
		public const string PluginAuthor = "chen-ror2";

		public const string PluginName = "KarmaClimb";

		public const string PluginGuid = "chen-ror2.KarmaClimb";

		public const string PluginVersion = "2.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			KarmaClimbLanguage.Register();
			KarmaDescriptions.Register();
			KarmaClimbDifficulties.Register();
			KarmaClimbUnlockables.Init();
			EclipseLadderHooks.Init();
			EclipseKarmaLock.Init();
			KarmaRun.Init();
			KarmaStatEffects.Init();
			KarmaBossShell.Init();
			KarmaDirectorEffects.Init();
			KarmaEliteEffects.Init();
			EclipseMenuMedals.Init();
			EclipseMenuKarmaPanel.Init();
			EclipseMenuLayout.Init(((BaseUnityPlugin)this).Config.Bind<float>("Eclipse menu", "RightPanelExtraWidth", 260f, "Pixels to widen the Eclipse menu's right-hand column by, growing leftwards. 0 disables.").Value);
			EclipseMenuEscape.Init();
			EclipseMenuDump.Init(((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "LogEclipseMenuHierarchy", false, "Logs the Eclipse menu's transform tree once, to position the Karma section against the real hierarchy. Turn off when the layout is settled.").Value);
			Log.Info(string.Format("{0} {1} ready: Eclipse now climbs to {2}.", "KarmaClimb", "2.0.0", 16));
		}
	}
	internal static class KarmaClimbUnlockables
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_SetUnlockableDefs <>9__0_0;

			internal void <Init>b__0_0(orig_SetUnlockableDefs orig, UnlockableDef[] unlockableDefs)
			{
				orig.Invoke(Append(unlockableDefs));
			}
		}

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				hook_SetUnlockableDefs val = delegate(orig_SetUnlockableDefs orig, UnlockableDef[] unlockableDefs)
				{
					orig.Invoke(Append(unlockableDefs));
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			UnlockableCatalog.SetUnlockableDefs += (hook_SetUnlockableDefs)obj;
		}

		private static UnlockableDef[] Append(UnlockableDef[] vanillaDefs)
		{
			string text = "." + 8;
			Dictionary<string, UnlockableDef> dictionary = new Dictionary<string, UnlockableDef>();
			foreach (UnlockableDef val in vanillaDefs)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string cachedName = val.cachedName;
					if (!string.IsNullOrEmpty(cachedName) && cachedName.StartsWith("Eclipse.") && cachedName.EndsWith(text))
					{
						string key = cachedName.Substring("Eclipse.".Length, cachedName.Length - "Eclipse.".Length - text.Length);
						dictionary[key] = val;
					}
				}
			}
			if (dictionary.Count == 0)
			{
				Log.Error("Found no vanilla Eclipse level-8 unlockables; levels 9-16 will be unreachable.");
				return vanillaDefs;
			}
			List<UnlockableDef> list = new List<UnlockableDef>(dictionary.Count * 8);
			foreach (KeyValuePair<string, UnlockableDef> item in dictionary)
			{
				for (int j = 9; j <= 16; j++)
				{
					UnlockableDef val2 = Object.Instantiate<UnlockableDef>(item.Value);
					val2.cachedName = KarmaClimbLadder.UnlockableName(item.Key, j);
					((Object)val2).name = val2.cachedName;
					val2.nameToken = KarmaClimbLadder.UnlockableNameToken(j);
					list.Add(val2);
				}
			}
			Log.Info($"Added {list.Count} Eclipse unlockables across {dictionary.Count} survivors (levels {9}-{16}).");
			return vanillaDefs.Concat(list).ToArray();
		}
	}
	internal static class KarmaDescriptions
	{
		internal const string HeadingToken = "KARMACLIMB_MENU_KARMA_HEADING";

		internal const string HintToken = "KARMACLIMB_MENU_KARMA_HINT";

		private static readonly string[] General = new string[9] { null, "All enemies and bosses deal <style=cIsDamage>+10% damage</style>.\n\nKill gold <style=cIsUtility>+4%</style>.", "All enemies and bosses gain <style=cIsDamage>+15% attack speed</style>.\n\nKill gold <style=cIsUtility>+4%</style> (<style=cIsUtility>+8%</style> total).", "The teleporter starts with a <style=cIsUtility>Shrine of the Mountain</style> stack: one extra boss, and one extra item when the bosses are beaten.\n\nKill gold <style=cIsUtility>+4%</style> (<style=cIsUtility>+12%</style> total).", "Voidling, False Son and Solus Wing gain a <style=cIsUtility>shell</style> each time they lose <style=cIsHealth>33%</style> of their maximum health, taking <style=cIsUtility>80% less damage for 5 seconds</style>.\n\nKill gold <style=cIsUtility>+4%</style> (<style=cIsUtility>+16%</style> total).", "Monster credits <style=cIsDamage>+20%</style> on every stage.\n\nKill gold <style=cIsUtility>+4%</style> (<style=cIsUtility>+20%</style> total), which cancels Eclipse's <style=cIsHealth>-20%</style> Enemy Gold Drops.", "<style=cIsDamage>Voidtouched</style> and <style=cIsDamage>Perfected</style> elites can spawn on every stage, at the cost of Malachite-tier elites.", "Final bosses (Mithrix, Voidling, False Son, Solus Wing) gain <style=cIsHealing>+30% maximum health</style>.\n\nInteractable credits <style=cIsUtility>+20%</style>: more chests, shrines and drones.", "Final bosses spawn with a random <style=cIsDamage>elite aspect</style>: Blazing, Overloading, Glacial or Mending, the same one for every phase of the fight." };

		private static readonly string[] Mithrix = new string[9] { null, "Gains a crystal cluster on his hammer, and one further crystal piece at each Karma level up to 7.\n\nIn phases 1, 3 and 4, once he has taken damage equal to <style=cIsDamage>10%</style> of his maximum health he gains a <style=cIsUtility>5 second shell</style> that reduces every hit he takes to 1 damage.\n\nHis damage bonus is the <style=cIsDamage>+10%</style> above, replacing vanilla's +1% per Karma level.", "<style=cIsUtility>Movement speed +30%</style>. His attack speed bonus is the <style=cIsDamage>+15%</style> above, replacing vanilla's +30%.\n\nSky Leap drops four bombs at the cardinal points that detonate once he lands, each releasing a ring of shockwaves for <style=cIsDamage>400% damage</style> that <style=cIsUtility>Cripple</style>. A gravity well also forms above his landing point and pulls players in while he is airborne.\n\nHis dash leaves three crystal spikes dealing <style=cIsDamage>200% damage</style> and applying <style=cIsDamage>Lunar Ruin</style>.\n\nIn phase 2, the throne grants items to monsters on his team every <style=cIsUtility>25 seconds</style>.", "Hammer Smash adds crawling waves and a ring of crystal spikes.\n\nHammer Swing releases a fan of five crystal spike trails.\n\nNeedle Barrage and Needle Burst travel faster and leave <style=cIsDamage>Lunar Ruin</style> spikes where they strike terrain.\n\nIn phase 2, monsters that die erupt into lines of flame.", "His subtitle becomes <style=cIsUtility>Apocalypse Aspirant</style>.\n\nHis Sky Leap landing calls down a meteor storm that damages every character in the arena.\n\nHis dash grants <style=cIsUtility>knockback immunity for 5 seconds</style>.\n\nIn phase 4, Lunar Orbs also send out spiralling crystal spike trails.", "<style=cIsDamage>Karmic Spires</style>: at the start of phases 1 and 3 he summons up to six spires roughly 75m away.\n\nIn phase 2, the throne periodically fires a blast at a player.", "After Big Spinny and Forbidden Pizza he resummons spires, up to six.\n\nIn phase 3, Shock Wave adds pairs of crawling waves that apply <style=cIsDamage>Lunar Ruin</style>, and his dash launches a homing bomb.\n\nMonsters from the director in phase 3 gain the <style=cIsDamage>Perfected</style> affix, and the <style=cIsDamage>Twisted</style> affix if Seekers of the Storm is enabled.\n\nIn phase 4, at 50% health or less, he gains a mortar volley, Lunar Chimera Golems and Lunar Chimera Wisps.\n\n<style=cSub>Vanilla also halves his cooldowns here, but Eclipse already halves every enemy's cooldowns, and the two do not stack.</style>", "No new mechanics at this level.", "<style=cIsHealing>Maximum health +50%</style>, replacing the +30% from Karma 7.\n\nThe sky above the arena changes, and he uses different spawn lines, including separate lines when a player is the Heretic." };

		internal static string TitleToken(int karmaLevel)
		{
			return $"KARMACLIMB_KARMA_{karmaLevel}_TITLE";
		}

		internal static string BodyToken(int karmaLevel)
		{
			return $"KARMACLIMB_KARMA_{karmaLevel}_BODY";
		}

		internal static void Register()
		{
			LanguageAPI.Add("KARMACLIMB_MENU_KARMA_HEADING", "Karma");
			LanguageAPI.Add("KARMACLIMB_MENU_KARMA_HINT", "<style=cSub>Hover over a Karma level to see what it adds.</style>");
			for (int i = 1; i <= 8; i++)
			{
				LanguageAPI.Add(TitleToken(i), $"Karma {i}");
				LanguageAPI.Add(BodyToken(i), General[i] + "\n\n<style=cSub>— Mithrix —</style>\n\n" + Mithrix[i]);
			}
		}
	}
	internal static class KarmaDirectorEffects
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnKilledServer <>9__5_0;

			public static hook_Start <>9__5_1;

			public static Action<SceneDirector> <>9__5_2;

			public static hook_Awake <>9__5_3;

			internal void <Init>b__5_0(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
			{
				float num = 0.04f * (float)Mathf.Min(KarmaRun.Level, 5);
				if (num <= 0f)
				{
					orig.Invoke(self, damageReport);
					return;
				}
				uint goldReward = self.goldReward;
				self.goldReward = (uint)((float)goldReward * (0.8f + num) / 0.8f);
				orig.Invoke(self, damageReport);
				self.goldReward = goldReward;
			}

			internal void <Init>b__5_1(orig_Start orig, TeleporterInteraction self)
			{
				orig.Invoke(self);
				if (NetworkServer.active && KarmaRun.Level >= 3)
				{
					self.AddShrineStack();
				}
			}

			internal void <Init>b__5_2(SceneDirector director)
			{
				int level = KarmaRun.Level;
				if (level >= 5)
				{
					director.monsterCredit = (int)((float)director.monsterCredit * 1.2f);
				}
				if (level >= 7)
				{
					director.onPopulateCreditMultiplier *= 1.2f;
				}
			}

			internal void <Init>b__5_3(orig_Awake orig, CombatDirector self)
			{
				orig.Invoke(self);
				if (!NetworkServer.active || KarmaRun.Level < 5 || self.moneyWaves == null)
				{
					return;
				}
				TeleporterInteraction component = ((Component)self).GetComponent<TeleporterInteraction>();
				if (!Object.op_Implicit((Object)(object)component) || !((Object)(object)component.bossDirector == (Object)(object)self))
				{
					DirectorMoneyWave[] moneyWaves = self.moneyWaves;
					foreach (DirectorMoneyWave obj in moneyWaves)
					{
						obj.multiplier *= 1.2f;
					}
				}
			}
		}

		private const float GoldBonusPerKarma = 0.04f;

		private const int GoldBonusMaxKarma = 5;

		private const float EclipseGoldMult = 0.8f;

		private const float MonsterCreditMult = 1.2f;

		private const float InteractableCreditMult = 1.2f;

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//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_0043: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				hook_OnKilledServer val = delegate(orig_OnKilledServer orig, DeathRewards self, DamageReport damageReport)
				{
					float num = 0.04f * (float)Mathf.Min(KarmaRun.Level, 5);
					if (num <= 0f)
					{
						orig.Invoke(self, damageReport);
					}
					else
					{
						uint goldReward = self.goldReward;
						self.goldReward = (uint)((float)goldReward * (0.8f + num) / 0.8f);
						orig.Invoke(self, damageReport);
						self.goldReward = goldReward;
					}
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			DeathRewards.OnKilledServer += (hook_OnKilledServer)obj;
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				hook_Start val2 = delegate(orig_Start orig, TeleporterInteraction self)
				{
					orig.Invoke(self);
					if (NetworkServer.active && KarmaRun.Level >= 3)
					{
						self.AddShrineStack();
					}
				};
				<>c.<>9__5_1 = val2;
				obj2 = (object)val2;
			}
			TeleporterInteraction.Start += (hook_Start)obj2;
			SceneDirector.onPrePopulateSceneServer += delegate(SceneDirector director)
			{
				int level = KarmaRun.Level;
				if (level >= 5)
				{
					director.monsterCredit = (int)((float)director.monsterCredit * 1.2f);
				}
				if (level >= 7)
				{
					director.onPopulateCreditMultiplier *= 1.2f;
				}
			};
			object obj3 = <>c.<>9__5_3;
			if (obj3 == null)
			{
				hook_Awake val3 = delegate(orig_Awake orig, CombatDirector self)
				{
					orig.Invoke(self);
					if (NetworkServer.active && KarmaRun.Level >= 5 && self.moneyWaves != null)
					{
						TeleporterInteraction component = ((Component)self).GetComponent<TeleporterInteraction>();
						if (!Object.op_Implicit((Object)(object)component) || !((Object)(object)component.bossDirector == (Object)(object)self))
						{
							DirectorMoneyWave[] moneyWaves = self.moneyWaves;
							foreach (DirectorMoneyWave obj4 in moneyWaves)
							{
								obj4.multiplier *= 1.2f;
							}
						}
					}
				};
				<>c.<>9__5_3 = val3;
				obj3 = (object)val3;
			}
			CombatDirector.Awake += (hook_Awake)obj3;
		}
	}
	internal static class KarmaEliteEffects
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_PromoteIfHonor <0>__PromoteFinalBoss;
		}

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

			public static hook_Awake <>9__3_0;

			public static Func<EliteDef, bool> <>9__5_0;

			internal void <Init>b__3_0(orig_Awake orig, CombatDirector self)
			{
				RefreshVoidAndPerfectedTier();
				orig.Invoke(self);
			}

			internal bool <PromoteFinalBoss>b__5_0(EliteDef elite)
			{
				return elite.IsAvailable();
			}

			internal bool <.cctor>b__6_0(EliteRules rules)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				if ((int)rules == 0)
				{
					return KarmaRun.Level >= 6;
				}
				return false;
			}
		}

		private static readonly EliteTierDef voidAndPerfectedTier = new EliteTierDef
		{
			costMultiplier = CombatDirector.baseEliteCostMultiplier * 6f,
			eliteTypes = Array.Empty<EliteDef>(),
			isAvailable = (EliteRules rules) => (int)rules == 0 && KarmaRun.Level >= 6,
			canSelectWithoutAvailableEliteDef = false
		};

		private static EliteDef fightAspect;

		private static Stage fightAspectStage;

		internal static void Init()
		{
			//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_002a: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			EliteAPI.AppendCustomEliteTier(voidAndPerfectedTier);
			object obj = <>c.<>9__3_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, CombatDirector self)
				{
					RefreshVoidAndPerfectedTier();
					orig.Invoke(self);
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			CombatDirector.Awake += (hook_Awake)obj;
			object obj2 = <>O.<0>__PromoteFinalBoss;
			if (obj2 == null)
			{
				hook_PromoteIfHonor val2 = PromoteFinalBoss;
				<>O.<0>__PromoteFinalBoss = val2;
				obj2 = (object)val2;
			}
			EliteOnlyArtifactManager.PromoteIfHonor += (hook_PromoteIfHonor)obj2;
		}

		private static void RefreshVoidAndPerfectedTier()
		{
			EliteTierDef vanillaEliteTierDef = EliteAPI.GetVanillaEliteTierDef((VanillaEliteTier)5);
			EliteDef[] array = (EliteDef[])(object)new EliteDef[2]
			{
				Elites.Lunar,
				Elites.Void
			};
			voidAndPerfectedTier.eliteTypes = ((Object.op_Implicit((Object)(object)Run.instance) && Run.instance.loopClearCount > 0 && vanillaEliteTierDef != null) ? array.Concat(vanillaEliteTierDef.eliteTypes).ToArray() : array);
		}

		private static void PromoteFinalBoss(orig_PromoteIfHonor orig, CharacterMaster master, Xoroshiro128Plus rng, EliteDef[] eliteDefs)
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null);
			if (KarmaRun.Level < KarmaManager.maxKarma || !Object.op_Implicit((Object)(object)val) || !KarmaRun.IsFinalBoss(val))
			{
				orig.Invoke(master, rng, eliteDefs);
				return;
			}
			if ((Object)(object)fightAspectStage != (Object)(object)Stage.instance)
			{
				EliteDef[] array = EliteOnlyArtifactManager.eliteDefs.Where((EliteDef elite) => elite.IsAvailable()).ToArray();
				fightAspect = ((array.Length != 0) ? array[rng.RangeInt(0, array.Length)] : null);
				fightAspectStage = Stage.instance;
			}
			if (Object.op_Implicit((Object)(object)fightAspect))
			{
				Inventory inventory = master.inventory;
				EquipmentIndex equipmentIndex = fightAspect.eliteEquipmentDef.equipmentIndex;
				EquipmentLocation activeEquipmentLocation = master.inventory.activeEquipmentLocation;
				inventory.SetEquipmentIndex(equipmentIndex, ref activeEquipmentLocation);
			}
		}
	}
	internal class KarmaPanelPlacer : MonoBehaviour
	{
		internal RectTransform anchor;

		internal float gap;

		private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];

		private TMP_Text anchorText;

		private void Start()
		{
			anchorText = (Object.op_Implicit((Object)(object)anchor) ? ((Component)anchor).GetComponent<TMP_Text>() : null);
		}

		private void LateUpdate()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)anchor))
			{
				return;
			}
			anchor.GetWorldCorners(corners);
			float x = corners[1].x;
			float num = corners[0].y;
			if (Object.op_Implicit((Object)(object)anchorText))
			{
				Bounds textBounds = anchorText.textBounds;
				if (((Bounds)(ref textBounds)).size.y > 0f)
				{
					float num2 = num;
					RectTransform obj = anchor;
					textBounds = anchorText.textBounds;
					num = Mathf.Min(num2, ((Transform)obj).TransformPoint(new Vector3(0f, ((Bounds)(ref textBounds)).min.y, 0f)).y);
				}
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(x, num - gap * ((Transform)anchor).lossyScale.y, ((Component)this).transform.position.z);
			Vector3 val2 = ((Component)this).transform.position - val;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
			{
				((Component)this).transform.position = val;
			}
		}
	}
	internal static class KarmaRun
	{
		private static readonly string[] FinalBossBodyNames = new string[9] { "BrotherBody", "BrotherHurtBody", "MiniVoidRaidCrabBodyPhase1", "MiniVoidRaidCrabBodyPhase2", "MiniVoidRaidCrabBodyPhase3", "FalseSonBossBody", "FalseSonBossBodyLunarShard", "FalseSonBossBodyBrokenLunarShard", "SolusWingBody" };

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

		internal static int Level
		{
			get
			{
				if (!(Run.instance is EclipseRun) || !Object.op_Implicit((Object)(object)KarmaManager.instance))
				{
					return 0;
				}
				return KarmaManager.instance.GetEffectiveKarma();
			}
		}

		internal static void Init()
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Invalid comparison between Unknown and I4
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				string[] finalBossBodyNames = FinalBossBodyNames;
				foreach (string text in finalBossBodyNames)
				{
					BodyIndex val = BodyCatalog.FindBodyIndex(text);
					if ((int)val == -1)
					{
						Log.Warning("Final boss body " + text + " not found; Karma will not treat it as a final boss.");
					}
					else
					{
						finalBosses.Add(val);
					}
				}
			});
		}

		internal static bool IsFinalBoss(CharacterBody body)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return finalBosses.Contains(body.bodyIndex);
		}
	}
	internal static class KarmaStatEffects
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__3_0;

			internal void <Init>b__3_0(CharacterBody body, StatHookEventArgs args)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Invalid comparison between Unknown and I4
				int level = KarmaRun.Level;
				bool flag = level <= 0 || !Object.op_Implicit((Object)(object)body.teamComponent);
				if (!flag)
				{
					TeamIndex teamIndex = body.teamComponent.teamIndex;
					bool flag2 = teamIndex - 2 <= 2;
					flag = !flag2;
				}
				if (flag)
				{
					return;
				}
				args.damageTotalMult *= 1.1f;
				if (level >= 2)
				{
					args.attackSpeedTotalMult *= 1.15f;
				}
				bool flag3 = BrotherKarmaUtils.IsBrother(body);
				if (flag3)
				{
					args.damageTotalMult /= 1f + 0.01f * (float)level;
					if (level >= 2)
					{
						args.attackSpeedTotalMult /= 1.3f;
					}
				}
				if (level >= 7 && KarmaRun.IsFinalBoss(body) && (!flag3 || level < KarmaManager.maxKarma))
				{
					args.healthTotalMult *= 1.3f;
				}
			}
		}

		private const float DamageMult = 1.1f;

		private const float AttackSpeedMult = 1.15f;

		private const float FinalBossHealthMult = 1.3f;

		internal static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			object obj = <>c.<>9__3_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody body, StatHookEventArgs args)
				{
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_002a: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Unknown result type (might be due to invalid IL or missing references)
					//IL_002d: Unknown result type (might be due to invalid IL or missing references)
					//IL_002f: Invalid comparison between Unknown and I4
					int level = KarmaRun.Level;
					bool flag = level <= 0 || !Object.op_Implicit((Object)(object)body.teamComponent);
					if (!flag)
					{
						TeamIndex teamIndex = body.teamComponent.teamIndex;
						bool flag2 = teamIndex - 2 <= 2;
						flag = !flag2;
					}
					if (!flag)
					{
						args.damageTotalMult *= 1.1f;
						if (level >= 2)
						{
							args.attackSpeedTotalMult *= 1.15f;
						}
						bool flag3 = BrotherKarmaUtils.IsBrother(body);
						if (flag3)
						{
							args.damageTotalMult /= 1f + 0.01f * (float)level;
							if (level >= 2)
							{
								args.attackSpeedTotalMult /= 1.3f;
							}
						}
						if (level >= 7 && KarmaRun.IsFinalBoss(body) && (!flag3 || level < KarmaManager.maxKarma))
						{
							args.healthTotalMult *= 1.3f;
						}
					}
				};
				<>c.<>9__3_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _source;

		internal static void Init(ManualLogSource source)
		{
			_source = source;
		}

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

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

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

		internal static void Warning(object data)
		{
			_source.LogWarning(data);
		}

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

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