Decompiled source of FaintAnimeUtilities v0.1.0

FaintAnimeUtilities.dll

Decompiled 20 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.BlendableTypes;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace FaintAnimeUtilities
{
	public class EnergyController : MonoBehaviour
	{
		private static readonly float[] BonusPerExtraStock = new float[4] { 10f, 15f, 40f, 80f };

		private CharacterBody body;

		private SkillLocator skills;

		private FighterSurvivor survivor;

		private FormController formController;

		private bool initialised;

		public float Current { get; private set; }

		public float Max { get; private set; } = 100f;

		public float Ratio => (Max > 0f) ? (Current / Max) : 0f;

		public bool Charging { get; set; }

		public float ChargePerSecond { get; set; }

		public float ExtraRegenPerSecond { get; set; }

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			skills = ((Component)this).GetComponent<SkillLocator>();
			formController = ((Component)this).GetComponent<FormController>();
		}

		private void Start()
		{
			FighterIdentity component = ((Component)this).GetComponent<FighterIdentity>();
			survivor = (Object.op_Implicit((Object)(object)component) ? component.Survivor : null);
			RecalculateMax();
			Current = Max;
			initialised = true;
		}

		private void Update()
		{
			if (initialised && Object.op_Implicit((Object)(object)body))
			{
				RecalculateMax();
				if (body.hasEffectiveAuthority)
				{
					Add(GetRegenPerSecond() * Time.deltaTime);
				}
			}
		}

		public float GetRegenPerSecond()
		{
			float num = ((survivor != null) ? survivor.EnergyRegenPerSecond : 1f) + ExtraRegenPerSecond;
			if (survivor != null)
			{
				num += MasteryController.GetBonusEnergyRegen(body, survivor.Forms);
			}
			FormDef formDef = (Object.op_Implicit((Object)(object)formController) ? formController.CurrentForm : null);
			if (formDef != null)
			{
				num += formDef.energyRegenBonus;
			}
			return num;
		}

		public void Add(float amount)
		{
			if (!(amount < 0f) || FaintAnimeUtilitiesPlugin.KiDrain == null || FaintAnimeUtilitiesPlugin.KiDrain.Value)
			{
				Current = Mathf.Clamp(Current + amount, 0f, Max);
			}
		}

		private void RecalculateMax()
		{
			float num = ((survivor != null) ? survivor.BaseMaxEnergy : 100f);
			if (survivor != null && Object.op_Implicit((Object)(object)body))
			{
				num += survivor.MaxEnergyPerLevel * Mathf.Max(0f, body.level - 1f);
				num += MasteryController.GetBonusMaxEnergy(body, survivor.Forms);
			}
			if (Object.op_Implicit((Object)(object)skills))
			{
				GenericSkill[] array = (GenericSkill[])(object)new GenericSkill[4] { skills.primary, skills.secondary, skills.utility, skills.special };
				for (int i = 0; i < array.Length; i++)
				{
					if (Object.op_Implicit((Object)(object)array[i]))
					{
						num += BonusPerExtraStock[i] * (float)Mathf.Max(0, array[i].maxStock - 1);
					}
				}
			}
			Max = Mathf.Max(1f, num);
			if (Current > Max)
			{
				Current = Max;
			}
		}
	}
	public class FighterHud : MonoBehaviour
	{
		private class Bar
		{
			public GameObject root;

			public RectTransform fill;

			public Image fillImage;

			public Text label;

			public Text rightLabel;
		}

		private class Portrait
		{
			public Sprite silhouette;

			public Sprite outline;

			public Func<float> ratio;

			public Func<Color> color;

			public Func<bool> pulse;

			public Func<string> label;

			public RectTransform root;

			public Image fill;

			public Text text;
		}

		private const float RightSkew = 6f;

		private readonly List<Portrait> portraits = new List<Portrait>();

		private readonly List<GameObject> createdObjects = new List<GameObject>();

		private CharacterBody body;

		private EnergyController energy;

		private FormController forms;

		private MasteryController mastery;

		private FlightController flight;

		private EntityStateMachine bodyMachine;

		private FighterSurvivor survivor;

		private HUD hud;

		private bool built;

		private float searchTimer;

		private Bar energyBar;

		private GameObject formPanel;

		private Text levelNumber;

		private Text formName;

		private Bar masteryBar;

		private Bar infoBar;

		private Text ultimateKeyText;

		private Image ultimateIcon;

		private Text ultimateCost;

		private Text noticeText;

		private float noticeTimer;

		private static Font font;

		private static Font HudFont => Object.op_Implicit((Object)(object)font) ? font : (font = Resources.GetBuiltinResource<Font>("Arial.ttf"));

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			energy = ((Component)this).GetComponent<EnergyController>();
			forms = ((Component)this).GetComponent<FormController>();
			mastery = ((Component)this).GetComponent<MasteryController>();
			flight = ((Component)this).GetComponent<FlightController>();
			bodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
		}

		private void Start()
		{
			FighterIdentity component = ((Component)this).GetComponent<FighterIdentity>();
			survivor = (Object.op_Implicit((Object)(object)component) ? component.Survivor : null);
		}

		public void AddPortraitMeter(Sprite silhouette, Sprite outline, Func<float> ratio, Func<Color> color, Func<bool> pulse = null, Func<string> label = null)
		{
			portraits.Add(new Portrait
			{
				silhouette = silhouette,
				outline = outline,
				ratio = ratio,
				color = color,
				pulse = pulse,
				label = label
			});
			built = false;
			ClearCreated();
		}

		public void ShowNotice(string text, float duration = 2.5f)
		{
			if (Object.op_Implicit((Object)(object)noticeText))
			{
				noticeText.text = text;
			}
			noticeTimer = duration;
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)body) || !body.hasEffectiveAuthority || !FaintAnimeUtilitiesPlugin.ShowHud.Value || (built && (!Object.op_Implicit((Object)(object)hud) || (Object)(object)hud.targetBodyObject != (Object)(object)((Component)this).gameObject)))
			{
				SetVisible(visible: false);
				return;
			}
			if (!built)
			{
				searchTimer -= Time.unscaledDeltaTime;
				if (searchTimer > 0f)
				{
					return;
				}
				searchTimer = 0.5f;
				TryBuild();
				if (!built)
				{
					return;
				}
			}
			SetVisible(visible: true);
			Refresh();
		}

		private void OnDestroy()
		{
			ClearCreated();
		}

		private void TryBuild()
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Expected O, but got Unknown
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Expected O, but got Unknown
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Unknown result type (might be due to invalid IL or missing references)
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0586: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			hud = null;
			HUD[] array = Object.FindObjectsOfType<HUD>();
			foreach (HUD val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && (Object)(object)val.targetBodyObject == (Object)(object)((Component)this).gameObject)
				{
					hud = val;
				}
			}
			if (!Object.op_Implicit((Object)(object)hud))
			{
				return;
			}
			Transform val2 = FighterUtil.FindDeep(((Component)hud).transform, "BarRoots");
			Transform val3 = FighterUtil.FindDeep(((Component)hud).transform, "BottomRightCluster");
			if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
			{
				return;
			}
			ClearCreated();
			float value = FaintAnimeUtilitiesPlugin.HudScale.Value;
			Color color = ((survivor != null) ? survivor.EnergyColor : Color.cyan);
			GameObject val4 = new GameObject("FighterLeftBars", new Type[1] { typeof(RectTransform) });
			createdObjects.Add(val4);
			RectTransform val5 = (RectTransform)val4.transform;
			((Transform)val5).SetParent(val2, false);
			val4.AddComponent<LayoutElement>().ignoreLayout = true;
			val5.anchorMin = new Vector2(0f, 0f);
			val5.anchorMax = new Vector2(1f, 0f);
			val5.pivot = new Vector2(0.5f, 1f);
			val5.offsetMin = new Vector2(22f * value, 0f);
			val5.offsetMax = new Vector2(-22f * value, 0f);
			val5.anchoredPosition = new Vector2(0f, -4f * value);
			float num = 0f;
			energyBar = CreateBar((Transform)(object)val5, "FighterKiBar", color, 17, 13);
			PlaceRow(energyBar, num, 26f * value);
			num += 30f * value;
			val5.sizeDelta = new Vector2(val5.sizeDelta.x, num);
			float num2 = 0f;
			Vector2 val7 = default(Vector2);
			Rect r = default(Rect);
			foreach (Portrait portrait in portraits)
			{
				RectTransform val6 = CreateFrame(val2, "FighterPortraitMeter", new Rect(0f, 0f, 74f, 112f), value);
				((Component)val6).gameObject.AddComponent<LayoutElement>().ignoreLayout = true;
				val7 = (val6.anchorMin = (val6.anchorMax = new Vector2(0f, 1f)));
				val6.pivot = new Vector2(0f, 0f);
				val6.anchoredPosition = new Vector2(num2, 34f * value);
				num2 += 80f * value;
				portrait.root = val6;
				((Rect)(ref r))..ctor(6f * value, 18f * value, 62f * value, 88f * value);
				Image val10 = CreateImage((Transform)(object)val6, "Silhouette", r, new Color(0.18f, 0.18f, 0.2f, 0.95f));
				val10.sprite = portrait.silhouette;
				val10.preserveAspect = true;
				portrait.fill = CreateImage((Transform)(object)val6, "Fill", r, Color.red);
				portrait.fill.sprite = portrait.silhouette;
				portrait.fill.preserveAspect = true;
				portrait.fill.type = (Type)3;
				portrait.fill.fillMethod = (FillMethod)1;
				portrait.fill.fillOrigin = 0;
				portrait.fill.fillAmount = 0f;
				if (Object.op_Implicit((Object)(object)portrait.outline))
				{
					Image val11 = CreateImage((Transform)(object)val6, "Outline", r, new Color(1f, 1f, 1f, 0.9f));
					val11.sprite = portrait.outline;
					val11.preserveAspect = true;
				}
				portrait.text = CreateText((Transform)(object)val6, "Label", 11, (TextAnchor)4, (Rect?)new Rect(0f, 3f * value, 74f * value, 15f * value));
			}
			formPanel = new GameObject("FighterFormPanel", new Type[1] { typeof(RectTransform) });
			createdObjects.Add(formPanel);
			RectTransform val12 = (RectTransform)formPanel.transform;
			((Transform)val12).SetParent(val3, false);
			((Vector2)(ref val7))..ctor(1f, 1f);
			val12.anchorMax = val7;
			val12.anchorMin = val7;
			val12.pivot = new Vector2(1f, 0f);
			val12.sizeDelta = new Vector2(450f, 84f) * value;
			val12.anchoredPosition = new Vector2(-20f * value, 24f * value);
			((Transform)val12).rotation = Quaternion.Euler(0f, 6f, 0f);
			formPanel.AddComponent<LayoutElement>().ignoreLayout = true;
			RectTransform parent = CreateFrame((Transform)(object)val12, "LevelBox", new Rect(0f, 0f, 88f, 84f), value);
			CreateText((Transform)(object)parent, "LevelLabel", 14, (TextAnchor)1, (Rect?)new Rect(0f, 62f * value, 88f * value, 20f * value)).text = "Level";
			levelNumber = CreateText((Transform)(object)parent, "LevelNumber", 40, (TextAnchor)4, (Rect?)new Rect(0f, 8f * value, 88f * value, 52f * value));
			masteryBar = CreateBar((Transform)(object)parent, "MasteryBar", Color.white, 0, 0);
			PlaceAt(masteryBar, new Rect(6f * value, 5f * value, 76f * value, 5f * value));
			RectTransform parent2 = CreateFrame((Transform)(object)val12, "FormNameRow", new Rect(94f, 44f, 276f, 40f), value);
			formName = CreateText((Transform)(object)parent2, "FormName", 19, (TextAnchor)4, null);
			infoBar = CreateBar((Transform)(object)val12, "InfoRow", Color.white, 15, 0);
			PlaceAt(infoBar, new Rect(94f * value, 0f, 276f * value, 38f * value));
			ultimateKeyText = CreateText((Transform)(object)val12, "UltimateKey", 18, (TextAnchor)7, (Rect?)new Rect(382f * value, 86f * value, 68f * value, 22f * value));
			RectTransform parent3 = CreateFrame((Transform)(object)val12, "UltimateSlot", new Rect(382f, 4f, 68f, 68f), value);
			ultimateIcon = CreateImage((Transform)(object)parent3, "UltimateIcon", new Rect(6f * value, 6f * value, 56f * value, 56f * value), Color.clear);
			ultimateCost = CreateText((Transform)(object)parent3, "UltimateCost", 12, (TextAnchor)8, (Rect?)new Rect(0f, 2f * value, 64f * value, 16f * value));
			noticeText = CreateText((Transform)(object)val12, "Notice", 20, (TextAnchor)7, (Rect?)new Rect(0f, 110f * value, 370f * value, 28f * value));
			((Graphic)noticeText).color = new Color(1f, 0.85f, 0.4f);
			noticeText.text = "";
			built = true;
		}

		private Bar CreateBar(Transform parent, string name, Color color, int labelSize, int rightSize)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0059: 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_008a: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a3: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			createdObjects.Add(val);
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(parent, false);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(0f, 0f, 0f, 0.6f);
			((Graphic)val3).raycastTarget = false;
			GameObject val4 = new GameObject("Fill", new Type[1] { typeof(RectTransform) });
			RectTransform val5 = (RectTransform)val4.transform;
			((Transform)val5).SetParent((Transform)(object)val2, false);
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val5.offsetMin = new Vector2(2f, 2f);
			val5.offsetMax = new Vector2(-2f, -2f);
			Image val6 = val4.AddComponent<Image>();
			((Graphic)val6).color = color;
			((Graphic)val6).raycastTarget = false;
			Bar bar = new Bar
			{
				root = val,
				fill = val5,
				fillImage = val6
			};
			if (labelSize > 0)
			{
				bar.label = CreateText((Transform)(object)val2, "Label", labelSize, (TextAnchor)4, null);
			}
			if (rightSize > 0)
			{
				bar.rightLabel = CreateText((Transform)(object)val2, "RightLabel", rightSize, (TextAnchor)5, null);
			}
			return bar;
		}

		private static void PlaceRow(Bar bar, float y, float height)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)bar.root.transform;
			val.anchorMin = new Vector2(0f, 1f);
			val.anchorMax = new Vector2(1f, 1f);
			val.pivot = new Vector2(0.5f, 1f);
			val.anchoredPosition = new Vector2(0f, 0f - y);
			val.sizeDelta = new Vector2(0f, height);
		}

		private static void PlaceAt(Bar bar, Rect r)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)bar.root.transform;
			Vector2 anchorMin = (val.anchorMax = Vector2.zero);
			val.anchorMin = anchorMin;
			val.pivot = Vector2.zero;
			val.anchoredPosition = new Vector2(((Rect)(ref r)).x, ((Rect)(ref r)).y);
			val.sizeDelta = new Vector2(((Rect)(ref r)).width, ((Rect)(ref r)).height);
		}

		private RectTransform CreateFrame(Transform parent, string name, Rect r, float scale)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			Image val = CreateImage(parent, name, new Rect(((Rect)(ref r)).x * scale, ((Rect)(ref r)).y * scale, ((Rect)(ref r)).width * scale, ((Rect)(ref r)).height * scale), new Color(0.45f, 0.45f, 0.48f, 0.9f));
			CreateImage(((Component)val).transform, "Inner", new Rect(3f * scale, 3f * scale, (((Rect)(ref r)).width - 6f) * scale, (((Rect)(ref r)).height - 6f) * scale), new Color(0.04f, 0.04f, 0.05f, 0.92f));
			return (RectTransform)((Component)val).transform;
		}

		private Image CreateImage(Transform parent, string name, Rect r, Color color)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(parent, false);
			Vector2 anchorMin = (val2.anchorMax = Vector2.zero);
			val2.anchorMin = anchorMin;
			val2.pivot = Vector2.zero;
			val2.anchoredPosition = new Vector2(((Rect)(ref r)).x, ((Rect)(ref r)).y);
			val2.sizeDelta = new Vector2(((Rect)(ref r)).width, ((Rect)(ref r)).height);
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = color;
			((Graphic)val3).raycastTarget = false;
			return val3;
		}

		private Text CreateText(Transform parent, string name, int fontSize, TextAnchor anchor, Rect? placement)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_00a4: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent(parent, false);
			if (placement.HasValue)
			{
				Rect value = placement.Value;
				Vector2 anchorMin = (val2.anchorMax = Vector2.zero);
				val2.anchorMin = anchorMin;
				val2.pivot = Vector2.zero;
				val2.anchoredPosition = new Vector2(((Rect)(ref value)).x, ((Rect)(ref value)).y);
				val2.sizeDelta = new Vector2(((Rect)(ref value)).width, ((Rect)(ref value)).height);
			}
			else
			{
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = new Vector2(6f, 0f);
				val2.offsetMax = new Vector2(-6f, 0f);
			}
			Text val3 = val.AddComponent<Text>();
			val3.font = HudFont;
			val3.fontSize = Mathf.Max(8, Mathf.RoundToInt((float)fontSize * FaintAnimeUtilitiesPlugin.HudScale.Value));
			val3.fontStyle = (FontStyle)1;
			val3.alignment = anchor;
			((Graphic)val3).color = Color.white;
			((Graphic)val3).raycastTarget = false;
			val3.horizontalOverflow = (HorizontalWrapMode)0;
			val3.verticalOverflow = (VerticalWrapMode)1;
			val3.resizeTextForBestFit = true;
			val3.resizeTextMinSize = 8;
			val3.resizeTextMaxSize = val3.fontSize;
			Outline val4 = val.AddComponent<Outline>();
			((Shadow)val4).effectColor = new Color(0f, 0f, 0f, 0.8f);
			return val3;
		}

		private void Refresh()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)energy) && energyBar != null)
			{
				SetFill(energyBar, energy.Ratio);
				energyBar.label.text = $"{energy.Current:0} / {energy.Max:0}";
				float netEnergyPerSecond = GetNetEnergyPerSecond();
				energyBar.rightLabel.text = string.Format("{0}{1:0.0}/s", (netEnergyPerSecond >= 0f) ? "+" : "", netEnergyPerSecond);
				((Graphic)energyBar.rightLabel).color = (Color)((netEnergyPerSecond >= 0f) ? Color.white : new Color(1f, 0.55f, 0.5f));
			}
			foreach (Portrait portrait in portraits)
			{
				if (Object.op_Implicit((Object)(object)portrait.root))
				{
					portrait.fill.fillAmount = Mathf.Clamp01(portrait.ratio());
					((Graphic)portrait.fill).color = portrait.color();
					float num = ((portrait.pulse != null && portrait.pulse()) ? (1f + 0.06f * Mathf.Sin(Time.unscaledTime * 10f)) : 1f);
					((Transform)portrait.root).localScale = Vector3.one * num;
					portrait.text.text = ((portrait.label != null) ? portrait.label() : "");
				}
			}
			FormDef formDef = (Object.op_Implicit((Object)(object)forms) ? forms.CurrentForm : null);
			if (formDef != null && Object.op_Implicit((Object)(object)formName))
			{
				formName.text = formDef.displayName;
				((Graphic)formName).color = formDef.color;
				if (Object.op_Implicit((Object)(object)mastery))
				{
					levelNumber.text = MasteryController.GetLevel(body, formDef).ToString();
					SetFill(masteryBar, mastery.CurrentFormProgress);
					((Graphic)masteryBar.fillImage).color = formDef.color;
					int levelsNeeded;
					FormDef nextLockedForm = mastery.GetNextLockedForm(out levelsNeeded);
					SetFill(infoBar, mastery.CurrentFormProgress);
					((Graphic)infoBar.fillImage).color = new Color(formDef.color.r, formDef.color.g, formDef.color.b, 0.35f);
					infoBar.label.text = ((nextLockedForm != null) ? $"Next: {nextLockedForm.displayName} ({levelsNeeded} Lv)" : "All forms unlocked");
				}
				ultimateKeyText.text = ((object)FaintAnimeUtilitiesPlugin.UltimateKey.Value/*cast due to .constrained prefix*/).ToString();
				if (formDef.ultimateState != null)
				{
					string text = ((survivor != null) ? survivor.EnergyName : "Ki");
					bool flag = Object.op_Implicit((Object)(object)energy) && energy.Current >= formDef.ultimateEnergyCost;
					if (Object.op_Implicit((Object)(object)formDef.ultimateIcon))
					{
						ultimateIcon.sprite = formDef.ultimateIcon;
						((Graphic)ultimateIcon).color = Color.white;
					}
					else
					{
						((Graphic)ultimateIcon).color = formDef.color;
					}
					if (!flag)
					{
						Image obj = ultimateIcon;
						((Graphic)obj).color = ((Graphic)obj).color * new Color(0.4f, 0.4f, 0.4f, 1f);
					}
					ultimateCost.text = $"{formDef.ultimateEnergyCost:0}";
				}
				else
				{
					((Graphic)ultimateIcon).color = Color.clear;
					ultimateCost.text = "";
				}
			}
			if (noticeTimer > 0f)
			{
				noticeTimer -= Time.deltaTime;
				if (noticeTimer <= 0f && Object.op_Implicit((Object)(object)noticeText))
				{
					noticeText.text = "";
				}
			}
		}

		private float GetNetEnergyPerSecond()
		{
			float num = energy.GetRegenPerSecond();
			if (energy.Charging)
			{
				num += energy.ChargePerSecond;
			}
			FormDef formDef = (Object.op_Implicit((Object)(object)forms) ? forms.CurrentForm : null);
			if (formDef != null && !formDef.IsBaseForm && !energy.Charging)
			{
				num -= formDef.energyDrainPerSecond * MasteryController.GetDrainMult(body, formDef) * FaintAnimeUtilitiesPlugin.FormEnergyDrainMult.Value;
			}
			if (Object.op_Implicit((Object)(object)flight) && Object.op_Implicit((Object)(object)bodyMachine) && bodyMachine.state is FlightState)
			{
				num -= flight.DrainPerSecond * (body.isSprinting ? 2.5f : 1f);
			}
			return num;
		}

		private static void SetFill(Bar bar, float ratio)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (bar != null && Object.op_Implicit((Object)(object)bar.fill))
			{
				bar.fill.anchorMax = new Vector2(Mathf.Clamp01(ratio), 1f);
			}
		}

		private void SetVisible(bool visible)
		{
			foreach (GameObject createdObject in createdObjects)
			{
				if (Object.op_Implicit((Object)(object)createdObject) && createdObject.activeSelf != visible)
				{
					createdObject.SetActive(visible);
				}
			}
		}

		private void ClearCreated()
		{
			foreach (GameObject createdObject in createdObjects)
			{
				if (Object.op_Implicit((Object)(object)createdObject))
				{
					Object.Destroy((Object)(object)createdObject);
				}
			}
			createdObjects.Clear();
			energyBar = null;
			formPanel = null;
			built = false;
		}
	}
	public class FighterMenuIntro : MonoBehaviour
	{
		public string animationState;

		public string voiceEvent;

		public float voiceDelay = 0.1f;

		private static readonly Dictionary<string, int> nextLine = new Dictionary<string, int>();

		private uint playingVoice;

		private void OnEnable()
		{
			((MonoBehaviour)this).StartCoroutine(Play());
		}

		private void OnDisable()
		{
			FighterUtil.StopSound(ref playingVoice);
		}

		private IEnumerator Play()
		{
			yield return null;
			Animator animator = ((Component)this).GetComponentInChildren<Animator>();
			if (Object.op_Implicit((Object)(object)animator) && !string.IsNullOrEmpty(animationState))
			{
				int layer = Mathf.Max(0, animator.GetLayerIndex("Body"));
				if (animator.HasState(layer, Animator.StringToHash(animationState)))
				{
					animator.CrossFadeInFixedTime(animationState, 0.2f, layer);
				}
			}
			if (voiceDelay > 0f)
			{
				yield return (object)new WaitForSeconds(voiceDelay);
			}
			playingVoice = FighterUtil.PlayVoice(NextLine(voiceEvent), ((Component)this).gameObject);
		}

		private static string NextLine(string lines)
		{
			if (string.IsNullOrEmpty(lines) || lines.IndexOf('|') < 0)
			{
				return lines;
			}
			string[] array = lines.Split('|');
			nextLine.TryGetValue(lines, out var value);
			nextLine[lines] = (value + 1) % array.Length;
			return array[value % array.Length];
		}
	}
	public class FighterModelController : MonoBehaviour
	{
		private Animator animator;

		private Transform modelTransform;

		private Transform chestBone;

		private Transform hipBone;

		private CharacterMotor motor;

		private Vector3 lastAnimPosition;

		private float smoothSpeed;

		private float airTime;

		private bool animGrounded = true;

		private bool animMoving;

		private Vector3 baseModelScale = Vector3.one;

		private Vector3 chestAim;

		private bool hasChestAim;

		private Vector3 bodyTiltDirection;

		private bool hasBodyTilt;

		private Vector3 smoothTiltDirection;

		private float tiltWeight;

		private float tiltAmount = 0.85f;

		private bool tiltPitchOnly;

		private float currentScale = 1f;

		private float targetScale = 1f;

		private float currentBodySize = 1f;

		private float targetBodySize = 1f;

		private Transform hurtBox;

		private Transform cameraPivot;

		private Vector3 cameraPivotBase;

		private float extraCameraZoom = 1f;

		private float targetCameraRise;

		private float cameraRise;

		private bool holdCameraHeight;

		private float heldCameraBodyY;

		public float modelHeight = 1.8f;

		public float cameraZoom = 1f;

		private CameraTargetParams cameraTargetParams;

		private CharacterCameraParamsData baseCameraData;

		private CameraParamsOverrideHandle cameraHandle;

		private float appliedCameraSize = -1f;

		private float appliedExtraZoom = 1f;

		private Transform leftFoot;

		private Transform rightFoot;

		private int lowerFoot;

		private float lastStepTime = -1f;

		private float lastY;

		private float smoothUpSpeed;

		private bool jumpArmed = true;

		private FighterIdentity identity;

		private static GameObject footstepDust;

		private bool straining;

		private float strainWeight;

		private float formVariant;

		private float targetFormVariant;

		private bool hasFormVariantParameter;

		private EntityStateMachine bodyMachine;

		private int bodyLayer = -1;

		private int gestureLayer = -1;

		private bool wasStunned;

		private float gestureWeight;

		public float BodySize => currentBodySize;

		public float ModelScale => currentScale;

		public string AnimationSuffix { get; private set; } = "";

		private void Start()
		{
			//IL_0014: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			identity = ((Component)this).GetComponent<FighterIdentity>();
			lastY = ((Component)this).transform.position.y;
			ModelLocator component = ((Component)this).GetComponent<ModelLocator>();
			modelTransform = (Object.op_Implicit((Object)(object)component) ? component.modelTransform : null);
			if (!Object.op_Implicit((Object)(object)modelTransform))
			{
				return;
			}
			animator = ((Component)modelTransform).GetComponent<Animator>();
			if (!Object.op_Implicit((Object)(object)animator))
			{
				animator = ((Component)modelTransform).GetComponentInChildren<Animator>();
			}
			if (Object.op_Implicit((Object)(object)animator))
			{
				animator.applyRootMotion = false;
			}
			baseModelScale = modelTransform.localScale;
			hurtBox = FighterUtil.FindDeep(modelTransform, "MainHurtbox");
			cameraPivot = (Object.op_Implicit((Object)(object)component.modelBaseTransform) ? component.modelBaseTransform.Find("CameraPivot") : null);
			if (Object.op_Implicit((Object)(object)cameraPivot))
			{
				cameraPivotBase = cameraPivot.localPosition;
			}
			cameraTargetParams = ((Component)this).GetComponent<CameraTargetParams>();
			if (Object.op_Implicit((Object)(object)cameraTargetParams) && Object.op_Implicit((Object)(object)cameraTargetParams.cameraParams))
			{
				baseCameraData = cameraTargetParams.cameraParams.data;
			}
			else
			{
				cameraTargetParams = null;
			}
			if (Object.op_Implicit((Object)(object)animator))
			{
				AnimatorControllerParameter[] parameters = animator.parameters;
				foreach (AnimatorControllerParameter val in parameters)
				{
					if (val.name == "formVariant")
					{
						hasFormVariantParameter = true;
					}
				}
				bodyLayer = animator.GetLayerIndex("Body");
				gestureLayer = animator.GetLayerIndex("Gesture");
			}
			bodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
			motor = ((Component)this).GetComponent<CharacterMotor>();
			lastAnimPosition = ((Component)this).transform.position;
			if (Object.op_Implicit((Object)(object)animator) && animator.isHuman)
			{
				chestBone = animator.GetBoneTransform((HumanBodyBones)8);
				hipBone = animator.GetBoneTransform((HumanBodyBones)0);
				leftFoot = animator.GetBoneTransform((HumanBodyBones)5);
				rightFoot = animator.GetBoneTransform((HumanBodyBones)6);
			}
			if (!Object.op_Implicit((Object)(object)footstepDust))
			{
				footstepDust = LegacyResourcesAPI.Load<GameObject>("Prefabs/GenericFootstepDust");
			}
			HideAllFormParts();
		}

		public Transform GetBone(HumanBodyBones bone)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)animator) || !animator.isHuman)
			{
				return null;
			}
			return animator.GetBoneTransform(bone);
		}

		public void SetChestAim(Vector3 direction)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			chestAim = ((Vector3)(ref direction)).normalized;
			hasChestAim = ((Vector3)(ref direction)).sqrMagnitude > 0.0001f;
		}

		public void SetExtraCameraZoom(float zoom)
		{
			extraCameraZoom = Mathf.Max(1f, zoom);
		}

		public void SetCameraRise(float metres)
		{
			targetCameraRise = Mathf.Max(0f, metres);
		}

		public void HoldCameraHeight(float bodyY)
		{
			holdCameraHeight = true;
			heldCameraBodyY = bodyY;
		}

		public void ReleaseCameraHeight()
		{
			holdCameraHeight = false;
		}

		public void ClearChestAim()
		{
			hasChestAim = false;
		}

		public void SetStraining(bool on)
		{
			straining = on;
		}

		public void SetBodyTilt(Vector3 direction, float amount = 0.85f, bool pitchOnly = false)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			bodyTiltDirection = direction;
			tiltAmount = amount;
			tiltPitchOnly = pitchOnly;
			hasBodyTilt = ((Vector3)(ref direction)).sqrMagnitude > 0.001f;
		}

		public void ClearBodyTilt()
		{
			hasBodyTilt = false;
		}

		public void SetForm(FormDef form)
		{
			targetScale = form?.modelScale ?? 1f;
			targetBodySize = form?.bodySize ?? 1f;
			AnimationSuffix = ((form != null && form.animationSuffix != null) ? form.animationSuffix : "");
			targetFormVariant = form?.animationVariant ?? 0f;
			if (Object.op_Implicit((Object)(object)modelTransform))
			{
				ApplyFormParts(modelTransform, (form != null) ? form.abbreviation : "BASE");
			}
		}

		private void HideAllFormParts()
		{
			ApplyFormParts(modelTransform, "BASE");
		}

		public static void ApplyFormParts(Transform modelRoot, string abbreviation)
		{
			if (!Object.op_Implicit((Object)(object)modelRoot))
			{
				return;
			}
			List<Transform> list = new List<Transform>();
			bool flag = false;
			Transform[] componentsInChildren = ((Component)modelRoot).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.StartsWith("Form_"))
				{
					list.Add(val);
					if (ListsForm(((Object)val).name, abbreviation))
					{
						flag = true;
					}
				}
			}
			string abbreviation2 = (flag ? abbreviation : "BASE");
			foreach (Transform item in list)
			{
				((Component)item).gameObject.SetActive(ListsForm(((Object)item).name, abbreviation2));
			}
		}

		private static bool ListsForm(string objectName, string abbreviation)
		{
			string[] array = objectName.Substring("Form_".Length).Split('+');
			foreach (string text in array)
			{
				if (text.Trim() == abbreviation)
				{
					return true;
				}
			}
			return false;
		}

		private void Update()
		{
			//IL_0040: 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_0050: 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_005d: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)animator) || !Object.op_Implicit((Object)(object)motor))
			{
				return;
			}
			float num = Mathf.Max(Time.deltaTime, 0.0001f);
			Vector3 val = ((Component)this).transform.position - lastAnimPosition;
			lastAnimPosition = ((Component)this).transform.position;
			val.y = 0f;
			smoothSpeed = Mathf.Lerp(smoothSpeed, ((Vector3)(ref val)).magnitude / num, 1f - Mathf.Exp(-12f * num));
			float magnitude = smoothSpeed;
			if (motor.hasEffectiveAuthority)
			{
				Vector3 val2 = new Vector3(motor.velocity.x, 0f, motor.velocity.z);
				magnitude = ((Vector3)(ref val2)).magnitude;
			}
			animMoving = (animMoving ? (magnitude > 0.4f) : (magnitude > 1f));
			if (motor.isGrounded)
			{
				airTime = 0f;
				animGrounded = true;
			}
			else
			{
				airTime += num;
				if (airTime > 0.15f || motor.velocity.y > 4f)
				{
					animGrounded = false;
				}
			}
			bool flag = animGrounded;
			animator.SetBool("fighterGrounded", flag);
			animator.SetBool("fighterMoving", flag && animMoving);
			UpdateJump(num);
			if (Object.op_Implicit((Object)(object)bodyMachine) && bodyMachine.state is FighterMainState)
			{
				if (bodyLayer >= 0 && !animator.IsInTransition(bodyLayer))
				{
					AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(bodyLayer);
					if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Flight_Idle") || ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Flight_Forward") || (!((AnimatorStateInfo)(ref currentAnimatorStateInfo)).loop && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime >= 1f) || (flag && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName("Fall")))
					{
						animator.CrossFadeInFixedTime(flag ? "Idle" : "Fall", 0.2f, bodyLayer);
					}
				}
				if (gestureLayer >= 0 && !animator.IsInTransition(gestureLayer))
				{
					AnimatorStateInfo currentAnimatorStateInfo2 = animator.GetCurrentAnimatorStateInfo(gestureLayer);
					if (!((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).IsName("BufferEmpty") && !((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).loop && ((AnimatorStateInfo)(ref currentAnimatorStateInfo2)).normalizedTime >= 1f)
					{
						animator.CrossFadeInFixedTime("BufferEmpty", 0.2f, gestureLayer);
					}
				}
			}
			UpdateGestureWeight(num);
		}

		private void UpdateGestureWeight(float dt)
		{
			//IL_0055: 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_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (gestureLayer >= 0)
			{
				AnimatorStateInfo val;
				bool num;
				if (!animator.IsInTransition(gestureLayer))
				{
					val = animator.GetCurrentAnimatorStateInfo(gestureLayer);
					num = !((AnimatorStateInfo)(ref val)).IsName("BufferEmpty");
				}
				else
				{
					val = animator.GetNextAnimatorStateInfo(gestureLayer);
					num = !((AnimatorStateInfo)(ref val)).IsName("BufferEmpty");
				}
				bool flag = num;
				gestureWeight = Mathf.MoveTowards(gestureWeight, flag ? 1f : 0f, dt / 0.15f);
				animator.SetLayerWeight(gestureLayer, gestureWeight);
			}
		}

		private void UpdateStraining()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			strainWeight = Mathf.MoveTowards(strainWeight, straining ? 1f : 0f, Time.deltaTime * 4f);
			if (strainWeight <= 0f)
			{
				return;
			}
			float t = Time.time;
			Vector3 right = modelTransform.right;
			Vector3 up = modelTransform.up;
			Vector3 forward = modelTransform.forward;
			if (Object.op_Implicit((Object)(object)chestBone))
			{
				chestBone.rotation = Quaternion.AngleAxis(-1.6f * strainWeight * Mathf.Sin(t * 2.5f), right) * chestBone.rotation;
			}
			HumanBodyBones[] array = (HumanBodyBones[])(object)new HumanBodyBones[2]
			{
				(HumanBodyBones)17,
				(HumanBodyBones)18
			};
			int i;
			for (i = 0; i < array.Length; i++)
			{
				Transform bone = GetBone(array[i]);
				if (Object.op_Implicit((Object)(object)bone))
				{
					bone.rotation = Quaternion.AngleAxis(n(0.1f), right) * Quaternion.AngleAxis(n(3.7f), up) * Quaternion.AngleAxis(n(9.2f), forward) * bone.rotation;
				}
			}
			float n(float seed)
			{
				return (Mathf.PerlinNoise(t * 11f, seed + (float)i * 7.3f) - 0.5f) * 2f * 3f * strainWeight;
			}
		}

		private void UpdateFootsteps()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)leftFoot) || !Object.op_Implicit((Object)(object)rightFoot) || !Object.op_Implicit((Object)(object)motor) || !motor.isGrounded || !animGrounded || !animMoving)
			{
				lowerFoot = 0;
				return;
			}
			float num = 0.03f * modelHeight * currentScale * currentBodySize;
			float y = leftFoot.position.y;
			float y2 = rightFoot.position.y;
			if (lowerFoot != 1 && y < y2 - num)
			{
				lowerFoot = 1;
				Footstep(leftFoot);
			}
			else if (lowerFoot != 2 && y2 < y - num)
			{
				lowerFoot = 2;
				Footstep(rightFoot);
			}
		}

		private void Footstep(Transform foot)
		{
			//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)
			if (!(Time.time - lastStepTime < 0.15f))
			{
				lastStepTime = Time.time;
				FighterSurvivor fighterSurvivor = (Object.op_Implicit((Object)(object)identity) ? identity.Survivor : null);
				FighterUtil.PlaySound((fighterSurvivor != null) ? fighterSurvivor.Audio.footstep : "Play_player_footstep", ((Component)this).gameObject);
				if (Object.op_Implicit((Object)(object)foot) && Object.op_Implicit((Object)(object)footstepDust))
				{
					FighterUtil.SpawnLocal(footstepDust, foot.position, Quaternion.identity, 2f);
				}
			}
		}

		private void UpdateJump(float dt)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			float num = (((Component)this).transform.position.y - lastY) / dt;
			lastY = ((Component)this).transform.position.y;
			if (Mathf.Abs(num) > 100f)
			{
				num = 0f;
			}
			smoothUpSpeed = Mathf.Lerp(smoothUpSpeed, num, 1f - Mathf.Exp(-15f * dt));
			float num2 = (motor.hasEffectiveAuthority ? motor.velocity.y : smoothUpSpeed);
			if (num2 < 3f)
			{
				jumpArmed = true;
			}
			else if (jumpArmed && !(num2 < 7f) && Object.op_Implicit((Object)(object)bodyMachine) && bodyMachine.state is FighterMainState)
			{
				jumpArmed = false;
				FighterSurvivor fighterSurvivor = (Object.op_Implicit((Object)(object)identity) ? identity.Survivor : null);
				if (fighterSurvivor != null)
				{
					FighterUtil.PlaySound(fighterSurvivor.Audio.jump, ((Component)this).gameObject);
				}
				if (airTime < 0.1f)
				{
					Footstep(leftFoot);
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: 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_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: 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_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_040e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03da: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)modelTransform))
			{
				return;
			}
			UpdateFootsteps();
			if (!Mathf.Approximately(currentScale, targetScale))
			{
				currentScale = Mathf.MoveTowards(currentScale, targetScale, Time.deltaTime * 0.75f);
				modelTransform.localScale = baseModelScale * currentScale;
			}
			if (!Mathf.Approximately(currentBodySize, targetBodySize))
			{
				currentBodySize = Mathf.MoveTowards(currentBodySize, targetBodySize, Time.deltaTime * 1.5f);
			}
			if (Object.op_Implicit((Object)(object)hurtBox))
			{
				hurtBox.localScale = Vector3.one * currentBodySize;
			}
			if (Object.op_Implicit((Object)(object)cameraPivot))
			{
				cameraPivot.localPosition = cameraPivotBase * (currentBodySize * currentScale);
				cameraRise = Mathf.Lerp(cameraRise, targetCameraRise, 1f - Mathf.Exp(-4f * Time.deltaTime));
				if (holdCameraHeight || cameraRise > 0.001f)
				{
					Vector3 position = cameraPivot.position;
					if (holdCameraHeight)
					{
						position.y += Mathf.Min(0f, heldCameraBodyY - ((Component)this).transform.position.y);
					}
					position.y += cameraRise;
					cameraPivot.position = position;
				}
			}
			UpdateCameraDistance(currentBodySize * currentScale);
			if (hasFormVariantParameter)
			{
				formVariant = Mathf.MoveTowards(formVariant, targetFormVariant, Time.deltaTime * 3f);
				animator.SetFloat("formVariant", formVariant);
			}
			UpdateHitReactions();
			if (hasChestAim && Object.op_Implicit((Object)(object)chestBone))
			{
				Vector3 val = Vector3.ProjectOnPlane(chestAim, Vector3.up);
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					chestBone.rotation = Quaternion.FromToRotation(((Vector3)(ref val)).normalized, chestAim) * chestBone.rotation;
				}
			}
			UpdateStraining();
			float deltaTime = Time.deltaTime;
			tiltWeight = Mathf.MoveTowards(tiltWeight, hasBodyTilt ? 1f : 0f, deltaTime * 5f);
			if (hasBodyTilt)
			{
				smoothTiltDirection = ((((Vector3)(ref smoothTiltDirection)).sqrMagnitude < 0.001f) ? ((Vector3)(ref bodyTiltDirection)).normalized : Vector3.Slerp(smoothTiltDirection, ((Vector3)(ref bodyTiltDirection)).normalized, 1f - Mathf.Exp(-10f * deltaTime)));
			}
			if (tiltWeight > 0f && Object.op_Implicit((Object)(object)hipBone) && ((Vector3)(ref smoothTiltDirection)).sqrMagnitude > 0.001f)
			{
				Vector3 normalized = ((Vector3)(ref smoothTiltDirection)).normalized;
				Quaternion val3;
				if (tiltPitchOnly)
				{
					Vector3 val2 = Vector3.ProjectOnPlane(normalized, Vector3.up);
					if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
					{
						val2 = Vector3.ProjectOnPlane(modelTransform.forward, Vector3.up);
					}
					val3 = Quaternion.Slerp(Quaternion.identity, Quaternion.FromToRotation(((Vector3)(ref val2)).normalized, normalized), tiltAmount);
				}
				else
				{
					Vector3 val4 = Vector3.Slerp(Vector3.up, normalized, tiltAmount);
					val3 = Quaternion.FromToRotation(Vector3.up, val4);
				}
				hipBone.rotation = Quaternion.Slerp(Quaternion.identity, val3, tiltWeight) * hipBone.rotation;
			}
			else if (!hasBodyTilt && tiltWeight <= 0f)
			{
				smoothTiltDirection = Vector3.zero;
			}
		}

		private void UpdateHitReactions()
		{
			if (Object.op_Implicit((Object)(object)animator) && bodyLayer >= 0)
			{
				bool flag = Object.op_Implicit((Object)(object)bodyMachine) && (bodyMachine.state is StunState || bodyMachine.state is ShockState);
				if (flag != wasStunned)
				{
					wasStunned = flag;
					PlayFormState(bodyLayer, flag ? "Stunned" : "Idle");
				}
			}
		}

		private void PlayFormState(int layer, string state)
		{
			int num = Animator.StringToHash(state + AnimationSuffix);
			int num2 = ((AnimationSuffix.Length > 0 && animator.HasState(layer, num)) ? num : Animator.StringToHash(state));
			if (animator.HasState(layer, num2))
			{
				animator.CrossFadeInFixedTime(num2, 0.08f, layer, 0f);
			}
		}

		private void UpdateCameraDistance(float size)
		{
			//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_009b: 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_00a6: 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)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)cameraTargetParams == (Object)null) && (!(appliedCameraSize > 0f) || !(Mathf.Abs(size - appliedCameraSize) < 0.02f) || !(Mathf.Abs(extraCameraZoom - appliedExtraZoom) < 0.02f * appliedExtraZoom)))
			{
				float num = cameraZoom * (1f + (size - 1f) * 0.75f) * extraCameraZoom;
				CharacterCameraParamsData cameraParamsData = baseCameraData;
				cameraParamsData.idealLocalCameraPos = BlendableVector3.op_Implicit(baseCameraData.idealLocalCameraPos.value * num);
				float num2 = ((appliedCameraSize < 0f) ? 0f : 0.4f);
				if (((CameraParamsOverrideHandle)(ref cameraHandle)).isValid)
				{
					cameraTargetParams.RemoveParamsOverride(cameraHandle, num2);
				}
				cameraHandle = cameraTargetParams.AddParamsOverride(new CameraParamsOverrideRequest
				{
					cameraParamsData = cameraParamsData,
					priority = 0f
				}, num2);
				appliedCameraSize = size;
				appliedExtraZoom = extraCameraZoom;
			}
		}

		private void OnDestroy()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)cameraTargetParams) && ((CameraParamsOverrideHandle)(ref cameraHandle)).isValid)
			{
				cameraTargetParams.RemoveParamsOverride(cameraHandle, 0f);
			}
		}
	}
	public class FighterRunMemory : MonoBehaviour
	{
		private readonly HashSet<string> done = new HashSet<string>();

		public static bool FirstTime(CharacterBody body, string key)
		{
			CharacterMaster val = (Object.op_Implicit((Object)(object)body) ? body.master : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return false;
			}
			FighterRunMemory fighterRunMemory = ((Component)val).GetComponent<FighterRunMemory>();
			if (!Object.op_Implicit((Object)(object)fighterRunMemory))
			{
				fighterRunMemory = ((Component)val).gameObject.AddComponent<FighterRunMemory>();
			}
			return fighterRunMemory.done.Add(key);
		}
	}
	public class FighterSkinParts : MonoBehaviour
	{
		public string[] skinIds = new string[0];

		private ModelSkinController skins;

		private readonly List<GameObject> parts = new List<GameObject>();

		private int shown = -1;

		private void Awake()
		{
			skins = ((Component)this).GetComponent<ModelSkinController>();
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.StartsWith("Skin_"))
				{
					parts.Add(((Component)val).gameObject);
				}
			}
			Show(0);
		}

		private void LateUpdate()
		{
			int num = (Object.op_Implicit((Object)(object)skins) ? Mathf.Max(0, skins.currentSkinIndex) : 0);
			if (num != shown)
			{
				Show(num);
			}
		}

		private void Show(int index)
		{
			shown = index;
			if (skinIds.Length == 0)
			{
				return;
			}
			string text = "Skin_" + skinIds[Mathf.Min(index, skinIds.Length - 1)];
			foreach (GameObject part in parts)
			{
				if (Object.op_Implicit((Object)(object)part))
				{
					part.SetActive(((Object)part).name == text);
				}
			}
		}
	}
	public class FighterSkin
	{
		public string id;

		public string name;

		public Sprite icon;
	}
	public class FighterTargetTracker : MonoBehaviour
	{
		public float maxDistance = 22f;

		public float maxAngle = 30f;

		public float refreshInterval = 0.1f;

		private CharacterBody body;

		private InputBankTest input;

		private TeamComponent team;

		private readonly BullseyeSearch search = new BullseyeSearch();

		private Indicator indicator;

		private float timer;

		public HurtBox Target { get; private set; }

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			input = ((Component)this).GetComponent<InputBankTest>();
			team = ((Component)this).GetComponent<TeamComponent>();
		}

		private void Start()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			GameObject val = LegacyResourcesAPI.Load<GameObject>("Prefabs/HuntressTrackingIndicator");
			if (Object.op_Implicit((Object)(object)val))
			{
				indicator = new Indicator(((Component)this).gameObject, val);
			}
		}

		private void OnDisable()
		{
			if (indicator != null)
			{
				indicator.active = false;
			}
		}

		private void FixedUpdate()
		{
			//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_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_00a3: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			if (!Object.op_Implicit((Object)(object)body) || !body.hasEffectiveAuthority || !Object.op_Implicit((Object)(object)input) || !Object.op_Implicit((Object)(object)team))
			{
				return;
			}
			timer -= Time.fixedDeltaTime;
			if (!(timer > 0f))
			{
				timer = refreshInterval;
				Ray aimRay = input.GetAimRay();
				search.teamMaskFilter = TeamMask.all;
				((TeamMask)(ref search.teamMaskFilter)).RemoveTeam(team.teamIndex);
				search.filterByLoS = true;
				search.searchOrigin = ((Ray)(ref aimRay)).origin;
				search.searchDirection = ((Ray)(ref aimRay)).direction;
				search.sortMode = (SortMode)1;
				search.maxDistanceFilter = maxDistance;
				search.maxAngleFilter = maxAngle;
				search.RefreshCandidates();
				search.FilterOutGameObject(((Component)this).gameObject);
				Target = search.GetResults().FirstOrDefault();
				if (indicator != null)
				{
					indicator.targetTransform = (Object.op_Implicit((Object)(object)Target) ? ((Component)Target).transform : null);
					indicator.active = Object.op_Implicit((Object)(object)Target);
				}
			}
		}
	}
	public class FlightController : MonoBehaviour
	{
		public const float FlightDrainPercentPerSecond = 0.02f;

		public const float EmptyKiCooldown = 5f;

		private CharacterBody body;

		private CharacterMotor motor;

		private InputBankTest input;

		private EnergyController energy;

		private EntityStateMachine bodyMachine;

		private FighterSurvivor survivor;

		private float jumpHeldTime;

		private bool needJumpRelease;

		private float cooldown;

		private GameObject hoverEffect;

		private float hoverEffectLinger;

		public float DrainPerSecond => Object.op_Implicit((Object)(object)energy) ? (energy.Max * 0.02f * FaintAnimeUtilitiesPlugin.FlightEnergyDrainMult.Value) : 0f;

		public void RequireJumpRelease()
		{
			needJumpRelease = true;
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			motor = ((Component)this).GetComponent<CharacterMotor>();
			input = ((Component)this).GetComponent<InputBankTest>();
			energy = ((Component)this).GetComponent<EnergyController>();
			bodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
		}

		private void Start()
		{
			FighterIdentity component = ((Component)this).GetComponent<FighterIdentity>();
			survivor = (Object.op_Implicit((Object)(object)component) ? component.Survivor : null);
		}

		public void StartCooldown(float seconds = 5f)
		{
			cooldown = seconds;
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)body) || !body.hasEffectiveAuthority || !Object.op_Implicit((Object)(object)input) || !Object.op_Implicit((Object)(object)motor) || !Object.op_Implicit((Object)(object)bodyMachine))
			{
				return;
			}
			if (cooldown > 0f)
			{
				cooldown -= Time.deltaTime;
			}
			if (input.jump.down)
			{
				jumpHeldTime += Time.deltaTime;
			}
			else
			{
				jumpHeldTime = 0f;
			}
			if (needJumpRelease)
			{
				if (input.jump.down)
				{
					jumpHeldTime = 0f;
				}
				else
				{
					needJumpRelease = false;
				}
			}
			if (jumpHeldTime >= FaintAnimeUtilitiesPlugin.FlightHoldTime.Value && CanStartFlight())
			{
				jumpHeldTime = 0f;
				bodyMachine.SetNextState((EntityState)(object)new FlightState());
			}
			bool hovering = false;
			if (bodyMachine.state is FighterSkillState { allowHover: not false } && input.jump.down && !motor.isGrounded && motor.velocity.y < 0f && Object.op_Implicit((Object)(object)energy) && energy.Current > 0f)
			{
				energy.Add((0f - DrainPerSecond) * Time.deltaTime);
				motor.velocity.y = 0f;
				hovering = true;
			}
			UpdateHoverEffect(hovering);
		}

		private bool CanStartFlight()
		{
			if (cooldown > 0f || !Object.op_Implicit((Object)(object)energy) || energy.Current <= 0f)
			{
				return false;
			}
			return bodyMachine.state is FighterMainState;
		}

		private void UpdateHoverEffect(bool hovering)
		{
			//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)
			if (hovering)
			{
				hoverEffectLinger = 0.1f;
				if (!Object.op_Implicit((Object)(object)hoverEffect) && survivor != null && Object.op_Implicit((Object)(object)survivor.HoverEffect))
				{
					hoverEffect = FighterUtil.SpawnLocal(survivor.HoverEffect, ((Component)this).transform.position, Quaternion.identity, -1f, ((Component)this).transform);
				}
			}
			else if (Object.op_Implicit((Object)(object)hoverEffect))
			{
				hoverEffectLinger -= Time.deltaTime;
				if (hoverEffectLinger <= 0f)
				{
					Object.Destroy((Object)(object)hoverEffect);
					hoverEffect = null;
				}
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)hoverEffect))
			{
				Object.Destroy((Object)(object)hoverEffect);
			}
		}
	}
	[DefaultExecutionOrder(1000)]
	public class FollowerRigDriver : MonoBehaviour
	{
		private class BonePair
		{
			public Transform main;

			public Transform follower;

			public Quaternion mainRest;

			public Quaternion followerRest;

			public int depth;
		}

		private class Rig
		{
			public GameObject root;

			public readonly List<BonePair> pairs = new List<BonePair>();

			public BonePair hips;

			public Vector3 mainHipsRest;

			public Vector3 followerHipsRest;

			public float heightRatio = 1f;
		}

		private readonly List<Rig> rigs = new List<Rig>();

		private void Awake()
		{
			//IL_00d2: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: 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_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			List<Transform> list = new List<Transform>();
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.StartsWith("FollowRig_"))
				{
					list.Add(val);
				}
			}
			if (list.Count == 0)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren2)
			{
				if (!IsInside(val2, list) && !dictionary.ContainsKey(((Object)val2).name))
				{
					dictionary[((Object)val2).name] = val2;
				}
			}
			Quaternion val3 = Quaternion.Inverse(((Component)this).transform.rotation);
			Animator componentInChildren = ((Component)this).GetComponentInChildren<Animator>();
			Transform mainHips = ((Object.op_Implicit((Object)(object)componentInChildren) && componentInChildren.isHuman) ? componentInChildren.GetBoneTransform((HumanBodyBones)0) : null);
			foreach (Transform item in list)
			{
				string text = ((Object)item).name.Substring("FollowRig_".Length) + "_";
				Rig rig = new Rig
				{
					root = ((Component)item).gameObject
				};
				Transform[] componentsInChildren3 = ((Component)item).GetComponentsInChildren<Transform>(true);
				foreach (Transform val4 in componentsInChildren3)
				{
					if (((Object)val4).name.StartsWith(text) && dictionary.TryGetValue(((Object)val4).name.Substring(text.Length), out var value))
					{
						rig.pairs.Add(new BonePair
						{
							main = value,
							follower = val4,
							mainRest = val3 * value.rotation,
							followerRest = val3 * val4.rotation,
							depth = Depth(val4)
						});
					}
				}
				rig.pairs.Sort((BonePair a, BonePair b) => a.depth.CompareTo(b.depth));
				if (rig.pairs.Count > 0)
				{
					rig.hips = rig.pairs.Find((BonePair p) => (Object)(object)p.main == (Object)(object)mainHips) ?? rig.pairs[0];
					rig.mainHipsRest = ((Component)this).transform.InverseTransformPoint(rig.hips.main.position);
					rig.followerHipsRest = ((Component)this).transform.InverseTransformPoint(rig.hips.follower.position);
					if (rig.mainHipsRest.y > 0.1f)
					{
						rig.heightRatio = Mathf.Clamp(rig.followerHipsRest.y / rig.mainHipsRest.y, 0.5f, 2f);
					}
				}
				rigs.Add(rig);
				Log.Info($"{((Object)this).name}: {((Object)item).name} follows {rig.pairs.Count} bones.");
			}
		}

		private static bool IsInside(Transform t, List<Transform> roots)
		{
			Transform val = t;
			while (Object.op_Implicit((Object)(object)val))
			{
				if (roots.Contains(val))
				{
					return true;
				}
				val = val.parent;
			}
			return false;
		}

		private static int Depth(Transform t)
		{
			int num = 0;
			Transform parent = t.parent;
			while (Object.op_Implicit((Object)(object)parent))
			{
				num++;
				parent = parent.parent;
			}
			return num;
		}

		private void LateUpdate()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0082: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			Quaternion rotation = ((Component)this).transform.rotation;
			Quaternion val = Quaternion.Inverse(rotation);
			foreach (Rig rig in rigs)
			{
				if (!Object.op_Implicit((Object)(object)rig.root) || !rig.root.activeInHierarchy || rig.hips == null)
				{
					continue;
				}
				foreach (BonePair pair in rig.pairs)
				{
					Quaternion val2 = val * pair.main.rotation * Quaternion.Inverse(pair.mainRest);
					pair.follower.rotation = rotation * (val2 * pair.followerRest);
				}
				Vector3 val3 = ((Component)this).transform.InverseTransformPoint(rig.hips.main.position) - rig.mainHipsRest;
				rig.hips.follower.position = ((Component)this).transform.TransformPoint(rig.followerHipsRest + val3 * rig.heightRatio);
			}
		}
	}
	public class FormController : MonoBehaviour
	{
		private CharacterBody body;

		private EnergyController energy;

		private FighterModelController modelController;

		private EntityStateMachine bodyMachine;

		private EntityStateMachine weaponMachine;

		private FighterSurvivor survivor;

		private IReadOnlyList<FormDef> forms;

		private IStackablePowerUp[] powerUps = new IStackablePowerUp[0];

		private int appliedFormIndex = -1;

		private GameObject auraInstance;

		private GameObject chargeAura;

		private ParticleSystem[] auraChargeEffects;

		private ParticleSystem[] auraGroundEffects;

		private bool auraCharging;

		private float auraCharge;

		private uint auraSoundId;

		private float lockedMessageCooldown;

		private float transformKeyHeldTime;

		private bool holdTriggered;

		private float powerDownKeyHeldTime;

		private bool powerDownHoldTriggered;

		public static readonly Vector3 ChargedAuraScale = new Vector3(1.6f, 1.08f, 1.6f);

		private const float AuraChangePerSecond = 3f;

		public float StillTime { get; private set; }

		public FormDef CurrentForm => (forms != null && forms.Count > 0) ? forms[CurrentFormIndex] : null;

		public IReadOnlyList<FormDef> Forms => forms;

		public int CurrentFormIndex
		{
			get
			{
				if (forms == null || !Object.op_Implicit((Object)(object)body))
				{
					return 0;
				}
				for (int num = forms.Count - 1; num >= 1; num--)
				{
					if (Object.op_Implicit((Object)(object)forms[num].buffDef) && body.HasBuff(forms[num].buffDef))
					{
						return num;
					}
				}
				return 0;
			}
		}

		public int CurrentStep => FormLineup.GetStep(survivor, CurrentFormIndex);

		public bool AnyPowerUpActive
		{
			get
			{
				IStackablePowerUp[] array = powerUps;
				foreach (IStackablePowerUp stackablePowerUp in array)
				{
					if (stackablePowerUp != null && stackablePowerUp.IsActive)
					{
						return true;
					}
				}
				return false;
			}
		}

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			energy = ((Component)this).GetComponent<EnergyController>();
			modelController = ((Component)this).GetComponent<FighterModelController>();
			bodyMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
			weaponMachine = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Weapon");
		}

		private void Start()
		{
			FighterIdentity component = ((Component)this).GetComponent<FighterIdentity>();
			survivor = (Object.op_Implicit((Object)(object)component) ? component.Survivor : null);
			forms = survivor?.Forms;
			powerUps = ((Component)this).GetComponents<IStackablePowerUp>();
		}

		private void OnDestroy()
		{
			FighterUtil.StopSound(ref auraSoundId);
			if (Object.op_Implicit((Object)(object)auraInstance))
			{
				Object.Destroy((Object)(object)auraInstance);
			}
			if (Object.op_Implicit((Object)(object)chargeAura))
			{
				Object.Destroy((Object)(object)chargeAura);
			}
		}

		private void Update()
		{
			if (forms != null && Object.op_Implicit((Object)(object)body))
			{
				int currentFormIndex = CurrentFormIndex;
				if (currentFormIndex != appliedFormIndex)
				{
					ApplyFormVisuals(currentFormIndex);
				}
				UpdateAuraSize();
				if (body.hasEffectiveAuthority)
				{
					AuthorityUpdate(currentFormIndex);
				}
			}
		}

		private void ApplyFormVisuals(int index)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			appliedFormIndex = index;
			FormDef formDef = forms[index];
			if (Object.op_Implicit((Object)(object)auraInstance))
			{
				Object.Destroy((Object)(object)auraInstance);
			}
			if (Object.op_Implicit((Object)(object)chargeAura))
			{
				Object.Destroy((Object)(object)chargeAura);
			}
			FighterUtil.StopSound(ref auraSoundId);
			if (Object.op_Implicit((Object)(object)formDef.auraEffect))
			{
				auraInstance = Object.Instantiate<GameObject>(formDef.auraEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
				auraInstance.transform.localPosition = Vector3.zero;
				auraChargeEffects = FindChargeEffects(auraInstance, out auraGroundEffects);
			}
			auraSoundId = FighterUtil.PlaySound(formDef.auraLoopSound, ((Component)this).gameObject);
			SfxLocator component = ((Component)this).GetComponent<SfxLocator>();
			if (Object.op_Implicit((Object)(object)component) && survivor != null && !string.IsNullOrEmpty(survivor.DeathSound))
			{
				component.deathSound = survivor.DeathSound + formDef.voiceSuffix;
			}
			if (Object.op_Implicit((Object)(object)modelController))
			{
				modelController.SetForm(formDef);
			}
		}

		public void SetAuraCharging(bool charging)
		{
			auraCharging = charging;
		}

		private void UpdateAuraSize()
		{
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			auraCharge = Mathf.MoveTowards(auraCharge, auraCharging ? 1f : 0f, Time.deltaTime * 3f);
			float num = Mathf.SmoothStep(0f, 1f, auraCharge);
			if (Object.op_Implicit((Object)(object)auraInstance))
			{
				SetAuraSize(auraInstance, Vector3.Lerp(Vector3.one, ChargedAuraScale, num));
				SetChargeEffects(auraCharging);
				return;
			}
			if (auraCharge > 0f && !Object.op_Implicit((Object)(object)chargeAura) && survivor != null && Object.op_Implicit((Object)(object)survivor.BaseChargeAura))
			{
				chargeAura = Object.Instantiate<GameObject>(survivor.BaseChargeAura, ((Component)this).transform.position, ((Component)this).transform.rotation, ((Component)this).transform);
				auraChargeEffects = FindChargeEffects(chargeAura, out auraGroundEffects);
			}
			if (Object.op_Implicit((Object)(object)chargeAura))
			{
				if (auraCharge <= 0f)
				{
					Object.Destroy((Object)(object)chargeAura);
					return;
				}
				SetAuraSize(chargeAura, num * ChargedAuraScale);
				SetChargeEffects(auraCharging);
			}
		}

		private static ParticleSystem[] FindChargeEffects(GameObject aura, out ParticleSystem[] ground)
		{
			Transform val = aura.transform.Find("auraCharge");
			Transform val2 = (Object.op_Implicit((Object)(object)val) ? val.Find("ground") : null);
			ground = (ParticleSystem[])(Object.op_Implicit((Object)(object)val2) ? ((Array)((Component)val2).GetComponentsInChildren<ParticleSystem>()) : ((Array)new ParticleSystem[0]));
			return (ParticleSystem[])(Object.op_Implicit((Object)(object)val) ? ((Array)((Component)val).GetComponentsInChildren<ParticleSystem>()) : ((Array)new ParticleSystem[0]));
		}

		private void SetChargeEffects(bool on)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			bool flag = on && Physics.Raycast(body.footPosition + Vector3.up * 0.5f, Vector3.down, 3f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask));
			Switch(auraChargeEffects, on);
			Switch(auraGroundEffects, flag);
		}

		private static void Switch(ParticleSystem[] effects, bool on)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (effects == null)
			{
				return;
			}
			foreach (ParticleSystem val in effects)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					EmissionModule emission = val.emission;
					((EmissionModule)(ref emission)).enabled = on;
				}
			}
		}

		private void SetAuraSize(GameObject aura, Vector3 scale)
		{
			//IL_000d: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)this).transform.InverseTransformPoint(body.footPosition);
			aura.transform.localScale = scale;
			aura.transform.localPosition = val - Vector3.Scale(val, scale);
		}

		private void AuthorityUpdate(int index)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			FormDef formDef = forms[index];
			lockedMessageCooldown -= Time.deltaTime;
			CharacterMotor characterMotor = body.characterMotor;
			bool flag = Object.op_Implicit((Object)(object)characterMotor) && characterMotor.isGrounded;
			bool flag2 = Object.op_Implicit((Object)(object)body.inputBank) && ((Vector3)(ref body.inputBank.moveVector)).sqrMagnitude < 0.01f;
			int num;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				Vector3 val = new Vector3(characterMotor.velocity.x, 0f, characterMotor.velocity.z);
				num = ((((Vector3)(ref val)).sqrMagnitude < 1f) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag3 = (byte)num != 0;
			StillTime = ((flag && flag2 && flag3) ? (StillTime + Time.deltaTime) : 0f);
			bool flag4 = Object.op_Implicit((Object)(object)bodyMachine) && bodyMachine.state is TransformState;
			if (!formDef.IsBaseForm && !flag4 && Object.op_Implicit((Object)(object)energy) && !energy.Charging && formDef.energyDrainPerSecond > 0f)
			{
				float num2 = formDef.energyDrainPerSecond * MasteryController.GetDrainMult(body, formDef) * FaintAnimeUtilitiesPlugin.FormEnergyDrainMult.Value;
				energy.Add((0f - num2) * Time.deltaTime);
				if (energy.Current <= 0f && formDef.revertWhenEnergyEmpty)
				{
					int num3 = EnergyEmptyTarget(index);
					RequestPowerDown(num3, num3 == 0);
				}
			}
			if (IsGamePaused())
			{
				return;
			}
			bool flag5 = CanUseFormInputs();
			KeyCode value = FaintAnimeUtilitiesPlugin.TransformKey.Value;
			if (Input.GetKey(value))
			{
				transformKeyHeldTime += Time.deltaTime;
				if (!holdTriggered && transformKeyHeldTime >= FaintAnimeUtilitiesPlugin.PowerUpHoldTime.Value)
				{
					holdTriggered = true;
					if (flag5)
					{
						TryActivatePowerUps();
					}
				}
			}
			if (Input.GetKeyUp(value))
			{
				if (!holdTriggered && flag5)
				{
					TryTransformUp(index);
				}
				transformKeyHeldTime = 0f;
				holdTriggered = false;
			}
			KeyCode value2 = FaintAnimeUtilitiesPlugin.PowerDownKey.Value;
			if (Input.GetKey(value2))
			{
				powerDownKeyHeldTime += Time.deltaTime;
				if (!powerDownHoldTriggered && flag5 && powerDownKeyHeldTime >= FaintAnimeUtilitiesPlugin.FullPowerDownHoldTime.Value)
				{
					powerDownHoldTriggered = true;
					RequestPowerDown(0, powerUpsOff: true);
				}
			}
			if (Input.GetKeyUp(value2))
			{
				if (!powerDownHoldTriggered && flag5 && powerDownKeyHeldTime < FaintAnimeUtilitiesPlugin.FullPowerDownHoldTime.Value)
				{
					StepDown(index);
				}
				powerDownKeyHeldTime = 0f;
				powerDownHoldTriggered = false;
			}
			if (flag5 && Input.GetKeyDown(FaintAnimeUtilitiesPlugin.UltimateKey.Value))
			{
				TryUltimate(formDef);
			}
		}

		private bool CanUseFormInputs()
		{
			if (!Object.op_Implicit((Object)(object)bodyMachine))
			{
				return false;
			}
			return bodyMachine.state is FighterMainState || bodyMachine.state is FlightState;
		}

		private static bool IsGamePaused()
		{
			return Time.timeScale <= 0f;
		}

		private void TryTransformUp(int index)
		{
			int nextForm = FormLineup.GetNextForm(survivor, index);
			if (nextForm >= 1 && nextForm < forms.Count)
			{
				FormDef formDef = forms[nextForm];
				int totalMastery = MasteryController.GetTotalMastery(body, forms);
				if (formDef.MasteryNeeded > totalMastery)
				{
					ShowLockedMessage($"{formDef.displayName} needs {formDef.MasteryNeeded - totalMastery} more mastery levels.");
				}
				else if (formDef.energyDrainPerSecond > 0f && Object.op_Implicit((Object)(object)energy) && energy.Current <= 0f)
				{
					ShowLockedMessage("Not enough " + survivor.EnergyName + " to transform.");
				}
				else
				{
					bodyMachine.SetInterruptState((EntityState)(object)TransformState.Create(body, nextForm, formDef, bodyMachine.state is FlightState), (InterruptPriority)1);
				}
			}
		}

		private void TryActivatePowerUps()
		{
			IStackablePowerUp[] array = powerUps;
			foreach (IStackablePowerUp stackablePowerUp in array)
			{
				if (stackablePowerUp != null && !stackablePowerUp.IsActive)
				{
					stackablePowerUp.AuthorityTryActivate();
				}
			}
		}

		public void RequestPowerDown(int targetForm, bool powerUpsOff)
		{
			if (!Object.op_Implicit((Object)(object)bodyMachine) || bodyMachine.state is PowerDownState || (Object.op_Implicit((Object)(object)weaponMachine) && weaponMachine.state is PowerDownState))
			{
				return;
			}
			int currentFormIndex = CurrentFormIndex;
			if (targetForm < 0 || targetForm >= currentFormIndex)
			{
				targetForm = 0;
			}
			if (currentFormIndex != 0 || (powerUpsOff && AnyPowerUpActive))
			{
				if (Object.op_Implicit((Object)(object)weaponMachine) && bodyMachine.state is FighterMainState)
				{
					weaponMachine.SetInterruptState((EntityState)(object)new PowerDownState
					{
						targetForm = targetForm,
						powerUpsOff = powerUpsOff
					}, (InterruptPriority)1);
				}
				else
				{
					bodyMachine.SetInterruptState((EntityState)(object)new PowerDownState
					{
						targetForm = targetForm,
						powerUpsOff = powerUpsOff,
						flying = (bodyMachine.state is FlightState)
					}, (InterruptPriority)1);
				}
			}
		}

		private void StepDown(int index)
		{
			RequestPowerDown((index != 0) ? FormLineup.GetPreviousForm(survivor, index) : 0, powerUpsOff: true);
		}

		private int EnergyEmptyTarget(int index)
		{
			string energyEmptyForm = forms[index].energyEmptyForm;
			if (string.IsNullOrEmpty(energyEmptyForm))
			{
				return 0;
			}
			for (int i = 1; i < index; i++)
			{
				if (forms[i].abbreviation == energyEmptyForm)
				{
					return i;
				}
			}
			return 0;
		}

		private void TryUltimate(FormDef form)
		{
			if (form.ultimateState == null)
			{
				return;
			}
			float num = form.ultimateEnergyCost;
			SkillLocator skillLocator = body.skillLocator;
			if (Object.op_Implicit((Object)(object)skillLocator) && Object.op_Implicit((Object)(object)skillLocator.special))
			{
				num = Mathf.Max(1f, num * skillLocator.special.cooldownScale);
			}
			if (!Object.op_Implicit((Object)(object)energy) || energy.Current < num)
			{
				ShowLockedMessage("Not enough " + survivor.EnergyName + " for " + form.ultimateName + ".");
			}
			else
			{
				object? obj = Activator.CreateInstance(form.ultimateState);
				EntityState val = (EntityState)((obj is EntityState) ? obj : null);
				if (val != null)
				{
					energy.Add(0f - num);
					bodyMachine.SetInterruptState(val, (InterruptPriority)1);
				}
			}
		}

		public void ShowLockedMessage(string message)
		{
			if (!(lockedMessageCooldown > 0f) && !string.IsNullOrEmpty(message))
			{
				lockedMessageCooldown = 2f;
				Log.Info(message);
			}
		}

		public void ServerSetForm(int index)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || forms == null)
			{
				return;
			}
			for (int i = 1; i < forms.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)forms[i].buffDef))
				{
					body.SetBuffCount(forms[i].buffDef.buffIndex, (i == index) ? 1 : 0);
				}
			}
		}

		public void ServerDeactivatePowerUps()
		{
			if (NetworkServer.active)
			{
				IStackablePowerUp[] array = powerUps;
				for (int i = 0; i < array.Length; i++)
				{
					array[i]?.ServerDeactivate();
				}
			}
		}
	}
	[DefaultExecutionOrder(900)]
	public class HelperBoneDriver : MonoBehaviour
	{
		private enum Mode
		{
			Bend,
			SwingAndTwist,
			TwistOnly
		}

		private class Helper
		{
			public Transform helper;

			public Transform source;

			public Quaternion helperRest;

			public Quaternion sourceRest;

			public Vector3 axis;

			public Mode mode;

			public float share;
		}

		private static readonly (string helper, string source, string towards, Mode mode, float share)[] Rules = new(string, string, string, Mode, float)[8]
		{
			("b_L_Elbow", "b_L_Arm2", null, Mode.Bend, 0.5f),
			("b_R_Elbow", "b_R_Arm2", null, Mode.Bend, 0.5f),
			("b_L_Knee", "b_L_Leg2", null, Mode.Bend, 0.5f),
			("b_R_Knee", "b_R_Leg2", null, Mode.Bend, 0.5f),
			("b_L_ArmHelper", "b_L_Arm1", "b_L_Arm2", Mode.SwingAndTwist, 0.65f),
			("b_R_ArmHelper", "b_R_Arm1", "b_R_Arm2", Mode.SwingAndTwist, 0.65f),
			("b_L_ArmRoll", "b_L_Hand", "b_L_Hand", Mode.TwistOnly, 0.5f),
			("b_R_ArmRoll", "b_R_Hand", "b_R_Hand", Mode.TwistOnly, 0.5f)
		};

		private readonly List<Helper> helpers = new List<Helper>();

		private void Awake()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to inval