Decompiled source of Helldiver v1.0.3

HelldiverMod.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Commando;
using HelldiverMod.States;
using KinematicCharacterController;
using R2API;
using RoR2;
using RoR2.Audio;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.SurvivorMannequins;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace HelldiverMod
{
	internal static class Assets
	{
		private static readonly Dictionary<string, Sprite> sprites = new Dictionary<string, Sprite>();

		public static GameObject MuzzleFlash;

		public static GameObject Tracer;

		public static GameObject HitSpark;

		public static GameObject ShotgunTracer;

		public static GameObject ShotgunHitSpark;

		public static GameObject StrikeIndicator;

		public static GameObject DashJets;

		public static GameObject ThrowArc;

		public static GameObject EmsDrop;

		public static GameObject ResupplyDrop;

		public static GameObject HeGrenade;

		public static GameObject StunGrenade;

		public static T Load<T>(string key) where T : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				return Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("asset '" + key + "' failed: " + ex.Message));
				return default(T);
			}
		}

		public static void LoadVanilla()
		{
			MuzzleFlash = Assets.Load<GameObject>("RoR2/Base/Common/VFX/Muzzleflash1.prefab");
			Tracer = Assets.Load<GameObject>("RoR2/Base/Commando/TracerCommandoDefault.prefab");
			HitSpark = Assets.Load<GameObject>("RoR2/Base/Commando/HitsparkCommando.prefab");
			ShotgunTracer = Assets.Load<GameObject>("RoR2/Base/Commando/TracerCommandoShotgun.prefab");
			ShotgunHitSpark = Assets.Load<GameObject>("RoR2/Base/Commando/HitsparkCommandoShotgun.prefab");
			StrikeIndicator = Assets.Load<GameObject>("RoR2/Base/Treebot/TreebotMortarAreaIndicator.prefab");
			DashJets = Assets.Load<GameObject>("RoR2/Base/Commando/CommandoDashJets.prefab");
			ThrowArc = Assets.Load<GameObject>("RoR2/Base/Common/VFX/BasicThrowableVisualizer.prefab");
			EmsDrop = Assets.Load<GameObject>("RoR2/Base/Captain/CaptainSupplyDrop, Shocking.prefab");
			ResupplyDrop = Assets.Load<GameObject>("RoR2/Base/Captain/CaptainSupplyDrop, Healing.prefab");
			HeGrenade = CloneProjectile("RoR2/Base/Commando/CommandoGrenadeProjectile.prefab", "HelldiverHeGrenade", Settings.HeRadius.Value, 10f);
			StunGrenade = CloneProjectile("RoR2/Base/Commando/CommandoGrenadeProjectile.prefab", "HelldiverStunGrenade", Settings.StunRadius.Value, 10f);
		}

		public static GameObject CloneProjectile(string key, string name, float radius, float fuse)
		{
			GameObject obj = PrefabAPI.InstantiateClone(Assets.Load<GameObject>(key), name, true);
			ProjectileImpactExplosion component = obj.GetComponent<ProjectileImpactExplosion>();
			((ProjectileExplosion)component).blastRadius = radius;
			component.lifetime = fuse;
			ContentAddition.AddProjectile(obj);
			return obj;
		}

		private static byte[] Embedded(string name)
		{
			using Stream stream = typeof(Assets).Assembly.GetManifestResourceStream("HelldiverMod.Assets." + name + ".png");
			if (stream == null)
			{
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num <= 0)
				{
					break;
				}
			}
			return array;
		}

		public static Texture2D Icon(string name)
		{
			//IL_0052: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0079: Expected O, but got Unknown
			byte[] array = Embedded(name);
			if (array == null)
			{
				string path = Path.Combine(Plugin.Dir, "Assets", name + ".png");
				if (File.Exists(path))
				{
					array = File.ReadAllBytes(path);
				}
			}
			if (array == null)
			{
				Plugin.Log.LogWarning((object)("missing icon " + name));
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)1,
				name = "hd_" + name
			};
			ImageConversion.LoadImage(val, array, true);
			return val;
		}

		public static Sprite Sprite(string name)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			if (sprites.TryGetValue(name, out var value))
			{
				return value;
			}
			Texture2D val = Icon(name);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			value = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0);
			((Object)value).name = "hd_" + name;
			return sprites[name] = value;
		}
	}
	public class DemocracyProtects : MonoBehaviour, IOnIncomingDamageServerReceiver
	{
		private float nextReady;

		private CharacterBody body;

		private HealthComponent health;

		private void Awake()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
			health = ((Component)this).GetComponent<HealthComponent>();
		}

		public void OnIncomingDamageServer(DamageInfo damageInfo)
		{
			//IL_0036: 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_00f6: 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)
			if (damageInfo.rejected || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)health) || Time.time < nextReady || (damageInfo.damageType.damageType & 0x40000) != 0)
			{
				return;
			}
			float armor = body.armor;
			if (!(damageInfo.damage * ((armor >= 0f) ? (100f / (100f + armor)) : (2f - 100f / (100f - armor))) < health.combinedHealth))
			{
				nextReady = Time.time + Settings.PassiveCooldown.Value;
				if (!(Random.value * 100f >= Settings.PassiveChance.Value))
				{
					damageInfo.rejected = true;
					body.AddTimedBuff(Buffs.Immune, Settings.PassiveInvulnerability.Value);
					health.HealFraction(Settings.PassiveHeal.Value / 100f, default(ProcChainMask));
					Util.PlaySound("Play_item_proc_extraLife", ((Component)this).gameObject);
					Chat.AddMessage("<style=cShrine>For Super Earth! Democracy protected the Helldiver.</style>");
				}
			}
		}
	}
	internal static class Survivor
	{
		public static GameObject Body;

		public static GameObject Display;

		public const int PrimarySlot = 0;

		public const int SecondarySlot = 1;

		public const int UtilitySlot = 2;

		public const int SpecialSlot = 3;

		public static readonly SkillFamily[] Families = (SkillFamily[])(object)new SkillFamily[4];

		public static SkillDef[] Primaries;

		public static SkillDef JumpPack;

		public static readonly Color Yellow = new Color(0.96f, 0.77f, 0.1f);

		private static SkillDef Skill(string id, Type state, string machine, float cooldown, string icon, InterruptPriority priority, int maxStock = 1, int stockToConsume = 1, bool mustKeyPress = true, bool combat = true, bool cancelSprint = true)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			SkillDef obj = ScriptableObject.CreateInstance<SkillDef>();
			((Object)obj).name = "Helldiver" + id;
			obj.skillName = "Helldiver" + id;
			obj.skillNameToken = "HELLDIVER_" + id.ToUpperInvariant() + "_NAME";
			obj.skillDescriptionToken = "HELLDIVER_" + id.ToUpperInvariant() + "_DESC";
			obj.icon = Assets.Sprite(icon);
			obj.activationState = new SerializableEntityStateType(state);
			obj.activationStateMachineName = machine;
			obj.baseMaxStock = maxStock;
			obj.baseRechargeInterval = cooldown;
			obj.rechargeStock = 1;
			obj.requiredStock = 1;
			obj.stockToConsume = stockToConsume;
			obj.interruptPriority = priority;
			obj.mustKeyPress = mustKeyPress;
			obj.isCombatSkill = combat;
			obj.cancelSprintingOnActivation = cancelSprint;
			obj.canceledFromSprinting = false;
			obj.fullRestockOnAssign = true;
			ContentAddition.AddSkillDef(obj);
			bool flag = default(bool);
			ContentAddition.AddEntityState(state, ref flag);
			return obj;
		}

		private static void Family(int slot, GenericSkill gs, string name, params SkillDef[] defs)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val).name = "Helldiver" + name + "Family";
			val.variants = (Variant[])(object)new Variant[defs.Length];
			for (int i = 0; i < defs.Length; i++)
			{
				Variant[] variants = val.variants;
				int num = i;
				Variant val2 = new Variant
				{
					skillDef = defs[i],
					unlockableDef = null
				};
				((Variant)(ref val2)).viewableNode = new Node(defs[i].skillNameToken, false, (Node)null);
				variants[num] = val2;
			}
			ContentAddition.AddSkillFamily(val);
			typeof(GenericSkill).GetField("_skillFamily", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(gs, val);
			gs.skillName = "Helldiver" + name;
			Families[slot] = val;
		}

		public static void Create()
		{
			//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_02ea: 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_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0390: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: 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)
			Assets.LoadVanilla();
			Stratagems.Create();
			Body = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/Commando/CommandoBody.prefab"), "HelldiverBody", true);
			CharacterBody component = Body.GetComponent<CharacterBody>();
			component.baseNameToken = "HELLDIVER_BODY_NAME";
			component.subtitleNameToken = "HELLDIVER_BODY_SUBTITLE";
			component.portraitIcon = (Texture)(object)Assets.Icon("portrait");
			component.bodyColor = Yellow;
			component.baseMaxHealth = Settings.BaseHealth.Value;
			component.levelMaxHealth = Settings.HealthPerLevel.Value;
			component.baseRegen = Settings.BaseRegen.Value;
			component.levelRegen = Settings.RegenPerLevel.Value;
			component.baseArmor = Settings.BaseArmor.Value;
			component.baseDamage = Settings.BaseDamage.Value;
			component.levelDamage = Settings.DamagePerLevel.Value;
			component.baseMoveSpeed = Settings.MoveSpeed.Value;
			component.baseJumpCount = 1;
			Body.AddComponent<DemocracyProtects>();
			Body.AddComponent<HelldiverAmmo>();
			((Component)Body.GetComponentInChildren<CharacterModel>()).gameObject.AddComponent<HelldiverVisuals>();
			GenericSkill[] components = Body.GetComponents<GenericSkill>();
			Primaries = (SkillDef[])(object)new SkillDef[2]
			{
				Skill("Liberator", typeof(FireLiberator), "Weapon", 0f, "rifle", (InterruptPriority)0, 1, 0, mustKeyPress: false),
				Skill("Breaker", typeof(FireBreaker), "Weapon", 0f, "shotgun", (InterruptPriority)0, 1, 0, mustKeyPress: false)
			};
			Family(0, components[0], "Primary", Primaries);
			Family(1, components[1], "Secondary", Skill("HeGrenade", typeof(ThrowHeGrenade), "Weapon", Settings.HeCooldown.Value, "grenade_he", (InterruptPriority)1, Settings.HeCharges.Value), Skill("StunGrenade", typeof(ThrowStunGrenade), "Weapon", Settings.StunCooldown.Value, "grenade_stun", (InterruptPriority)1, Settings.StunCharges.Value));
			JumpPack = Skill("JumpPack", typeof(JumpPackBurst), "Body", Settings.JumpPackCooldown.Value, "jump", (InterruptPriority)2, 1, 1, mustKeyPress: true, combat: false, cancelSprint: false);
			Family(2, components[2], "Utility", Skill("Dive", typeof(HelldiverDive), "Body", Settings.DiveCooldown.Value, "dive", (InterruptPriority)2, 1, 1, mustKeyPress: true, combat: false, cancelSprint: false), JumpPack);
			SkillDef[] array = (SkillDef[])(object)new SkillDef[Stratagems.All.Length];
			bool flag = default(bool);
			for (int i = 0; i < array.Length; i++)
			{
				StratagemDef stratagemDef = Stratagems.All[i];
				array[i] = Skill(stratagemDef.id, stratagemDef.input, "Weapon", stratagemDef.cooldown.Value, stratagemDef.icon, (InterruptPriority)1, 1, 0);
				ContentAddition.AddEntityState(stratagemDef.armed, ref flag);
			}
			Family(3, components[3], "Stratagem", array);
			ContentAddition.AddEntityState(typeof(StratagemThrown), ref flag);
			ContentAddition.AddEntityState(typeof(ReloadLiberator), ref flag);
			ContentAddition.AddEntityState(typeof(ReloadBreaker), ref flag);
			Body.GetComponent<SkillLocator>().passiveSkill = new PassiveSkill
			{
				enabled = true,
				skillNameToken = "HELLDIVER_PASSIVE_NAME",
				skillDescriptionToken = "HELLDIVER_PASSIVE_DESC",
				keywordToken = "",
				icon = Assets.Sprite("passive_democracy")
			};
			ContentAddition.AddBody(Body);
			Display = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Base/Commando/CommandoDisplay.prefab"), "HelldiverDisplay", false);
			((Component)Display.GetComponentInChildren<CharacterModel>()).gameObject.AddComponent<HelldiverVisuals>();
			SurvivorDef obj = ScriptableObject.CreateInstance<SurvivorDef>();
			obj.cachedName = "Helldiver";
			obj.bodyPrefab = Body;
			obj.displayPrefab = Display;
			obj.primaryColor = Yellow;
			obj.displayNameToken = "HELLDIVER_BODY_NAME";
			obj.descriptionToken = "HELLDIVER_DESCRIPTION";
			obj.outroFlavorToken = "HELLDIVER_OUTRO";
			obj.mainEndingEscapeFailureFlavorToken = "HELLDIVER_FAIL";
			obj.desiredSortPosition = 100f;
			ContentAddition.AddSurvivorDef(obj);
			Tokens.Add();
		}
	}
	internal static class Tokens
	{
		private static string N(float v)
		{
			return v.ToString("0.##", CultureInfo.InvariantCulture);
		}

		private static string Dmg(ConfigEntry<float> percent)
		{
			return "<style=cIsDamage>" + N(percent.Value) + "% damage</style>";
		}

		private static string Sec(float s)
		{
			return N(s) + ((s == 1f) ? " second" : " seconds");
		}

		private static string Reload(ConfigEntry<float> time, ConfigEntry<float> auto)
		{
			return Sec(time.Value) + " to reload (faster with <style=cIsDamage>attack speed</style>)." + ((auto.Value > 0f) ? (" Reloads by itself after " + Sec(auto.Value) + " without firing.") : "");
		}

		private static string Code(BeaconKind k)
		{
			return "<style=cKeywordName>" + string.Join(" ", Stratagems.Get(k).code.Select((Arrow a) => a switch
			{
				Arrow.Down => "↓", 
				Arrow.Right => "→", 
				Arrow.Up => "↑", 
				_ => "←", 
			})) + "</style> ";
		}

		public static void Add()
		{
			L("HELLDIVER_BODY_NAME", "Helldiver");
			L("HELLDIVER_BODY_SUBTITLE", "Soldier of Super Earth");
			L("HELLDIVER_DESCRIPTION", "The Helldiver is a self-reliant soldier who calls the planet's finest firepower down on the enemy.<color=#CCD3E0>\r\n\r\n< ! > Pick a rifle for sustained fire or a shotgun for close quarters.\r\n\r\n< ! > Grenades clear crowds. Stun grenades buy you breathing room.\r\n\r\n< ! > Dive or jump-pack out of trouble.\r\n\r\n< ! > Choose your stratagem before you deploy. Type the code with the arrow keys, aim, then fire to throw the beacon.\r\n\r\n</color>");
			L("HELLDIVER_OUTRO", "..and so they left, with a medal for Super Earth.");
			L("HELLDIVER_FAIL", "..and so they vanished, for Democracy.");
			L("HELLDIVER_PASSIVE_NAME", "Democracy Protects");
			L("HELLDIVER_PASSIVE_DESC", "A lethal hit has a <style=cIsHealing>" + N(Settings.PassiveChance.Value) + "%</style> chance to be <style=cIsHealing>survived</style>: the damage is negated, you recover <style=cIsHealing>" + N(Settings.PassiveHeal.Value) + "% health</style> and are invulnerable for <style=cIsUtility>" + Sec(Settings.PassiveInvulnerability.Value) + "</style>. Checked at most once every <style=cIsUtility>" + Sec(Settings.PassiveCooldown.Value) + "</style>.");
			L("HELLDIVER_LIBERATOR_NAME", "AR-23 Liberator");
			L("HELLDIVER_LIBERATOR_DESC", "Fire an automatic rifle for " + Dmg(Settings.LiberatorDamage) + " per bullet at " + N(Settings.LiberatorFireRate.Value) + " rounds per minute. " + Settings.LiberatorMagazine.Value + "-round magazine, " + Reload(Settings.LiberatorReload, Settings.LiberatorAutoReload) + " Spread builds as you hold the trigger.");
			L("HELLDIVER_BREAKER_NAME", "SG-225 Breaker");
			L("HELLDIVER_BREAKER_DESC", "Fire a shotgun blast of " + Settings.BreakerPellets.Value + " pellets for <style=cIsDamage>" + Settings.BreakerPellets.Value + "x" + N(Settings.BreakerDamage.Value) + "% damage</style>. " + Settings.BreakerMagazine.Value + " shells, " + Reload(Settings.BreakerReload, Settings.BreakerAutoReload) + " Damage falls off with range.");
			L("HELLDIVER_HEGRENADE_NAME", "G-12 High Explosive");
			L("HELLDIVER_HEGRENADE_DESC", "Throw a grenade that bounces and explodes a second after it lands, for " + Dmg(Settings.HeDamage) + "." + ((Settings.HeCharges.Value > 1) ? (" Holds " + Settings.HeCharges.Value + " charges.") : ""));
			L("HELLDIVER_STUNGRENADE_NAME", "G-23 Stun");
			L("HELLDIVER_STUNGRENADE_DESC", "Throw a stun grenade that explodes a second after it lands, for " + Dmg(Settings.StunDamage) + " in a wide radius that <style=cIsUtility>stuns</style>." + ((Settings.StunCharges.Value > 1) ? (" Holds " + Settings.StunCharges.Value + " charges.") : ""));
			L("HELLDIVER_DIVE_NAME", "Dive");
			L("HELLDIVER_DIVE_DESC", "Dive a short distance in the direction you are moving.");
			L("HELLDIVER_JUMPPACK_NAME", "LIFT-850 Jump Pack");
			L("HELLDIVER_JUMPPACK_DESC", "On the ground, <style=cIsUtility>launch up and forward</style>. In mid air, <style=cIsUtility>hover</style> for up to " + Sec(Settings.JumpPackHover.Value) + " to stop a fall.");
			string text = " Type the code with the <style=cIsUtility>arrow keys</style>, aim, then <style=cIsUtility>fire</style> to throw the beacon ball. It <style=cIsUtility>sticks</style> to the ground or to enemies and calls the stratagem in on that spot after a moment. Cancel with the Special key. Only costs a charge when thrown.";
			L("HELLDIVER_ORBITALSTRIKE_NAME", "Orbital Precision Strike");
			L("HELLDIVER_ORBITALSTRIKE_DESC", Code(BeaconKind.OrbitalStrike) + "A single orbital shot lands after " + Sec(Settings.StrikeDelay.Value) + " for " + Dmg(Settings.StrikeDamage) + " and <style=cIsUtility>stuns</style>." + text);
			L("HELLDIVER_EAGLEAIRSTRIKE_NAME", "Eagle Airstrike");
			L("HELLDIVER_EAGLEAIRSTRIKE_DESC", Code(BeaconKind.EagleAirstrike) + "An Eagle drops <style=cIsDamage>" + 6 + " bombs</style> in two parallel lines of " + 3 + " toward the target, each for " + Dmg(Settings.EagleDamage) + "." + text);
			L("HELLDIVER_EAGLEBOMB_NAME", "Eagle 500kg Bomb");
			L("HELLDIVER_EAGLEBOMB_DESC", Code(BeaconKind.EagleBomb) + "One enormous bomb lands after " + Sec(Settings.BombDelay.Value) + " for " + Dmg(Settings.BombDamage) + " in a huge radius (" + N(Settings.BombRadius.Value) + " m)." + text);
			L("HELLDIVER_ORBITALEMS_NAME", "Orbital EMS Strike");
			L("HELLDIVER_ORBITALEMS_DESC", Code(BeaconKind.Ems) + "A beacon that repeatedly <style=cIsUtility>shocks and stuns</style> every enemy near it." + text);
			L("HELLDIVER_RESUPPLY_NAME", "Resupply");
			L("HELLDIVER_RESUPPLY_DESC", Code(BeaconKind.Resupply) + "A supply beacon that <style=cIsHealing>heals</style> nearby allies, and <style=cIsUtility>instantly resets your Secondary and Utility cooldowns</style>." + text);
			static void L(string k, string v)
			{
				LanguageAPI.Add(k, v);
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("terr4.helldiver", "Helldiver", "1.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "terr4.helldiver";

		public const string Version = "1.0.3";

		public static ManualLogSource Log;

		public static string Dir;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Dir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
			Settings.Bind(((BaseUnityPlugin)this).Config);
			((Component)this).gameObject.AddComponent<HelldiverHud>();
			Survivor.Create();
			ModelFiles.Preload();
			Log.LogInfo((object)"Helldiver 1.0.3 registered. For Super Earth!");
		}
	}
	internal static class Settings
	{
		public static ConfigEntry<float> BaseHealth;

		public static ConfigEntry<float> HealthPerLevel;

		public static ConfigEntry<float> BaseRegen;

		public static ConfigEntry<float> RegenPerLevel;

		public static ConfigEntry<float> BaseArmor;

		public static ConfigEntry<float> BaseDamage;

		public static ConfigEntry<float> DamagePerLevel;

		public static ConfigEntry<float> MoveSpeed;

		public static ConfigEntry<float> PassiveChance;

		public static ConfigEntry<float> PassiveCooldown;

		public static ConfigEntry<float> PassiveHeal;

		public static ConfigEntry<float> PassiveInvulnerability;

		public static ConfigEntry<float> LiberatorDamage;

		public static ConfigEntry<float> LiberatorFireRate;

		public static ConfigEntry<float> LiberatorReload;

		public static ConfigEntry<float> LiberatorAutoReload;

		public static ConfigEntry<int> LiberatorMagazine;

		public static ConfigEntry<float> BreakerDamage;

		public static ConfigEntry<float> BreakerFireRate;

		public static ConfigEntry<float> BreakerReload;

		public static ConfigEntry<float> BreakerAutoReload;

		public static ConfigEntry<int> BreakerMagazine;

		public static ConfigEntry<int> BreakerPellets;

		public static ConfigEntry<float> HeDamage;

		public static ConfigEntry<float> HeRadius;

		public static ConfigEntry<float> HeCooldown;

		public static ConfigEntry<float> StunDamage;

		public static ConfigEntry<float> StunRadius;

		public static ConfigEntry<float> StunCooldown;

		public static ConfigEntry<int> HeCharges;

		public static ConfigEntry<int> StunCharges;

		public static ConfigEntry<float> DiveCooldown;

		public static ConfigEntry<float> JumpPackCooldown;

		public static ConfigEntry<float> JumpPackHover;

		public static ConfigEntry<float> JumpPackLift;

		public static ConfigEntry<float> JumpPackForward;

		public static ConfigEntry<float> StrikeDamage;

		public static ConfigEntry<float> StrikeRadius;

		public static ConfigEntry<float> StrikeDelay;

		public static ConfigEntry<float> StrikeCooldown;

		public static ConfigEntry<float> EagleDamage;

		public static ConfigEntry<float> EagleRadius;

		public static ConfigEntry<float> EagleCooldown;

		public static ConfigEntry<float> BombDamage;

		public static ConfigEntry<float> BombRadius;

		public static ConfigEntry<float> BombDelay;

		public static ConfigEntry<float> BombCooldown;

		public static ConfigEntry<float> EmsDamage;

		public static ConfigEntry<float> EmsCooldown;

		public static ConfigEntry<float> ResupplyDamage;

		public static ConfigEntry<float> ResupplyCooldown;

		public static ConfigEntry<float> CodeTime;

		public static ConfigEntry<float> BeaconDelay;

		public static ConfigEntry<float> ThrowRange;

		public static ConfigEntry<bool> Cape;

		public static ConfigEntry<bool> AmmoCounter;

		public static ConfigEntry<bool> AmmoOnSkillIcon;

		private const string Restart = " Restart the game after changing it.";

		private const string Mp = " In multiplayer every player should use the same values.";

		private static ConfigEntry<float> F(ConfigFile c, string section, string key, float value, string desc, float min, float max)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return c.Bind<float>(section, key, value, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
		}

		private static ConfigEntry<int> I(ConfigFile c, string section, string key, int value, string desc, int min, int max)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			return c.Bind<int>(section, key, value, new ConfigDescription(desc, (AcceptableValueBase)(object)new AcceptableValueRange<int>(min, max), Array.Empty<object>()));
		}

		public static void Bind(ConfigFile c)
		{
			BaseHealth = F(c, "01. Character", "Base Health", 110f, "Health at level 1. Restart the game after changing it.", 1f, 10000f);
			HealthPerLevel = F(c, "01. Character", "Health Per Level", 33f, "Health gained per level. Restart the game after changing it.", 0f, 1000f);
			BaseRegen = F(c, "01. Character", "Base Regen", 1f, "Health regenerated per second at level 1. Restart the game after changing it.", 0f, 100f);
			RegenPerLevel = F(c, "01. Character", "Regen Per Level", 0.2f, "Regeneration gained per level. Restart the game after changing it.", 0f, 10f);
			BaseArmor = F(c, "01. Character", "Armor", 8f, "Armor (each point is about 1% less damage taken at low values). Restart the game after changing it.", -100f, 1000f);
			BaseDamage = F(c, "01. Character", "Base Damage", 12f, "Damage stat at level 1. Every skill's damage % is a share of this. Restart the game after changing it.", 1f, 1000f);
			DamagePerLevel = F(c, "01. Character", "Damage Per Level", 2.4f, "Damage stat gained per level. Restart the game after changing it.", 0f, 100f);
			MoveSpeed = F(c, "01. Character", "Move Speed", 7f, "Movement speed in m/s (Commando: 7). Restart the game after changing it.", 1f, 30f);
			PassiveChance = F(c, "02. Passive - Democracy Protects", "Chance", 50f, "Chance (%) that a lethal hit is survived.", 0f, 100f);
			PassiveCooldown = F(c, "02. Passive - Democracy Protects", "Cooldown", 40f, "Seconds before the passive can be checked again after a lethal hit.", 0f, 600f);
			PassiveHeal = F(c, "02. Passive - Democracy Protects", "Heal", 25f, "Health restored when it triggers, in % of maximum health.", 0f, 100f);
			PassiveInvulnerability = F(c, "02. Passive - Democracy Protects", "Invulnerability", 1.5f, "Seconds of invulnerability when it triggers.", 0f, 10f);
			LiberatorDamage = F(c, "03. Primary - AR-23 Liberator", "Damage", 70f, "Damage per bullet (%).", 0f, 10000f);
			LiberatorFireRate = F(c, "03. Primary - AR-23 Liberator", "Fire Rate", 640f, "Rounds per minute (attack speed raises it).", 30f, 3000f);
			LiberatorMagazine = I(c, "03. Primary - AR-23 Liberator", "Magazine", 30, "Rounds per magazine.", 1, 1000);
			LiberatorReload = F(c, "03. Primary - AR-23 Liberator", "Reload Time", 1.9f, "Seconds to reload (attack speed shortens it).", 0.1f, 10f);
			LiberatorAutoReload = F(c, "03. Primary - AR-23 Liberator", "Auto Reload Delay", 2.5f, "Seconds without firing before a partly empty magazine reloads by itself (0 = only when empty).", 0f, 30f);
			BreakerDamage = F(c, "04. Primary - SG-225 Breaker", "Damage", 55f, "Damage per pellet (%).", 0f, 10000f);
			BreakerPellets = I(c, "04. Primary - SG-225 Breaker", "Pellets", 9, "Pellets per shot.", 1, 50);
			BreakerFireRate = F(c, "04. Primary - SG-225 Breaker", "Fire Rate", 300f, "Shots per minute (attack speed raises it).", 10f, 1200f);
			BreakerMagazine = I(c, "04. Primary - SG-225 Breaker", "Magazine", 6, "Shells per magazine.", 1, 100);
			BreakerReload = F(c, "04. Primary - SG-225 Breaker", "Reload Time", 2.4f, "Seconds to reload (attack speed shortens it).", 0.1f, 10f);
			BreakerAutoReload = F(c, "04. Primary - SG-225 Breaker", "Auto Reload Delay", 2.5f, "Seconds without firing before a partly empty magazine reloads by itself (0 = only when empty).", 0f, 30f);
			HeDamage = F(c, "05. Secondary - G-12 High Explosive", "Damage", 700f, "Explosion damage (%).", 0f, 100000f);
			HeRadius = F(c, "05. Secondary - G-12 High Explosive", "Blast Radius", 10f, "Explosion radius in metres. In multiplayer every player should use the same values.", 1f, 50f);
			HeCooldown = F(c, "05. Secondary - G-12 High Explosive", "Cooldown", 12f, "Seconds to recharge one grenade. Restart the game after changing it.", 0f, 120f);
			HeCharges = I(c, "05. Secondary - G-12 High Explosive", "Charges", 1, "Grenades held. Restart the game after changing it.", 1, 10);
			StunDamage = F(c, "06. Secondary - G-23 Stun", "Damage", 300f, "Explosion damage (%). The blast stuns.", 0f, 100000f);
			StunRadius = F(c, "06. Secondary - G-23 Stun", "Blast Radius", 15f, "Explosion radius in metres. In multiplayer every player should use the same values.", 1f, 50f);
			StunCooldown = F(c, "06. Secondary - G-23 Stun", "Cooldown", 15f, "Seconds to recharge one grenade. Restart the game after changing it.", 0f, 120f);
			StunCharges = I(c, "06. Secondary - G-23 Stun", "Charges", 2, "Grenades held. Restart the game after changing it.", 1, 10);
			DiveCooldown = F(c, "07. Utility - Dive", "Cooldown", 4f, "Seconds between dives. Restart the game after changing it.", 0f, 60f);
			JumpPackCooldown = F(c, "08. Utility - LIFT-850 Jump Pack", "Cooldown", 9f, "Seconds between uses. Restart the game after changing it.", 0f, 120f);
			JumpPackLift = F(c, "08. Utility - LIFT-850 Jump Pack", "Launch Speed", 24f, "Upward speed of the launch from the ground (m/s).", 1f, 100f);
			JumpPackForward = F(c, "08. Utility - LIFT-850 Jump Pack", "Forward Speed", 14f, "Forward speed of the launch (m/s).", 0f, 100f);
			JumpPackHover = F(c, "08. Utility - LIFT-850 Jump Pack", "Hover Time", 2.6f, "Seconds of hover when used in mid air.", 0.1f, 20f);
			StrikeDamage = F(c, "09. Stratagem - Orbital Precision Strike", "Damage", 8000f, "Damage of the shot (%). Stuns.", 0f, 1000000f);
			StrikeRadius = F(c, "09. Stratagem - Orbital Precision Strike", "Blast Radius", 8f, "Explosion radius in metres. In multiplayer every player should use the same values.", 1f, 100f);
			StrikeDelay = F(c, "09. Stratagem - Orbital Precision Strike", "Impact Delay", 2.2f, "Seconds from the call-in to the impact. In multiplayer every player should use the same values.", 0.1f, 20f);
			StrikeCooldown = F(c, "09. Stratagem - Orbital Precision Strike", "Cooldown", 45f, "Seconds to recharge. Restart the game after changing it.", 0f, 600f);
			EagleDamage = F(c, "10. Stratagem - Eagle Airstrike", "Damage", 1200f, "Damage of each of the 6 bombs (%). Stuns.", 0f, 1000000f);
			EagleRadius = F(c, "10. Stratagem - Eagle Airstrike", "Blast Radius", 8.5f, "Explosion radius of each bomb in metres. In multiplayer every player should use the same values.", 1f, 100f);
			EagleCooldown = F(c, "10. Stratagem - Eagle Airstrike", "Cooldown", 50f, "Seconds to recharge. Restart the game after changing it.", 0f, 600f);
			BombDamage = F(c, "11. Stratagem - Eagle 500kg Bomb", "Damage", 5000f, "Damage of the bomb (%). Stuns.", 0f, 1000000f);
			BombRadius = F(c, "11. Stratagem - Eagle 500kg Bomb", "Blast Radius", 24f, "Explosion radius in metres. In multiplayer every player should use the same values.", 1f, 100f);
			BombDelay = F(c, "11. Stratagem - Eagle 500kg Bomb", "Impact Delay", 3.2f, "Seconds from the call-in to the impact. In multiplayer every player should use the same values.", 0.1f, 20f);
			BombCooldown = F(c, "11. Stratagem - Eagle 500kg Bomb", "Cooldown", 65f, "Seconds to recharge. Restart the game after changing it.", 0f, 600f);
			EmsDamage = F(c, "12. Stratagem - Orbital EMS Strike", "Damage", 2000f, "Damage of the beacon's landing (%); the beacon then keeps shocking and stunning enemies near it.", 0f, 1000000f);
			EmsCooldown = F(c, "12. Stratagem - Orbital EMS Strike", "Cooldown", 60f, "Seconds to recharge. Restart the game after changing it.", 0f, 600f);
			ResupplyDamage = F(c, "13. Stratagem - Resupply", "Damage", 2000f, "Damage of the beacon's landing (%); the beacon then heals allies near it.", 0f, 1000000f);
			ResupplyCooldown = F(c, "13. Stratagem - Resupply", "Cooldown", 50f, "Seconds to recharge. Restart the game after changing it.", 0f, 600f);
			CodeTime = F(c, "14. Stratagems - All", "Code Time", 6f, "Seconds to type a stratagem code before the input closes.", 1f, 60f);
			BeaconDelay = F(c, "14. Stratagems - All", "Beacon Delay", 0.8f, "Seconds between the beacon sticking and the stratagem being called in. In multiplayer every player should use the same values.", 0f, 10f);
			ThrowRange = F(c, "14. Stratagems - All", "Throw Range", 95f, "Maximum throw distance of the beacon in metres.", 10f, 300f);
			Cape = c.Bind<bool>("15. Visuals", "Cape", true, "Show the simulated cape (full package only). Restart the game after changing it.");
			AmmoCounter = c.Bind<bool>("15. Visuals", "Ammo Counter", true, "Show the rounds left next to the crosshair while firing and reloading.");
			AmmoOnSkillIcon = c.Bind<bool>("15. Visuals", "Ammo On Skill Icon", true, "Always show the rounds left on the primary skill icon (bottom right).");
			MigrateOldEntries(c);
		}

		private static void MigrateOldEntries(ConfigFile c)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			if (!(typeof(ConfigFile).GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(c) is Dictionary<ConfigDefinition, string> dictionary))
			{
				return;
			}
			List<ConfigDefinition> list = dictionary.Keys.Where((ConfigDefinition k) => k.Section == "Model").ToList();
			if (list.Count == 0)
			{
				return;
			}
			if (dictionary.TryGetValue(new ConfigDefinition("Model", "Cape"), out var value) && bool.TryParse(value, out var result))
			{
				Cape.Value = result;
			}
			foreach (ConfigDefinition item in list)
			{
				dictionary.Remove(item);
			}
			c.Save();
		}

		public static float Coef(this ConfigEntry<float> percent)
		{
			return percent.Value / 100f;
		}
	}
	public class HelldiverHud : MonoBehaviour
	{
		public static HelldiverHud Instance;

		private static readonly Color Yellow = new Color(0.96f, 0.77f, 0.1f);

		private static readonly Color Alert = new Color(1f, 0.45f, 0.3f);

		private static readonly Color Wrong = new Color(1f, 0.25f, 0.2f);

		private static readonly Color Done = new Color(0.6f, 1f, 0.6f);

		public bool visible;

		public bool armed;

		public string title = "";

		public string hint = "";

		public Arrow[] code = new Arrow[0];

		public int progress;

		private float wrongUntil;

		private string ammoText = "";

		private bool ammoAlert;

		private float ammoUntil;

		private GUIStyle big;

		private GUIStyle small;

		private GameObject iconBody;

		private HelldiverAmmo iconAmmo;

		private SkillIcon icon;

		private TextMeshProUGUI iconText;

		private int iconRounds = -1;

		private int iconMagazine;

		private void Awake()
		{
			Instance = this;
			((MonoBehaviour)this).useGUILayout = false;
		}

		public void ShowCode(string name, Arrow[] arrows)
		{
			visible = true;
			armed = false;
			title = name.ToUpperInvariant();
			code = arrows;
			progress = 0;
			hint = "Arrow keys: enter the code   |   Special again: cancel";
		}

		public void ShowArmed(string name)
		{
			visible = true;
			armed = true;
			title = name.ToUpperInvariant();
			hint = "Fire: throw the beacon   |   Special: cancel";
		}

		public void MarkWrong()
		{
			progress = 0;
			wrongUntil = Time.unscaledTime + 0.3f;
		}

		public void Hide()
		{
			visible = false;
		}

		public void ShowAmmo(string text, float seconds, bool alert = false)
		{
			if (Settings.AmmoCounter.Value)
			{
				ammoText = text;
				ammoAlert = alert;
				ammoUntil = Time.unscaledTime + seconds;
			}
		}

		private void LateUpdate()
		{
			UpdateSkillIcon();
		}

		private void UpdateSkillIcon()
		{
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: 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)
			HelldiverAmmo helldiverAmmo = null;
			SkillIcon val = null;
			if (Settings.AmmoOnSkillIcon.Value)
			{
				foreach (HUD readOnlyInstance in HUD.readOnlyInstanceList)
				{
					GameObject val2 = (Object.op_Implicit((Object)(object)readOnlyInstance) ? readOnlyInstance.targetBodyObject : null);
					if (!Object.op_Implicit((Object)(object)val2) || readOnlyInstance.skillIcons == null)
					{
						continue;
					}
					if ((Object)(object)val2 != (Object)(object)iconBody)
					{
						iconBody = val2;
						iconAmmo = val2.GetComponent<HelldiverAmmo>();
					}
					if (!Object.op_Implicit((Object)(object)iconAmmo) || !Util.HasEffectiveAuthority(val2))
					{
						continue;
					}
					SkillIcon[] skillIcons = readOnlyInstance.skillIcons;
					foreach (SkillIcon val3 in skillIcons)
					{
						if (Object.op_Implicit((Object)(object)val3) && (int)val3.targetSkillSlot == 0)
						{
							val = val3;
						}
					}
					if (Object.op_Implicit((Object)(object)val))
					{
						helldiverAmmo = iconAmmo;
						break;
					}
				}
			}
			if ((Object)(object)val != (Object)(object)icon)
			{
				if (Object.op_Implicit((Object)(object)iconText))
				{
					Object.Destroy((Object)(object)((Component)iconText).gameObject);
				}
				iconText = null;
				icon = val;
				iconRounds = -1;
				if (Object.op_Implicit((Object)(object)icon) && Object.op_Implicit((Object)(object)icon.stockText))
				{
					iconText = Object.Instantiate<GameObject>(((Component)icon.stockText).gameObject, ((TMP_Text)icon.stockText).transform.parent).GetComponent<TextMeshProUGUI>();
					((Object)iconText).name = "HelldiverAmmoText";
				}
			}
			if (Object.op_Implicit((Object)(object)iconText))
			{
				int rounds = 0;
				int magazine = 0;
				bool isLiberator;
				bool flag = Object.op_Implicit((Object)(object)helldiverAmmo) && helldiverAmmo.Current(out rounds, out magazine, out isLiberator);
				if (((Component)iconText).gameObject.activeSelf != flag)
				{
					((Component)iconText).gameObject.SetActive(flag);
				}
				if (flag && (rounds != iconRounds || magazine != iconMagazine))
				{
					iconRounds = rounds;
					iconMagazine = magazine;
					((TMP_Text)iconText).SetText("{0}", (float)rounds);
					((Graphic)iconText).color = ((rounds * 4 <= magazine) ? Alert : Color.white);
				}
			}
		}

		private static string Glyph(Arrow d)
		{
			return d switch
			{
				Arrow.Up => "↑", 
				Arrow.Right => "→", 
				Arrow.Down => "↓", 
				_ => "←", 
			};
		}

		private void OnGUI()
		{
			//IL_0089: 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_003e: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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_009a: 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_025f: 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_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ammoText.Length > 0 && Time.unscaledTime < ammoUntil;
			if (!flag && !visible)
			{
				return;
			}
			if (big == null)
			{
				big = new GUIStyle(GUI.skin.label)
				{
					fontSize = 46,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				small = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
			}
			Color color = GUI.color;
			if (flag)
			{
				GUI.color = (ammoAlert ? Alert : Yellow);
				GUI.Label(new Rect((float)Screen.width / 2f + 40f, (float)Screen.height / 2f + 30f, 260f, 30f), ammoText, small);
			}
			if (visible)
			{
				float num = 560f;
				float num2 = 150f;
				float num3 = ((float)Screen.width - num) / 2f;
				float num4 = (float)Screen.height * 0.62f;
				GUI.color = new Color(0f, 0f, 0f, 0.6f);
				GUI.DrawTexture(new Rect(num3, num4, num, num2), (Texture)(object)Texture2D.whiteTexture);
				GUI.color = Yellow;
				GUI.Label(new Rect(num3, num4 + 6f, num, 30f), title, small);
				if (!armed)
				{
					float num5 = 70f;
					float num6 = num3 + (num - num5 * (float)code.Length) / 2f;
					bool flag2 = Time.unscaledTime < wrongUntil;
					for (int i = 0; i < code.Length; i++)
					{
						GUI.color = (Color)(flag2 ? Wrong : ((i < progress) ? Yellow : new Color(0.75f, 0.75f, 0.75f)));
						GUI.Label(new Rect(num6 + (float)i * num5, num4 + 40f, num5, 70f), Glyph(code[i]), big);
					}
				}
				else
				{
					GUI.color = Done;
					GUI.Label(new Rect(num3, num4 + 50f, num, 50f), "BEACON READY", big);
				}
				GUI.color = new Color(1f, 1f, 1f, 0.85f);
				GUI.Label(new Rect(num3, num4 + 114f, num, 28f), hint, small);
			}
			GUI.color = color;
		}
	}
	public enum Arrow
	{
		Up,
		Right,
		Down,
		Left
	}
	public enum BeaconKind
	{
		OrbitalStrike,
		EagleAirstrike,
		EagleBomb,
		Ems,
		Resupply
	}
	internal class StratagemDef
	{
		public BeaconKind kind;

		public string id;

		public string name;

		public string icon;

		public Arrow[] code;

		public ConfigEntry<float> damage;

		public ConfigEntry<float> cooldown;

		public float indicatorRadius;

		public Type input;

		public Type armed;

		public GameObject beacon;
	}
	internal static class Stratagems
	{
		public static StratagemDef[] All;

		public const float BeaconSpeed = 55f;

		public const int EagleBombsPerLane = 3;

		public const float EagleSpacing = 10f;

		public const float EagleLaneGap = 18f;

		public const float EagleIndicator = 12f;

		public const float SupplyIndicator = 10f;

		public static GameObject StrikeProjectile;

		public static GameObject EagleStrafeProjectile;

		public static GameObject EagleBombProjectile;

		public static StratagemDef Get(BeaconKind kind)
		{
			return All[(int)kind];
		}

		public static void Create()
		{
			All = new StratagemDef[5]
			{
				new StratagemDef
				{
					kind = BeaconKind.OrbitalStrike,
					id = "OrbitalStrike",
					name = "Orbital Precision Strike",
					icon = "orbital_strike",
					code = new Arrow[3]
					{
						Arrow.Right,
						Arrow.Right,
						Arrow.Up
					},
					damage = Settings.StrikeDamage,
					cooldown = Settings.StrikeCooldown,
					indicatorRadius = Settings.StrikeRadius.Value,
					input = typeof(InputOrbitalStrike),
					armed = typeof(ArmedOrbitalStrike)
				},
				new StratagemDef
				{
					kind = BeaconKind.EagleAirstrike,
					id = "EagleAirstrike",
					name = "Eagle Airstrike",
					icon = "eagle_airstrike",
					code = new Arrow[4]
					{
						Arrow.Up,
						Arrow.Right,
						Arrow.Down,
						Arrow.Right
					},
					damage = Settings.EagleDamage,
					cooldown = Settings.EagleCooldown,
					indicatorRadius = 12f,
					input = typeof(InputEagleAirstrike),
					armed = typeof(ArmedEagleAirstrike)
				},
				new StratagemDef
				{
					kind = BeaconKind.EagleBomb,
					id = "EagleBomb",
					name = "Eagle 500kg Bomb",
					icon = "eagle_bomb",
					code = new Arrow[5]
					{
						Arrow.Up,
						Arrow.Right,
						Arrow.Down,
						Arrow.Down,
						Arrow.Down
					},
					damage = Settings.BombDamage,
					cooldown = Settings.BombCooldown,
					indicatorRadius = Settings.BombRadius.Value,
					input = typeof(InputEagleBomb),
					armed = typeof(ArmedEagleBomb)
				},
				new StratagemDef
				{
					kind = BeaconKind.Ems,
					id = "OrbitalEms",
					name = "Orbital EMS Strike",
					icon = "orbital_ems",
					code = new Arrow[4]
					{
						Arrow.Right,
						Arrow.Right,
						Arrow.Left,
						Arrow.Down
					},
					damage = Settings.EmsDamage,
					cooldown = Settings.EmsCooldown,
					indicatorRadius = 10f,
					input = typeof(InputOrbitalEms),
					armed = typeof(ArmedEms)
				},
				new StratagemDef
				{
					kind = BeaconKind.Resupply,
					id = "Resupply",
					name = "Resupply",
					icon = "resupply",
					code = new Arrow[4]
					{
						Arrow.Down,
						Arrow.Down,
						Arrow.Up,
						Arrow.Right
					},
					damage = Settings.ResupplyDamage,
					cooldown = Settings.ResupplyCooldown,
					indicatorRadius = 10f,
					input = typeof(InputResupply),
					armed = typeof(ArmedResupply)
				}
			};
			StrikeProjectile = Assets.CloneProjectile("RoR2/Base/Captain/CaptainAirstrikeProjectile1.prefab", "HelldiverOrbitalStrikeProjectile", Settings.StrikeRadius.Value, Settings.StrikeDelay.Value);
			EagleStrafeProjectile = Assets.CloneProjectile("RoR2/Base/Captain/CaptainAirstrikeProjectile1.prefab", "HelldiverEagleBombProjectile", Settings.EagleRadius.Value, 1.6f);
			EagleBombProjectile = Assets.CloneProjectile("RoR2/Base/Captain/CaptainAirstrikeProjectile1.prefab", "HelldiverEagle500kgProjectile", Settings.BombRadius.Value, Settings.BombDelay.Value);
			EagleBombProjectile.AddComponent<BigExplosionFx>().radius = Settings.BombRadius.Value;
			StrikeProjectile.AddComponent<ImpactSounds>().sounds = new string[3] { "Play_item_use_meteor_impact", "Play_item_proc_missile_explo", "Play_commando_M2_grenade_explo" };
			EagleStrafeProjectile.AddComponent<ImpactSounds>().sounds = new string[2] { "Play_item_proc_missile_explo", "Play_commando_M2_grenade_explo" };
			EagleBombProjectile.AddComponent<ImpactSounds>().sounds = new string[4] { "Play_item_use_BFG_explode", "Play_item_use_meteor_impact", "Play_item_proc_missile_explo", "Play_commando_M2_grenade_explo" };
			StratagemDef[] all = All;
			foreach (StratagemDef obj in all)
			{
				obj.beacon = MakeBeacon(obj.kind);
			}
		}

		private static GameObject MakeBeacon(BeaconKind kind)
		{
			GameObject obj = PrefabAPI.InstantiateClone(Assets.Load<GameObject>("RoR2/Junk/Commando/CommandoStickyGrenadeProjectile.prefab"), "HelldiverBeacon" + kind, true);
			ProjectileImpactExplosion component = obj.GetComponent<ProjectileImpactExplosion>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			ProjectileSimple component2 = obj.GetComponent<ProjectileSimple>();
			component2.desiredForwardSpeed = 55f;
			component2.lifetime = 30f;
			ProjectileStickOnImpact component3 = obj.GetComponent<ProjectileStickOnImpact>();
			component3.ignoreWorld = false;
			component3.ignoreCharacters = false;
			obj.AddComponent<StratagemBeacon>().kind = kind;
			ContentAddition.AddProjectile(obj);
			return obj;
		}
	}
	public class StratagemBeacon : MonoBehaviour
	{
		public BeaconKind kind;

		private ProjectileStickOnImpact stick;

		private ProjectileController controller;

		private ProjectileDamage damage;

		private float born;

		private float armedAt = -1f;

		private bool done;

		private void Awake()
		{
			stick = ((Component)this).GetComponent<ProjectileStickOnImpact>();
			controller = ((Component)this).GetComponent<ProjectileController>();
			damage = ((Component)this).GetComponent<ProjectileDamage>();
			born = Time.time;
		}

		private void FixedUpdate()
		{
			if (NetworkServer.active && !done)
			{
				if (armedAt < 0f && Object.op_Implicit((Object)(object)stick) && stick.stuck)
				{
					armedAt = Time.time;
					Util.PlaySound("Play_captain_shift_start", ((Component)this).gameObject);
				}
				if ((armedAt >= 0f && Time.time - armedAt >= Settings.BeaconDelay.Value) || Time.time - born >= 10f)
				{
					Trigger();
				}
			}
		}

		private void Trigger()
		{
			//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_0060: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			done = true;
			Vector3 position = ((Component)this).transform.position;
			GameObject val = (Object.op_Implicit((Object)(object)controller) ? controller.owner : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				switch (kind)
				{
				case BeaconKind.OrbitalStrike:
					Strike(Stratagems.StrikeProjectile, position, val, 0f);
					break;
				case BeaconKind.EagleBomb:
					Strike(Stratagems.EagleBombProjectile, position, val, 0f);
					break;
				case BeaconKind.EagleAirstrike:
					EagleRun(position, val);
					break;
				case BeaconKind.Ems:
					Supply(Assets.EmsDrop, position, val.GetComponent<CharacterBody>());
					break;
				case BeaconKind.Resupply:
					Supply(Assets.ResupplyDrop, position, val.GetComponent<CharacterBody>());
					break;
				}
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void Strike(GameObject prefab, Vector3 pos, GameObject owner, float fuse)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			ProjectileManager instance = ProjectileManager.instance;
			FireProjectileInfo val = new FireProjectileInfo
			{
				crit = (Object.op_Implicit((Object)(object)damage) && damage.crit),
				owner = owner,
				position = pos,
				projectilePrefab = prefab,
				rotation = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)
			};
			((FireProjectileInfo)(ref val)).speedOverride = 0f;
			val.damage = (Object.op_Implicit((Object)(object)damage) ? damage.damage : 0f);
			val.damageTypeOverride = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)32), (DamageTypeExtended)0, (DamageSource)8);
			((FireProjectileInfo)(ref val)).fuseOverride = ((fuse <= 0f) ? (-1f) : fuse);
			instance.FireProjectile(val);
		}

		private void EagleRun(Vector3 pos, GameObject owner)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pos - owner.transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 1f)
			{
				val = owner.transform.forward;
				val.y = 0f;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			int num = 3;
			for (int i = 0; i < 2; i++)
			{
				float num2 = ((i == 0) ? (-0.5f) : 0.5f) * 18f;
				for (int j = 0; j < num; j++)
				{
					float num3 = ((float)j - (float)(num - 1) / 2f) * 10f;
					Strike(Stratagems.EagleStrafeProjectile, pos + val * num3 + val2 * num2, owner, 1.4f + (float)j * 0.2f + (float)i * 0.05f);
				}
			}
		}

		private void Supply(GameObject prefab, Vector3 pos, CharacterBody ownerBody)
		{
			//IL_0011: 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_001c: 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_0026: 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)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)prefab) && Object.op_Implicit((Object)(object)ownerBody))
			{
				Vector3 val = pos + Vector3.up * 1f;
				Vector3 down = Vector3.down;
				LayerIndex world = LayerIndex.world;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, down, ref val2, 300f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask)))
				{
					pos = ((RaycastHit)(ref val2)).point;
				}
				GameObject obj = Object.Instantiate<GameObject>(prefab, pos, Quaternion.identity);
				obj.GetComponent<TeamFilter>().teamIndex = ownerBody.teamComponent.teamIndex;
				obj.GetComponent<GenericOwnership>().ownerObject = ((Component)ownerBody).gameObject;
				Deployable component = obj.GetComponent<Deployable>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)ownerBody.master))
				{
					ownerBody.master.AddDeployable(component, (DeployableSlot)21);
				}
				ProjectileDamage component2 = obj.GetComponent<ProjectileDamage>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.crit = Object.op_Implicit((Object)(object)damage) && damage.crit;
					component2.damage = (Object.op_Implicit((Object)(object)damage) ? damage.damage : 0f);
					component2.damageColorIndex = (DamageColorIndex)0;
					component2.force = 9700f;
					component2.damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)0), (DamageTypeExtended)0, (DamageSource)8);
				}
				NetworkServer.Spawn(obj);
			}
		}
	}
	public class BigExplosionFx : MonoBehaviour
	{
		public float radius = 24f;

		private static GameObject nova;

		private static GameObject meteor;

		private static GameObject omni;

		private static bool loaded;

		private void OnDestroy()
		{
			//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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			Scene scene = ((Component)this).gameObject.scene;
			if (((Scene)(ref scene)).isLoaded)
			{
				if (!loaded)
				{
					loaded = true;
					nova = Assets.Load<GameObject>("RoR2/Base/Vagrant/VagrantNovaExplosion.prefab");
					meteor = Assets.Load<GameObject>("RoR2/Base/Meteor/MeteorStrikeImpact.prefab");
					omni = Assets.Load<GameObject>("RoR2/Base/Common/VFX/OmniExplosionVFX.prefab");
				}
				Vector3 position = ((Component)this).transform.position;
				Spawn(nova, position, radius);
				Spawn(meteor, position, radius * 0.9f);
				Spawn(omni, position + Vector3.up * 2f, radius * 1.1f);
				Spawn(omni, position + Vector3.up * 8f, radius * 0.7f);
			}
		}

		private static void Spawn(GameObject prefab, Vector3 pos, float scale)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)prefab))
			{
				EffectManager.SpawnEffect(prefab, new EffectData
				{
					origin = pos,
					scale = scale
				}, true);
			}
		}
	}
	internal static class StratagemSounds
	{
		public const string MeteorImpact = "Play_item_use_meteor_impact";

		public const string MissileBlast = "Play_item_proc_missile_explo";

		public const string GrenadeBlast = "Play_commando_M2_grenade_explo";

		public const string BigBlast = "Play_item_use_BFG_explode";
	}
	public class ImpactSounds : MonoBehaviour
	{
		public string[] sounds;

		private void OnDestroy()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Scene scene = ((Component)this).gameObject.scene;
			if (((Scene)(ref scene)).isLoaded && sounds != null)
			{
				Vector3 position = ((Component)this).transform.position;
				string[] array = sounds;
				for (int i = 0; i < array.Length; i++)
				{
					PointSoundManager.EmitSoundLocal((AkEventIdArg)array[i], position);
				}
			}
		}
	}
	internal class CapeData
	{
		public int cols;

		public int rows;

		public int sc;

		public int sr;

		public int nP;

		public Vector3[] rest;

		public Vector3[] renderRest;

		public Vector2[] uv;

		public float[] t;

		public float[] wChest;

		public int[] conA;

		public int[] conB;

		public float[] conL;

		public float[] conK;

		public int[] tris;

		public int nV => cols * rows;

		public static CapeData Load(string path)
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = File.ReadAllBytes(path);
			if (array.Length < 12 || array[0] != 72 || array[1] != 68 || array[2] != 67 || array[3] != 50)
			{
				return null;
			}
			CapeData capeData = new CapeData
			{
				cols = BitConverter.ToInt32(array, 4),
				rows = BitConverter.ToInt32(array, 8)
			};
			if (capeData.cols < 3 || capeData.rows < 3 || (capeData.cols & 1) == 0 || (capeData.rows & 1) == 0)
			{
				return null;
			}
			capeData.renderRest = (Vector3[])(object)new Vector3[capeData.nV];
			int num = 0;
			int num2 = 12;
			while (num < capeData.nV)
			{
				capeData.renderRest[num] = new Vector3(BitConverter.ToSingle(array, num2), BitConverter.ToSingle(array, num2 + 4), BitConverter.ToSingle(array, num2 + 8));
				num++;
				num2 += 12;
			}
			int num3 = 12 + capeData.nV * 12;
			if (array.Length >= num3 + capeData.nV * 8)
			{
				capeData.uv = (Vector2[])(object)new Vector2[capeData.nV];
				int num4 = 0;
				int num5 = num3;
				while (num4 < capeData.nV)
				{
					capeData.uv[num4] = new Vector2(BitConverter.ToSingle(array, num5), BitConverter.ToSingle(array, num5 + 4));
					num4++;
					num5 += 8;
				}
			}
			capeData.sc = (capeData.cols + 1) / 2;
			capeData.sr = (capeData.rows + 1) / 2;
			capeData.nP = capeData.sc * capeData.sr;
			capeData.rest = (Vector3[])(object)new Vector3[capeData.nP];
			capeData.t = new float[capeData.nP];
			capeData.wChest = new float[capeData.nP];
			for (int i = 0; i < capeData.sr; i++)
			{
				for (int j = 0; j < capeData.sc; j++)
				{
					int num6 = i * capeData.sc + j;
					capeData.rest[num6] = capeData.renderRest[2 * i * capeData.cols + 2 * j];
					capeData.t[num6] = (float)i / (float)(capeData.sr - 1);
					capeData.wChest[num6] = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((capeData.rest[num6].y - 0.85f) / 0.45f));
				}
			}
			List<int> a = new List<int>();
			List<int> b = new List<int>();
			List<float> k = new List<float>();
			for (int l = 0; l < capeData.sr; l++)
			{
				for (int m = 0; m < capeData.sc; m++)
				{
					int num7 = l * capeData.sc + m;
					if (m + 1 < capeData.sc)
					{
						Link(num7, num7 + 1, 1f);
					}
					if (l + 1 < capeData.sr)
					{
						Link(num7, num7 + capeData.sc, 1f);
					}
					if (m + 1 < capeData.sc && l + 1 < capeData.sr)
					{
						Link(num7, num7 + capeData.sc + 1, 0.5f);
						Link(num7 + 1, num7 + capeData.sc, 0.5f);
					}
					if (m + 2 < capeData.sc)
					{
						Link(num7, num7 + 2, 0.15f);
					}
					if (l + 2 < capeData.sr)
					{
						Link(num7, num7 + 2 * capeData.sc, 0.3f);
					}
				}
			}
			capeData.conA = a.ToArray();
			capeData.conB = b.ToArray();
			capeData.conK = k.ToArray();
			capeData.conL = new float[capeData.conA.Length];
			for (int n = 0; n < capeData.conA.Length; n++)
			{
				capeData.conL[n] = Vector3.Distance(capeData.rest[capeData.conA[n]], capeData.rest[capeData.conB[n]]);
			}
			List<int> list = new List<int>();
			for (int num8 = 0; num8 + 1 < capeData.rows; num8++)
			{
				for (int num9 = 0; num9 + 1 < capeData.cols; num9++)
				{
					int num10 = num8 * capeData.cols + num9;
					int item = num10 + 1;
					int num11 = num10 + capeData.cols;
					int item2 = num11 + 1;
					list.Add(num10);
					list.Add(item);
					list.Add(num11);
					list.Add(item);
					list.Add(item2);
					list.Add(num11);
				}
			}
			capeData.tris = list.ToArray();
			return capeData;
			void Link(int p, int q, float stiff)
			{
				a.Add(p);
				b.Add(q);
				k.Add(stiff);
			}
		}
	}
	[DefaultExecutionOrder(32000)]
	public class HelldiverCape : MonoBehaviour
	{
		public static float Gravity = 9.8f;

		public static float Damping = 0.985f;

		public static float PullTop = 30f;

		public static float PullHem = 8f;

		public static float MaxDistTop = 0.02f;

		public static float MaxDistHem = 0.3f;

		public static float Inert = 0.5f;

		public static float AirDrag = 2.5f;

		public static float Gust = 1.2f;

		public static float Margin = 0.03f;

		public static float SubstepHz = 90f;

		public static float Friction = 0.8f;

		public static int Iterations = 4;

		public static int MaxSubsteps = 3;

		public static float NormalStrength = 0.7f;

		public static bool HideCape;

		private static CapeData data;

		private static bool dataTried;

		private static Material material;

		public CharacterModel model;

		private Transform chest;

		private Transform pelvis;

		private Transform thighL;

		private Transform thighR;

		private Transform calfL;

		private Transform calfR;

		private Transform footL;

		private Transform footR;

		private Matrix4x4 bindChest = Matrix4x4.identity;

		private Matrix4x4 bindPelvis = Matrix4x4.identity;

		private SkinnedMeshRenderer bodySmr;

		private bool initialised;

		private bool found;

		private bool asleep;

		private Matrix4x4 sleepInv;

		private float[] px;

		private float[] py;

		private float[] pz;

		private float[] qx;

		private float[] qy;

		private float[] qz;

		private float[] a0x;

		private float[] a0y;

		private float[] a0z;

		private float[] a1x;

		private float[] a1y;

		private float[] a1z;

		private float[] maxDist;

		private const int NCol = 7;

		private readonly Vector3[] colPrevA = (Vector3[])(object)new Vector3[7];

		private readonly Vector3[] colPrevB = (Vector3[])(object)new Vector3[7];

		private readonly Vector3[] colCurA = (Vector3[])(object)new Vector3[7];

		private readonly Vector3[] colCurB = (Vector3[])(object)new Vector3[7];

		private readonly float[] cr = new float[7];

		private readonly float[] cax = new float[7];

		private readonly float[] cay = new float[7];

		private readonly float[] caz = new float[7];

		private readonly float[] cbx = new float[7];

		private readonly float[] cby = new float[7];

		private readonly float[] cbz = new float[7];

		private readonly float[] cmx = new float[7];

		private readonly float[] cmy = new float[7];

		private readonly float[] cmz = new float[7];

		private readonly float[] cm2 = new float[7];

		private Vector3 lastChest;

		private Vector3 velSmooth;

		private GameObject go;

		private Mesh mesh;

		private Vector3[] rpos;

		private Vector3[] verts;

		private Vector3[] norms;

		private Vector4[] tang;

		public static bool Available
		{
			get
			{
				if (!dataTried)
				{
					dataTried = true;
					try
					{
						if (ModelFiles.Exists("cape.bin"))
						{
							data = CapeData.Load(ModelFiles.PathOf("cape.bin"));
						}
						if (data != null)
						{
							Plugin.Log.LogInfo((object)("Helldiver cape: " + data.cols + "x" + data.rows + " render points, " + data.nP + " particles, " + data.conA.Length + " links"));
						}
					}
					catch (Exception ex)
					{
						Plugin.Log.LogWarning((object)("Helldiver cape failed to load: " + ex.Message));
					}
				}
				return data != null;
			}
		}

		private static Material GetMaterial()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)material))
			{
				return material;
			}
			Material bodyMaterial = HelldiverModel.BodyMaterial;
			if (!Object.op_Implicit((Object)(object)bodyMaterial))
			{
				return null;
			}
			Texture2D val = ModelFiles.Texture("cape_tex.png", ModelFiles.Kind.Cutout);
			bool flag = Object.op_Implicit((Object)(object)val);
			if (!Object.op_Implicit((Object)(object)val))
			{
				val = new Texture2D(4, 4, (TextureFormat)4, false)
				{
					name = "tex_cape"
				};
				Color32[] array = (Color32[])(object)new Color32[16];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = new Color32((byte)29, (byte)29, (byte)32, byte.MaxValue);
				}
				val.SetPixels32(array);
				val.Apply(false, true);
			}
			material = ModelFiles.MakeMaterial(bodyMaterial, "mat_cape", val, flag ? ModelFiles.Texture("cape_nrm.png", ModelFiles.Kind.Normal) : null, 0.12f, NormalStrength);
			if (flag)
			{
				if (material.HasProperty("_EnableCutout"))
				{
					material.SetFloat("_EnableCutout", 1f);
				}
				material.EnableKeyword("CUTOUT");
			}
			return material;
		}

		private bool Find()
		{
			if (!Object.op_Implicit((Object)(object)model))
			{
				return false;
			}
			Transform[] array = ModelFiles.Find(((Component)model).transform, "chest", "pelvis", "thigh.l", "thigh.r", "calf.l", "calf.r", "foot.l", "foot.r");
			chest = array[0];
			pelvis = array[1];
			thighL = array[2];
			thighR = array[3];
			calfL = array[4];
			calfR = array[5];
			footL = array[6];
			footR = array[7];
			if (!Object.op_Implicit((Object)(object)chest) || !Object.op_Implicit((Object)(object)pelvis) || !Object.op_Implicit((Object)(object)thighL) || !Object.op_Implicit((Object)(object)thighR) || !Object.op_Implicit((Object)(object)calfL) || !Object.op_Implicit((Object)(object)calfR) || !Object.op_Implicit((Object)(object)footL) || !Object.op_Implicit((Object)(object)footR))
			{
				return false;
			}
			bodySmr = ModelFiles.BodyRenderer(model);
			if (ModelFiles.BindPose(bodySmr, chest, out bindChest))
			{
				return ModelFiles.BindPose(bodySmr, pelvis, out bindPelvis);
			}
			return false;
		}

		private void Setup()
		{
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Expected O, but got Unknown
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_01a0: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			int nP = data.nP;
			px = new float[nP];
			py = new float[nP];
			pz = new float[nP];
			qx = new float[nP];
			qy = new float[nP];
			qz = new float[nP];
			a0x = new float[nP];
			a0y = new float[nP];
			a0z = new float[nP];
			a1x = new float[nP];
			a1y = new float[nP];
			a1z = new float[nP];
			maxDist = new float[nP];
			for (int i = 0; i < nP; i++)
			{
				maxDist[i] = Mathf.Lerp(MaxDistTop, MaxDistHem, data.t[i]);
			}
			int nV = data.nV;
			rpos = (Vector3[])(object)new Vector3[nV];
			verts = (Vector3[])(object)new Vector3[nV * 2];
			norms = (Vector3[])(object)new Vector3[nV * 2];
			tang = (Vector4[])(object)new Vector4[nV * 2];
			Vector2[] array = (Vector2[])(object)new Vector2[nV * 2];
			int[] array2 = new int[data.tris.Length * 2];
			for (int j = 0; j < data.rows; j++)
			{
				for (int k = 0; k < data.cols; k++)
				{
					int num = j * data.cols + k;
					array[nV + num] = (array[num] = (Vector2)((data.uv != null) ? data.uv[num] : new Vector2((float)k / (float)(data.cols - 1), 1f - (float)j / (float)(data.rows - 1))));
				}
			}
			int num2 = data.tris.Length;
			for (int l = 0; l < num2; l += 3)
			{
				array2[l] = data.tris[l];
				array2[l + 1] = data.tris[l + 1];
				array2[l + 2] = data.tris[l + 2];
				array2[num2 + l] = data.tris[l] + nV;
				array2[num2 + l + 1] = data.tris[l + 2] + nV;
				array2[num2 + l + 2] = data.tris[l + 1] + nV;
			}
			mesh = new Mesh
			{
				name = "HelldiverCape",
				indexFormat = (IndexFormat)0
			};
			mesh.MarkDynamic();
			mesh.vertices = verts;
			mesh.uv = array;
			mesh.triangles = array2;
			go = new GameObject("HD_Cape")
			{
				layer = ((Component)model).gameObject.layer
			};
			go.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer val = go.AddComponent<MeshRenderer>();
			((Renderer)val).sharedMaterial = GetMaterial();
			((Renderer)val).shadowCastingMode = (ShadowCastingMode)1;
			((Renderer)val).receiveShadows = true;
			HelldiverVisuals component = ((Component)model).GetComponent<HelldiverVisuals>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.Track((Renderer)(object)val);
			}
		}

		private void Colliders(Vector3[] a, Vector3[] b)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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)
			Vector3 position = chest.position;
			Vector3 position2 = pelvis.position;
			Vector3 val = position - position2;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			a[0] = position2 + normalized * 0.02f;
			b[0] = position2 + normalized * 0.3f;
			cr[0] = 0.19f;
			a[1] = position2 - normalized * 0.03f;
			b[1] = position2 + normalized * 0.02f;
			cr[1] = 0.17f;
			a[2] = thighL.position;
			b[2] = calfL.position;
			cr[2] = 0.125f;
			a[3] = thighR.position;
			b[3] = calfR.position;
			cr[3] = 0.125f;
			a[4] = calfL.position;
			b[4] = footL.position + Vector3.up * 0.06f;
			cr[4] = 0.1f;
			a[5] = calfR.position;
			b[5] = footR.position + Vector3.up * 0.06f;
			cr[5] = 0.1f;
			a[6] = Vector3.Lerp(thighL.position, thighR.position, 0.5f);
			b[6] = a[6] + Vector3.down * 0.15f;
			cr[6] = 0.11f;
		}

		private void OnDisable()
		{
			if (Object.op_Implicit((Object)(object)go))
			{
				go.SetActive(false);
			}
		}

		private void OnEnable()
		{
			if (Object.op_Implicit((Object)(object)go))
			{
				go.SetActive(true);
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)go))
			{
				Object.Destroy((Object)(object)go);
			}
			if (Object.op_Implicit((Object)(object)mesh))
			{
				Object.Destroy((Object)(object)mesh);
			}
		}

		private void LateUpdate()
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: 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_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: 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_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			if (data == null || !Object.op_Implicit((Object)(object)model))
			{
				return;
			}
			if (!found)
			{
				found = Find();
				if (!found)
				{
					return;
				}
			}
			if ((Object)(object)go == (Object)null)
			{
				if (!Object.op_Implicit((Object)(object)GetMaterial()))
				{
					return;
				}
				Setup();
			}
			bool flag = !HideCape && Object.op_Implicit((Object)(object)bodySmr) && ((Renderer)bodySmr).enabled && ((Component)bodySmr).gameObject.activeInHierarchy;
			if (go.activeSelf != flag)
			{
				go.SetActive(flag);
			}
			if (!flag || !((Renderer)bodySmr).isVisible)
			{
				if (!asleep)
				{
					asleep = true;
					sleepInv = chest.worldToLocalMatrix;
				}
				Matrix4x4 val = chest.localToWorldMatrix * sleepInv;
				go.transform.SetPositionAndRotation(Vector4.op_Implicit(((Matrix4x4)(ref val)).GetColumn(3)), ((Matrix4x4)(ref val)).rotation);
				return;
			}
			if (asleep)
			{
				asleep = false;
				initialised = false;
				go.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity);
			}
			float num = Mathf.Clamp(Time.deltaTime, 0f, 0.05f);
			int nP = data.nP;
			Array.Copy(a1x, a0x, nP);
			Array.Copy(a1y, a0y, nP);
			Array.Copy(a1z, a0z, nP);
			Array.Copy(colCurA, colPrevA, 7);
			Array.Copy(colCurB, colPrevB, 7);
			Matrix4x4 val2 = chest.localToWorldMatrix * bindChest;
			Matrix4x4 val3 = pelvis.localToWorldMatrix * bindPelvis;
			for (int i = 0; i < nP; i++)
			{
				Vector3 val4 = Vector3.Lerp(((Matrix4x4)(ref val3)).MultiplyPoint3x4(data.rest[i]), ((Matrix4x4)(ref val2)).MultiplyPoint3x4(data.rest[i]), data.wChest[i]);
				a1x[i] = val4.x;
				a1y[i] = val4.y;
				a1z[i] = val4.z;
			}
			Colliders(colCurA, colCurB);
			float num2 = a1x[0] - a0x[0];
			float num3 = a1y[0] - a0y[0];
			float num4 = a1z[0] - a0z[0];
			if (!initialised || num2 * num2 + num3 * num3 + num4 * num4 > 2.25f)
			{
				for (int j = 0; j < nP; j++)
				{
					px[j] = (qx[j] = (a0x[j] = a1x[j]));
					py[j] = (qy[j] = (a0y[j] = a1y[j]));
					pz[j] = (qz[j] = (a0z[j] = a1z[j]));
				}
				Array.Copy(colCurA, colPrevA, 7);
				Array.Copy(colCurB, colPrevB, 7);
				lastChest = chest.position;
				velSmooth = Vector3.zero;
				initialised = true;
				num = 0f;
			}
			if (num > 0f)
			{
				velSmooth = Vector3.Lerp(velSmooth, (chest.position - lastChest) / num, 1f - Mathf.Exp(-12f * num));
				int num5 = Mathf.Clamp(Mathf.CeilToInt(num * SubstepHz), 1, MaxSubsteps);
				float h = num / (float)num5;
				for (int k = 1; k <= num5; k++)
				{
					Step(h, (float)(k - 1) / (float)num5, (float)k / (float)num5);
				}
			}
			lastChest = chest.position;
			BuildMesh();
		}

		private void SetCapsule(int c, Vector3 a, Vector3 b)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			cax[c] = a.x;
			cay[c] = a.y;
			caz[c] = a.z;
			cbx[c] = b.x;
			cby[c] = b.y;
			cbz[c] = b.z;
			cmx[c] = (a.x + b.x) * 0.5f;
			cmy[c] = (a.y + b.y) * 0.5f;
			cmz[c] = (a.z + b.z) * 0.5f;
			Vector3 val = b - a;
			float num = ((Vector3)(ref val)).magnitude * 0.5f + cr[c] + Margin;
			cm2[c] = num * num;
		}

		private bool Near(int c, float x, float y, float z)
		{
			float num = x - cmx[c];
			float num2 = y - cmy[c];
			float num3 = z - cmz[c];
			return num * num + num2 * num2 + num3 * num3 < cm2[c];
		}

		private void Step(float h, float s0, float s1)
		{
			//IL_0026: 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_0039: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			int nP = data.nP;
			int sc = data.sc;
			for (int i = 0; i < 7; i++)
			{
				SetCapsule(i, Vector3.Lerp(colPrevA[i], colCurA[i], s1), Vector3.Lerp(colPrevB[i], colCurB[i], s1));
			}
			Vector3 forward = ((Component)model).transform.forward;
			float x = forward.x;
			float y = forward.y;
			float z = forward.z;
			float num = Mathf.Clamp01(((Vector3)(ref velSmooth)).magnitude / 7f);
			float num2 = 1f - Mathf.Exp((0f - AirDrag) * h);
			float num3 = Mathf.Pow(Damping, h * 120f);
			float time = Time.time;
			float num4 = h * h;
			float num5 = (0f - Gravity) * num4;
			for (int j = 0; j < nP; j++)
			{
				float num6 = a0x[j] + (a1x[j] - a0x[j]) * s0;
				float num7 = a0y[j] + (a1y[j] - a0y[j]) * s0;
				float num8 = a0z[j] + (a1z[j] - a0z[j]) * s0;
				float num9 = a0x[j] + (a1x[j] - a0x[j]) * s1;
				float num10 = a0y[j] + (a1y[j] - a0y[j]) * s1;
				float num11 = a0z[j] + (a1z[j] - a0z[j]) * s1;
				if (j < sc)
				{
					qx[j] = px[j];
					qy[j] = py[j];
					qz[j] = pz[j];
					px[j] = num9;
					py[j] = num10;
					pz[j] = num11;
					continue;
				}
				float num12 = data.t[j];
				float num13 = (px[j] - qx[j]) * num3;
				float num14 = (py[j] - qy[j]) * num3;
				float num15 = (pz[j] - qz[j]) * num3;
				float num16 = (num13 * x + num14 * y + num15 * z) * num2;
				num13 -= x * num16;
				num14 -= y * num16;
				num15 -= z * num16;
				float num17 = Mathf.Sin(time * 7.3f + py[j] * 9f + px[j] * 6f) * Gust * num * num12 * num4;
				float num18 = px[j] + (num9 - num6) * Inert;
				float num19 = py[j] + (num10 - num7) * Inert;
				float num20 = pz[j] + (num11 - num8) * Inert;
				qx[j] = num18 - num13;
				qy[j] = num19 - num14;
				qz[j] = num20 - num15;
				num18 += x * num17;
				num19 += num5 + y * num17;
				num20 += z * num17;
				float num21 = 1f - Mathf.Exp((0f - (PullTop + (PullHem - PullTop) * num12)) * h);
				px[j] = num18 + (num9 - num18) * num21;
				py[j] = num19 + (num10 - num19) * num21;
				pz[j] = num20 + (num11 - num20) * num21;
			}
			int[] conA = data.conA;
			int[] conB = data.conB;
			float[] conL = data.conL;
			float[] conK = data.conK;
			for (int k = 0; k < Iterations; k++)
			{
				for (int l = sc; l < nP; l++)
				{
					float num22 = a0x[l] + (a1x[l] - a0x[l]) * s1;
					float num23 = a0y[l] + (a1y[l] - a0y[l]) * s1;
					float num24 = a0z[l] + (a1z[l] - a0z[l]) * s1;
					float num25 = px[l] - num22;
					float num26 = py[l] - num23;
					float num27 = pz[l] - num24;
					float num28 = num25 * num25 + num26 * num26 + num27 * num27;
					float num29 = maxDist[l];
					if (num28 > num29 * num29)
					{
						float num30 = num29 / Mathf.Sqrt(num28);
						px[l] = num22 + num25 * num30;
						py[l] = num23 + num26 * num30;
						pz[l] = num24 + num27 * num30;
					}
				}
				for (int m = 0; m < conA.Length; m++)
				{
					int num31 = conA[m];
					int num32 = conB[m];
					float num33 = px[num32] - px[num31];
					float num34 = py[num32] - py[num31];
					float num35 = pz[num32] - pz[num31];
					float num36 = Mathf.Sqrt(num33 * num33 + num34 * num34 + num35 * num35);
					if (!(num36 < 1E-06f))
					{
						float num37 = ((num31 < sc) ? 0f : 1f);
						float num38 = ((num32 < sc) ? 0f : 1f);
						float num39 = num37 + num38;
						if (num39 != 0f)
						{
							float num40 = (num36 - conL[m]) / num36 * conK[m] / num39;
							num33 *= num40;
							num34 *= num40;
							num35 *= num40;
							px[num31] += num33 * num37;
							py[num31] += num34 * num37;
							pz[num31] += num35 * num37;
							px[num32] -= num33 * num38;
							py[num32] -= num34 * num38;
							pz[num32] -= num35 * num38;
						}
					}
				}
				for (int n = sc; n < nP; n++)
				{
					for (int num41 = 0; num41 < 7; num41++)
					{
						if (Near(num41, px[n], py[n], pz[n]))
						{
							Push(n, num41, x, y, z);
						}
					}
				}
			}
		}

		private void Push(int i, int c, float fx, float fy, float fz)
		{
			float num = cbx[c] - cax[c];
			float num2 = cby[c] - cay[c];
			float num3 = cbz[c] - caz[c];
			float num4 = num * num + num2 * num2 + num3 * num3;
			float num5 = ((num4 > 1E-08f) ? (((px[i] - cax[c]) * num + (py[i] - cay[c]) * num2 + (pz[i] - caz[c]) * num3) / num4) : 0f);
			num5 = ((num5 < 0f) ? 0f : ((num5 > 1f) ? 1f : num5));
			float num6 = cax[c] + num * num5;
			float num7 = cay[c] + num2 * num5;
			float num8 = caz[c] + num3 * num5;
			float num9 = px[i] - num6;
			float num10 = py[i] - num7;
			float num11 = pz[i] - num8;
			float num12 = num9 * num9 + num10 * num10 + num11 * num11;
			float num13 = cr[c] + Margin;
			if (!(num12 >= num13 * num13))
			{
				float num14 = Mathf.Sqrt(num12);
				float num15;
				float num16;
				float num17;
				if (num14 > 1E-05f)
				{
					num15 = num9 / num14;
					num16 = num10 / num14;
					num17 = num11 / num14;
				}
				else
				{
					num15 = 0f - fx;
					num16 = 0f - fy;
					num17 = 0f - fz;
				}
				float num18 = num6 + num15 * num13;
				float num19 = num7 + num16 * num13;
				float num20 = num8 + num17 * num13;
				float num21 = num18 - qx[i];
				float num22 = num19 - qy[i];
				float num23 = num20 - qz[i];
				float num24 = num21 * num15 + num22 * num16 + num23 * num17;
				float num25 = num21 - num24 * num15;
				float num26 = num22 - num24 * num16;
				float num27 = num23 - num24 * num17;
				float num28 = ((num24 > 0f) ? num24 : 0f);
				qx[i] = num18 - (num25 * Friction + num28 * num15);
				qy[i] = num19 - (num26 * Friction + num28 * num16);
				qz[i] = num20 - (num27 * Friction + num28 * num17);
				px[i] = num18;
				py[i] = num19;
				pz[i] = num20;
			}
		}

		private void BuildMesh()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0619: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: 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_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04da: Unknown result type (might be due to invalid IL or missing references)
			//IL_04df: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: 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_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052a: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_056a: Unknown result type (might be due to invalid IL or missing references)
			//IL_056f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057f: 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_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			int cols = data.cols;
			int rows = data.rows;
			int sc = data.sc;
			int sr = data.sr;
			int nV = data.nV;