Decompiled source of IvoryBastion v0.22.0

BepInEx/plugins/IvoryBastion/IvoryBastion.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.BlendableTypes;
using IL.RoR2;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CharacterAI;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace IvoryBastion
{
	internal static class BastionAbilityShield
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__ShieldStat;

			public static hook_RecalculateStats <1>__Recalculate;

			public static Manipulator <2>__Regeneration;

			public static Action<Action<HealthComponent, float>, HealthComponent, float> <3>__Write;
		}

		private static Hook shieldWrite;

		internal static void Install()
		{
			//IL_0010: 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_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			object obj = <>O.<0>__ShieldStat;
			if (obj == null)
			{
				Manipulator val = ShieldStat;
				<>O.<0>__ShieldStat = val;
				obj = (object)val;
			}
			CharacterBody.RecalculateStats += (Manipulator)obj;
			object obj2 = <>O.<1>__Recalculate;
			if (obj2 == null)
			{
				hook_RecalculateStats val2 = Recalculate;
				<>O.<1>__Recalculate = val2;
				obj2 = (object)val2;
			}
			CharacterBody.RecalculateStats += (hook_RecalculateStats)obj2;
			object obj3 = <>O.<2>__Regeneration;
			if (obj3 == null)
			{
				Manipulator val3 = Regeneration;
				<>O.<2>__Regeneration = val3;
				obj3 = (object)val3;
			}
			HealthComponent.ServerFixedUpdate += (Manipulator)obj3;
			shieldWrite = new Hook((MethodBase)typeof(HealthComponent).GetProperty("Networkshield").GetSetMethod(), (Delegate)new Action<Action<HealthComponent, float>, HealthComponent, float>(Write));
		}

		internal static void Remove()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			Hook obj = shieldWrite;
			if (obj != null)
			{
				obj.Dispose();
			}
			shieldWrite = null;
			object obj2 = <>O.<0>__ShieldStat;
			if (obj2 == null)
			{
				Manipulator val = ShieldStat;
				<>O.<0>__ShieldStat = val;
				obj2 = (object)val;
			}
			CharacterBody.RecalculateStats -= (Manipulator)obj2;
			object obj3 = <>O.<1>__Recalculate;
			if (obj3 == null)
			{
				hook_RecalculateStats val2 = Recalculate;
				<>O.<1>__Recalculate = val2;
				obj3 = (object)val2;
			}
			CharacterBody.RecalculateStats -= (hook_RecalculateStats)obj3;
			object obj4 = <>O.<2>__Regeneration;
			if (obj4 == null)
			{
				Manipulator val3 = Regeneration;
				<>O.<2>__Regeneration = val3;
				obj4 = (object)val3;
			}
			HealthComponent.ServerFixedUpdate -= (Manipulator)obj4;
		}

		private static void Write(Action<HealthComponent, float> orig, HealthComponent hp, float value)
		{
			BastionController bastionController = ((NetworkServer.active && Object.op_Implicit((Object)(object)hp.body)) ? ((Component)hp.body).GetComponent<BastionController>() : null);
			if (Object.op_Implicit((Object)(object)bastionController) && bastionController.ShieldStatDepth == 0)
			{
				if (value < hp.shield)
				{
					bastionController.LastShieldHit = Time.time;
				}
				value = bastionController.AbilityShield.ChangeTotal(hp.shield, value, hp.fullShield);
			}
			orig(hp, value);
		}

		private static void Recalculate(orig_RecalculateStats orig, CharacterBody body)
		{
			BastionController bastionController = (NetworkServer.active ? ((Component)body).GetComponent<BastionController>() : null);
			if (!Object.op_Implicit((Object)(object)bastionController) || !Object.op_Implicit((Object)(object)body.healthComponent) || bastionController.ShieldStatDepth > 0)
			{
				orig.Invoke(body);
				return;
			}
			float shield = body.healthComponent.shield;
			float maxShield = body.maxShield;
			bastionController.ShieldStatDepth++;
			try
			{
				orig.Invoke(body);
				float capacity = bastionController.AbilityShieldBase / Mathf.Max(1f, body.cursePenalty);
				float num = bastionController.AbilityShield.Resize(capacity, shield, maxShield, body.maxShield);
				if (bastionController.RestoreFlightShield)
				{
					num = bastionController.AbilityShield.Refill(num, body.maxShield, bastionController.AbilityShield.Capacity);
					bastionController.RestoreFlightShield = false;
				}
				body.healthComponent.Networkshield = num;
			}
			finally
			{
				bastionController.ShieldStatDepth--;
			}
		}

		private static void Regeneration(ILContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0044: 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)
			ILCursor val = new ILCursor(context);
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(i, "set_Networkshield")
			}))
			{
				throw new InvalidOperationException("Ivory Bastion: native shield recharge write was not found.");
			}
			val.Emit(OpCodes.Ldarg_0);
			val.Emit(OpCodes.Ldarg_1);
			val.EmitDelegate<Func<float, HealthComponent, float, float>>((Func<float, HealthComponent, float, float>)delegate(float value, HealthComponent hp, float dt)
			{
				BastionController bastionController = ((NetworkServer.active && Object.op_Implicit((Object)(object)hp.body)) ? ((Component)hp.body).GetComponent<BastionController>() : null);
				return (!Object.op_Implicit((Object)(object)bastionController) || value <= hp.shield) ? value : bastionController.AbilityShield.Recharge(hp.shield, hp.fullShield, dt, abilityAllowed: false);
			});
		}

		private static void ShieldStat(ILContext context)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(context);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction i) => ILPatternMatchingExt.MatchLdfld<CharacterBody>(i, "baseMaxShield")
			}) || !val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				delegate(Instruction i)
				{
					//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)
					//IL_0009: Unknown result type (might be due to invalid IL or missing references)
					//IL_0013: Invalid comparison between Unknown and I4
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Invalid comparison between Unknown and I4
					//IL_0028: Unknown result type (might be due to invalid IL or missing references)
					//IL_002d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					//IL_0037: Invalid comparison between Unknown and I4
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_003f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0049: Invalid comparison between Unknown and I4
					//IL_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0051: Unknown result type (might be due to invalid IL or missing references)
					//IL_0054: Unknown result type (might be due to invalid IL or missing references)
					//IL_005b: Invalid comparison between Unknown and I4
					//IL_005e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0066: Unknown result type (might be due to invalid IL or missing references)
					//IL_006d: Invalid comparison between Unknown and I4
					OpCode opCode = i.OpCode;
					if ((int)((OpCode)(ref opCode)).Code != 204)
					{
						opCode = i.OpCode;
						if ((int)((OpCode)(ref opCode)).Code != 19)
						{
							opCode = i.OpCode;
							if ((int)((OpCode)(ref opCode)).Code != 10)
							{
								opCode = i.OpCode;
								if ((int)((OpCode)(ref opCode)).Code != 11)
								{
									opCode = i.OpCode;
									if ((int)((OpCode)(ref opCode)).Code != 12)
									{
										opCode = i.OpCode;
										return (int)((OpCode)(ref opCode)).Code == 13;
									}
								}
							}
						}
					}
					return true;
				}
			}))
			{
				throw new InvalidOperationException("Ivory Bastion: native shield calculation was not found.");
			}
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<float, CharacterBody, float>>((Func<float, CharacterBody, float>)delegate(float baseShield, CharacterBody body)
			{
				BastionController component = ((Component)body).GetComponent<BastionController>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return baseShield;
				}
				component.AbilityShieldBase = BastionDefenseRules.ShieldCapacity(body.maxHealth, component.Sieged, component.Bank.ShieldCapacityMultiplier);
				return baseShield + component.AbilityShieldBase;
			});
		}

		internal static void Tick(BastionController c, float delta)
		{
			if (NetworkServer.active && c.Alive)
			{
				float num = BastionDefenseRules.RechargeStep(Time.time - c.LastShieldHit, delta, c.Sieged);
				if (!(num <= 0f))
				{
					Restore(c, c.AbilityShield.Capacity / BastionBalance.Get(c.Sieged ? BastionSetting.SiegeShieldRefill : BastionSetting.MobileShieldRefill) * num);
				}
			}
		}

		internal static void Restore(BastionController c, float amount)
		{
			if (NetworkServer.active && c.Alive)
			{
				HealthComponent healthComponent = c.Body.healthComponent;
				healthComponent.Networkshield = c.AbilityShield.Refill(healthComponent.shield, healthComponent.fullShield, amount);
			}
		}
	}
	public sealed class BastionAccentFx : MonoBehaviour
	{
		private BastionFxKind kind;

		private CharacterBody owner;

		private float age;

		private float duration;

		private bool packing;

		private LineRenderer[] lines;

		private static Material sparkMaterial;

		internal static void Create(BastionFxKind kind, Vector3 at, CharacterBody owner = null, float value = 0f)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isBatchMode && (kind == BastionFxKind.Transform || kind == BastionFxKind.Saturation || kind == BastionFxKind.Upgrade))
			{
				GameObject val = new GameObject("Seraph " + kind.ToString() + " articulation light");
				val.transform.position = at;
				BastionAccentFx bastionAccentFx = val.AddComponent<BastionAccentFx>();
				bastionAccentFx.kind = kind;
				bastionAccentFx.owner = owner;
				bastionAccentFx.packing = value < 0f;
				bastionAccentFx.duration = kind switch
				{
					BastionFxKind.Saturation => 1.2f, 
					BastionFxKind.Transform => Mathf.Max(0.3f, Mathf.Abs(value)) + 0.25f, 
					_ => 0.85f, 
				};
				int num = kind switch
				{
					BastionFxKind.Saturation => 10, 
					BastionFxKind.Transform => 12, 
					_ => 6, 
				};
				bastionAccentFx.lines = (LineRenderer[])(object)new LineRenderer[num];
				for (int i = 0; i < num; i++)
				{
					bastionAccentFx.lines[i] = BastionFx.Line(val.transform, 5, 0.035f, BastionModel.Blue, world: false);
					bastionAccentFx.lines[i].widthCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[4]
					{
						new Keyframe(0f, 0.3f),
						new Keyframe(0.25f, 1f),
						new Keyframe(0.75f, 1f),
						new Keyframe(1f, 0.3f)
					});
				}
				if (Object.op_Implicit((Object)(object)owner))
				{
					val.transform.rotation = Quaternion.Euler(0f, ((Component)owner).transform.eulerAngles.y, 0f);
				}
				bastionAccentFx.Render();
			}
		}

		private void Update()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			age += Time.deltaTime;
			if (age >= duration)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			if (Object.op_Implicit((Object)(object)owner) && kind != BastionFxKind.Transform)
			{
				((Component)this).transform.position = owner.corePosition;
			}
			Render();
		}

		private void Render()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: 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_0199: 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)
			float num = Mathf.Clamp01(age / duration);
			float num2 = Mathf.Sin(num * MathF.PI);
			float num3 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num * 1.8f));
			if (packing)
			{
				num3 = 1f - num3;
			}
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < lines.Length; i++)
			{
				Color val = ((i % 3 == 0) ? BastionModel.White : BastionModel.Blue);
				val.a = num2 * ((kind == BastionFxKind.Transform) ? 0.52f : 0.7f);
				lines[i].startColor = val;
				val.a *= ((kind == BastionFxKind.Transform) ? 0.8f : 0.22f);
				lines[i].endColor = val;
				float num4 = (float)i / (float)lines.Length * MathF.PI * 2f;
				((Vector3)(ref val2))..ctor(Mathf.Cos(num4), 0f, Mathf.Sin(num4));
				for (int j = 0; j < 5; j++)
				{
					float num5 = (float)j / 4f;
					Vector3 val3;
					if (kind == BastionFxKind.Transform)
					{
						val3 = BastionEffectGeometry.Deployment(i, j, num3);
					}
					else if (kind == BastionFxKind.Saturation)
					{
						float num6 = Mathf.Clamp01((num - (float)i * 0.024f) * 1.6f);
						float num7 = 2.1f + Mathf.Sin(num4 * 2f) * 0.18f;
						val3 = val2 * (num7 - num5 * 0.18f) + Vector3.up * (0.45f + num6 * 2.7f + num5 * 0.8f);
						lines[i].widthMultiplier = 0.035f + 0.025f * Mathf.Sin(num6 * MathF.PI);
					}
					else
					{
						float num8 = 0.6f + Mathf.Sin(num5 * MathF.PI) * 0.5f;
						val3 = val2 * num8 + Vector3.up * (-0.65f + num * 1.7f + num5 * 0.5f);
					}
					lines[i].SetPosition(j, val3);
				}
			}
		}

		internal static void Sparks(Vector3 at, Vector3 direction, bool impact, float scale = 1f)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Expected O, but got Unknown
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: 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_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: 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_029d: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isBatchMode)
			{
				return;
			}
			if (((Vector3)(ref direction)).sqrMagnitude < 0.001f)
			{
				direction = Vector3.up;
			}
			((Vector3)(ref direction)).Normalize();
			if (!Object.op_Implicit((Object)(object)sparkMaterial))
			{
				sparkMaterial = new Material(BastionFx.LineMaterial)
				{
					name = "Seraph needle scintillation"
				};
				sparkMaterial.SetTexture("_MainTex", (Texture)(object)BastionContent.Icon("missile_flash").texture);
				if (sparkMaterial.HasProperty("_DstBlend"))
				{
					sparkMaterial.SetFloat("_DstBlend", 1f);
				}
			}
			GameObject val = new GameObject(impact ? "Needle impact sparks" : "Needle muzzle flash");
			val.transform.position = at;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).duration = 0.35f;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.24f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.1f * scale);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(impact ? 0.35f : 0f);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 8;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = false;
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(BastionModel.Blue, 0.4f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0f));
			ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = sparkMaterial;
			component.renderMode = (ParticleSystemRenderMode)1;
			component.velocityScale = 0.045f;
			component.lengthScale = (impact ? 2.4f : 3.3f);
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			((Renderer)component).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0;
			Vector3 val4 = Vector3.Cross(direction, (Mathf.Abs(direction.y) > 0.95f) ? Vector3.forward : Vector3.up);
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			Vector3 val5 = Vector3.Cross(direction, normalized);
			val2.Play();
			int num = (impact ? 7 : 4);
			for (int i = 0; i < num; i++)
			{
				float num2 = (float)i * 2.399963f;
				Vector3 val6 = normalized * Mathf.Cos(num2) + val5 * Mathf.Sin(num2);
				EmitParams val7 = default(EmitParams);
				((EmitParams)(ref val7)).position = at;
				((EmitParams)(ref val7)).velocity = (direction * (impact ? 1.6f : 4.2f) + val6 * (impact ? 2.4f : 0.38f)) * scale;
				((EmitParams)(ref val7)).startSize = ((i == 0) ? 0.22f : 0.07f) * scale;
				((EmitParams)(ref val7)).startLifetime = (impact ? (0.2f + (float)i * 0.015f) : (0.075f + (float)i * 0.01f));
				((EmitParams)(ref val7)).startColor = Color32.op_Implicit(Color.white);
				EmitParams val8 = val7;
				val2.Emit(val8, 1);
			}
			Object.Destroy((Object)(object)val, 0.5f);
		}
	}
	internal sealed class BastionAegisGeometry
	{
		internal Vector3[] Vertices;

		internal Vector3[] Normals;

		internal int[] Triangles;

		internal byte[] Kinds;

		internal float[] Heights;

		internal float[] EdgeWeights;

		internal static BastionAegisGeometry Build()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> vertices = new List<Vector3>();
			List<Vector3> normals = new List<Vector3>();
			List<int> list = new List<int>();
			List<byte> kinds = new List<byte>();
			List<float> heights = new List<float>();
			List<float> weights = new List<float>();
			Vector2[] outline = (Vector2[])(object)new Vector2[8]
			{
				new Vector2(-0.72f, -1f),
				new Vector2(0.72f, -1f),
				new Vector2(1f, -0.72f),
				new Vector2(1f, 0.72f),
				new Vector2(0.72f, 1f),
				new Vector2(-0.72f, 1f),
				new Vector2(-1f, 0.72f),
				new Vector2(-1f, -0.72f)
			};
			int row;
			float yaw;
			float latitude;
			for (row = 0; row < 5; row++)
			{
				for (int i = 0; i < 12; i++)
				{
					yaw = ((float)i + 0.5f) * MathF.PI * 2f / 12f;
					latitude = -1.54f + ((float)row + 0.5f) * 3.08f / 5f;
					int num = Add(Vector2.zero, 0, 0.25f);
					int count = vertices.Count;
					for (int j = 1; j <= 3; j++)
					{
						for (int k = 0; k < 32; k++)
						{
							Add(Boundary(k) * ((float)j / 3f), 0, (float)j / 3f);
						}
					}
					for (int l = 0; l < 32; l++)
					{
						int num2 = (l + 1) % 32;
						list.AddRange(new int[3]
						{
							num,
							count + l,
							count + num2
						});
						for (int m = 0; m < 2; m++)
						{
							int num3 = count + m * 32 + l;
							int num4 = count + m * 32 + num2;
							int num5 = num3 + 32;
							int num6 = num4 + 32;
							list.AddRange(new int[6] { num3, num5, num4, num4, num5, num6 });
						}
						byte kind = (byte)((l < 12 || l >= 24) ? 1u : 2u);
						int num7 = Add(Boundary(l), kind, 1f, 0.0015f);
						Add(Boundary(num2), kind, 1f, 0.0015f);
						Add(Boundary(num2) * 0.975f, kind, 1f, 0.0015f);
						Add(Boundary(l) * 0.975f, kind, 1f, 0.0015f);
						list.AddRange(new int[6]
						{
							num7,
							num7 + 1,
							num7 + 2,
							num7,
							num7 + 2,
							num7 + 3
						});
					}
					int Add(Vector2 p, byte item, float edge, float lift = 0f)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						//IL_000b: Unknown result type (might be due to invalid IL or missing references)
						//IL_001f: Unknown result type (might be due to invalid IL or missing references)
						//IL_002c: Unknown result type (might be due to invalid IL or missing references)
						//IL_0038: Unknown result type (might be due to invalid IL or missing references)
						//IL_0044: Unknown result type (might be due to invalid IL or missing references)
						//IL_0050: Unknown result type (might be due to invalid IL or missing references)
						//IL_0055: Unknown result type (might be due to invalid IL or missing references)
						//IL_0058: Unknown result type (might be due to invalid IL or missing references)
						//IL_0069: Unknown result type (might be due to invalid IL or missing references)
						Vector3 val = Point(p, lift);
						int count2 = vertices.Count;
						vertices.Add(val);
						List<Vector3> list2 = normals;
						Vector3 val2 = new Vector3(val.x / 11.9025f, val.y / 6.76f, val.z / 14.822499f);
						list2.Add(((Vector3)(ref val2)).normalized);
						heights.Add(val.y / 2.6f);
						kinds.Add(item);
						weights.Add(edge);
						return count2;
					}
				}
			}
			return new BastionAegisGeometry
			{
				Vertices = vertices.ToArray(),
				Normals = normals.ToArray(),
				Triangles = list.ToArray(),
				Kinds = kinds.ToArray(),
				Heights = heights.ToArray(),
				EdgeWeights = weights.ToArray()
			};
			Vector2 Boundary(int num9)
			{
				//IL_0019: 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)
				int num8 = num9 % 32 / 4;
				float num10 = (float)(num9 % 4) / 4f;
				return Vector2.Lerp(outline[num8], outline[(num8 + 1) % 8], num10);
			}
			Vector3 Point(Vector2 p, float lift = 0f)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: 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)
				bool flag = (row == 0 && p.y < 0f) || (row == 4 && p.y > 0f);
				float num8 = yaw + p.x * MathF.PI / 12f * 0.925f;
				float num9 = latitude + p.y * 1.54f / 5f * (flag ? 1.095f : 0.915f);
				float num10 = (float)Math.Pow(Math.Max(0.0, Math.Cos(num9)), 0.45);
				return new Vector3((float)Math.Sin(num8) * 3.45f * num10, (float)((double)Math.Sign(num9) * Math.Pow(Math.Abs(Math.Sin(num9)), 0.85)) * 2.6f, (float)Math.Cos(num8) * 3.85f * num10) * (1f + lift);
			}
		}
	}
	internal sealed class BastionAegisHexGeometry
	{
		internal Vector3[] Vertices;

		internal Vector3[] Normals;

		internal int[] Triangles;

		internal byte[] Kinds;

		internal int Hexagons;

		internal int Pentagons;

		internal static BastionAegisHexGeometry Build()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: 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_04d3: 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_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_0597: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0684: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_0738: Unknown result type (might be due to invalid IL or missing references)
			//IL_073f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0744: Unknown result type (might be due to invalid IL or missing references)
			//IL_0748: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_074f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0751: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0761: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_0768: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_077a: Unknown result type (might be due to invalid IL or missing references)
			//IL_077f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Unknown result type (might be due to invalid IL or missing references)
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07be: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07df: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			float num = (1f + (float)Math.Sqrt(5.0)) * 0.5f;
			List<Vector3> points = new List<Vector3>
			{
				new Vector3(-1f, num, 0f),
				new Vector3(1f, num, 0f),
				new Vector3(-1f, 0f - num, 0f),
				new Vector3(1f, 0f - num, 0f),
				new Vector3(0f, -1f, num),
				new Vector3(0f, 1f, num),
				new Vector3(0f, -1f, 0f - num),
				new Vector3(0f, 1f, 0f - num),
				new Vector3(num, 0f, -1f),
				new Vector3(num, 0f, 1f),
				new Vector3(0f - num, 0f, -1f),
				new Vector3(0f - num, 0f, 1f)
			};
			Vector3 val;
			for (int i = 0; i < points.Count; i++)
			{
				List<Vector3> list = points;
				int index = i;
				val = points[i];
				list[index] = ((Vector3)(ref val)).normalized;
			}
			List<int[]> list2 = new List<int[]>();
			list2.Add(new int[3] { 0, 11, 5 });
			list2.Add(new int[3] { 0, 5, 1 });
			list2.Add(new int[3] { 0, 1, 7 });
			list2.Add(new int[3] { 0, 7, 10 });
			list2.Add(new int[3] { 0, 10, 11 });
			list2.Add(new int[3] { 1, 5, 9 });
			list2.Add(new int[3] { 5, 11, 4 });
			list2.Add(new int[3] { 11, 10, 2 });
			list2.Add(new int[3] { 10, 7, 6 });
			list2.Add(new int[3] { 7, 1, 8 });
			list2.Add(new int[3] { 3, 9, 4 });
			list2.Add(new int[3] { 3, 4, 2 });
			list2.Add(new int[3] { 3, 2, 6 });
			list2.Add(new int[3] { 3, 6, 8 });
			list2.Add(new int[3] { 3, 8, 9 });
			list2.Add(new int[3] { 4, 9, 5 });
			list2.Add(new int[3] { 2, 4, 11 });
			list2.Add(new int[3] { 6, 2, 10 });
			list2.Add(new int[3] { 8, 6, 7 });
			list2.Add(new int[3] { 9, 8, 1 });
			List<int[]> list3 = list2;
			for (int j = 0; j < 2; j++)
			{
				Dictionary<long, int> midpoints = new Dictionary<long, int>();
				List<int[]> list4 = new List<int[]>();
				foreach (int[] item in list3)
				{
					int num2 = item[0];
					int num3 = item[1];
					int num4 = item[2];
					int num5 = Midpoint(num2, num3);
					int num6 = Midpoint(num3, num4);
					int num7 = Midpoint(num4, num2);
					list4.Add(new int[3] { num2, num5, num7 });
					list4.Add(new int[3] { num3, num6, num5 });
					list4.Add(new int[3] { num4, num7, num6 });
					list4.Add(new int[3] { num5, num6, num7 });
				}
				list3 = list4;
				int Midpoint(int a, int b)
				{
					//IL_0040: 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_0056: 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)
					long key = ((long)Math.Min(a, b) << 32) | (uint)Math.Max(a, b);
					if (midpoints.TryGetValue(key, out var value))
					{
						return value;
					}
					value = points.Count;
					List<Vector3> list7 = points;
					Vector3 val3 = points[a] + points[b];
					list7.Add(((Vector3)(ref val3)).normalized);
					midpoints[key] = value;
					return value;
				}
			}
			List<Vector3>[] array = new List<Vector3>[points.Count];
			for (int k = 0; k < array.Length; k++)
			{
				array[k] = new List<Vector3>();
			}
			foreach (int[] item2 in list3)
			{
				val = points[item2[0]] + points[item2[1]] + points[item2[2]];
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				int[] array2 = item2;
				foreach (int num8 in array2)
				{
					array[num8].Add(normalized);
				}
			}
			List<Vector3> vertices = new List<Vector3>();
			List<Vector3> normals = new List<Vector3>();
			List<int> list5 = new List<int>();
			List<byte> kinds = new List<byte>();
			int num9 = 0;
			int num10 = 0;
			for (int m = 0; m < points.Count; m++)
			{
				Vector3 val2 = points[m];
				val = Vector3.Cross((Math.Abs(val2.y) > 0.9f) ? Vector3.right : Vector3.up, val2);
				Vector3 tangent = ((Vector3)(ref val)).normalized;
				Vector3 bitangent = Vector3.Cross(val2, tangent);
				List<Vector3> list6 = array[m];
				list6.Sort((Vector3 a, Vector3 b) => Math.Atan2(Vector3.Dot(a, bitangent), Vector3.Dot(a, tangent)).CompareTo(Math.Atan2(Vector3.Dot(b, bitangent), Vector3.Dot(b, tangent))));
				if (list6.Count == 6)
				{
					num9++;
				}
				else if (list6.Count == 5)
				{
					num10++;
				}
				int num11 = Add(val2, 0);
				for (int num12 = 0; num12 < list6.Count; num12++)
				{
					val = Vector3.Lerp(val2, list6[num12], 0.94f);
					Vector3 normalized2 = ((Vector3)(ref val)).normalized;
					val = Vector3.Lerp(val2, list6[(num12 + 1) % list6.Count], 0.94f);
					Vector3 normalized3 = ((Vector3)(ref val)).normalized;
					int num13 = Add(normalized2, 0);
					int num14 = Add(normalized3, 0);
					list5.AddRange(new int[3] { num11, num13, num14 });
					int num15 = Add(normalized2 * 1.001f, 1);
					Add(normalized3 * 1.001f, 1);
					val = Vector3.Lerp(val2, normalized3, 0.94f);
					Add(((Vector3)(ref val)).normalized * 1.001f, 1);
					val = Vector3.Lerp(val2, normalized2, 0.94f);
					Add(((Vector3)(ref val)).normalized * 1.001f, 1);
					list5.AddRange(new int[6]
					{
						num15,
						num15 + 1,
						num15 + 2,
						num15,
						num15 + 2,
						num15 + 3
					});
					val = Vector3.Lerp(val2, normalized2, 0.82f);
					Vector3 normalized4 = ((Vector3)(ref val)).normalized;
					val = Vector3.Lerp(val2, normalized3, 0.82f);
					Vector3 normalized5 = ((Vector3)(ref val)).normalized;
					val = Vector3.Lerp(normalized4, normalized5, 0.24f);
					Vector3 normalized6 = ((Vector3)(ref val)).normalized;
					int num16 = Add(normalized4 * 1.002f, 2);
					Add(normalized6 * 1.002f, 2);
					val = Vector3.Lerp(val2, normalized6, 0.96f);
					Add(((Vector3)(ref val)).normalized * 1.002f, 2);
					val = Vector3.Lerp(val2, normalized4, 0.96f);
					Add(((Vector3)(ref val)).normalized * 1.002f, 2);
					list5.AddRange(new int[6]
					{
						num16,
						num16 + 1,
						num16 + 2,
						num16,
						num16 + 2,
						num16 + 3
					});
				}
			}
			return new BastionAegisHexGeometry
			{
				Vertices = vertices.ToArray(),
				Normals = normals.ToArray(),
				Triangles = list5.ToArray(),
				Kinds = kinds.ToArray(),
				Hexagons = num9,
				Pentagons = num10
			};
			int Add(Vector3 point, byte kind)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				int count = vertices.Count;
				vertices.Add(point);
				normals.Add(((Vector3)(ref point)).normalized);
				kinds.Add(kind);
				return count;
			}
		}

		internal static Color Tint(byte kind, Vector3 normal, Vector3 view, float age, float impact, float visibility)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Math.Pow(1f - Math.Abs(Vector3.Dot(normal, view)), 2.5);
			float num2 = (float)Math.Sin(age * 1.7f - 0.8f);
			float num3 = Math.Max(0f, 1f - Math.Abs(normal.y - num2) / 0.12f);
			float num4 = kind switch
			{
				1 => 0.2f + 0.19f * num + 0.36f * impact + 0.08f * num3, 
				0 => 0.009f + 0.021f * num + 0.065f * impact + 0.005f * num3, 
				_ => 0.31f + 0.18f * num + 0.34f * impact + 0.15f * num3, 
			};
			Color result = (Color)(kind switch
			{
				1 => new Color(1f, 0.82f + 0.12f * impact, 0.12f + 0.52f * impact), 
				0 => new Color(1f, 0.72f, 0.07f), 
				_ => new Color(1f, 0.91f + 0.08f * impact, 0.48f + 0.38f * impact), 
			});
			result.a = num4 * visibility;
			return result;
		}
	}
	public sealed class BastionAegisVisual : MonoBehaviour
	{
		private BastionController owner;

		private BastionShieldVisual innerShield;

		private GameObject field;

		private Mesh mesh;

		private Material material;

		private BastionAegisHexGeometry geometry;

		private Color[] colors;

		private float visibility;

		private float activated;

		private float impact;

		private readonly float[] hitTimes = new float[3] { -99f, -99f, -99f };

		private readonly float[][] hitAngles = new float[3][];

		private int nextHit;

		private bool wasActive;

		private void Start()
		{
			owner = ((Component)this).GetComponent<BastionController>();
			innerShield = ((Component)this).GetComponent<BastionShieldVisual>();
		}

		private void OnEnable()
		{
			GlobalEventManager.onClientDamageNotified += OnDamage;
		}

		private void OnDisable()
		{
			GlobalEventManager.onClientDamageNotified -= OnDamage;
		}

		private void OnDamage(DamageDealtMessage message)
		{
			//IL_009e: 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_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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isBatchMode && !((Object)(object)message.victim != (Object)(object)((Component)this).gameObject) && !(message.damage <= 0f) && Object.op_Implicit((Object)(object)owner) && owner.Alive && owner.Sieged && !(owner.Bank.DefenseTime <= 0f))
			{
				if (!Object.op_Implicit((Object)(object)field))
				{
					Build();
				}
				Vector3 val = (Object.op_Implicit((Object)(object)innerShield) ? innerShield.Center : owner.Body.corePosition);
				Vector3 val2 = message.position - val;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.01f && Object.op_Implicit((Object)(object)message.attacker))
				{
					val2 = message.attacker.transform.position - val;
				}
				val2 = ((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward);
				int num = nextHit++ % hitTimes.Length;
				hitTimes[num] = Time.time;
				for (int i = 0; i < colors.Length; i++)
				{
					hitAngles[num][i] = Mathf.Acos(Mathf.Clamp(Vector3.Dot(geometry.Normals[i], val2), -1f, 1f));
				}
			}
		}

		internal void Trigger()
		{
			activated = Time.time;
			impact = 0.65f;
		}

		private void Build()
		{
			//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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			geometry = BastionAegisHexGeometry.Build();
			colors = (Color[])(object)new Color[geometry.Vertices.Length];
			for (int i = 0; i < hitAngles.Length; i++)
			{
				hitAngles[i] = new float[colors.Length];
			}
			mesh = new Mesh
			{
				name = "Seraph Aegis hexagonal outer shell",
				vertices = geometry.Vertices,
				normals = geometry.Normals,
				triangles = geometry.Triangles,
				colors = colors
			};
			mesh.MarkDynamic();
			mesh.RecalculateBounds();
			material = new Material(BastionFx.LineMaterial)
			{
				name = "Seraph yellow Aegis",
				renderQueue = 3100
			};
			if (material.HasProperty("_Cull"))
			{
				material.SetFloat("_Cull", 2f);
			}
			field = new GameObject("Seraph yellow hexagonal Aegis barrier");
			field.AddComponent<MeshFilter>().sharedMesh = mesh;
			MeshRenderer obj = field.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = material;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			((Renderer)obj).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)obj).reflectionProbeUsage = (ReflectionProbeUsage)0;
		}

		private void LateUpdate()
		{
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isBatchMode || !Object.op_Implicit((Object)(object)owner))
			{
				return;
			}
			bool flag = owner.Alive && owner.Sieged && owner.Bank.DefenseTime > 0f;
			if (flag && !wasActive)
			{
				Trigger();
			}
			wasActive = flag;
			float num = (flag ? Mathf.Clamp01(owner.Bank.DefenseTime / 0.35f) : 0f);
			visibility = Mathf.MoveTowards(visibility, num, Time.deltaTime * (flag ? 4.5f : 7f));
			if (visibility <= 0f || !owner.Alive)
			{
				if (Object.op_Implicit((Object)(object)field))
				{
					field.SetActive(false);
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)field))
			{
				Build();
			}
			field.SetActive(true);
			impact = Mathf.MoveTowards(impact, 0f, Time.deltaTime * 4f);
			field.transform.position = (Object.op_Implicit((Object)(object)innerShield) ? innerShield.Center : owner.Body.corePosition);
			field.transform.rotation = Quaternion.identity;
			float num2 = (Object.op_Implicit((Object)(object)innerShield) ? innerShield.CurrentRadius : 4.2f) + 0.22f;
			field.transform.localScale = Vector3.one * (num2 * owner.Body.currentScale);
			Camera main = Camera.main;
			Vector3 val = (Object.op_Implicit((Object)(object)main) ? (((Component)main).transform.position - field.transform.position) : (-owner.Body.inputBank.aimDirection));
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			float num3 = Time.time - activated;
			for (int i = 0; i < colors.Length; i++)
			{
				float num4 = Mathf.SmoothStep(0f, 1f, (num3 - (geometry.Normals[i].y + 1f) * 0.06f) * 6f);
				float num5 = impact * 0.35f;
				for (int j = 0; j < hitTimes.Length; j++)
				{
					if (Time.time - hitTimes[j] < 0.85f)
					{
						num5 += BastionShieldGeometry.Ripple(hitAngles[j][i], Time.time - hitTimes[j], 1f);
					}
				}
				colors[i] = BastionAegisHexGeometry.Tint(geometry.Kinds[i], geometry.Normals[i], normalized, num3, Mathf.Clamp01(num5), visibility * num4);
			}
			mesh.colors = colors;
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)mesh))
			{
				Object.Destroy((Object)(object)mesh);
			}
			if (Object.op_Implicit((Object)(object)field))
			{
				Object.Destroy((Object)(object)field);
			}
			if (Object.op_Implicit((Object)(object)material))
			{
				Object.Destroy((Object)(object)material);
			}
		}
	}
	[DefaultExecutionOrder(12000)]
	public sealed class BastionAnimation : MonoBehaviour
	{
		public CharacterBody Owner;

		public Transform Mobile;

		public Transform Siege;

		public Transform[] MobileBones;

		public Transform[] SiegeBones;

		public Renderer[] Original;

		public RendererInfo[] MobileRenderers;

		public RendererInfo[] SiegeRenderers;

		private Vector3[] mr;

		private Vector3[] sr;

		private Quaternion[] mp;

		private Quaternion[] sp;

		private Light[] lights;

		private Renderer[] emissive;

		private readonly BastionPoseInput input = new BastionPoseInput();

		private readonly BastionPoseFrame mobileFrame = new BastionPoseFrame();

		private readonly BastionPoseFrame siegeFrame = new BastionPoseFrame();

		private readonly float[] hatchTimes = Enumerable.Repeat(-100f, 72).ToArray();

		private readonly float[] hatchAges = new float[72];

		private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock();

		private float shootUntil;

		private float leftKick;

		private float rightKick;

		private float laserKick;

		private float missileKick;

		private float deathAge;

		private float transformTime = -99f;

		private float transformSpan;

		private float salvoUntil;

		private float powerStarted = -99f;

		private float leftSkyfallKick;

		private float rightSkyfallKick;

		private float aim;

		private float boost;

		private float forward;

		private float strafe;

		private float vertical;

		private float brake;

		private float turn;

		private float pitch;

		private float lastSpeed;

		private float lastYaw;

		private float defense;

		private float overdrive;

		private float nextDisplays;

		private float haloPhase;

		private void Start()
		{
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			mr = MobileBones.Select((Transform b) => b.localPosition).ToArray();
			sr = SiegeBones.Select((Transform b) => b.localPosition).ToArray();
			mp = MobileBones.Select((Transform b) => b.localRotation).ToArray();
			sp = SiegeBones.Select((Transform b) => b.localRotation).ToArray();
			lights = ((Component)this).GetComponentsInChildren<Light>(true);
			emissive = (from i in MobileRenderers.Concat(SiegeRenderers)
				where ((Object)i.renderer).name.EndsWith("_Blue") || ((Object)i.renderer).name.EndsWith("_Core") || ((Object)i.renderer).name.EndsWith("_Reconstructed")
				select i.renderer).ToArray();
			lastYaw = ((Component)this).transform.eulerAngles.y;
		}

		internal Vector3 Muzzle(bool laser, int sequence)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((IEnumerable<Transform>)(laser ? SiegeBones : MobileBones)).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == (laser ? "cannon_muzzle" : ((sequence % 2 == 0) ? "muzzle_l" : "muzzle_r"))));
			if (Object.op_Implicit((Object)(object)val))
			{
				return val.position;
			}
			if (laser)
			{
				Transform val2 = ((IEnumerable<Transform>)SiegeBones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == "cannon"));
				if (Object.op_Implicit((Object)(object)val2))
				{
					return val2.TransformPoint(new Vector3(0f, 0f, 1.81f));
				}
			}
			int sign = ((sequence % 2 != 0) ? 1 : (-1));
			Transform val3 = ((IEnumerable<Transform>)MobileBones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == ((sign < 0) ? "fore_l" : "fore_r")));
			if (!Object.op_Implicit((Object)(object)val3))
			{
				return ((Component)this).transform.position;
			}
			return val3.TransformPoint(new Vector3((float)sign * 0.023f, -0.251f, 0.07f));
		}

		internal Vector3 MissilePort(uint sequence)
		{
			//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_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: 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_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: 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_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: 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_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			if (SiegeBones.Any((Transform b) => ((Object)b).name == "cannon_muzzle"))
			{
				string portName = $"hatch_{sequence % 4}_{sequence / 4 % 6}_{sequence / 24 % 3}";
				Transform val = ((IEnumerable<Transform>)SiegeBones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == portName));
				if (Object.op_Implicit((Object)(object)val))
				{
					return val.TransformPoint(new Vector3(0f, 0f, 0.04f));
				}
			}
			bool flag = sequence % 4 >= 2;
			int num = ((sequence % 2 != 0) ? 1 : (-1));
			string name = (flag ? "shield_" : "rack_") + ((num < 0) ? "l" : "r");
			Transform val2 = ((IEnumerable<Transform>)SiegeBones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == name));
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return ((Component)this).transform.position;
			}
			float num2 = (flag ? (-0.59f) : 0.28f);
			float num3 = (flag ? (-0.17f) : 0f);
			float num4 = (flag ? 0.16f : 0f);
			Vector3[] obj = new Vector3[5]
			{
				new Vector3((float)num * (0.79f + num3), 0.46f, num2),
				new Vector3((float)num * (1.16f + num3), 0.85f, num2 - 0.04f),
				new Vector3((float)num * (1.36f + num3), 1.5f, num2 - 0.12f),
				new Vector3((float)num * (1.2f + num3), 2.18f + num4, num2 - 0.22f),
				new Vector3((float)num * (0.97f + num3), 2.59f + num4, num2 - 0.26f)
			};
			int num5 = (int)(sequence / 4 % 6);
			int num6 = (int)(sequence / 24 % 3 - 1);
			float num7 = 1f + ((float)num5 + 0.6f) / 6.9f * 2.4f;
			int num8 = Mathf.Min(3, (int)num7);
			float num9 = num7 - (float)num8;
			Vector3 val3 = obj[Mathf.Max(0, num8 - 1)];
			Vector3 val4 = obj[num8];
			Vector3 val5 = obj[num8 + 1];
			Vector3 val6 = obj[Mathf.Min(4, num8 + 2)];
			Vector3 val7 = 0.5f * (2f * val4 + (-val3 + val5) * num9 + (2f * val3 - 5f * val4 + 4f * val5 - val6) * num9 * num9 + (-val3 + 3f * val4 - 3f * val5 + val6) * num9 * num9 * num9);
			val7 += new Vector3((float)num6 * ((num5 < 4) ? 0.145f : 0.12f), 0f, 0.23f);
			return val2.TransformPoint(val7 - new Vector3((float)num * 0.8f, 0.47f, num2));
		}

		internal Vector3 SkyfallPort(int sequence)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			string suffix = ((sequence % 2 == 0) ? "l" : "r");
			Transform val = ((IEnumerable<Transform>)SiegeBones).FirstOrDefault((Func<Transform, bool>)((Transform b) => ((Object)b).name == "skyfall_muzzle_" + suffix));
			if (!Object.op_Implicit((Object)(object)val))
			{
				return Siege.TransformPoint(new Vector3((sequence % 2 == 0) ? (-0.78f) : 0.78f, 2.6f, -1.94f));
			}
			return val.position;
		}

		internal void Cue(BastionFxKind kind, float value = 0f, Vector3 source = default(Vector3), uint id = 0u)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: 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_00f5: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			if (kind == BastionFxKind.Pistol)
			{
				if (Object.op_Implicit((Object)(object)Owner))
				{
					val = source - Owner.corePosition;
					if (((Vector3)(ref val)).sqrMagnitude > 25f)
					{
						return;
					}
				}
				shootUntil = Time.time + 0.28f;
				val = Muzzle(laser: false, 0) - source;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				val = Muzzle(laser: false, 1) - source;
				if (sqrMagnitude < ((Vector3)(ref val)).sqrMagnitude)
				{
					leftKick = 1f;
				}
				else
				{
					rightKick = 1f;
				}
			}
			if (kind == BastionFxKind.Laser)
			{
				laserKick = 1f;
				shootUntil = Time.time + 0.5f;
			}
			if (kind == BastionFxKind.Missile || kind == BastionFxKind.HeavyMissile)
			{
				missileKick = 1f;
				int num = 0;
				float num2 = float.PositiveInfinity;
				Transform[] siegeBones = SiegeBones;
				foreach (Transform val2 in siegeBones)
				{
					if (((Object)val2).name.StartsWith("hatch_"))
					{
						val = val2.position - source;
						float sqrMagnitude2 = ((Vector3)(ref val)).sqrMagnitude;
						if (sqrMagnitude2 < num2)
						{
							num2 = sqrMagnitude2;
							num = ((Object)val2).name[6] - 48 + (((Object)val2).name[8] - 48) * 4 + (((Object)val2).name[10] - 48) * 24;
						}
					}
				}
				hatchTimes[num] = Time.time;
			}
			if (kind == BastionFxKind.SiegeWarhead)
			{
				missileKick = 0.8f;
				val = SkyfallPort(0) - source;
				float sqrMagnitude3 = ((Vector3)(ref val)).sqrMagnitude;
				val = SkyfallPort(1) - source;
				if (sqrMagnitude3 < ((Vector3)(ref val)).sqrMagnitude)
				{
					leftSkyfallKick = 1f;
				}
				else
				{
					rightSkyfallKick = 1f;
				}
			}
			if (kind == BastionFxKind.Saturation)
			{
				salvoUntil = Time.time + 4.5f;
			}
			if (kind == BastionFxKind.Redline)
			{
				powerStarted = Time.time;
			}
			if (kind == BastionFxKind.Transform)
			{
				transformTime = Time.time;
				transformSpan = ((value == 0f) ? 0.8f : value);
			}
		}

		internal void CancelTransform()
		{
			transformTime = -99f;
			transformSpan = 0f;
		}

		private static float Damp(float a, float b, float rate, float dt)
		{
			return Mathf.Lerp(a, b, 1f - Mathf.Exp((0f - rate) * dt));
		}

		private static Vector3 U(Vector3 v)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v.X, v.Y, v.Z);
		}

		private void Apply(Transform[] bones, Vector3[] rest, Quaternion[] previous, BastionPoseFrame frame, float dt)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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_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_00c9: 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_00e0: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < bones.Length; i++)
			{
				if (frame.Bones.TryGetValue(((Object)bones[i]).name, out var value))
				{
					string name = ((Object)bones[i]).name;
					float num = (name.StartsWith("hatch_") ? 32 : ((name.StartsWith("wing_") || name.StartsWith("vane_")) ? 14 : ((name.StartsWith("leg_") || name.StartsWith("boot_")) ? 11 : ((name == "torso") ? 16 : 24))));
					Quaternion val = Quaternion.Euler(U(value.Rotation));
					previous[i] = Quaternion.Slerp(previous[i], val, 1f - Mathf.Exp((0f - num) * dt));
					bones[i].localRotation = previous[i];
					bones[i].localPosition = Vector3.Lerp(bones[i].localPosition, rest[i] + U(value.Offset), 1f - Mathf.Exp((0f - num) * dt));
				}
			}
		}

		private void LateUpdate()
		{
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: 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_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: 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_0433: 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_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_093d: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0954: Unknown result type (might be due to invalid IL or missing references)
			//IL_096a: Unknown result type (might be due to invalid IL or missing references)
			//IL_097a: Unknown result type (might be due to invalid IL or missing references)
			//IL_097f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0986: Unknown result type (might be due to invalid IL or missing references)
			//IL_0996: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
			if (mr == null)
			{
				return;
			}
			float num = Mathf.Min(0.05f, Time.deltaTime);
			Renderer[] original = Original;
			foreach (Renderer val in original)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.enabled = false;
				}
			}
			if (Time.unscaledTime >= nextDisplays)
			{
				nextDisplays = Time.unscaledTime + 0.5f;
				CharacterModel component = ((Component)this).GetComponent<CharacterModel>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.itemDisplayRuleSet = null;
					component.DisableAllItemDisplays();
				}
				ItemDisplay[] componentsInChildren = ((Component)this).GetComponentsInChildren<ItemDisplay>(true);
				foreach (ItemDisplay val2 in componentsInChildren)
				{
					if (((Component)val2).gameObject.activeSelf)
					{
						((Component)val2).gameObject.SetActive(false);
					}
				}
			}
			Light[] array;
			if (Object.op_Implicit((Object)(object)Owner) && Object.op_Implicit((Object)(object)Owner.healthComponent) && !Owner.healthComponent.alive)
			{
				deathAge += num;
				array = lights;
				foreach (Light val3 in array)
				{
					if (Object.op_Implicit((Object)(object)val3))
					{
						val3.intensity = Mathf.Max(0f, 1.2f - deathAge * 2f);
					}
				}
				float num2 = 1f - Mathf.Clamp01((deathAge - 0.6f) / 1f);
				Mobile.localRotation = Quaternion.Euler(15f + deathAge * 35f, 0f, deathAge * 20f);
				Mobile.localScale = Vector3.one * 0.78f * num2;
				Siege.localScale = Vector3.one * 1.45f * num2;
				return;
			}
			if (deathAge > 0f)
			{
				deathAge = 0f;
				powerStarted = -99f;
				transformTime = -99f;
				transformSpan = 0f;
				leftKick = (rightKick = (laserKick = (missileKick = (leftSkyfallKick = (rightSkyfallKick = 0f)))));
				Transform mobile = Mobile;
				Quaternion localRotation = (Siege.localRotation = Quaternion.identity);
				mobile.localRotation = localRotation;
			}
			BastionController bastionController = (Object.op_Implicit((Object)(object)Owner) ? ((Component)Owner).GetComponent<BastionController>() : null);
			bool flag = Object.op_Implicit((Object)(object)bastionController) && bastionController.Sieged;
			float time = Time.time;
			int num3;
			if (transformSpan != 0f)
			{
				if (time - transformTime < Mathf.Abs(transformSpan))
				{
					num3 = 1;
					goto IL_031f;
				}
				if (Object.op_Implicit((Object)(object)bastionController) && bastionController.Deploying)
				{
					num3 = ((bastionController.TransformTargetSiege == transformSpan > 0f) ? 1 : 0);
					if (num3 != 0)
					{
						goto IL_031f;
					}
				}
				else
				{
					num3 = 0;
				}
			}
			else
			{
				num3 = 0;
			}
			float num4 = (flag ? 1 : 0);
			goto IL_0338;
			IL_0338:
			float num5 = num4;
			if (num3 != 0 && transformSpan < 0f)
			{
				num5 = 1f - num5;
			}
			((Component)Mobile).gameObject.SetActive(num5 < 0.87f);
			((Component)Siege).gameObject.SetActive(num5 > 0.015f);
			BastionVisualSizing.SetRenderers(((Component)this).GetComponent<CharacterModel>(), (num5 >= 0.5f) ? SiegeRenderers : MobileRenderers);
			Vector3 val4 = ((Object.op_Implicit((Object)(object)Owner) && Object.op_Implicit((Object)(object)Owner.characterMotor)) ? Owner.characterMotor.velocity : Vector3.zero);
			Vector3 val5 = ((Component)this).transform.InverseTransformDirection(val4);
			float magnitude = ((Vector3)(ref val4)).magnitude;
			float y = ((Component)this).transform.eulerAngles.y;
			float num6 = Mathf.DeltaAngle(lastYaw, y) / Mathf.Max(0.001f, num);
			lastYaw = y;
			forward = Damp(forward, Mathf.Clamp(val5.z / 14f, -1f, 1f), 7f, num);
			strafe = Damp(strafe, Mathf.Clamp(val5.x / 14f, -1f, 1f), 7f, num);
			vertical = Damp(vertical, Mathf.Clamp(val5.y / 14f, -1f, 1f), 6f, num);
			float num7 = Mathf.Clamp01((lastSpeed - magnitude) / Mathf.Max(0.001f, num) / 55f);
			brake = Damp(brake, num7, (num7 > brake) ? 14f : 4.5f, num);
			lastSpeed = magnitude;
			turn = Damp(turn, Mathf.Clamp(num6 / 180f, -1f, 1f), 6f, num);
			aim = Damp(aim, (time < shootUntil) ? 1 : 0, 18f, num);
			boost = Damp(boost, (Object.op_Implicit((Object)(object)bastionController) && bastionController.Boosting) ? 1 : 0, 10f, num);
			defense = Damp(defense, (Object.op_Implicit((Object)(object)bastionController) && bastionController.Bank.DefenseTime > 0f) ? 1 : 0, 8f, num);
			overdrive = Damp(overdrive, (Object.op_Implicit((Object)(object)bastionController) && bastionController.Bank.RedlineTime > 0f) ? 1 : 0, 8f, num);
			leftKick = Damp(leftKick, 0f, 20f, num);
			rightKick = Damp(rightKick, 0f, 20f, num);
			laserKick = Damp(laserKick, 0f, 6f, num);
			missileKick = Damp(missileKick, 0f, 12f, num);
			leftSkyfallKick = Damp(leftSkyfallKick, 0f, 14f, num);
			rightSkyfallKick = Damp(rightSkyfallKick, 0f, 14f, num);
			input.LeftSkyfallKick = leftSkyfallKick;
			input.RightSkyfallKick = rightSkyfallKick;
			input.PowerAge = time - powerStarted;
			input.Time = time;
			input.Forward = forward;
			input.Strafe = strafe;
			input.Vertical = vertical;
			input.Brake = brake;
			input.Turn = turn;
			input.Aim = aim;
			input.Boost = boost;
			input.Defense = defense;
			input.Overdrive = overdrive;
			input.Unfold = num5;
			float b = ((Object.op_Implicit((Object)(object)Owner) && Object.op_Implicit((Object)(object)Owner.inputBank)) ? ((0f - Mathf.Asin(Mathf.Clamp(Owner.inputBank.aimDirection.y, -1f, 1f))) * 57.29578f) : 0f);
			pitch = Damp(pitch, b, 20f, num);
			input.Pitch = pitch;
			input.LeftKick = leftKick;
			input.RightKick = rightKick;
			input.LaserKick = laserKick;
			input.MissileKick = missileKick;
			input.Salvo = Mathf.Clamp01((salvoUntil - time) * 3f);
			haloPhase = Mathf.Repeat(haloPhase + num * (4f + defense * 6f + input.Salvo * 4f), 360f);
			input.HaloPhase = haloPhase;
			for (int j = 0; j < 72; j++)
			{
				hatchAges[j] = time - hatchTimes[j];
			}
			input.HatchAges = hatchAges;
			if (((Component)Mobile).gameObject.activeSelf)
			{
				BastionChoreography.Mobile(input, mobileFrame);
				float num8 = 1f - Mathf.Exp(-12f * num);
				Mobile.localPosition = Vector3.Lerp(Mobile.localPosition, U(mobileFrame.Offset), num8);
				Mobile.localRotation = Quaternion.Slerp(Mobile.localRotation, Quaternion.Euler(U(mobileFrame.Rotation)), num8);
				Mobile.localScale = Vector3.one * 0.78f * mobileFrame.Scale;
				Apply(MobileBones, mr, mp, mobileFrame, num);
			}
			if (((Component)Siege).gameObject.activeSelf)
			{
				BastionChoreography.Siege(input, siegeFrame);
				Siege.localPosition = U(siegeFrame.Offset);
				Siege.localRotation = Quaternion.identity;
				Siege.localScale = Vector3.one * 1.45f * siegeFrame.Scale;
				Apply(SiegeBones, sr, sp, siegeFrame, num);
			}
			float num9 = 1f + boost * 0.18f + defense * 0.12f + overdrive * 0.18f + laserKick * 0.25f + BastionChoreography.PowerCharge(input.PowerAge) * 0.65f + BastionChoreography.PowerRelease(input.PowerAge) * 0.8f;
			array = lights;
			foreach (Light val6 in array)
			{
				if (Object.op_Implicit((Object)(object)val6))
				{
					val6.intensity = 1.1f * num9;
				}
			}
			original = emissive;
			foreach (Renderer val7 in original)
			{
				if (Object.op_Implicit((Object)(object)val7))
				{
					val7.GetPropertyBlock(properties);
					properties.SetFloat("_EmPower", (((Object)val7).name.EndsWith("_Core") ? 2.1f : 1.35f) * num9);
					val7.SetPropertyBlock(properties);
				}
			}
			return;
			IL_031f:
			num4 = Mathf.Clamp01((time - transformTime) / Mathf.Abs(transformSpan));
			goto IL_0338;
		}
	}
	internal static class BastionAudio
	{
		private static readonly Dictionary<string, BastionPcmClip> clips = new Dictionary<string, BastionPcmClip>();

		private static readonly BastionPcmMixer mixer = new BastionPcmMixer();

		private static BastionWaveOut output;

		private static bool failed;

		private static float nextHit;

		private static BastionPcmVoice speaking;

		internal static void SetEnabled(bool enabled)
		{
			mixer.Muted = !enabled;
		}

		internal static void SetPaused(bool paused)
		{
			mixer.Paused = paused;
		}

		internal static void Shutdown()
		{
			output?.Dispose();
			output = null;
		}

		internal static void PositionVoice(BastionPcmVoice voice, Vector3 at)
		{
			//IL_0036: 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)
			//IL_0042: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			if (voice != null && !voice.Stopped)
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					voice.Volume = 0f;
					return;
				}
				Vector3 val2 = at - val.corePosition;
				voice.Volume = BastionPlugin.AudioVolume.Value * Mathf.Pow(Mathf.Clamp01(1f - ((Vector3)(ref val2)).magnitude / 90f), 2f);
				voice.Pan = Mathf.Clamp(Vector3.Dot(((Component)val).transform.right, ((Vector3)(ref val2)).normalized), -0.8f, 0.8f);
			}
		}

		internal static BastionPcmVoice Engine()
		{
			if (Application.isBatchMode || failed)
			{
				return null;
			}
			try
			{
				if (output == null)
				{
					output = new BastionWaveOut(mixer, delegate(string message)
					{
						BastionPlugin.Log.LogError((object)message);
					});
				}
				if (!clips.TryGetValue("engine", out var value))
				{
					using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("IvoryBastion.assets.sfx_engine.wav"))
					{
						value = BastionPcmClip.Read(stream);
					}
					clips["engine"] = value;
				}
				return mixer.Add(true, 0f, 0f, value);
			}
			catch (Exception ex)
			{
				failed = true;
				BastionPlugin.Log.LogError((object)ex.Message);
				return null;
			}
		}

		internal static BastionPcmVoice Cue(string name, Vector3 position, float gain = 1f, float pitch = 1f, bool voice = false)
		{
			//IL_004b: 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_01ec: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if (Application.isBatchMode || failed || mixer.Muted || BastionPlugin.AudioVolume.Value <= 0f)
			{
				return null;
			}
			LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
			CharacterBody val = ((firstLocalUser != null) ? firstLocalUser.cachedBody : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			float num = Vector3.Distance(position, val.corePosition);
			float num2 = (voice ? 90f : (name switch
			{
				"impact" => 75f, 
				"explosion" => 100f, 
				"siege_launch" => 100f, 
				"siege_impact" => 140f, 
				_ => 60f, 
			}));
			if (num >= num2)
			{
				return null;
			}
			if (name == "hit")
			{
				if (Time.unscaledTime < nextHit)
				{
					return null;
				}
				nextHit = Time.unscaledTime + 0.065f;
			}
			try
			{
				if (output == null)
				{
					output = new BastionWaveOut(mixer, delegate(string message)
					{
						BastionPlugin.Log.LogError((object)message);
					});
				}
				if (!clips.TryGetValue(name, out var value))
				{
					using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("IvoryBastion.assets.sfx_" + name + ".wav");
					if (stream == null)
					{
						throw new FileNotFoundException("Missing Ivory Bastion cue " + name);
					}
					value = BastionPcmClip.Read(stream);
					clips[name] = value;
				}
				float num3 = Mathf.Clamp01(gain) * BastionPlugin.AudioVolume.Value * Mathf.Pow(1f - num / num2, 2f) * ((name == "hook") ? 0.55f : 1f);
				if (!voice && speaking != null && !speaking.Stopped)
				{
					num3 *= 0.48f;
				}
				Vector3 right = ((Component)val).transform.right;
				Vector3 val2 = position - val.corePosition;
				float pan = Mathf.Clamp(Vector3.Dot(right, ((Vector3)(ref val2)).normalized), -0.8f, 0.8f);
				BastionPcmVoice bastionPcmVoice = mixer.Add(false, num3, pan, value);
				bastionPcmVoice.Pitch = Mathf.Clamp(pitch, 0.5f, 3f);
				if (voice)
				{
					speaking = bastionPcmVoice;
				}
				return bastionPcmVoice;
			}
			catch (Exception ex)
			{
				failed = true;
				BastionPlugin.Log.LogError((object)("Ivory Bastion audio: " + ex.Message));
			}
			return null;
		}
	}
	internal static class BastionBalanceConfig
	{
		internal const string Scope = "Host setting. Saved changes apply when the next run starts; multiplayer clients use the host's balance without changing their own config files. ";

		private static readonly List<ConfigEntryBase> entries = new List<ConfigEntryBase>();

		private static readonly Dictionary<ConfigEntryBase, BastionBalanceSpec> specs = new Dictionary<ConfigEntryBase, BastionBalanceSpec>();

		internal static void Bind(ConfigFile file)
		{
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			entries.Clear();
			specs.Clear();
			BastionBalanceSpec[] array = BastionBalance.Specs;
			foreach (BastionBalanceSpec bastionBalanceSpec in array)
			{
				string text = "Host setting. Saved changes apply when the next run starts; multiplayer clients use the host's balance without changing their own config files. " + bastionBalanceSpec.Description;
				ConfigEntryBase val = (ConfigEntryBase)(bastionBalanceSpec.Kind switch
				{
					BastionBalanceKind.Bool => file.Bind<bool>(bastionBalanceSpec.Category, bastionBalanceSpec.Key.ToString(), bastionBalanceSpec.Default > 0.5f, text), 
					BastionBalanceKind.Int => file.Bind<int>(bastionBalanceSpec.Category, bastionBalanceSpec.Key.ToString(), (int)bastionBalanceSpec.Default, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<int>((int)bastionBalanceSpec.Minimum, (int)bastionBalanceSpec.Maximum), Array.Empty<object>())), 
					_ => file.Bind<float>(bastionBalanceSpec.Category, bastionBalanceSpec.Key.ToString(), bastionBalanceSpec.Default, new ConfigDescription(text, (AcceptableValueBase)(object)new AcceptableValueRange<float>(bastionBalanceSpec.Minimum, bastionBalanceSpec.Maximum), Array.Empty<object>())), 
				});
				entries.Add(val);
				specs.Add(val, bastionBalanceSpec);
			}
		}

		internal static BastionBalanceSpec Find(ConfigEntryBase entry)
		{
			if (!specs.TryGetValue(entry, out var value))
			{
				return null;
			}
			return value;
		}

		internal static float[] Capture()
		{
			float[] array = BastionBalance.Defaults();
			for (int i = 0; i < entries.Count; i++)
			{
				array[i] = BastionBalance.Specs[i].Sanitize((entries[i].BoxedValue is bool flag) ? ((float)(flag ? 1 : 0)) : Convert.ToSingle(entries[i].BoxedValue));
			}
			return array;
		}
	}
	internal static class BastionBalanceRuntime
	{
		private static Run current;

		private static bool confirmed;

		private static float nextRequest;

		private static float nextBroadcast;

		private static float repeatUntil;

		private static float[] hostValues;

		internal static void Install()
		{
			NetworkingAPI.RegisterMessageType<BastionBalanceProfile>();
			NetworkingAPI.RegisterMessageType<BastionBalanceRequest>();
			Run.onRunStartGlobal += Begin;
			Run.onRunDestroyGlobal += End;
			if (Object.op_Implicit((Object)(object)Run.instance))
			{
				Begin(Run.instance);
			}
		}

		internal static void Remove()
		{
			Run.onRunStartGlobal -= Begin;
			Run.onRunDestroyGlobal -= End;
			current = null;
			confirmed = false;
			hostValues = null;
			BastionBalance.Reset();
		}

		private static void Begin(Run run)
		{
			current = run;
			confirmed = NetworkServer.active;
			nextRequest = (nextBroadcast = 0f);
			repeatUntil = Time.unscaledTime + 10f;
			if (NetworkServer.active)
			{
				hostValues = BastionBalanceConfig.Capture();
				BastionBalance.Apply(hostValues);
			}
			else
			{
				hostValues = null;
				BastionBalance.Reset();
			}
			Applied();
		}

		private static void End(Run run)
		{
			if (!((Object)(object)current != (Object)(object)run))
			{
				current = null;
				confirmed = false;
				hostValues = null;
				BastionBalance.Reset();
				BastionBalanceText.Refresh();
			}
		}

		internal static void Update()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing refe