Decompiled source of HextechAugments v0.6.3

HextechAugments.dll

Decompiled 26 minutes ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HextechAugments;

[Serializable]
public class AugmentFx
{
	public float damageMult;

	public float healthMult;

	public float moveSpeedMult;

	public float attackSpeedMult;

	public float critAdd;

	public float armorAdd;

	public float armorFromCrit;

	public float damageFromMoveSpeed;

	public float regenMult;

	public float scaleMult;

	public int killsPerStack;

	public float healthMultPerStack;

	public float damageMultPerStack;

	public bool stackDoubler;

	public float healPctMaxOnKill;

	public float shieldPctMaxOnKill;

	public float healPctMissingOnDamaged;

	public float moneyPctOnKill;

	public float shieldPerLevel;

	public float damageMultPerSilver;

	public float minionDamageMult;

	public float minionHealthMult;

	public int burnStacksOnHit;

	public int bleedStacksOnHit;

	public float slowPctOnHit;

	public float slowSeconds;

	public float arrowOnHit;

	public float explosionOnHit;

	public float explosionRadius;

	public int explosionBurnStacks;

	public float critMultAdd;

	public float equipDamageMult;

	public int rerollBonus;

	public bool upgradeNextCandidates;

	public string grantItemsTier;

	public int grantItemsCount;

	public string grantAugmentTier;

	public int grantAugmentCount;

	public bool pandora;

	public float maxHealthCostPct;

	public string sacrificeTier;

	public int sacrificeStages;

	public int extraPickCount;

	public string extraPickTier;

	public int eggKills;

	public float chainOnHit;

	public int chainJumps;

	public float chainSlowPct;

	public float chainSlowSeconds;

	public float chainInterval;

	public float cooldownPctOnKill;

	public bool specialCrit;

	public bool specialResetOnKill;

	public float specialBonusPerStack;

	public int specialMaxStacks;

	public float armorMultAdd;

	public float armorLowHealthAdd;

	public float lowHealthThreshold;

	public float armorMoveSpeedGate;

	public float rescueHealPct;

	public float rescueCooldown;

	public float rescueRadius;

	public float castBlastPct;

	public float castBlastRadius;

	public float castBlastArmorScale;

	public float markDuration;

	public float markBonusPct;

	public float markCooldownPct;

	public float primaryExtraPct;

	public float slimeSeconds;

	public float slimeRadius;

	public float slimeDamagePct;

	public float slimeHealPct;

	public float shredPctOnHit;

	public float shredPctBoss;
}
[Serializable]
public class AugmentDef
{
	public string id;

	public string name;

	public string tier;

	public string desc;

	public bool impl;

	public bool hidden;

	public string[] tags;

	public AugmentFx fx = new AugmentFx();
}
[Serializable]
public class CatalogFile
{
	public AugmentDef[] items;
}
public static class AugmentCatalog
{
	public static readonly List<AugmentDef> All = new List<AugmentDef>();

	private static readonly Dictionary<string, AugmentDef> byId = new Dictionary<string, AugmentDef>();

	public static void Load()
	{
		string text = Path.Combine(Path.GetDirectoryName(typeof(AugmentCatalog).Assembly.Location), "augments.json");
		if (!File.Exists(text))
		{
			text = Path.Combine(Paths.PluginPath, "HextechAugments", "augments.json");
		}
		if (!File.Exists(text))
		{
			HextechPlugin.Log.LogError((object)("找不到 augments.json:" + text));
			return;
		}
		CatalogFile catalogFile = JsonUtility.FromJson<CatalogFile>(File.ReadAllText(text));
		All.Clear();
		byId.Clear();
		if (catalogFile == null || catalogFile.items == null)
		{
			return;
		}
		AugmentDef[] items = catalogFile.items;
		foreach (AugmentDef augmentDef in items)
		{
			if (augmentDef.impl && !string.IsNullOrEmpty(augmentDef.id))
			{
				All.Add(augmentDef);
				byId[augmentDef.id] = augmentDef;
			}
		}
		HextechPlugin.Log.LogInfo((object)("已载入可用强化 " + All.Count + " 条"));
	}

	public static AugmentDef Get(string id)
	{
		if (!byId.TryGetValue(id, out var value))
		{
			return null;
		}
		return value;
	}

	public static bool InPool(AugmentDef def)
	{
		if (def != null)
		{
			return !def.hidden;
		}
		return false;
	}

	public static int CountTier(HexState state, string tier)
	{
		int num = 0;
		if (state == null)
		{
			return 0;
		}
		foreach (string item in state.owned)
		{
			AugmentDef augmentDef = Get(item);
			if (augmentDef != null && HexRuntime.EffectiveTier(state, augmentDef) == tier)
			{
				num++;
			}
		}
		return num;
	}
}
public static class ChoiceUI
{
	private sealed class Roller
	{
		private static readonly string[] tiers = new string[3] { "Silver", "Gold", "Prismatic" };

		public static List<AugmentDef> Roll(HexState state, int index)
		{
			Dictionary<string, List<AugmentDef>> dictionary = new Dictionary<string, List<AugmentDef>>();
			foreach (AugmentDef item in AugmentCatalog.All)
			{
				if (AugmentCatalog.InPool(item) && !HexStates.Owns(state, item.id))
				{
					if (!dictionary.ContainsKey(item.tier))
					{
						dictionary[item.tier] = new List<AugmentDef>();
					}
					dictionary[item.tier].Add(item);
				}
			}
			string text = PickTier(dictionary);
			if (state != null && state.upgradeNext && !string.IsNullOrEmpty(text))
			{
				state.upgradeNext = false;
				string text2 = NextTier(text);
				List<AugmentDef> value;
				if (string.IsNullOrEmpty(text2))
				{
					HexRuntime.GiveGold(state, 750u);
					HextechPlugin.Log.LogInfo((object)"勇中最勇:本批已是棱彩,折算 750 金币");
				}
				else if (dictionary.TryGetValue(text2, out value) && value.Count >= 3)
				{
					text = text2;
					HextechPlugin.Log.LogInfo((object)("勇中最勇:本批档位提升为 " + text2));
				}
				else
				{
					HexRuntime.GiveGold(state, 750u);
					HextechPlugin.Log.LogInfo((object)"勇中最勇:升档后池子不足 3 张,折算 750 金币");
				}
			}
			List<AugmentDef> list = new List<AugmentDef>();
			if (!string.IsNullOrEmpty(text) && dictionary.TryGetValue(text, out var value2))
			{
				while (list.Count < 3 && value2.Count > 0)
				{
					int index2 = Random.Range(0, value2.Count);
					list.Add(value2[index2]);
					value2.RemoveAt(index2);
				}
			}
			HextechPlugin.Log.LogInfo((object)("本批候选(" + text + " 同档):" + string.Join(" / ", list.ConvertAll((AugmentDef d) => d.tier + ":" + d.id).ToArray())));
			return list;
		}

		private static string NextTier(string tier)
		{
			if (tier == "Silver")
			{
				return "Gold";
			}
			if (tier == "Gold")
			{
				return "Prismatic";
			}
			return null;
		}

		private static string PickTier(Dictionary<string, List<AugmentDef>> byTier)
		{
			List<string> list = new List<string>();
			string[] array = tiers;
			foreach (string text in array)
			{
				if (byTier.TryGetValue(text, out var value) && value.Count >= 3)
				{
					list.Add(text);
				}
			}
			if (list.Count > 0)
			{
				return list[Random.Range(0, list.Count)];
			}
			string result = null;
			int num = 0;
			array = tiers;
			foreach (string text2 in array)
			{
				if (byTier.TryGetValue(text2, out var value2) && value2.Count > num)
				{
					num = value2.Count;
					result = text2;
				}
			}
			return result;
		}

		public static List<AugmentDef> RollTier(HexState state, string tier, int count)
		{
			List<AugmentDef> list = new List<AugmentDef>();
			List<AugmentDef> list2 = new List<AugmentDef>();
			foreach (AugmentDef item in AugmentCatalog.All)
			{
				if (AugmentCatalog.InPool(item) && !HexStates.Owns(state, item.id))
				{
					if (tier != null && item.tier == tier)
					{
						list.Add(item);
					}
					else
					{
						list2.Add(item);
					}
				}
			}
			List<AugmentDef> list3 = new List<AugmentDef>();
			while (list3.Count < count && list.Count > 0)
			{
				int index = Random.Range(0, list.Count);
				list3.Add(list[index]);
				list.RemoveAt(index);
			}
			while (list3.Count < count && list2.Count > 0)
			{
				int index2 = Random.Range(0, list2.Count);
				list3.Add(list2[index2]);
				list2.RemoveAt(index2);
			}
			HextechPlugin.Log.LogInfo((object)("额外选择(" + tier + ")候选:" + string.Join(" / ", list3.ConvertAll((AugmentDef d) => d.tier + ":" + d.id).ToArray())));
			return list3;
		}

		public static AugmentDef RollOne(HexState state, List<string> exclude, AugmentDef current)
		{
			string text = current?.tier;
			List<AugmentDef> list = new List<AugmentDef>();
			foreach (AugmentDef item in AugmentCatalog.All)
			{
				if (AugmentCatalog.InPool(item) && (text == null || !(item.tier != text)) && !HexStates.Owns(state, item.id) && (current == null || !(item.id == current.id)) && (exclude == null || !exclude.Contains(item.id)))
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return null;
			}
			return list[Random.Range(0, list.Count)];
		}

		private static AugmentDef Upgrade(AugmentDef def, HexState state, List<AugmentDef> siblings)
		{
			string text = HexRuntime.EffectiveTier(state, def);
			string text2;
			if (text == "Silver")
			{
				text2 = "Gold";
			}
			else
			{
				if (!(text == "Gold"))
				{
					return def;
				}
				text2 = "Prismatic";
			}
			List<AugmentDef> list = new List<AugmentDef>();
			foreach (AugmentDef item in AugmentCatalog.All)
			{
				if (AugmentCatalog.InPool(item) && !(item.tier != text2) && !HexStates.Owns(state, item.id) && (siblings == null || !siblings.Contains(item)) && !(item.id == def.id))
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return def;
			}
			return list[Random.Range(0, list.Count)];
		}
	}

	public static HexState PendingState;

	private static AugmentDef[] cards = new AugmentDef[0];

	private static int pickIndex;

	private const float FlipDur = 0.34f;

	private const float FlipGap = 0.16f;

	private static float[] flipAt = new float[0];

	private static AugmentDef[] swapTo = new AugmentDef[0];

	private static bool[] swapped = new bool[0];

	private static bool isOpening;

	private static bool pausedByUs;

	private static bool cursorSaved;

	private static bool prevCursorVisible;

	private static CursorLockMode prevCursorLock;

	private static Font cjkFont;

	private static GUIStyle titleStyle;

	private static GUIStyle subStyle;

	private static GUIStyle nameStyle;

	private static GUIStyle descStyle;

	private static GUIStyle tierStyle;

	private static GUIStyle hintStyle;

	private static GUIStyle rerollStyle;

	private static GUIStyle xStyle;

	private static GUIStyle indStyle;

	private static GUIStyle chipStyle;

	private static bool stylesReady;

	private static readonly Dictionary<string, Texture2D> iconCache = new Dictionary<string, Texture2D>();

	private const float CardW = 320f;

	private const float CardH = 448f;

	private const float CardGap = 22f;

	private static readonly Dictionary<string, Texture2D> uiCache = new Dictionary<string, Texture2D>();

	public static bool Open { get; private set; }

	public static HexState Owner { get; private set; }

	public static bool BeginPick(HexState state, bool opening)
	{
		if (state == null || Open)
		{
			return false;
		}
		List<AugmentDef> list = Roller.Roll(state, state.levelPicks + 1);
		if (list.Count == 0)
		{
			return false;
		}
		state.hasPending = true;
		state.pendingIsOpening = opening;
		state.pendingIsBonus = false;
		cards = list.ToArray();
		pickIndex = state.levelPicks + 1;
		isOpening = opening;
		Owner = state;
		SetupFlip(cards.Length, stagger: true);
		OpenPanel();
		return true;
	}

	public static bool BeginBonusPick(HexState state)
	{
		if (state == null || Open || state.bonusPicksLeft <= 0)
		{
			return false;
		}
		List<AugmentDef> list = Roller.RollTier(state, state.bonusPickTier, 3);
		if (list.Count == 0)
		{
			state.bonusPicksLeft = 0;
			state.bonusPickTier = null;
			return false;
		}
		state.hasPending = true;
		state.pendingIsOpening = false;
		state.pendingIsBonus = true;
		cards = list.ToArray();
		pickIndex = state.levelPicks;
		isOpening = false;
		Owner = state;
		SetupFlip(cards.Length, stagger: true);
		OpenPanel();
		return true;
	}

	private static void SetupFlip(int count, bool stagger)
	{
		flipAt = new float[count];
		swapTo = new AugmentDef[count];
		swapped = new bool[count];
		float unscaledTime = Time.unscaledTime;
		for (int i = 0; i < count; i++)
		{
			flipAt[i] = (stagger ? (unscaledTime + (float)i * 0.16f) : unscaledTime);
			swapped[i] = true;
		}
	}

	public static void CloseKeepPending()
	{
		Open = false;
		RestoreCursor();
		if (pausedByUs)
		{
			Time.timeScale = 1f;
			pausedByUs = false;
		}
	}

	public static bool Reopen(HexState state)
	{
		if (state == null || !state.hasPending || Open)
		{
			return false;
		}
		if (cards.Length == 0)
		{
			return BeginPick(state, state.pendingIsOpening);
		}
		Owner = state;
		isOpening = state.pendingIsOpening;
		pickIndex = state.levelPicks + 1;
		SetupFlip(cards.Length, stagger: true);
		OpenPanel();
		return true;
	}

	public static void Abort()
	{
		Open = false;
		Owner = null;
		PendingState = null;
		cards = new AugmentDef[0];
		RestoreCursor();
		if (pausedByUs)
		{
			Time.timeScale = 1f;
			pausedByUs = false;
		}
	}

	private static void OpenPanel()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		Open = true;
		if (!cursorSaved)
		{
			prevCursorVisible = Cursor.visible;
			prevCursorLock = Cursor.lockState;
			cursorSaved = true;
		}
		Cursor.visible = true;
		Cursor.lockState = (CursorLockMode)0;
		if (PlayerCharacterMasterController.instances.Count <= 1 && Time.timeScale > 0f)
		{
			Time.timeScale = 0f;
			pausedByUs = true;
		}
	}

	private static void RestoreCursor()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		if (cursorSaved)
		{
			Cursor.visible = prevCursorVisible;
			Cursor.lockState = prevCursorLock;
			cursorSaved = false;
		}
	}

	private static void Choose(AugmentDef def)
	{
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Expected O, but got Unknown
		HexState owner = Owner;
		if (owner == null || def == null)
		{
			return;
		}
		bool pendingIsBonus = owner.pendingIsBonus;
		owner.owned.Add(def.id);
		owner.ownedStamp++;
		if (pendingIsBonus)
		{
			owner.bonusPicksLeft--;
			if (owner.bonusPicksLeft <= 0)
			{
				owner.bonusPickTier = null;
			}
		}
		else if (!isOpening)
		{
			owner.levelPicks = pickIndex;
		}
		owner.hasPending = false;
		owner.pendingIsOpening = false;
		owner.pendingIsBonus = false;
		cards = new AugmentDef[0];
		CloseKeepPending();
		Owner = null;
		PendingState = null;
		CharacterBody val = (((Object)(object)owner.master != (Object)null) ? owner.master.GetBody() : null);
		HexRuntime.OnPick(owner, def, val);
		if ((Object)(object)val != (Object)null)
		{
			val.RecalculateStats();
		}
		HextechPlugin.Log.LogInfo((object)("选择海克斯:" + def.name));
		Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
		{
			baseToken = "<color=#ffd479>获得海克斯强化:" + def.name + "</color>"
		});
	}

	private static void RerollAll()
	{
		HexState owner = Owner;
		if (owner == null || owner.rerollsLeft <= 0 || cards.Length == 0)
		{
			return;
		}
		string tier = ((cards[0] != null) ? cards[0].tier : "Silver");
		List<AugmentDef> list = Roller.RollTier(owner, tier, cards.Length);
		if (list.Count == 0)
		{
			return;
		}
		for (int i = 0; i < cards.Length; i++)
		{
			AugmentDef augmentDef = list[Mathf.Min(i, list.Count - 1)];
			if (swapTo.Length == cards.Length)
			{
				swapTo[i] = augmentDef;
				swapped[i] = false;
				flipAt[i] = Time.unscaledTime + (float)i * 0.16f;
			}
			else
			{
				cards[i] = augmentDef;
			}
		}
		owner.rerollsLeft--;
		HextechPlugin.Log.LogInfo((object)("整批刷新,剩余 " + owner.rerollsLeft + " 次"));
	}

	private static void RerollAt(int index)
	{
		HexState owner = Owner;
		if (owner == null || owner.rerollsLeft <= 0 || index < 0 || index >= cards.Length)
		{
			return;
		}
		List<string> list = new List<string>();
		for (int i = 0; i < cards.Length; i++)
		{
			if (i != index && cards[i] != null)
			{
				list.Add(cards[i].id);
			}
		}
		AugmentDef augmentDef = Roller.RollOne(owner, list, cards[index]);
		if (augmentDef != null)
		{
			if (swapTo.Length == cards.Length)
			{
				swapTo[index] = augmentDef;
				swapped[index] = false;
				flipAt[index] = Time.unscaledTime;
			}
			else
			{
				cards[index] = augmentDef;
			}
			owner.rerollsLeft--;
			HextechPlugin.Log.LogInfo((object)("刷新第 " + (index + 1) + " 张,剩余 " + owner.rerollsLeft + " 次"));
		}
	}

	public static bool IsImmune(CharacterBody body)
	{
		HexState owner = Owner;
		if (!Open || owner == null || (Object)(object)body == (Object)null)
		{
			return false;
		}
		return (Object)(object)body.master == (Object)(object)owner.master;
	}

	public static Texture2D IconOf(string id)
	{
		return Icon(id);
	}

	private static Texture2D Icon(string id)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		if (iconCache.TryGetValue(id, out var value))
		{
			return value;
		}
		value = null;
		try
		{
			string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "icons"), id + ".png");
			if (File.Exists(path))
			{
				byte[] array = File.ReadAllBytes(path);
				value = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(value, array);
				((Texture)value).filterMode = (FilterMode)2;
			}
		}
		catch (Exception ex)
		{
			HextechPlugin.Log.LogWarning((object)("图标加载失败 " + id + ":" + ex.Message));
		}
		iconCache[id] = value;
		return value;
	}

	private static Texture2D Ui(string name)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		if (uiCache.TryGetValue(name, out var value))
		{
			return value;
		}
		value = null;
		try
		{
			string path = Path.Combine(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "ui"), name + ".png");
			if (File.Exists(path))
			{
				byte[] array = File.ReadAllBytes(path);
				value = new Texture2D(2, 2, (TextureFormat)4, false);
				ImageConversion.LoadImage(value, array);
				((Texture)value).filterMode = (FilterMode)2;
			}
		}
		catch (Exception ex)
		{
			HextechPlugin.Log.LogWarning((object)("UI 素材加载失败 " + name + ":" + ex.Message));
		}
		uiCache[name] = value;
		return value;
	}

	private static void Tex(Rect r, string name, Color c)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = Ui(name);
		if (!((Object)(object)val == (Object)null))
		{
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)val, (ScaleMode)0, true);
			GUI.color = color;
		}
	}

	private static void EnsureStyles()
	{
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Expected O, but got Unknown
		//IL_00b5: 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)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Expected O, but got Unknown
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Expected O, but got Unknown
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Expected O, but got Unknown
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Expected O, but got Unknown
		//IL_0210: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Expected O, but got Unknown
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Expected O, but got Unknown
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: 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_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Expected O, but got Unknown
		if (stylesReady)
		{
			return;
		}
		cjkFont = Font.CreateDynamicFontFromOSFont(new string[4] { "Microsoft YaHei", "SimHei", "Noto Sans CJK SC", "Arial Unicode MS" }, 18);
		titleStyle = new GUIStyle(GUI.skin.label)
		{
			fontSize = 30,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4
		};
		GUIStyle val = new GUIStyle(GUI.skin.label)
		{
			fontSize = 16,
			alignment = (TextAnchor)4
		};
		val.normal.textColor = new Color(1f, 1f, 1f, 0.6f);
		subStyle = val;
		GUIStyle val2 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 26,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4,
			wordWrap = true
		};
		val2.normal.textColor = new Color(0.97f, 0.96f, 0.93f, 1f);
		nameStyle = val2;
		GUIStyle val3 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 13,
			alignment = (TextAnchor)4
		};
		val3.normal.textColor = new Color(0.9f, 0.89f, 0.85f, 1f);
		chipStyle = val3;
		tierStyle = new GUIStyle(GUI.skin.label)
		{
			fontSize = 15,
			alignment = (TextAnchor)4
		};
		GUIStyle val4 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 14,
			alignment = (TextAnchor)4,
			wordWrap = true,
			richText = true
		};
		val4.normal.textColor = new Color(0.88f, 0.89f, 0.9f, 1f);
		descStyle = val4;
		GUIStyle val5 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 13,
			alignment = (TextAnchor)4
		};
		val5.normal.textColor = new Color(1f, 1f, 1f, 0.5f);
		hintStyle = val5;
		rerollStyle = new GUIStyle(GUI.skin.button)
		{
			fontSize = 17,
			alignment = (TextAnchor)4
		};
		xStyle = new GUIStyle(GUI.skin.button)
		{
			fontSize = 20,
			fontStyle = (FontStyle)1,
			alignment = (TextAnchor)4
		};
		GUIStyle val6 = new GUIStyle(GUI.skin.label)
		{
			fontSize = 13,
			alignment = (TextAnchor)4
		};
		val6.normal.textColor = Color.white;
		indStyle = val6;
		if ((Object)(object)cjkFont != (Object)null)
		{
			GUIStyle[] array = (GUIStyle[])(object)new GUIStyle[10] { titleStyle, subStyle, nameStyle, descStyle, tierStyle, hintStyle, rerollStyle, xStyle, indStyle, chipStyle };
			for (int i = 0; i < array.Length; i++)
			{
				array[i].font = cjkFont;
			}
		}
		stylesReady = true;
	}

	public static Color TierColor(string tier)
	{
		//IL_002b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		if (!(tier == "Gold"))
		{
			if (tier == "Prismatic")
			{
				return new Color(0.62f, 0.38f, 0.95f);
			}
			return new Color(0.72f, 0.76f, 0.82f);
		}
		return new Color(0.88f, 0.66f, 0.23f);
	}

	public static string TierCn(string tier)
	{
		if (!(tier == "Gold"))
		{
			if (tier == "Prismatic")
			{
				return "棱彩阶";
			}
			return "白银阶";
		}
		return "黄金阶";
	}

	private static void Fill(Rect r, Color c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		GUI.color = c;
		GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture);
		GUI.color = Color.white;
	}

	private static void Frame(Rect r, Color c, float w)
	{
		//IL_0016: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, w), c);
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - w, ((Rect)(ref r)).width, w), c);
		Fill(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c);
		Fill(new Rect(((Rect)(ref r)).xMax - w, ((Rect)(ref r)).y, w, ((Rect)(ref r)).height), c);
	}

	public static void Draw()
	{
		if (Open)
		{
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			DrawPanel();
			return;
		}
		HexState hexState = ((Owner != null && Owner.hasPending) ? Owner : PendingState);
		if (hexState != null && hexState.hasPending)
		{
			DrawPendingIndicator(hexState);
		}
	}

	private static void DrawPendingIndicator(HexState state)
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		EnsureStyles();
		float num = Screen.height;
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(26f, num * 0.5f - 46f, 92f, 92f);
		float num2 = 0.55f + 0.35f * Mathf.PingPong(Time.unscaledTime * 1.4f, 1f);
		Fill(val, new Color(0.06f, 0.07f, 0.1f, 0.92f));
		Frame(val, new Color(0.85f, 0.68f, 0.25f, num2), 2f);
		GUIStyle val2 = new GUIStyle(indStyle)
		{
			fontSize = 22,
			alignment = (TextAnchor)4
		};
		GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 12f, ((Rect)(ref val)).width, 34f), "海克斯", val2);
		GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + 46f, ((Rect)(ref val)).width, 18f), "待选 1 个", indStyle);
		GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax + 4f, ((Rect)(ref val)).width, 18f), "按 H 打开", hintStyle);
		if (GUI.Button(val, GUIContent.none, GUIStyle.none))
		{
			Reopen(state);
		}
		if (!Open && GUI.Button(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax + 22f, ((Rect)(ref val)).width, 20f), GUIContent.none, GUIStyle.none))
		{
			Reopen(state);
		}
	}

	private static void DrawPanel()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		EnsureStyles();
		HexState owner = Owner;
		float num = Screen.width;
		float num2 = Screen.height;
		Fill(new Rect(0f, 0f, num, num2), new Color(0f, 0f, 0f, 0.75f));
		string text = (isOpening ? "海克斯强化 · 开局赠送" : "海克斯强化 · 三选一");
		GUI.Label(new Rect(0f, num2 * 0.045f, num, 44f), text, titleStyle);
		GUI.Label(new Rect(0f, num2 * 0.045f + 46f, num, 24f), isOpening ? "不占用升级名额" : ("第 " + pickIndex + " / 6 次"), subStyle);
		Rect val = new Rect(num - 76f, 36f, 44f, 44f);
		GUI.backgroundColor = new Color(0.55f, 0.18f, 0.18f);
		if (GUI.Button(val, "X", xStyle))
		{
			CloseKeepPending();
			return;
		}
		GUI.backgroundColor = Color.white;
		int num3 = cards.Length;
		float num4 = (float)num3 * 320f + (float)Mathf.Max(0, num3 - 1) * 22f;
		float num5 = (num - num4) * 0.5f;
		float num6 = num2 * 0.17f;
		if (num6 + 448f + 120f > num2)
		{
			num6 = Mathf.Max(num2 * 0.1f, num2 - 448f - 130f);
		}
		for (int i = 0; i < num3; i++)
		{
			DrawCard(i, cards[i], new Rect(num5 + (float)i * 342f, num6, 320f, 448f));
		}
		int num7 = owner?.rerollsLeft ?? 0;
		bool flag = num7 > 0;
		Rect val2 = default(Rect);
		Rect val3 = default(Rect);
		for (int j = 0; j < num3; j++)
		{
			((Rect)(ref val2))..ctor(num5 + (float)j * 342f, num6, 320f, 448f);
			bool flag2 = ((flipAt.Length > j) ? Mathf.Clamp01((Time.unscaledTime - flipAt[j]) / 0.34f) : 1f) >= 1f;
			((Rect)(ref val3))..ctor(((Rect)(ref val2)).center.x - 48f, ((Rect)(ref val2)).yMax + 14f, 96f, 50f);
			Color c = (Color)((flag && flag2) ? Color.white : new Color(0.52f, 0.52f, 0.52f, 0.85f));
			Tex(val3, "btn", c);
			Tex(new Rect(((Rect)(ref val3)).center.x - 15f, ((Rect)(ref val3)).center.y - 15f, 30f, 30f), "refresh", (Color)((flag && flag2) ? Color.white : new Color(0.62f, 0.62f, 0.62f, 0.7f)));
			if (flag && flag2 && ((Rect)(ref val3)).Contains(Event.current.mousePosition))
			{
				Frame(new Rect(((Rect)(ref val3)).x + 3f, ((Rect)(ref val3)).y + 3f, ((Rect)(ref val3)).width - 6f, ((Rect)(ref val3)).height - 6f), new Color(0.98f, 0.85f, 0.55f, 0.7f), 2f);
			}
			GUI.enabled = flag && flag2;
			if (GUI.Button(val3, GUIContent.none, GUIStyle.none))
			{
				RerollAt(j);
			}
			GUI.enabled = true;
		}
		float num8 = num6 + 448f + 14f + 50f;
		GUI.Label(new Rect(0f, num8 + 6f, num, 26f), flag ? ("剩余刷新次数:" + num7 + "(三张共用)") : "刷新次数已用完", subStyle);
		GUI.Label(new Rect(0f, num8 + 32f, num, 22f), "左键点卡选择 · 卡下的箭头只换这一张 · 右上角 X 可先不选", hintStyle);
	}

	private static void DrawCard(int index, AugmentDef def, Rect rect)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		float num = ((flipAt.Length > index) ? Mathf.Clamp01((Time.unscaledTime - flipAt[index]) / 0.34f) : 1f);
		if (swapTo.Length > index && !swapped[index] && num >= 0.5f)
		{
			cards[index] = swapTo[index];
			swapped[index] = true;
			def = cards[index];
		}
		Matrix4x4 matrix = GUI.matrix;
		if (num < 1f)
		{
			GUIUtility.ScaleAroundPivot(new Vector2(Mathf.Max(0.02f, Mathf.Abs(1f - 2f * num)), 1f), ((Rect)(ref rect)).center);
		}
		if (num < 0.5f)
		{
			DrawCardBack(rect);
		}
		else
		{
			DrawCardFront(index, def, rect, num >= 1f);
		}
		GUI.matrix = matrix;
	}

	private static void DrawCardBack(Rect rect)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		Tex(rect, "card_back", Color.white);
		Tex(rect, "card_frame", Color.white);
		GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 92f, ((Rect)(ref rect)).width, 24f), "海 克 斯", hintStyle);
		GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 70f, ((Rect)(ref rect)).width, 18f), "翻 开 揭 晓", hintStyle);
	}

	private static void DrawChips(Rect card, AugmentDef def, string tierKey, Color tier, float yOffset)
	{
		//IL_0019: 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: Expected O, but got Unknown
		//IL_00b1: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: 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_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		List<string> list = new List<string>();
		List<Color> list2 = new List<Color>();
		list.Add(TierCn(tierKey));
		list2.Add(tier);
		if (def.tags != null)
		{
			for (int i = 0; i < def.tags.Length; i++)
			{
				if (list.Count >= 3)
				{
					break;
				}
				if (!string.IsNullOrEmpty(def.tags[i]))
				{
					list.Add(def.tags[i]);
					list2.Add(new Color(0.82f, 0.8f, 0.74f));
				}
			}
		}
		float num = 8f;
		float num2 = 20f;
		List<float> list3 = new List<float>();
		float num3 = 0f;
		for (int j = 0; j < list.Count; j++)
		{
			Vector2 val = chipStyle.CalcSize(new GUIContent(list[j]));
			float num4 = Mathf.Max(34f, val.x + 18f);
			list3.Add(num4);
			num3 += num4 + ((j > 0) ? num : 0f);
		}
		float num5 = ((Rect)(ref card)).x + (((Rect)(ref card)).width - num3) * 0.5f;
		float num6 = ((Rect)(ref card)).y + yOffset;
		for (int k = 0; k < list.Count; k++)
		{
			Rect val2 = new Rect(num5, num6, list3[k], num2);
			Fill(val2, new Color(1f, 1f, 1f, 0.06f));
			Frame(val2, new Color(list2[k].r, list2[k].g, list2[k].b, 0.55f), 1f);
			GUI.Label(val2, list[k], chipStyle);
			num5 += list3[k] + num;
		}
	}

	private static void DrawCardFront(int index, AugmentDef def, Rect rect, bool interactive)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Expected O, but got Unknown
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		if (def != null)
		{
			string text = HexRuntime.EffectiveTier(Owner, def);
			Color val = TierColor(text);
			bool flag = interactive && ((Rect)(ref rect)).Contains(Event.current.mousePosition);
			Tex(rect, "card_bg", Color.white);
			Tex(new Rect(((Rect)(ref rect)).x + (((Rect)(ref rect)).width - 224f) * 0.5f, ((Rect)(ref rect)).y + 10f, 224f, 224f), "glow", new Color(val.r, val.g, val.b, flag ? 0.62f : 0.42f));
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + (((Rect)(ref rect)).width - 136f) * 0.5f, ((Rect)(ref rect)).y + 54f, 136f, 136f);
			Texture2D val3 = Icon(def.id);
			if ((Object)(object)val3 != (Object)null)
			{
				GUI.DrawTexture(val2, (Texture)(object)val3, (ScaleMode)2);
			}
			else
			{
				GUI.Label(val2, (def.name != null && def.name.Length > 0) ? def.name.Substring(0, 1) : "?", new GUIStyle(chipStyle)
				{
					fontSize = 46,
					fontStyle = (FontStyle)1
				});
			}
			GUI.Label(new Rect(((Rect)(ref rect)).x + 14f, ((Rect)(ref rect)).y + 198f, ((Rect)(ref rect)).width - 28f, 38f), def.name, nameStyle);
			DrawChips(rect, def, text, val, 244f);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 26f, ((Rect)(ref rect)).y + 274f, ((Rect)(ref rect)).width - 52f, ((Rect)(ref rect)).height - 274f - 24f), def.desc, descStyle);
			Color c = Color.Lerp(Color.white, val, 0.82f);
			Tex(rect, "card_frame", c);
			if (flag)
			{
				Frame(new Rect(((Rect)(ref rect)).x + 18f, ((Rect)(ref rect)).y + 18f, ((Rect)(ref rect)).width - 36f, ((Rect)(ref rect)).height - 36f), new Color(val.r, val.g, val.b, 0.42f), 2f);
			}
			if (interactive && GUI.Button(rect, GUIContent.none, GUIStyle.none))
			{
				Choose(def);
			}
		}
	}
}
public class HexAgg
{
	public float damageMult;

	public float healthMult;

	public float moveSpeedMult;

	public float attackSpeedMult;

	public float critAdd;

	public float armorAdd;

	public float armorFromCrit;

	public float damageFromMoveSpeed;

	public float regenMult;

	public float perSilver;

	public float shieldPerLevel;

	public float capPenalty;

	public float critMultAdd;

	public float minionDamageMult;

	public float minionHealthMult;

	public int burnStacks;

	public int bleedStacks;

	public int explosionBurnStacks;

	public float slowPctOnHit;

	public float slowSeconds;

	public float arrowOnHit;

	public float explosionOnHit;

	public float explosionRadius;

	public float equipDamageMult;

	public float shredPctOnHit;

	public float shredPctBoss;

	public float chainOnHit;

	public float chainSlowPct;

	public float chainSlowSeconds;

	public float chainInterval;

	public int chainJumps;

	public float cooldownPctOnKill;

	public bool specialCrit;

	public bool specialResetOnKill;

	public float specialBonusPerStack;

	public int specialMaxStacks;

	public float armorMultAdd;

	public float armorLowHealthAdd;

	public float lowHealthThreshold;

	public float armorMoveSpeedGate;

	public float rescueHealPct;

	public float rescueCooldown;

	public float rescueRadius;

	public float castBlastPct;

	public float castBlastRadius;

	public float castBlastArmorScale;

	public float markDuration;

	public float markBonusPct;

	public float markCooldownPct;

	public float primaryExtraPct;

	public float slimeSeconds;

	public float slimeRadius;

	public float slimeDamagePct;

	public float slimeHealPct;

	public bool hasHitFx;
}
public static class HexAggs
{
	public static HexAgg Get(HexState state)
	{
		if (state == null)
		{
			return null;
		}
		if (state.agg != null && state.aggStamp == state.ownedStamp && state.aggKills == state.kills)
		{
			return state.agg;
		}
		HexAgg hexAgg = new HexAgg();
		foreach (string item in state.owned)
		{
			AugmentDef augmentDef = AugmentCatalog.Get(item);
			if (augmentDef != null && augmentDef.fx != null)
			{
				AugmentFx fx = augmentDef.fx;
				hexAgg.damageMult += fx.damageMult;
				hexAgg.healthMult += fx.healthMult;
				hexAgg.moveSpeedMult += fx.moveSpeedMult;
				hexAgg.attackSpeedMult += fx.attackSpeedMult;
				hexAgg.critAdd += fx.critAdd;
				hexAgg.armorAdd += fx.armorAdd;
				hexAgg.armorFromCrit += fx.armorFromCrit;
				hexAgg.damageFromMoveSpeed += fx.damageFromMoveSpeed;
				hexAgg.regenMult += fx.regenMult;
				hexAgg.perSilver += fx.damageMultPerSilver;
				hexAgg.shieldPerLevel += fx.shieldPerLevel;
				hexAgg.critMultAdd += fx.critMultAdd;
				int num = HexStates.Stacks(state, augmentDef);
				hexAgg.healthMult += fx.healthMultPerStack * (float)num;
				hexAgg.damageMult += fx.damageMultPerStack * (float)num;
				if (fx.maxHealthCostPct > 0f && state.Counter(item) >= 0)
				{
					hexAgg.capPenalty += fx.maxHealthCostPct;
				}
				hexAgg.minionDamageMult += fx.minionDamageMult;
				hexAgg.minionHealthMult += fx.minionHealthMult;
				hexAgg.burnStacks += fx.burnStacksOnHit;
				hexAgg.bleedStacks += fx.bleedStacksOnHit;
				if (fx.slowPctOnHit > hexAgg.slowPctOnHit)
				{
					hexAgg.slowPctOnHit = fx.slowPctOnHit;
					hexAgg.slowSeconds = Mathf.Max(hexAgg.slowSeconds, fx.slowSeconds);
				}
				hexAgg.arrowOnHit += fx.arrowOnHit;
				if (fx.explosionOnHit > hexAgg.explosionOnHit)
				{
					hexAgg.explosionOnHit = fx.explosionOnHit;
					hexAgg.explosionRadius = fx.explosionRadius;
					hexAgg.explosionBurnStacks += fx.explosionBurnStacks;
				}
				hexAgg.equipDamageMult += fx.equipDamageMult;
				hexAgg.shredPctOnHit += fx.shredPctOnHit;
				if (fx.shredPctBoss > hexAgg.shredPctBoss)
				{
					hexAgg.shredPctBoss = fx.shredPctBoss;
				}
				hexAgg.chainOnHit += fx.chainOnHit;
				if (fx.chainJumps > hexAgg.chainJumps)
				{
					hexAgg.chainJumps = fx.chainJumps;
				}
				if (fx.chainSlowPct > hexAgg.chainSlowPct)
				{
					hexAgg.chainSlowPct = fx.chainSlowPct;
					hexAgg.chainSlowSeconds = Mathf.Max(hexAgg.chainSlowSeconds, fx.chainSlowSeconds);
				}
				if (fx.chainInterval > hexAgg.chainInterval)
				{
					hexAgg.chainInterval = fx.chainInterval;
				}
				hexAgg.cooldownPctOnKill += fx.cooldownPctOnKill;
				hexAgg.specialCrit |= fx.specialCrit;
				hexAgg.specialResetOnKill |= fx.specialResetOnKill;
				hexAgg.specialBonusPerStack += fx.specialBonusPerStack;
				if (fx.specialMaxStacks > hexAgg.specialMaxStacks)
				{
					hexAgg.specialMaxStacks = fx.specialMaxStacks;
				}
				hexAgg.armorMultAdd += fx.armorMultAdd;
				hexAgg.armorLowHealthAdd += fx.armorLowHealthAdd;
				hexAgg.armorMoveSpeedGate += fx.armorMoveSpeedGate;
				if (fx.lowHealthThreshold > hexAgg.lowHealthThreshold)
				{
					hexAgg.lowHealthThreshold = fx.lowHealthThreshold;
				}
				hexAgg.rescueHealPct += fx.rescueHealPct;
				if (fx.rescueCooldown > hexAgg.rescueCooldown)
				{
					hexAgg.rescueCooldown = fx.rescueCooldown;
				}
				if (fx.rescueRadius > hexAgg.rescueRadius)
				{
					hexAgg.rescueRadius = fx.rescueRadius;
				}
				hexAgg.castBlastPct += fx.castBlastPct;
				if (fx.castBlastRadius > hexAgg.castBlastRadius)
				{
					hexAgg.castBlastRadius = fx.castBlastRadius;
				}
				hexAgg.castBlastArmorScale += fx.castBlastArmorScale;
				if (fx.markDuration > hexAgg.markDuration)
				{
					hexAgg.markDuration = fx.markDuration;
				}
				hexAgg.markBonusPct += fx.markBonusPct;
				hexAgg.markCooldownPct += fx.markCooldownPct;
				hexAgg.primaryExtraPct += fx.primaryExtraPct;
				if (fx.slimeSeconds > 0f && (hexAgg.slimeSeconds <= 0f || fx.slimeSeconds < hexAgg.slimeSeconds))
				{
					hexAgg.slimeSeconds = fx.slimeSeconds;
				}
				if (fx.slimeRadius > hexAgg.slimeRadius)
				{
					hexAgg.slimeRadius = fx.slimeRadius;
				}
				hexAgg.slimeDamagePct += fx.slimeDamagePct;
				hexAgg.slimeHealPct += fx.slimeHealPct;
			}
		}
		if (hexAgg.lowHealthThreshold <= 0f)
		{
			hexAgg.lowHealthThreshold = 0.4f;
		}
		if (hexAgg.perSilver != 0f)
		{
			hexAgg.damageMult += hexAgg.perSilver * (float)AugmentCatalog.CountTier(state, "Silver");
		}
		hexAgg.hasHitFx = hexAgg.burnStacks > 0 || hexAgg.bleedStacks > 0 || hexAgg.slowPctOnHit > 0f || hexAgg.arrowOnHit > 0f || hexAgg.explosionOnHit > 0f || hexAgg.equipDamageMult > 0f || hexAgg.shredPctOnHit > 0f || hexAgg.chainOnHit > 0f || hexAgg.markBonusPct > 0f || hexAgg.castBlastPct > 0f || hexAgg.primaryExtraPct > 0f || hexAgg.specialCrit || hexAgg.slimeHealPct > 0f || hexAgg.slimeDamagePct > 0f;
		state.agg = hexAgg;
		state.aggStamp = state.ownedStamp;
		state.aggKills = state.kills;
		return hexAgg;
	}
}
public static class HexEffects
{
	private static readonly object[] box = new object[1];

	private static readonly MethodInfo setDamage = Setter("damage");

	private static readonly MethodInfo setMaxHealth = Setter("maxHealth");

	private static readonly MethodInfo setMaxShield = Setter("maxShield");

	private static readonly MethodInfo setMoveSpeed = Setter("moveSpeed");

	private static readonly MethodInfo setAttackSpeed = Setter("attackSpeed");

	private static readonly MethodInfo setCrit = Setter("crit");

	private static readonly MethodInfo setArmor = Setter("armor");

	private static readonly MethodInfo setRegen = Setter("regen");

	private static readonly MethodInfo setCritMultiplier = Setter("critMultiplier");

	private static MethodInfo Setter(string name)
	{
		PropertyInfo property = typeof(CharacterBody).GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (property == null)
		{
			return null;
		}
		return property.GetSetMethod(nonPublic: true);
	}

	private static void Set(MethodInfo setter, CharacterBody body, float value)
	{
		if (!(setter == null))
		{
			box[0] = value;
			setter.Invoke(body, box);
		}
	}

	public static void Apply(CharacterBody body)
	{
		if ((Object)(object)body == (Object)null)
		{
			return;
		}
		float num = HexOnHit.ActiveSlow(body);
		if (num > 0f)
		{
			Set(setMoveSpeed, body, Mathf.Max(0f, body.moveSpeed * (1f - num)));
		}
		CharacterMaster master = body.master;
		if ((Object)(object)master == (Object)null)
		{
			return;
		}
		HexState hexState = HexStates.Get(master);
		if (hexState == null)
		{
			MinionOwnership minionOwnership = master.minionOwnership;
			CharacterMaster val = (((Object)(object)minionOwnership != (Object)null) ? minionOwnership.ownerMaster : null);
			if (!((Object)(object)val == (Object)null))
			{
				HexState hexState2 = HexStates.Get(val);
				if (hexState2 != null && hexState2.owned.Count != 0)
				{
					ApplyToMinion(body, hexState2);
				}
			}
		}
		else
		{
			if (hexState.owned.Count == 0)
			{
				return;
			}
			HexAgg hexAgg = HexAggs.Get(hexState);
			if (hexAgg == null)
			{
				return;
			}
			float damage = body.damage;
			float maxHealth = body.maxHealth;
			float moveSpeed = body.moveSpeed;
			float attackSpeed = body.attackSpeed;
			float crit = body.crit;
			float armor = body.armor;
			float regen = body.regen;
			float num2 = hexAgg.damageMult;
			if (hexAgg.damageFromMoveSpeed != 0f)
			{
				float num3 = moveSpeed / 7f - 1f;
				if (num3 > 0f)
				{
					num2 += num3 * hexAgg.damageFromMoveSpeed;
				}
			}
			if (num2 != 0f)
			{
				Set(setDamage, body, Mathf.Max(0f, damage * (1f + num2)));
			}
			if (hexAgg.healthMult != 0f || hexAgg.capPenalty != 0f)
			{
				Set(setMaxHealth, body, Mathf.Max(1f, maxHealth * (1f + hexAgg.healthMult) * (1f - Mathf.Min(hexAgg.capPenalty, 0.95f))));
			}
			if (hexAgg.regenMult != 0f)
			{
				Set(setRegen, body, Mathf.Max(0f, regen * (1f + hexAgg.regenMult)));
			}
			if (hexAgg.moveSpeedMult != 0f)
			{
				Set(setMoveSpeed, body, Mathf.Max(0f, moveSpeed * (1f + hexAgg.moveSpeedMult)));
			}
			if (hexAgg.attackSpeedMult != 0f)
			{
				Set(setAttackSpeed, body, Mathf.Max(0f, attackSpeed * (1f + hexAgg.attackSpeedMult)));
			}
			if (hexAgg.critAdd != 0f)
			{
				Set(setCrit, body, Mathf.Clamp(crit + hexAgg.critAdd * 100f, 0f, 100f));
			}
			float num4 = armor + hexAgg.armorAdd + body.crit * hexAgg.armorFromCrit;
			if (hexAgg.armorMultAdd != 0f)
			{
				num4 *= 1f + hexAgg.armorMultAdd;
			}
			if (hexAgg.armorLowHealthAdd != 0f)
			{
				HealthComponent healthComponent = body.healthComponent;
				float num5 = (((Object)(object)healthComponent != (Object)null && body.maxHealth > 0f) ? (healthComponent.health / body.maxHealth) : 1f);
				float num6 = ((hexAgg.lowHealthThreshold > 0f) ? hexAgg.lowHealthThreshold : 0.4f);
				if (num5 < num6)
				{
					num4 += hexAgg.armorLowHealthAdd;
				}
			}
			if (num4 != armor)
			{
				Set(setArmor, body, Mathf.Max(-100f, num4));
			}
			if (hexAgg.armorMoveSpeedGate > 0f && num4 >= 100f)
			{
				Set(setMoveSpeed, body, Mathf.Max(0f, body.moveSpeed * (1f + hexAgg.armorMoveSpeedGate)));
			}
			float num7 = hexAgg.shieldPerLevel * body.level + hexState.bonusShield;
			if (num7 != 0f)
			{
				Set(setMaxShield, body, Mathf.Max(0f, body.maxShield + num7));
			}
			if (hexAgg.critMultAdd != 0f)
			{
				Set(setCritMultiplier, body, Mathf.Max(1f, body.critMultiplier + hexAgg.critMultAdd));
			}
		}
	}

	private static void ApplyToMinion(CharacterBody body, HexState ownerState)
	{
		HexAgg hexAgg = HexAggs.Get(ownerState);
		if (hexAgg != null)
		{
			if (hexAgg.minionDamageMult != 0f)
			{
				Set(setDamage, body, Mathf.Max(0f, body.damage * (1f + hexAgg.minionDamageMult)));
			}
			if (hexAgg.minionHealthMult != 0f)
			{
				Set(setMaxHealth, body, Mathf.Max(1f, body.maxHealth * (1f + hexAgg.minionHealthMult)));
			}
		}
	}
}
public static class HexOnHit
{
	private const float BurnDuration = 4f;

	private const float BleedDuration = 3f;

	private const int MaxDotStacks = 5;

	private const float ProcInterval = 0.2f;

	private static readonly Dictionary<CharacterBody, float> slowUntil = new Dictionary<CharacterBody, float>();

	private static readonly Dictionary<CharacterBody, float> slowPct = new Dictionary<CharacterBody, float>();

	private static readonly Dictionary<CharacterBody, float> markUntil = new Dictionary<CharacterBody, float>();

	private static bool applyingExtra;

	private static readonly Dictionary<CharacterBody, float> shredOrig = new Dictionary<CharacterBody, float>();

	private static readonly Dictionary<CharacterBody, float> shredFactor = new Dictionary<CharacterBody, float>();

	public static void ShredMaxHealth(CharacterBody victim, float pct)
	{
		if ((Object)(object)victim == (Object)null || (Object)(object)victim.healthComponent == (Object)null || pct <= 0f || victim.isPlayerControlled)
		{
			return;
		}
		if (!shredOrig.TryGetValue(victim, out var value))
		{
			value = victim.baseMaxHealth;
			shredOrig[victim] = value;
			shredFactor[victim] = 1f;
		}
		if (value <= 1f)
		{
			return;
		}
		float num = shredFactor[victim];
		float num2 = num * (1f - pct);
		if (num2 < 0.1f)
		{
			num2 = 0.1f;
		}
		if (!(num2 >= num - 0.0005f))
		{
			shredFactor[victim] = num2;
			victim.baseMaxHealth = value * num2;
			victim.RecalculateStats();
			HealthComponent healthComponent = victim.healthComponent;
			if ((Object)(object)healthComponent != (Object)null && healthComponent.health > victim.maxHealth)
			{
				healthComponent.health = victim.maxHealth;
			}
		}
	}

	public static void PruneShred()
	{
		if (shredOrig.Count == 0)
		{
			return;
		}
		List<CharacterBody> list = new List<CharacterBody>();
		foreach (KeyValuePair<CharacterBody, float> item in shredOrig)
		{
			if ((Object)(object)item.Key == (Object)null || (Object)(object)item.Key.healthComponent == (Object)null || !item.Key.healthComponent.alive)
			{
				list.Add(item.Key);
			}
		}
		for (int i = 0; i < list.Count; i++)
		{
			shredOrig.Remove(list[i]);
			shredFactor.Remove(list[i]);
		}
	}

	public static void SetSlow(CharacterBody body, float pct, float seconds)
	{
		if (!((Object)(object)body == (Object)null) && !(pct <= 0f))
		{
			slowUntil[body] = Time.time + Mathf.Max(0.1f, seconds);
			slowPct[body] = Mathf.Clamp01(pct);
			body.RecalculateStats();
		}
	}

	public static float ActiveSlow(CharacterBody body)
	{
		if ((Object)(object)body == (Object)null)
		{
			return 0f;
		}
		slowUntil.TryGetValue(body, out var value);
		if (value <= Time.time)
		{
			slowUntil.Remove(body);
			slowPct.Remove(body);
			return 0f;
		}
		if (!slowPct.TryGetValue(body, out var value2))
		{
			return 0f;
		}
		return value2;
	}

	public static void Tick()
	{
		if (slowUntil.Count == 0)
		{
			return;
		}
		List<CharacterBody> list = null;
		foreach (KeyValuePair<CharacterBody, float> item in slowUntil)
		{
			if (!(item.Value > Time.time))
			{
				if (list == null)
				{
					list = new List<CharacterBody>();
				}
				list.Add(item.Key);
			}
		}
		if (list == null)
		{
			return;
		}
		for (int i = 0; i < list.Count; i++)
		{
			CharacterBody val = list[i];
			slowUntil.Remove(val);
			slowPct.Remove(val);
			if ((Object)(object)val != (Object)null)
			{
				val.RecalculateStats();
			}
		}
	}

	public static void OnHit(CharacterBody attacker, CharacterBody victim, DamageInfo info)
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Invalid comparison between Unknown and I4
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		if (applyingExtra || (Object)(object)attacker == (Object)null || (Object)(object)victim == (Object)null)
		{
			return;
		}
		CharacterMaster master = attacker.master;
		if ((Object)(object)master == (Object)null)
		{
			return;
		}
		HexState hexState = HexStates.Get(master);
		if (hexState == null)
		{
			return;
		}
		HexAgg hexAgg = HexAggs.Get(hexState);
		if (hexAgg == null || !hexAgg.hasHitFx || !victim.healthComponent.alive)
		{
			return;
		}
		TeamComponent teamComponent = attacker.teamComponent;
		TeamComponent teamComponent2 = victim.teamComponent;
		if (((Object)(object)teamComponent != (Object)null && (Object)(object)teamComponent2 != (Object)null && teamComponent.teamIndex == teamComponent2.teamIndex) || (int)info.damageType.damageSource == 32)
		{
			return;
		}
		GameObject gameObject = ((Component)attacker).gameObject;
		GameObject gameObject2 = ((Component)victim).gameObject;
		bool num = (Object)(object)DotController.FindDotController(gameObject2) != (Object)null;
		if (num && hexAgg.burnStacks > 0)
		{
			DotController.InflictDot(gameObject2, gameObject, (DotIndex)1, 4f, 1f, (uint?)5u);
		}
		if (num && hexAgg.bleedStacks > 0)
		{
			DotController.InflictDot(gameObject2, gameObject, (DotIndex)0, 3f, 1f, (uint?)5u);
		}
		if (hexAgg.slowPctOnHit > 0f)
		{
			SetSlow(victim, hexAgg.slowPctOnHit, (hexAgg.slowSeconds > 0f) ? hexAgg.slowSeconds : 2.5f);
		}
		if (hexAgg.arrowOnHit > 0f && Time.time >= hexState.arrowAt)
		{
			hexState.arrowAt = Time.time + 0.2f;
			FireSeekingArrow(attacker, victim, hexAgg.arrowOnHit);
		}
		if (hexAgg.explosionOnHit > 0f && Time.time >= hexState.explosionAt)
		{
			hexState.explosionAt = Time.time + 0.2f;
			float radius = ((hexAgg.explosionRadius > 0f) ? hexAgg.explosionRadius : 4f);
			Explode(attacker, victim, hexAgg.explosionOnHit, radius);
			if (hexAgg.explosionBurnStacks > 0)
			{
				BurnAround(attacker, victim, radius);
			}
		}
		if (hexAgg.chainOnHit > 0f && Time.time >= hexState.chainAt)
		{
			hexState.chainAt = Time.time + ((hexAgg.chainInterval > 0f) ? hexAgg.chainInterval : 0.6f);
			ChainLightning(attacker, victim, hexAgg);
		}
		if (hexAgg.slimeHealPct > 0f && Time.time >= hexState.slimeHealAt)
		{
			hexState.slimeHealAt = Time.time + 0.5f;
			HealthComponent healthComponent = attacker.healthComponent;
			if ((Object)(object)healthComponent != (Object)null && attacker.maxHealth > 0f)
			{
				healthComponent.health = Mathf.Min(healthComponent.health + attacker.maxHealth * hexAgg.slimeHealPct, attacker.maxHealth);
			}
		}
	}

	private static void ChainLightning(CharacterBody attacker, CharacterBody victim, HexAgg agg)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0078: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		int num = ((agg.chainJumps > 0) ? agg.chainJumps : 3);
		List<CharacterBody> list = new List<CharacterBody> { victim };
		CharacterBody val = victim;
		for (int i = 0; i < num; i++)
		{
			CharacterBody val2 = NearestEnemy(val, list, 24f);
			if (!((Object)(object)val2 == (Object)null))
			{
				float num2 = agg.chainOnHit * (1f - 0.25f * (float)i);
				if (!(num2 <= 0f))
				{
					Vector3 corePosition = val.corePosition;
					Vector3 val3 = val2.corePosition - corePosition;
					if (!(((Vector3)(ref val3)).sqrMagnitude < 0.01f))
					{
						new BulletAttack
						{
							owner = ((Component)attacker).gameObject,
							weapon = ((Component)attacker).gameObject,
							origin = corePosition,
							aimVector = ((Vector3)(ref val3)).normalized,
							maxDistance = ((Vector3)(ref val3)).magnitude + 4f,
							damage = attacker.damage * num2,
							bulletCount = 1u,
							procCoefficient = 0f,
							damageType = DamageTypeCombo.op_Implicit((DamageType)0),
							isCrit = false
						}.Fire();
						if (agg.chainSlowPct > 0f)
						{
							SetSlow(val2, agg.chainSlowPct, (agg.chainSlowSeconds > 0f) ? agg.chainSlowSeconds : 2f);
						}
						list.Add(val2);
						val = val2;
						continue;
					}
					break;
				}
				break;
			}
			break;
		}
	}

	private static CharacterBody NearestEnemy(CharacterBody center, List<CharacterBody> exclude, float maxDist)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)center == (Object)null)
		{
			return null;
		}
		TeamComponent teamComponent = center.teamComponent;
		float num = maxDist * maxDist;
		CharacterBody result = null;
		float num2 = float.MaxValue;
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if ((Object)(object)readOnlyInstances == (Object)null || !readOnlyInstances.healthComponent.alive || exclude.Contains(readOnlyInstances))
			{
				continue;
			}
			TeamComponent teamComponent2 = readOnlyInstances.teamComponent;
			if (!((Object)(object)teamComponent2 == (Object)null) && !((Object)(object)teamComponent == (Object)null) && teamComponent2.teamIndex != teamComponent.teamIndex)
			{
				Vector3 val = readOnlyInstances.corePosition - center.corePosition;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				if (!(sqrMagnitude > num) && !(sqrMagnitude >= num2))
				{
					num2 = sqrMagnitude;
					result = readOnlyInstances;
				}
			}
		}
		return result;
	}

	private static void BurnAround(CharacterBody attacker, CharacterBody center, float radius)
	{
		//IL_0071: 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_007f: 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_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)
		if ((Object)(object)center == (Object)null)
		{
			return;
		}
		float num = radius * radius;
		TeamComponent teamComponent = center.teamComponent;
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if ((Object)(object)readOnlyInstances == (Object)null || (Object)(object)readOnlyInstances == (Object)(object)center || !readOnlyInstances.healthComponent.alive)
			{
				continue;
			}
			TeamComponent teamComponent2 = readOnlyInstances.teamComponent;
			if (!((Object)(object)teamComponent2 == (Object)null) && !((Object)(object)teamComponent == (Object)null) && teamComponent2.teamIndex != teamComponent.teamIndex)
			{
				Vector3 val = readOnlyInstances.corePosition - center.corePosition;
				if (!(((Vector3)(ref val)).sqrMagnitude > num) && !((Object)(object)DotController.FindDotController(((Component)readOnlyInstances).gameObject) == (Object)null))
				{
					DotController.InflictDot(((Component)readOnlyInstances).gameObject, ((Object)(object)attacker != (Object)null) ? ((Component)attacker).gameObject : ((Component)center).gameObject, (DotIndex)1, 4f, 1f, (uint?)1u);
				}
			}
		}
	}

	private static void FireSeekingArrow(CharacterBody attacker, CharacterBody victim, float coefficient)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)victim == (Object)null))
		{
			Vector3 corePosition = attacker.corePosition;
			Vector3 val = victim.corePosition - corePosition;
			if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
			{
				new BulletAttack
				{
					owner = ((Component)attacker).gameObject,
					weapon = ((Component)attacker).gameObject,
					origin = corePosition,
					aimVector = ((Vector3)(ref val)).normalized,
					maxDistance = 400f,
					damage = attacker.damage * coefficient,
					bulletCount = 1u,
					procCoefficient = 0f,
					damageType = DamageTypeCombo.op_Implicit((DamageType)0),
					isCrit = false
				}.Fire();
			}
		}
	}

	private static void Explode(CharacterBody attacker, CharacterBody victim, float coefficient, float radius)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		new BlastAttack
		{
			attacker = ((Component)attacker).gameObject,
			inflictor = ((Component)attacker).gameObject,
			teamIndex = (TeamIndex)(((Object)(object)attacker.teamComponent != (Object)null) ? ((int)attacker.teamComponent.teamIndex) : 0),
			position = victim.corePosition,
			radius = radius,
			falloffModel = (FalloffModel)1,
			baseDamage = attacker.damage * coefficient,
			baseForce = 0f,
			procCoefficient = 0f,
			attackerFiltering = (AttackerFiltering)2
		}.Fire();
	}

	public static void OnDamageDealt(CharacterBody attacker, CharacterBody victim, DamageInfo info)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Invalid comparison between Unknown and I4
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0242: Invalid comparison between Unknown and I4
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Invalid comparison between Unknown and I4
		if (applyingExtra || (Object)(object)attacker == (Object)null || (Object)(object)victim == (Object)null)
		{
			return;
		}
		CharacterMaster master = attacker.master;
		if ((Object)(object)master == (Object)null)
		{
			return;
		}
		HexState hexState = HexStates.Get(master);
		if (hexState == null)
		{
			return;
		}
		HexAgg hexAgg = HexAggs.Get(hexState);
		if (hexAgg != null && hexAgg.hasHitFx)
		{
			if (hexAgg.equipDamageMult > 0f && (int)info.damageType.damageSource == 64)
			{
				ExtraDamage(attacker, victim, info, hexAgg.equipDamageMult, (DamageType)0);
			}
			if (hexAgg.shredPctOnHit > 0f && IsPrimaryLike(info) && victim.healthComponent.alive)
			{
				ShredMaxHealth(victim, victim.isBoss ? hexAgg.shredPctBoss : hexAgg.shredPctOnHit);
			}
			if (hexAgg.primaryExtraPct > 0f && IsPrimaryLike(info))
			{
				ExtraDamage(attacker, victim, info, hexAgg.primaryExtraPct, (DamageType)0);
			}
			if (hexAgg.markDuration > 0f && IsSkillSource(info) && victim.healthComponent.alive)
			{
				markUntil[victim] = Time.time + hexAgg.markDuration;
			}
			if (hexAgg.castBlastPct > 0f && hexState.impactPending && IsPrimaryLike(info) && Time.time - hexState.castAt <= 10f)
			{
				hexState.impactPending = false;
				float num = 1f + Mathf.Max(0f, attacker.armor) / 100f * ((hexAgg.castBlastArmorScale > 0f) ? hexAgg.castBlastArmorScale : 1f);
				Blast(attacker, victim, hexAgg.castBlastPct * num, (hexAgg.castBlastRadius > 0f) ? hexAgg.castBlastRadius : 6f, 0f);
			}
			if (hexAgg.markBonusPct > 0f && IsPrimaryLike(info) && markUntil.TryGetValue(victim, out var value) && Time.time <= value && Time.time >= hexState.markAt)
			{
				hexState.markAt = Time.time + 0.5f;
				markUntil.Remove(victim);
				ExtraDamage(attacker, victim, info, hexAgg.markBonusPct, (DamageType)0);
				HexRuntime.RefundCooldown(attacker, hexState.castSlot, hexAgg.markCooldownPct);
			}
			if (hexAgg.specialCrit && (int)info.damageType.damageSource == 8 && victim.healthComponent.alive && Random.value < attacker.crit / 100f)
			{
				ExtraDamage(attacker, victim, info, Mathf.Max(0f, attacker.critMultiplier - 1f), (DamageType)0);
			}
			if (hexState.specialBonus > 0f && (int)info.damageType.damageSource == 8)
			{
				float specialBonus = hexState.specialBonus;
				hexState.specialBonus = 0f;
				hexState.specialStacks = 0;
				ExtraDamage(attacker, victim, info, specialBonus, (DamageType)0);
			}
		}
	}

	private static bool IsSkillSource(DamageInfo info)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Invalid comparison between Unknown and I4
		DamageSource damageSource = info.damageType.damageSource;
		if ((int)damageSource != 2 && (int)damageSource != 4)
		{
			return (int)damageSource == 8;
		}
		return true;
	}

	private static bool IsPrimaryLike(DamageInfo info)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		DamageSource damageSource = info.damageType.damageSource;
		if ((int)damageSource != 1)
		{
			return (int)damageSource == 0;
		}
		return true;
	}

	private static void ExtraDamage(CharacterBody attacker, CharacterBody victim, DamageInfo info, float pct, DamageType type = (DamageType)0u)
	{
		//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_0046: 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_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		if (pct <= 0f || (Object)(object)victim == (Object)null || !victim.healthComponent.alive)
		{
			return;
		}
		DamageInfo val = new DamageInfo
		{
			attacker = (((Object)(object)info.attacker != (Object)null) ? info.attacker : ((Component)attacker).gameObject),
			inflictor = info.inflictor,
			damage = info.damage * pct,
			crit = false,
			procCoefficient = 0f,
			damageType = DamageTypeCombo.op_Implicit(type),
			damageColorIndex = (DamageColorIndex)0,
			position = info.position
		};
		applyingExtra = true;
		try
		{
			victim.healthComponent.TakeDamage(val);
		}
		finally
		{
			applyingExtra = false;
		}
	}

	private static void Blast(CharacterBody attacker, CharacterBody victim, float coefficient, float radius, float force)
	{
		//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_001b: 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_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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: 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: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)victim == (Object)null))
		{
			new BlastAttack
			{
				attacker = ((Component)attacker).gameObject,
				inflictor = ((Component)attacker).gameObject,
				teamIndex = (TeamIndex)(((Object)(object)attacker.teamComponent != (Object)null) ? ((int)attacker.teamComponent.teamIndex) : 0),
				position = victim.corePosition,
				radius = radius,
				falloffModel = (FalloffModel)1,
				baseDamage = attacker.damage * coefficient,
				baseForce = force,
				procCoefficient = 0f,
				attackerFiltering = (AttackerFiltering)2
			}.Fire();
		}
	}
}
public static class HexRuntime
{
	private static readonly Dictionary<CharacterBody, float> lastAidTime = new Dictionary<CharacterBody, float>();

	private static float pruneAt;

	private static readonly FieldInfo fFinalRecharge = typeof(GenericSkill).GetField("finalRechargeInterval", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly string[] dragonSouls = new string[4] { "InfernalSoul", "OceanSoul", "MountainSoul", "HextechSoul" };

	public const string DragonEggId = "AncientDragonSoul";

	private static void Heal(CharacterBody body, float amount)
	{
		if (!((Object)(object)body == (Object)null) && !(amount <= 0f))
		{
			HealthComponent healthComponent = body.healthComponent;
			if (!((Object)(object)healthComponent == (Object)null))
			{
				healthComponent.health = Mathf.Min(healthComponent.health + amount, body.maxHealth);
			}
		}
	}

	private static void AddShield(HexState state, CharacterBody body, float amount)
	{
		if (state != null && !((Object)(object)body == (Object)null) && !(amount <= 0f))
		{
			HealthComponent healthComponent = body.healthComponent;
			if (!((Object)(object)healthComponent == (Object)null))
			{
				state.bonusShield += amount;
				body.RecalculateStats();
				healthComponent.shield = Mathf.Min(healthComponent.shield + amount, Mathf.Max(body.maxShield, healthComponent.shield + amount));
			}
		}
	}

	private static GenericSkill SkillAt(CharacterBody body, int slot)
	{
		if ((Object)(object)body == (Object)null)
		{
			return null;
		}
		SkillLocator skillLocator = body.skillLocator;
		if ((Object)(object)skillLocator == (Object)null)
		{
			return null;
		}
		return (GenericSkill)(slot switch
		{
			0 => skillLocator.primary, 
			1 => skillLocator.secondary, 
			2 => skillLocator.utility, 
			3 => skillLocator.special, 
			_ => null, 
		});
	}

	private static float RechargeInterval(GenericSkill skill)
	{
		if (fFinalRecharge == null || (Object)(object)skill == (Object)null)
		{
			return 1f;
		}
		object value = fFinalRecharge.GetValue(skill);
		float num = ((value is float) ? ((float)value) : 1f);
		if (!(num > 0.01f))
		{
			return 1f;
		}
		return num;
	}

	public static void RefundCooldown(CharacterBody body, int slot, float pct)
	{
		if (!(pct <= 0f))
		{
			GenericSkill val = SkillAt(body, slot);
			if (!((Object)(object)val == (Object)null) && val.stock <= 0)
			{
				float num = RechargeInterval(val);
				val.rechargeStopwatch = Mathf.Max(0f, val.rechargeStopwatch - num * pct);
			}
		}
	}

	public static void ResetSkill(CharacterBody body, int slot)
	{
		GenericSkill val = SkillAt(body, slot);
		if (!((Object)(object)val == (Object)null))
		{
			val.rechargeStopwatch = RechargeInterval(val);
		}
	}

	private static void WatchSkills(HexState state, CharacterBody body)
	{
		if ((Object)(object)(((Object)(object)body != (Object)null) ? body.skillLocator : null) == (Object)null)
		{
			return;
		}
		for (int i = 0; i < 4; i++)
		{
			GenericSkill val = SkillAt(body, i);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			float rechargeStopwatch = val.rechargeStopwatch;
			int stock = val.stock;
			if (!state.castWatchInit)
			{
				state.lastStock[i] = stock;
				state.lastRecharge[i] = rechargeStopwatch;
				continue;
			}
			bool num = stock < state.lastStock[i] || (rechargeStopwatch < state.lastRecharge[i] - 0.02f && stock <= state.lastStock[i]);
			state.lastStock[i] = stock;
			state.lastRecharge[i] = rechargeStopwatch;
			if (num)
			{
				state.castAt = Time.time;
				state.castSlot = i;
			}
		}
		state.castWatchInit = true;
		HexAgg hexAgg = HexAggs.Get(state);
		if (hexAgg != null && hexAgg.castBlastPct > 0f)
		{
			state.impactPending = true;
		}
	}

	public static void Tick(HexState state, CharacterBody body)
	{
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0283: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: 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_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: 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_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Expected O, but got Unknown
		if (state == null || (Object)(object)body == (Object)null)
		{
			return;
		}
		WatchSkills(state, body);
		if (Time.time >= pruneAt)
		{
			pruneAt = Time.time + 5f;
			HexOnHit.PruneShred();
		}
		HexAgg hexAgg = HexAggs.Get(state);
		if (hexAgg == null)
		{
			return;
		}
		if (hexAgg.rescueHealPct > 0f)
		{
			HealthComponent healthComponent = body.healthComponent;
			if ((Object)(object)healthComponent != (Object)null && healthComponent.alive && body.maxHealth > 0f && healthComponent.health / body.maxHealth < ((hexAgg.lowHealthThreshold > 0f) ? hexAgg.lowHealthThreshold : 0.3f) && Time.time >= state.rescueAt)
			{
				state.rescueAt = Time.time + ((hexAgg.rescueCooldown > 0f) ? hexAgg.rescueCooldown : 70f);
				new BlastAttack
				{
					attacker = ((Component)body).gameObject,
					inflictor = ((Component)body).gameObject,
					teamIndex = (TeamIndex)(((Object)(object)body.teamComponent != (Object)null) ? ((int)body.teamComponent.teamIndex) : 0),
					position = body.corePosition,
					radius = ((hexAgg.rescueRadius > 0f) ? hexAgg.rescueRadius : 12f),
					falloffModel = (FalloffModel)1,
					baseDamage = 0f,
					baseForce = 700f,
					procCoefficient = 0f,
					attackerFiltering = (AttackerFiltering)2
				}.Fire();
				Heal(body, body.maxHealth * hexAgg.rescueHealPct);
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<color=#9fe6a0>拯救触发:" + Mathf.RoundToInt(hexAgg.rescueHealPct * 100f) + "% 生命回复</color>"
				});
			}
		}
		if (hexAgg.slimeDamagePct > 0f && Time.time >= state.slimeAt)
		{
			state.slimeAt = Time.time + ((hexAgg.slimeSeconds > 0f) ? hexAgg.slimeSeconds : 8f);
			new BlastAttack
			{
				attacker = ((Component)body).gameObject,
				inflictor = ((Component)body).gameObject,
				teamIndex = (TeamIndex)(((Object)(object)body.teamComponent != (Object)null) ? ((int)body.teamComponent.teamIndex) : 0),
				position = body.corePosition,
				radius = ((hexAgg.slimeRadius > 0f) ? hexAgg.slimeRadius : 8f),
				falloffModel = (FalloffModel)1,
				baseDamage = body.damage * hexAgg.slimeDamagePct,
				baseForce = 0f,
				procCoefficient = 0f,
				attackerFiltering = (AttackerFiltering)2
			}.Fire();
		}
	}

	public static void OnKill(HexState state, CharacterBody body)
	{
		if (state == null)
		{
			return;
		}
		foreach (string item in HexStates.Snapshot(state))
		{
			AugmentDef augmentDef = AugmentCatalog.Get(item);
			if (augmentDef == null || augmentDef.fx == null)
			{
				continue;
			}
			AugmentFx fx = augmentDef.fx;
			if (fx.healPctMaxOnKill > 0f && (Object)(object)body != (Object)null)
			{
				Heal(body, body.maxHealth * fx.healPctMaxOnKill);
			}
			if (fx.shieldPctMaxOnKill > 0f && (Object)(object)body != (Object)null)
			{
				HexTemp.Add(body, body.maxHealth * fx.shieldPctMaxOnKill);
			}
			if (fx.cooldownPctOnKill > 0f && (Object)(object)body != (Object)null)
			{
				RefundCooldown(body, 3, fx.cooldownPctOnKill);
			}
			if (fx.specialResetOnKill && (Object)(object)body != (Object)null)
			{
				ResetSkill(body, 3);
				int num = ((fx.specialMaxStacks > 0) ? fx.specialMaxStacks : 3);
				if (state.specialStacks < num)
				{
					state.specialStacks++;
					state.specialBonus += ((fx.specialBonusPerStack > 0f) ? fx.specialBonusPerStack : 0.4f);
				}
			}
			if (fx.eggKills > 0)
			{
				int num2 = state.Counter(item) + 1;
				if (num2 >= fx.eggKills)
				{
					state.SetCounter(item, 0);
					GrantAugment(state, "Prismatic", 1, "棱彩蛋孵化");
				}
				else
				{
					state.SetCounter(item, num2);
				}
			}
		}
	}

	public static void OnKillMoney(HexState state, CharacterBody victim)
	{
		if (state == null || (Object)(object)state.master == (Object)null || (Object)(object)victim == (Object)null)
		{
			return;
		}
		float num = 0f;
		foreach (string item in state.owned)
		{
			AugmentDef augmentDef = AugmentCatalog.Get(item);
			if (augmentDef != null && augmentDef.fx != null)
			{
				num += augmentDef.fx.moneyPctOnKill;
			}
		}
		if (num <= 0f)
		{
			return;
		}
		DeathRewards component = ((Component)victim).GetComponent<DeathRewards>();
		if ((Object)(object)component == (Object)null)
		{
			return;
		}
		float num2 = component.goldReward;
		if (!(num2 <= 0f))
		{
			state.moneyBank += num2 * num;
			int num3 = Mathf.FloorToInt(state.moneyBank);
			if (num3 > 0)
			{
				state.moneyBank -= num3;
				state.master.GiveMoney((uint)num3);
			}
		}
	}

	public static void OnDamaged(HealthComponent hc)
	{
		if ((Object)(object)hc == (Object)null || (Object)(object)hc.body == (Object)null)
		{
			return;
		}
		CharacterBody body = hc.body;
		CharacterMaster master = body.master;
		if ((Object)(object)master == (Object)null)
		{
			return;
		}
		HexState hexState = HexStates.Get(master);
		if (hexState == null)
		{
			return;
		}
		float num = Mathf.Max(0f, body.maxHealth - hc.health);
		if (num <= 0f)
		{
			return;
		}
		float unscaledTime = Time.unscaledTime;
		if (lastAidTime.TryGetValue(body, out var value) && unscaledTime - value < 1f)
		{
			return;
		}
		float num2 = 0f;
		foreach (string item in hexState.owned)
		{
			AugmentDef augmentDef = AugmentCatalog.Get(item);
			if (augmentDef != null && augmentDef.fx != null)
			{
				num2 += augmentDef.fx.healPctMissingOnDamaged;
			}
		}
		if (!(num2 <= 0f))
		{
			lastAidTime[body] = unscaledTime;
			Heal(body, num * Mathf.Min(num2, 1f));
		}
	}

	public static void OnPick(HexState state, AugmentDef def, CharacterBody body)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Expected O, but got Unknown
		if (state == null || def == null || def.fx == null)
		{
			return;
		}
		AugmentFx fx = def.fx;
		if (fx.maxHealthCostPct > 0f)
		{
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<color=#c86f6f>献祭了 " + Mathf.RoundToInt(fx.maxHealthCostPct * 100f) + "% 生命上限</color>"
			});
		}
		if (fx.rerollBonus > 0)
		{
			state.rerollsLeft += fx.rerollBonus;
			SimpleChatMessage val = new SimpleChatMessage();
			val.baseToken = "<color=#7fc8ff>刷新次数 +" + fx.rerollBonus + "(剩余 " + state.rerollsLeft + ")</color>";
			Chat.SendBroadcastChat((ChatMessageBase)(object)val);
		}
		if (fx.upgradeNextCandidates)
		{
			state.upgradeNext = true;
		}
		if ((Object)(object)body != (Object)null && !string.IsNullOrEmpty(fx.grantItemsTier))
		{
			GrantItems(body, fx.grantItemsTier, Mathf.Max(1, fx.grantItemsCount));
		}
		if (fx.pandora)
		{
			Pandora(state);
		}
		if (!string.IsNullOrEmpty(fx.grantAugmentTier))
		{
			GrantAugment(state, fx.grantAugmentTier, Mathf.Max(1, fx.grantAugmentCount), null);
		}
		if (!string.IsNullOrEmpty(fx.sacrificeTier))
		{
			state.SetCounter(def.id, 0);
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<color=#d7b46a>再经过 " + fx.sacrificeStages + " 次传送器事件后恢复上限并兑现</color>"
			});
		}
		if ((Object)(object)body != (Object)null)
		{
			float maxHealth = body.maxHealth;
			body.RecalculateStats();
			float maxHealth2 = body.maxHealth;
			HealthComponent healthComponent = body.healthComponent;
			if ((Object)(object)healthComponent != (Object)null && maxHealth2 > maxHealth)
			{
				healthComponent.health = Mathf.Min(healthComponent.health + (maxHealth2 - maxHealth), maxHealth2);
			}
		}
		RefreshMinions(state);
	}

	private static void RefreshMinions(HexState state)
	{
		CharacterMaster val = state?.master;
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
		for (int i = 0; i < readOnlyInstancesList.Count; i++)
		{
			CharacterBody val2 = readOnlyInstancesList[i];
			if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.master == (Object)null))
			{
				MinionOwnership minionOwnership = val2.master.minionOwnership;
				if (!((Object)(object)minionOwnership == (Object)null) && !((Object)(object)minionOwnership.ownerMaster != (Object)(object)val))
				{
					val2.RecalculateStats();
				}
			}
		}
	}

	public static string EffectiveTier(HexState state, AugmentDef def)
	{
		if (def == null)
		{
			return "Silver";
		}
		return def.tier;
	}

	public static void CheckStage(HexState state)
	{
		//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)
		//IL_011c: Expected O, but got Unknown
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Expected O, but got Unknown
		Run instance = Run.instance;
		if ((Object)(object)instance == (Object)null || state == null)
		{
			return;
		}
		int stageClearCount = instance.stageClearCount;
		if (state.lastStage < 0 || stageClearCount < state.lastStage)
		{
			state.lastStage = stageClearCount;
		}
		else
		{
			if (stageClearCount == state.lastStage)
			{
				return;
			}
			int num = stageClearCount - state.lastStage;
			state.lastStage = stageClearCount;
			foreach (string item in HexStates.Snapshot(state))
			{
				AugmentDef augmentDef = AugmentCatalog.Get(item);
				if (augmentDef == null || augmentDef.fx == null || augmentDef.fx.sacrificeStages <= 0)
				{
					continue;
				}
				int num2 = state.Counter(item);
				if (num2 < 0)
				{
					continue;
				}
				int num3 = num2 + num;
				if (num3 >= augmentDef.fx.sacrificeStages)
				{
					state.SetCounter(item, -1);
					CharacterBody val = (((Object)(object)state.master != (Object)null) ? state.master.GetBody() : null);
					if ((Object)(object)val != (Object)null)
					{
						val.RecalculateStats();
						Heal(val, val.maxHealth);
					}
					Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
					{
						baseToken = "<color=#9fe6a0>献祭兑现:生命上限已恢复</color>"
					});
					int extraPickCount = augmentDef.fx.extraPickCount;
					if (extraPickCount > 0)
					{
						state.bonusPicksLeft += extraPickCount;
						state.bonusPickTier = (string.IsNullOrEmpty(augmentDef.fx.extraPickTier) ? augmentDef.fx.sacrificeTier : augmentDef.fx.extraPickTier);
						Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
						{
							baseToken = "<color=#d7b46a>额外 " + extraPickCount + " 次海克斯选择,选择界面马上弹出</color>"
						});
					}
					else
					{
						GrantAugment(state, augmentDef.fx.sacrificeTier, 1, "献祭兑现");
					}
				}
				else
				{
					state.SetCounter(item, num3);
				}
			}
		}
	}

	public static void GiveGold(HexState state, uint amount)
	{
		//IL_0021: 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_0047: Expected O, but got Unknown
		if (state != null && !((Object)(object)state.master == (Object)null) && amount != 0)
		{
			state.master.GiveMoney(amount);
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<color=#ffd479>获得 " + amount + " 金币</color>"
			});
		}
	}

	public static void GrantItems(CharacterBody body, string tier, int count)
	{
		//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)
		//IL_0082: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result ty