Decompiled source of Hollow Saint v1.2.0

plugins/HollowSaint/HollowSaint.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HG.BlendableTypes;
using HollowSaint.FoundationKit;
using HollowSaint.FoundationKit.ArcBolt;
using HollowSaint.FoundationKit.ArcStep;
using HollowSaint.FoundationKit.Gaze;
using HollowSaint.FoundationKit.Gaze.Fx;
using HollowSaint.FoundationKit.OpenCircuit;
using HollowSaint.FoundationKit.OpenCircuit.Fx;
using HollowSaint.FoundationKit.SpearDischarge;
using HollowSaint.FoundationKit.Storm;
using HollowSaint.FoundationKit.Stormspear;
using HollowSaint.FoundationKit.Stormspear.Fx;
using HollowSaint.FoundationKit.Vfx;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPathsBetter;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[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("HollowSaint")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0+47d1178adbdfcbca3aa03a772fe61612ba2c9e30")]
[assembly: AssemblyProduct("HollowSaint")]
[assembly: AssemblyTitle("HollowSaint")]
[assembly: AssemblyVersion("1.2.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 HollowSaint
{
	internal static class CrimsonMasteryMaterials
	{
		private static Texture2D lightMask;

		private static bool warned;

		private static readonly Dictionary<Material, Material> materials = new Dictionary<Material, Material>();

		private static readonly Dictionary<Material, Color> intendedAlbedos = new Dictionary<Material, Color>();

		private static readonly Dictionary<Texture, Texture2D[]> atlases = new Dictionary<Texture, Texture2D[]>();

		internal static void Load(AssetBundle bundle)
		{
			if (!Object.op_Implicit((Object)(object)lightMask))
			{
				if (!Object.op_Implicit((Object)(object)bundle))
				{
					throw new ArgumentNullException("bundle");
				}
				lightMask = bundle.LoadAsset<Texture2D>("HS_BodyLightMask");
				if (!Object.op_Implicit((Object)(object)lightMask))
				{
					throw new InvalidOperationException("Crimson Vow needs the existing HS_BodyLightMask");
				}
			}
		}

		internal static Material Tint(Material source)
		{
			//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_004c: Expected O, but got Unknown
			//IL_0053: 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_0269: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Invalid comparison between Unknown and I4
			//IL_0169: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)source))
			{
				return source;
			}
			if (materials.TryGetValue(source, out var value) && Object.op_Implicit((Object)(object)value))
			{
				return value;
			}
			CrimsonMasteryVisuals.Style style = CrimsonMasteryVisuals.Describe(((Object)source).name);
			Material val = new Material(source)
			{
				name = ((Object)source).name + " (Crimson Vow)"
			};
			intendedAlbedos[val] = style.Albedo;
			bool flag = false;
			try
			{
				if (val.HasProperty("_Color"))
				{
					val.SetColor("_Color", style.Albedo);
				}
				if (val.HasProperty("_Metallic"))
				{
					val.SetFloat("_Metallic", style.Metallic);
				}
				if (val.HasProperty("_Glossiness"))
				{
					val.SetFloat("_Glossiness", style.Smoothness);
				}
				if (val.HasProperty("_EmissionColor"))
				{
					val.SetColor("_EmissionColor", style.Emission);
				}
				if (style.IsLight)
				{
					val.EnableKeyword("_EMISSION");
				}
				else
				{
					val.DisableKeyword("_EMISSION");
				}
				if (Object.op_Implicit((Object)(object)source.mainTexture) && ((Object)source.mainTexture).name == "body_base")
				{
					if (!Object.op_Implicit((Object)(object)lightMask))
					{
						throw new InvalidOperationException("Call CrimsonMasteryMaterials.Load before Tint");
					}
					if (val.HasProperty("_EmissionMap") && val.HasProperty("_EmissionColor"))
					{
						val.SetTexture("_EmissionMap", (Texture)(object)lightMask);
						val.SetColor("_EmissionColor", CrimsonMasteryVisuals.Arc * 0.72f);
						val.EnableKeyword("_EMISSION");
						flag = true;
					}
					else
					{
						val.DisableKeyword("_EMISSION");
					}
					bool flag2 = (int)SystemInfo.graphicsDeviceType == 4;
					val.mainTexture = (Texture)(object)(flag2 ? Texture2D.whiteTexture : Atlas(source.mainTexture, style.Kind == CrimsonMasteryVisuals.Role.Plate));
					if (!flag2 && val.HasProperty("_Color"))
					{
						val.SetColor("_Color", Color.white);
					}
				}
				materials[source] = val;
				return val;
			}
			catch (Exception ex)
			{
				if (!warned)
				{
					warned = true;
					Plugin.Log.LogWarning("Crimson Vow atlas fallback: " + ex.Message);
				}
				if (Object.op_Implicit((Object)(object)source.mainTexture) && ((Object)source.mainTexture).name == "body_base")
				{
					val.mainTexture = source.mainTexture;
					if (val.HasProperty("_Color"))
					{
						val.SetColor("_Color", style.Albedo);
					}
					if (!flag)
					{
						val.DisableKeyword("_EMISSION");
					}
				}
				materials[source] = val;
				return val;
			}
		}

		internal static bool TryGetIntendedAlbedo(Material material, out Color albedo)
		{
			return intendedAlbedos.TryGetValue(material, out albedo);
		}

		private static Texture2D Atlas(Texture source, bool plate)
		{
			//IL_007c: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			if (!atlases.TryGetValue(source, out var value))
			{
				value = (Texture2D[])(object)new Texture2D[2];
				atlases.Add(source, value);
			}
			int num = (plate ? 1 : 0);
			if (Object.op_Implicit((Object)(object)value[num]))
			{
				return value[num];
			}
			int num2 = Mathf.Min(2048, source.width);
			int num3 = Mathf.Min(2048, source.height);
			Color[] array = ReadPixels(source, num2, num3);
			Color[] array2 = ReadPixels((Texture)(object)lightMask, num2, num3);
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = CrimsonMasteryVisuals.AtlasPixel(array[i], Mathf.Max(array2[i].r, Mathf.Max(array2[i].g, array2[i].b)), plate);
			}
			Texture2D val = new Texture2D(num2, num3, (TextureFormat)4, true)
			{
				name = "HS_CrimsonVow_" + (plate ? "Plate" : "Body"),
				wrapMode = source.wrapMode,
				filterMode = source.filterMode
			};
			val.SetPixels(array);
			val.Apply(true, true);
			value[num] = val;
			return val;
		}

		private static Color[] ReadPixels(Texture source, int width, int height)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			RenderTexture active = RenderTexture.active;
			RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2);
			Texture2D val = null;
			try
			{
				Graphics.Blit(source, temporary);
				RenderTexture.active = temporary;
				val = new Texture2D(width, height, (TextureFormat)4, false);
				val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0, false);
				return val.GetPixels();
			}
			finally
			{
				RenderTexture.active = active;
				RenderTexture.ReleaseTemporary(temporary);
				if (Object.op_Implicit((Object)(object)val))
				{
					Object.Destroy((Object)(object)val);
				}
			}
		}
	}
	internal static class CrimsonMasteryVisuals
	{
		internal enum Role
		{
			Body,
			Plate,
			Cloth,
			Crown,
			Trim,
			Light,
			HotCore
		}

		internal readonly struct Style
		{
			internal readonly Role Kind;

			internal readonly Color Albedo;

			internal readonly Color Emission;

			internal readonly float Metallic;

			internal readonly float Smoothness;

			internal bool IsLight
			{
				get
				{
					if (Kind != Role.Light)
					{
						return Kind == Role.HotCore;
					}
					return true;
				}
			}

			internal Style(Role kind, Color albedo, Color emission, float metal, float smooth)
			{
				//IL_0008: 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_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				Kind = kind;
				Albedo = albedo;
				Emission = emission;
				Metallic = metal;
				Smoothness = smooth;
			}
		}

		internal const string SkinName = "HollowSaintCrimsonVow";

		internal const string MaterialSuffix = " (Crimson Vow)";

		internal const string NameToken = "HS_SKIN_CRIMSON_VOW_NAME";

		internal static readonly Color Plate = new Color(0.17f, 0.18f, 0.22f);

		internal static readonly Color Graphite = new Color(0.055f, 0.06f, 0.075f);

		internal static readonly Color Cloth = new Color(0.105f, 0.027f, 0.042f);

		internal static readonly Color Crown = new Color(0.4f, 0.055f, 0.075f);

		internal static readonly Color Trim = new Color(0.62f, 0.39f, 0.2f);

		internal static readonly Color Arc = new Color(1f, 0.075f, 0.12f);

		internal static readonly Color Outer = new Color(0.52f, 0.025f, 0.065f);

		internal static readonly Color Core = new Color(1f, 0.8f, 0.7f);

		internal static readonly Color Pulse = new Color(1f, 0.73f, 0.22f);

		internal static readonly Color PulseEdge = new Color(1f, 0.92f, 0.72f);

		internal static bool MatchesMaterial(string name)
		{
			return name?.EndsWith(" (Crimson Vow)", StringComparison.Ordinal) ?? false;
		}

		internal static Style Describe(string sourceName)
		{
			//IL_002b: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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)
			string text = (sourceName ?? "").ToLowerInvariant();
			if (text.Contains("core_hot") || text.Contains("core hot"))
			{
				return new Style(Role.HotCore, Arc, new Color(1f, 0.23f, 0.09f) * 0.9f, 0.25f, 0.55f);
			}
			if (text.Contains("conductor") || text.Contains("gap light") || text.Contains("gap_light") || text.Contains("contained_lightning") || text.Contains("energy_point") || text.Contains("pulse_entering"))
			{
				return new Style(Role.Light, Arc * 0.6f, Arc * 0.75f, 0.2f, 0.48f);
			}
			if (text.Contains("tabard") && (text.Contains("trim") || text.Contains("copper")))
			{
				return new Style(Role.Trim, Trim, Color.black, 0.85f, 0.65f);
			}
			if (text.Contains("tabard") || text.Contains("cloth"))
			{
				return new Style(Role.Cloth, Cloth, Color.black, 0f, 0.18f);
			}
			if (text.Contains("copper") || text.Contains("halo bone") || text.Contains("crescent"))
			{
				return new Style(Role.Crown, Crown, Color.black, 0.88f, 0.62f);
			}
			if ((text.Contains("ivory") || text.Contains("ceramic")) && !text.Contains("source_texture"))
			{
				return new Style(Role.Plate, Plate, Color.black, 0.35f, 0.55f);
			}
			return new Style(Role.Body, Graphite, Color.black, 0.22f, 0.38f);
		}

		internal static Color AtlasPixel(Color source, float lightMask, bool plate)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Clamp01(source.r * 0.2126f + source.g * 0.7152f + source.b * 0.0722f);
			Color val = (plate ? (Plate * 0.55f) : Graphite);
			Color val2 = (plate ? (Plate * 1.25f) : Plate);
			Color val3 = Color.Lerp(val, val2, num);
			val3 = Color.Lerp(val3, Arc * 0.3f, Mathf.Clamp01(lightMask));
			val3.a = source.a;
			return val3;
		}
	}
	internal sealed class DevAutopilot : MonoBehaviour
	{
		private sealed class Tally
		{
			public float damage;

			public int hits;

			public int onHit;

			public int onHitAll;
		}

		private string assistTestPrefab;

		private int assistTestHits;

		private readonly StringBuilder audioLog = new StringBuilder();

		private bool audioHooked;

		private string output;

		private readonly StringBuilder trace = new StringBuilder();

		private int errors;

		private int pops;

		private bool scripting;

		private bool fire1;

		private bool fire2;

		private bool fire3;

		private bool fire4;

		private bool jump;

		private bool sprint;

		private Vector3 move;

		private Vector3? aimTarget;

		private bool prev1;

		private bool prev2;

		private bool prev3;

		private bool prev4;

		private bool prevJump;

		private float aimPitch;

		private CharacterBody pilot;

		private Vector3 mark;

		private float markYaw;

		private Vector3 facing;

		private readonly List<CharacterBody> dummies = new List<CharacterBody>();

		private Camera shotCamera;

		private RenderTexture shotTarget;

		private float scriptTime;

		private string segment = "-";

		internal static bool Active;

		private static bool gameLoaded;

		private bool scriptingOrSetup = true;

		private bool crownOverride;

		private readonly Dictionary<string, Tally> tally = new Dictionary<string, Tally>();

		private readonly StringBuilder items = new StringBuilder();

		private bool tallying;

		private int hitDepth;

		private int maxHitDepth;

		private int onHitCalls;

		private int kills;

		private int slowFrames;

		private int statsErrors;

		private float worstFrame;

		private float lastShotReal = -10f;

		private float tallyStart;

		private CharacterBody tank;

		private readonly List<CharacterBody> pack = new List<CharacterBody>();

		private bool javelinChecking;

		private readonly List<CharacterBody> live = new List<CharacterBody>();

		private Vector3 cameraLook;

		private float syncFlashUntil;

		private Vector3? cameraWant;

		private CameraParamsOverrideHandle cameraHandle;

		private bool cameraHandleSet;

		private static FieldInfo camInstanceField;

		private static MethodInfo setLookMethod;

		private static long WallMs => (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;

		private Vector3 Right => Vector3.Cross(Vector3.up, facing);

		private IEnumerator AimAssistSegments()
		{
			float boltCone = KitTuning.ArcBoltAssistConeDegrees;
			float spearCone = StormspearTuning.AssistConeDegrees;
			float burst = StormspearTuning.BurstDamageFraction;
			GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(ObserveAssistHit);
			try
			{
				DevAutopilot devAutopilot = this;
				DevAutopilot devAutopilot2 = this;
				bool flag = false;
				devAutopilot2.fire2 = false;
				devAutopilot.fire1 = flag;
				StormspearTuning.BurstDamageFraction = 0f;
				bool[] array = new bool[2] { false, true };
				foreach (bool spear in array)
				{
					bool[] array2 = new bool[2] { false, true };
					foreach (bool flag2 in array2)
					{
						KitTuning.ArcBoltAssistConeDegrees = (flag2 ? 3f : 0f);
						StormspearTuning.AssistConeDegrees = (flag2 ? 3f : 0f);
						yield return AssistShot(spear, flag2);
					}
				}
			}
			finally
			{
				DevAutopilot devAutopilot3 = this;
				GlobalEventManager.OnHitEnemy -= new hook_OnHitEnemy(devAutopilot3.ObserveAssistHit);
				KitTuning.ArcBoltAssistConeDegrees = boltCone;
				StormspearTuning.AssistConeDegrees = spearCone;
				StormspearTuning.BurstDamageFraction = burst;
				devAutopilot3.assistTestPrefab = null;
			}
		}

		private IEnumerator AssistShot(bool spear, bool assisted)
		{
			string label = (spear ? "spear" : "bolt") + (assisted ? "-assisted" : "-straight");
			yield return Segment("aim-" + label);
			if (dummies.Count == 0 || !Object.op_Implicit((Object)(object)dummies[0]))
			{
				AssistCheck(ok: false, label + " missing target");
				yield break;
			}
			CharacterBody val = dummies[0];
			HurtBox mainHurtBox = val.mainHurtBox;
			Vector3 val2;
			if (!Object.op_Implicit((Object)(object)mainHurtBox) || !Object.op_Implicit((Object)(object)mainHurtBox.collider))
			{
				val2 = val.corePosition;
			}
			else
			{
				Bounds bounds = mainHurtBox.collider.bounds;
				val2 = ((Bounds)(ref bounds)).center;
			}
			Vector3 val3 = val2;
			Vector3 val4 = val3 - facing * 40f + Vector3.up * 15f;
			Vector3 val5 = val3 - val4;
			Vector3 normalized = ((Vector3)(ref val5)).normalized;
			Vector3 val6 = Quaternion.AngleAxis(-2.8f, Right) * normalized;
			if (Physics.Linecast(val4, val3, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				AssistCheck(ok: false, label + " test lane obstructed");
				yield break;
			}
			GameObject val7 = (spear ? StormspearProjectile.Prefab : ArcBoltProjectile.Prefab);
			assistTestPrefab = ((Object)val7).name;
			assistTestHits = 0;
			ProjectileManager.instance.FireProjectile(new FireProjectileInfo
			{
				projectilePrefab = val7,
				position = val4,
				rotation = Util.QuaternionSafeLookRotation(val6),
				owner = ((Component)pilot).gameObject,
				damage = pilot.damage * (spear ? StormspearTuning.TapDamage : KitTuning.ArcBoltDamageCoefficient)
			});
			float end = scriptTime + 1.2f;
			float turn = 0f;
			bool acquired = false;
			while (scriptTime < end)
			{
				yield return Wait(0.02f);
				ProjectileAimForgiveness[] array = Object.FindObjectsOfType<ProjectileAimForgiveness>();
				foreach (ProjectileAimForgiveness projectileAimForgiveness in array)
				{
					if (Object.op_Implicit((Object)(object)projectileAimForgiveness) && ((Object)projectileAimForgiveness).name.StartsWith(assistTestPrefab))
					{
						if (Object.op_Implicit((Object)(object)projectileAimForgiveness.LockedTarget))
						{
							acquired = true;
						}
						turn = Mathf.Max(turn, projectileAimForgiveness.TurnUsed);
					}
				}
			}
			trace.AppendLine("AIM_FLIGHT " + label + " acquired=" + acquired + " turn=" + turn.ToString("0.00") + " directHits=" + assistTestHits);
			AssistCheck(turn <= 8.01f, label + " exceeded turn budget");
			AssistCheck((!assisted) ? (!acquired && turn == 0f && assistTestHits == 0) : (acquired && turn > 0f && assistTestHits == 1), label + " near-miss flight result incorrect");
			assistTestPrefab = null;
		}

		private void ObserveAssistHit(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo info, GameObject victim)
		{
			if (assistTestPrefab != null && (Object)(object)info.attacker == (Object)(object)((Component)pilot).gameObject && Object.op_Implicit((Object)(object)info.inflictor) && ((Object)info.inflictor).name.StartsWith(assistTestPrefab))
			{
				assistTestHits++;
			}
			orig.Invoke(self, info, victim);
		}

		private void AssistCheck(bool ok, string why)
		{
			if (!ok)
			{
				errors++;
				trace.AppendLine("AIM_FAIL " + why);
				Plugin.Log.LogError("AIM_CHECK " + why);
			}
		}

		private void HookAudio()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!audioHooked)
			{
				audioHooked = true;
				Util.PlaySound_string_GameObject += new hook_PlaySound_string_GameObject(LogSound);
				audioLog.AppendLine("START " + WallMs);
			}
		}

		private void UnhookAudio()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (audioHooked)
			{
				audioHooked = false;
				Util.PlaySound_string_GameObject -= new hook_PlaySound_string_GameObject(LogSound);
			}
		}

		private void AudioMark(string label)
		{
			if (audioHooked)
			{
				audioLog.AppendLine("MARK " + WallMs + " " + label);
			}
		}

		private uint LogSound(orig_PlaySound_string_GameObject orig, string sound, GameObject source)
		{
			//IL_0037: 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)
			uint num = orig.Invoke(sound, source);
			try
			{
				if (!string.IsNullOrEmpty(sound))
				{
					Camera main = Camera.main;
					float num2 = ((Object.op_Implicit((Object)(object)main) && Object.op_Implicit((Object)(object)source)) ? Vector3.Distance(((Component)main).transform.position, source.transform.position) : (-1f));
					audioLog.Append("SND ").Append(WallMs).Append(' ')
						.Append(sound)
						.Append(' ')
						.Append(Object.op_Implicit((Object)(object)source) ? ((Object)source).name.Replace(' ', '_') : "-")
						.Append(' ')
						.Append(num2.ToString("0.0"))
						.Append(' ')
						.Append((num == 0) ? "FAILED" : "ok")
						.Append('\n');
				}
			}
			catch
			{
			}
			return num;
		}

		private IEnumerator AudioProbe()
		{
			yield return Segment("audio-probe");
			AkSoundEngine.SetRTPCValue("Volume_MSX", 0f);
			TeamComponent[] array = TeamComponent.GetTeamMembers((TeamIndex)2).ToArray();
			foreach (TeamComponent val in array)
			{
				HealthComponent val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<HealthComponent>() : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.godMode = false;
					val2.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
				}
			}
			yield return Wait(4f);
			AudioMark("SYNC");
			Util.PlaySound("Play_HS_SpearImpact", ((Component)pilot).gameObject);
			yield return Wait(1.5f);
			string[] names = new string[39]
			{
				"GazeLoad1", "GazeLoad2", "GazeLoad3", "GazeSurgeHit1", "GazeSurgeHit2", "GazeSurgeHit3", "GazeSurge1", "GazeSurge3", "GazeSurge5", "ArcBoltCast",
				"BoltImpact", "ChainHop", "Electrocute", "StaticTier", "ChargeTick", "MeterFull", "SpearChargeStart", "SpearThrow", "SpearThrowHeavy", "SpearImpact",
				"SpearBurst", "SpearStruck", "SpearPulse", "SpearCatch", "ArcStepStart", "ArcStepEnd", "AirJump", "Land", "CircuitUnfold", "CircuitOpen",
				"CircuitPulse", "CircuitClose", "ThunderTelegraph", "ThunderRelease", "ThunderStrike", "CircuitLoop", "SpearChargeLoop", "GlideLoop", "FanLoop"
			};
			if (Environment.GetEnvironmentVariable("HS_PROBE_GAZE") == "1" && Object.op_Implicit((Object)(object)GazeRegistration.SkillDef))
			{
				GenericSkill slot = pilot.skillLocator.special;
				slot.SetSkillOverride((object)this, GazeRegistration.SkillDef, (SkillOverridePriority)3);
				pilot.SetBuffCount(DischargeMeter.ChargeBuff.buffIndex, 5);
				pilot.skillLocator.ResetSkills();
				aimTarget = pilot.footPosition + facing * 8f;
				yield return Wait(0.3f);
				yield return Press(4);
				yield return Wait(1.3f);
				EntityStateMachine val3 = EntityStateMachine.FindByCustomName(((Component)pilot).gameObject, "Crown");
				trace.AppendLine("PROBE_GAZE_STATE " + (Object.op_Implicit((Object)(object)val3) ? ((object)val3.state).GetType().Name : "none"));
				AudioMark("GAZE_BEAM");
				yield return Wait(2f);
				AudioMark("GAZE_HOLD");
				fire1 = true;
				yield return Wait(3f);
				AudioMark("GAZE_RELEASE");
				fire1 = false;
				yield return Wait(2.5f);
				AudioMark("GAZE_DONE");
				yield return Press(4);
				yield return Wait(1.5f);
				slot.UnsetSkillOverride((object)this, GazeRegistration.SkillDef, (SkillOverridePriority)3);
			}
			for (int k = 0; k < 3; k++)
			{
				AudioMark("PROBE ThunderImpactFx");
				RoyalCapacitorFx.Strike(pilot.footPosition + facing * 4f, pilot);
				yield return Wait(2.6f);
			}
			for (int k = 0; k < 2; k++)
			{
				AudioMark("PROBE ThunderStrikeFresh");
				GameObject emitter = new GameObject("HS_ProbeEmitter");
				emitter.transform.position = pilot.corePosition + facing * 2f;
				Util.PlaySound("Play_HS_ThunderStrike", emitter);
				yield return Wait(2.6f);
				Object.Destroy((Object)(object)emitter, 0.1f);
			}
			if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("HS_PROBE_REPEAT")))
			{
				List<string> list = new List<string>();
				string[] array2 = new string[6] { "GazeLoad1", "GazeSurgeHit3", "MeterFull", "ArcStepStart", "ThunderStrike", "BoltImpact" };
				foreach (string item in array2)
				{
					for (int j = 0; j < 4; j++)
					{
						list.Add(item);
					}
				}
				names = list.ToArray();
			}
			string[] array3 = names;
			foreach (string n in array3)
			{
				AudioMark("PROBE " + n);
				Util.PlaySound("Play_HS_" + n, ((Component)pilot).gameObject);
				yield return Wait(n.EndsWith("Loop") ? 0.8f : 1.1f);
				if (n.EndsWith("Loop"))
				{
					Util.PlaySound("Stop_HS_" + n, ((Component)pilot).gameObject);
					yield return Wait(0.6f);
				}
			}
		}

		private void WriteAudioLog()
		{
			try
			{
				File.WriteAllText(Path.Combine(output, "audio-events.txt"), audioLog.ToString());
			}
			catch (Exception data)
			{
				Plugin.Log.LogError(data);
			}
		}

		private IEnumerator CircuitTerrainSegments()
		{
			Dictionary<string, KeyValuePair<Vector3, Vector3>> dictionary = FindTerrainSpots();
			foreach (KeyValuePair<string, KeyValuePair<Vector3, Vector3>> item in dictionary)
			{
				trace.AppendLine("TERRAIN_SPOT " + item.Key + " at=" + ((object)item.Value.Key/*cast due to .constrained prefix*/).ToString() + " face=" + ((object)item.Value.Value/*cast due to .constrained prefix*/).ToString());
			}
			DumpLines("idle-before-circuit");
			GenericSkill slot = pilot.skillLocator.special;
			if (!Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
			{
				trace.AppendLine("TERRAIN no Open Circuit def");
				errors++;
				yield break;
			}
			slot.SetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
			Vector3 savedFacing = facing;
			foreach (KeyValuePair<string, KeyValuePair<Vector3, Vector3>> kv in dictionary)
			{
				yield return Segment("circuit-terrain-" + kv.Key);
				Vector3 key = kv.Value.Key;
				facing = kv.Value.Value;
				TeleportHelper.TeleportBody(pilot, key);
				if (Object.op_Implicit((Object)(object)pilot.characterMotor))
				{
					pilot.characterMotor.velocity = Vector3.zero;
				}
				if (Object.op_Implicit((Object)(object)pilot.characterDirection))
				{
					pilot.characterDirection.forward = facing;
				}
				aimTarget = key + facing * 10f + Vector3.up;
				yield return Wait(0.5f);
				pilot.skillLocator.ResetSkills();
				yield return Press(4);
				yield return Wait(1.5f);
				OpenCircuitDomeFx dome = ((Component)pilot).GetComponent<OpenCircuitDomeFx>();
				for (int k = 0; k < 3; k++)
				{
					Shot("ct-" + kv.Key + "-" + k);
					if (k == 1)
					{
						TopShot("ct-" + kv.Key + "-top");
						ScreenCapture.CaptureScreenshot(Path.Combine(output, "ct-" + kv.Key + "-native.png"));
					}
					yield return Wait(0.11f);
				}
				trace.AppendLine("TERRAIN_BRANCHES " + kv.Key + " " + (Object.op_Implicit((Object)(object)dome) ? dome.DebugBranches() : "no dome"));
				DumpLines("terrain-" + kv.Key);
				yield return WaitCrownEnd();
			}
			facing = savedFacing;
			slot.UnsetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
		}

		private void TopShot(string name)
		{
			lastShotReal = Time.realtimeSinceStartup;
			((MonoBehaviour)this).StartCoroutine(TopShotRoutine(name));
		}

		private IEnumerator TopShotRoutine(string name)
		{
			yield return (object)new WaitForEndOfFrame();
			if (Object.op_Implicit((Object)(object)shotCamera) && Object.op_Implicit((Object)(object)pilot))
			{
				Vector3 footPosition = pilot.footPosition;
				Render(name, footPosition + Vector3.up * 13f - facing * 5f, footPosition + facing * 1f);
			}
		}

		private static bool Ground(Vector3 at, out RaycastHit hit)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_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_0025: Unknown result type (might be due to invalid IL or missing references)
			return Physics.Raycast(at + Vector3.up * 30f, Vector3.down, ref hit, 60f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1);
		}

		private Dictionary<string, KeyValuePair<Vector3, Vector3>> FindTerrainSpots()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: 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_0184: 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_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: 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_01b8: 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_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: 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_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: 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_0364: 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)
			Dictionary<string, KeyValuePair<Vector3, Vector3>> dictionary = new Dictionary<string, KeyValuePair<Vector3, Vector3>>();
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			for (int i = 0; i < 8; i++)
			{
				array[i] = Quaternion.Euler(0f, (float)i * 45f, 0f) * Vector3.forward;
			}
			for (float num = 4f; num <= 46f; num += 1.5f)
			{
				if (dictionary.Count >= 5)
				{
					break;
				}
				for (int j = 0; j < 48; j++)
				{
					if (!Ground(mark + Quaternion.Euler(0f, (float)j * 7.5f, 0f) * Vector3.forward * num, out var hit) || Mathf.Abs(((RaycastHit)(ref hit)).point.y - mark.y) > 12f)
					{
						continue;
					}
					Vector3 point = ((RaycastHit)(ref hit)).point;
					float y = ((RaycastHit)(ref hit)).normal.y;
					float num2 = 0f;
					float num3 = 0f;
					int num4 = 0;
					Vector3 face = Vector3.zero;
					float num5 = 0f;
					Vector3 val = Vector3.zero;
					Vector3[] array2 = array;
					foreach (Vector3 val2 in array2)
					{
						if (Ground(point + val2 * 3f, out var hit2))
						{
							float num6 = ((RaycastHit)(ref hit2)).point.y - point.y;
							num2 = Mathf.Min(num2, num6);
							num3 = Mathf.Max(num3, num6);
							if (num6 < num5)
							{
								num5 = num6;
								face = val2;
							}
						}
						else
						{
							num4++;
							face = val2;
							num5 = -99f;
						}
						if (val == Vector3.zero && Physics.Raycast(point + Vector3.up * 1f, val2, 2.5f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
						{
							val = val2;
						}
					}
					Vector3 val3 = Vector3.ProjectOnPlane(mark - point, Vector3.up);
					Vector3 val4 = ((Vector3)(ref val3)).normalized;
					if (val4 == Vector3.zero)
					{
						val4 = Vector3.forward;
					}
					if (!dictionary.ContainsKey("slope") && y > 0.55f && y < 0.82f)
					{
						val3 = Vector3.ProjectOnPlane(-((RaycastHit)(ref hit)).normal, Vector3.up);
						dictionary["slope"] = Pair(point, ((Vector3)(ref val3)).normalized * -1f);
					}
					else if (!dictionary.ContainsKey("wall") && y > 0.9f && val != Vector3.zero)
					{
						dictionary["wall"] = Pair(point, val);
					}
					else if (!dictionary.ContainsKey("edge") && y > 0.9f && num5 < -4f)
					{
						dictionary["edge"] = Pair(point, face);
					}
					else if (!dictionary.ContainsKey("rocky") && y > 0.75f && num3 - num2 > 1f && num3 - num2 < 3f && val == Vector3.zero)
					{
						dictionary["rocky"] = Pair(point, val4);
					}
					else if (!dictionary.ContainsKey("flat") && y > 0.97f && num3 - num2 < 0.25f && val == Vector3.zero && num4 == 0)
					{
						dictionary["flat"] = Pair(point, val4);
					}
				}
			}
			return dictionary;
		}

		private static KeyValuePair<Vector3, Vector3> Pair(Vector3 at, Vector3 face)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: 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_0010: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			return new KeyValuePair<Vector3, Vector3>(at + Vector3.up * 0.2f, (((Vector3)(ref face)).sqrMagnitude > 0.01f) ? ((Vector3)(ref face)).normalized : Vector3.forward);
		}

		internal static void TryStart()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			string environmentVariable = Environment.GetEnvironmentVariable("HS_AUTOPILOT");
			if (!string.IsNullOrEmpty(environmentVariable))
			{
				Active = true;
				RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
				{
					gameLoaded = true;
				});
				GameObject val = new GameObject("HollowSaintDevAutopilot");
				Object.DontDestroyOnLoad((Object)val);
				val.AddComponent<DevAutopilot>().output = environmentVariable;
				Directory.CreateDirectory(environmentVariable);
				Plugin.Log.LogWarning("HOLLOW_SAINT_AUTOPILOT active, output=" + environmentVariable);
			}
		}

		private void OnEnable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			Application.logMessageReceived += new LogCallback(OnLog);
			HookAudio();
			PlayerCharacterMasterController.FixedUpdate += new hook_FixedUpdate(AfterPlayerInput);
			PlayerCharacterMasterController.Update += new hook_Update(AfterPlayerUpdate);
		}

		private void OnDisable()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			Application.logMessageReceived -= new LogCallback(OnLog);
			UnhookAudio();
			PlayerCharacterMasterController.FixedUpdate -= new hook_FixedUpdate(AfterPlayerInput);
			PlayerCharacterMasterController.Update -= new hook_Update(AfterPlayerUpdate);
		}

		private void AfterPlayerUpdate(orig_Update orig, PlayerCharacterMasterController self)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (scripting && Object.op_Implicit((Object)(object)self.master))
			{
				CharacterBody body = self.master.GetBody();
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.inputBank))
				{
					body.inputBank.aimDirection = ScriptedAim(body.inputBank);
				}
			}
		}

		private Vector3 ScriptedAim(InputBankTest bank)
		{
			//IL_0032: 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_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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (aimTarget.HasValue)
			{
				Vector3 val = aimTarget.Value - bank.aimOrigin;
				return ((Vector3)(ref val)).normalized;
			}
			return Quaternion.AngleAxis(aimPitch, Vector3.Cross(Vector3.up, facing)) * facing;
		}

		private void OnLog(string message, string stack, LogType type)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Invalid comparison between Unknown and I4
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (((int)type == 4 || (int)type == 0) && scripting)
			{
				errors++;
				trace.AppendLine("ERROR [" + segment + "] " + message);
			}
		}

		private void AfterPlayerInput(orig_FixedUpdate orig, PlayerCharacterMasterController self)
		{
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody val = ((scripting && Object.op_Implicit((Object)(object)self.master)) ? self.master.GetBody() : null);
			InputBankTest val2 = (Object.op_Implicit((Object)(object)val) ? val.inputBank : null);
			bool claimed = Object.op_Implicit((Object)(object)val2) && val2.skill1.hasPressBeenClaimed;
			bool claimed2 = Object.op_Implicit((Object)(object)val2) && val2.skill2.hasPressBeenClaimed;
			bool claimed3 = Object.op_Implicit((Object)(object)val2) && val2.skill3.hasPressBeenClaimed;
			bool claimed4 = Object.op_Implicit((Object)(object)val2) && val2.skill4.hasPressBeenClaimed;
			orig.Invoke(self);
			if (scripting && Object.op_Implicit((Object)(object)self.master))
			{
				CharacterBody body = self.master.GetBody();
				InputBankTest val3 = (Object.op_Implicit((Object)(object)body) ? body.inputBank : null);
				if (Object.op_Implicit((Object)(object)val3))
				{
					Set(ref val3.skill1, fire1, ref prev1, claimed);
					Set(ref val3.skill2, fire2, ref prev2, claimed2);
					Set(ref val3.skill3, fire3, ref prev3, claimed3);
					Set(ref val3.skill4, fire4, ref prev4, claimed4);
					Set(ref val3.jump, jump, ref prevJump);
					val3.sprint.down = sprint;
					val3.moveVector = move;
					val3.aimDirection = ScriptedAim(val3);
				}
			}
		}

		private static void Set(ref ButtonState button, bool down, ref bool previous, bool claimed = false)
		{
			button.hasPressBeenClaimed = (down & previous) && claimed;
			button.wasDown = previous;
			button.down = down;
			previous = down;
		}

		private IEnumerator Start()
		{
			Scene activeScene;
			while (true)
			{
				activeScene = SceneManager.GetActiveScene();
				if (!(((Scene)(ref activeScene)).name != "title") && LocalUserManager.GetFirstLocalUser() != null)
				{
					break;
				}
				if (gameLoaded)
				{
					activeScene = SceneManager.GetActiveScene();
					if (((Scene)(ref activeScene)).name != "title")
					{
						activeScene = SceneManager.GetActiveScene();
						if (((Scene)(ref activeScene)).name != "splash" && !IntroCutsceneController.shouldSkip)
						{
							IntroCutsceneController.shouldSkip = true;
						}
					}
				}
				yield return null;
			}
			yield return Real(6f);
			Console.instance.SubmitCmd((NetworkUser)null, "transition_command \"gamemode ClassicRun; host 0;\"", false);
			float wait = 0f;
			while (!Object.op_Implicit((Object)(object)PreGameController.instance) && wait < 60f)
			{
				wait += Time.unscaledDeltaTime;
				yield return null;
			}
			if (!Object.op_Implicit((Object)(object)PreGameController.instance))
			{
				Finish("no lobby");
				yield break;
			}
			yield return Real(2f);
			LocalUser user = LocalUserManager.GetFirstLocalUser();
			wait = 0f;
			while ((user == null || !Object.op_Implicit((Object)(object)user.currentNetworkUser)) && wait < 20f)
			{
				wait += Time.unscaledDeltaTime;
				yield return null;
				user = LocalUserManager.GetFirstLocalUser();
			}
			SurvivorDef survivorDef = SurvivorCatalog.GetSurvivorDef(SurvivorCatalog.GetSurvivorIndexFromBodyIndex(BodyCatalog.FindBodyIndex("HollowSaintBody")));
			if (user == null || !Object.op_Implicit((Object)(object)user.currentNetworkUser) || !Object.op_Implicit((Object)(object)survivorDef))
			{
				Finish("no survivor");
				yield break;
			}
			user.currentNetworkUser.SetSurvivorPreferenceClient(survivorDef);
			yield return Real(2f);
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "lobby")
			{
				yield return LobbySegments();
				Finish("complete");
				yield break;
			}
			if (Object.op_Implicit((Object)(object)PreGameController.instance))
			{
				PreGameController.instance.StartLaunch();
			}
			wait = 0f;
			while (((Object)(object)user.cachedBody == (Object)null || !Object.op_Implicit((Object)(object)Run.instance)) && wait < 90f)
			{
				wait += Time.unscaledDeltaTime;
				yield return null;
			}
			if (!Object.op_Implicit((Object)(object)user.cachedBody))
			{
				Finish("no body on stage 1");
				yield break;
			}
			yield return Real(2f);
			string arena = Environment.GetEnvironmentVariable("HS_ARENA");
			if (string.IsNullOrEmpty(arena))
			{
				arena = "golemplains";
			}
			activeScene = SceneManager.GetActiveScene();
			if (((Scene)(ref activeScene)).name != arena)
			{
				SceneDef val = SceneCatalog.FindSceneDef(arena);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Finish("no scene " + arena);
					yield break;
				}
				Run.instance.AdvanceStage(val);
				wait = 0f;
				while (true)
				{
					activeScene = SceneManager.GetActiveScene();
					if ((!(((Scene)(ref activeScene)).name != arena) && !((Object)(object)user.cachedBody == (Object)null)) || !(wait < 90f))
					{
						break;
					}
					wait += Time.unscaledDeltaTime;
					yield return null;
				}
				if (Object.op_Implicit((Object)(object)user.cachedBody))
				{
					activeScene = SceneManager.GetActiveScene();
					if (!(((Scene)(ref activeScene)).name != arena))
					{
						goto IL_04a0;
					}
				}
				Finish("did not reach " + arena);
				yield break;
			}
			goto IL_04a0;
			IL_04a0:
			CombatDirector[] array = CombatDirector.instancesList.ToArray();
			foreach (CombatDirector val2 in array)
			{
				if (Object.op_Implicit((Object)(object)val2))
				{
					((Behaviour)val2).enabled = false;
				}
			}
			yield return Real(3f);
			pilot = user.cachedBody;
			if (!SetUpArena())
			{
				Finish("arena setup failed");
				yield break;
			}
			yield return Real(2f);
			((MonoBehaviour)this).StartCoroutine(Monitor());
			yield return Script();
			Finish("complete");
		}

		private static IEnumerator Real(float seconds)
		{
			float t = 0f;
			while (t < seconds)
			{
				t += Time.unscaledDeltaTime;
				yield return null;
			}
		}

		private bool SetUpArena()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: 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_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: 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)
			CombatDirector[] array = CombatDirector.instancesList.ToArray();
			foreach (CombatDirector val in array)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					((Behaviour)val).enabled = false;
				}
			}
			TeamComponent[] array2 = TeamComponent.GetTeamMembers((TeamIndex)2).ToArray();
			foreach (TeamComponent val2 in array2)
			{
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.body) && Object.op_Implicit((Object)(object)val2.body.healthComponent))
				{
					val2.body.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
				}
			}
			if (Object.op_Implicit((Object)(object)pilot.healthComponent))
			{
				pilot.healthComponent.godMode = true;
			}
			mark = pilot.footPosition;
			string text = Environment.GetEnvironmentVariable("HS_ARENA_MARK");
			if (string.IsNullOrEmpty(text))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "golemplains")
				{
					text = "-112.88,-139.02,-374.76";
				}
			}
			if (!string.IsNullOrEmpty(text))
			{
				string[] array3 = text.Split(',');
				if (array3.Length == 3 && float.TryParse(array3[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array3[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array3[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3))
				{
					mark = new Vector3(result, result2, result3);
					TeleportHelper.TeleportBody(pilot, mark);
				}
			}
			int num = 0;
			PurchaseInteraction[] array4 = Object.FindObjectsOfType<PurchaseInteraction>();
			foreach (PurchaseInteraction val3 in array4)
			{
				if (Object.op_Implicit((Object)(object)val3))
				{
					Vector3 val4 = ((Component)val3).transform.position - mark;
					if (((Vector3)(ref val4)).sqrMagnitude < 64f)
					{
						Object.Destroy((Object)(object)((Component)val3).gameObject);
						num++;
					}
				}
			}
			trace.AppendLine("ARENA fixedMark=" + (string.IsNullOrEmpty(text) ? "none" : text) + " clearedInteractables=" + num);
			float num2 = -1f;
			RaycastHit val6 = default(RaycastHit);
			for (int j = 0; j < 24; j++)
			{
				float num3 = (float)j * 15f;
				Vector3 val5 = Quaternion.Euler(0f, num3, 0f) * Vector3.forward;
				float num4 = 40f;
				if (Physics.Raycast(mark + Vector3.up * 1.2f, val5, ref val6, 40f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
				{
					num4 = ((RaycastHit)(ref val6)).distance;
				}
				if (num4 > num2 + 0.5f)
				{
					num2 = num4;
					markYaw = num3;
				}
			}
			facing = Quaternion.Euler(0f, markYaw, 0f) * Vector3.forward;
			trace.AppendLine("ARENA mark=" + ((Vector3)(ref mark)).ToString("F2") + " yaw=" + markYaw + " clear=" + num2.ToString("0.0") + "m");
			Vector3 val7 = Vector3.Cross(Vector3.up, facing);
			SpawnDummy("LemurianMaster", mark + facing * 9f);
			SpawnDummy("BeetleMaster", mark + facing * 7f + val7 * 3.5f);
			SpawnDummy("BeetleMaster", mark + facing * 7f - val7 * 3.5f);
			MakeShotCamera();
			return (Object)(object)shotCamera != (Object)null;
		}

		private void SpawnDummy(string masterName, Vector3 near)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: 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_0068: 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)
			GameObject val = MasterCatalog.FindMasterPrefab(masterName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				trace.AppendLine("ARENA missing " + masterName);
				return;
			}
			Vector3 val2 = near;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(near + Vector3.up * 6f, Vector3.down, ref val3, 20f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				val2 = ((RaycastHit)(ref val3)).point;
			}
			CharacterMaster val4 = new MasterSummon
			{
				masterPrefab = val,
				position = val2,
				rotation = Quaternion.LookRotation(-facing),
				summonerBodyObject = null,
				teamIndexOverride = (TeamIndex)2,
				ignoreTeamMemberLimit = true
			}.Perform();
			if (!Object.op_Implicit((Object)(object)val4))
			{
				trace.AppendLine("ARENA failed " + masterName);
				return;
			}
			BaseAI[] components = ((Component)val4).GetComponents<BaseAI>();
			for (int i = 0; i < components.Length; i++)
			{
				((Behaviour)components[i]).enabled = false;
			}
			((MonoBehaviour)this).StartCoroutine(HoldDummy(val4, val2));
		}

		private IEnumerator HoldDummy(CharacterMaster master, Vector3 spot)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody body = null;
			float t = 0f;
			while (!Object.op_Implicit((Object)(object)body) && t < 5f)
			{
				body = (Object.op_Implicit((Object)(object)master) ? master.GetBody() : null);
				t += Time.deltaTime;
				yield return null;
			}
			if (!Object.op_Implicit((Object)(object)body))
			{
				yield break;
			}
			if (Object.op_Implicit((Object)(object)body.healthComponent))
			{
				body.healthComponent.godMode = true;
			}
			dummies.Add(body);
			TeleportHelper.TeleportBody(body, spot);
			while (Object.op_Implicit((Object)(object)body) && scriptingOrSetup)
			{
				if (Object.op_Implicit((Object)(object)body.inputBank))
				{
					body.inputBank.moveVector = Vector3.zero;
				}
				Vector3 val = body.footPosition - spot;
				if (((Vector3)(ref val)).sqrMagnitude > 0.25f)
				{
					TeleportHelper.TeleportBody(body, spot);
				}
				yield return (object)new WaitForSeconds(0.2f);
			}
		}

		private void MakeShotCamera()
		{
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			ReadOnlyCollection<CameraRigController> readOnlyInstancesList = CameraRigController.readOnlyInstancesList;
			Camera val = ((readOnlyInstancesList.Count > 0) ? readOnlyInstancesList[0].sceneCam : Camera.main);
			if (!Object.op_Implicit((Object)(object)val))
			{
				trace.AppendLine("ARENA no scene camera");
				return;
			}
			GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject);
			((Object)val2).name = "HollowSaintShotCamera";
			Behaviour[] componentsInChildren = val2.GetComponentsInChildren<Behaviour>(true);
			foreach (Behaviour val3 in componentsInChildren)
			{
				string name = ((object)val3).GetType().Name;
				if (!(val3 is Camera) && !name.Contains("PostProcess"))
				{
					val3.enabled = false;
				}
			}
			Camera[] componentsInChildren2 = val2.GetComponentsInChildren<Camera>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Behaviour)componentsInChildren2[i]).enabled = false;
			}
			shotCamera = val2.GetComponent<Camera>();
			shotCamera.fieldOfView = 50f;
			shotTarget = new RenderTexture(1280, 720, 24, (RenderTextureFormat)0);
			Object.DontDestroyOnLoad((Object)(object)val2);
		}

		private void Shot(string name)
		{
			lastShotReal = Time.realtimeSinceStartup;
			((MonoBehaviour)this).StartCoroutine(ShotRoutine(name));
		}

		private void DumpLines(string label)
		{
			//IL_0099: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: 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_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: 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)
			StringBuilder stringBuilder = new StringBuilder("LINE_DUMP " + label);
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val in array)
			{
				if (!val.enabled || !((Component)val).gameObject.activeInHierarchy || (!(val is LineRenderer) && !(val is TrailRenderer)))
				{
					continue;
				}
				LineRenderer val2 = (LineRenderer)(object)((val is LineRenderer) ? val : null);
				TrailRenderer val3 = (TrailRenderer)(object)((val is TrailRenderer) ? val : null);
				int num = (Object.op_Implicit((Object)(object)val2) ? val2.positionCount : val3.positionCount);
				if (num >= 2)
				{
					Vector3 val4 = (Object.op_Implicit((Object)(object)val2) ? val2.GetPosition(0) : val3.GetPosition(0));
					Vector3 val5 = (Object.op_Implicit((Object)(object)val2) ? val2.GetPosition(num - 1) : val3.GetPosition(num - 1));
					if (Object.op_Implicit((Object)(object)val2) && !val2.useWorldSpace)
					{
						val4 = ((Component)val2).transform.TransformPoint(val4);
						val5 = ((Component)val2).transform.TransformPoint(val5);
					}
					string text = ((Object)val).name;
					Transform parent = ((Component)val).transform.parent;
					int num2 = 0;
					while (Object.op_Implicit((Object)(object)parent) && num2 < 4)
					{
						text = ((Object)parent).name + "/" + text;
						num2++;
						parent = parent.parent;
					}
					StringBuilder stringBuilder2 = stringBuilder.Append("\n  ").Append(text).Append(' ')
						.Append(((object)val).GetType().Name)
						.Append(" n=")
						.Append(num)
						.Append(" len=")
						.Append(Vector3.Distance(val4, val5).ToString("0.0"))
						.Append(" size=");
					Bounds bounds = val.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					stringBuilder2.Append(((Vector3)(ref size)).magnitude.ToString("0.0")).Append(" mat=").Append(Object.op_Implicit((Object)(object)val.sharedMaterial) ? ((Object)val.sharedMaterial).name : "-")
						.Append(" w=")
						.Append((Object.op_Implicit((Object)(object)val2) ? val2.widthMultiplier : val3.widthMultiplier).ToString("0.000"))
						.Append(" from=")
						.Append(((Vector3)(ref val4)).ToString("0"))
						.Append(" to=")
						.Append(((Vector3)(ref val5)).ToString("0"));
				}
			}
			trace.AppendLine(stringBuilder.ToString());
		}

		private void DumpEffects(string label, Vector3 center, float radius)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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)
			StringBuilder stringBuilder = new StringBuilder("FX_DUMP " + label + " ");
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val in array)
			{
				if (!val.enabled || !((Component)val).gameObject.activeInHierarchy || ((Component)val).gameObject.isStatic || ((Object)(object)((Component)val).GetComponentInParent<CharacterModel>() != (Object)null && val.sharedMaterials.Length < 2 && !(val is ParticleSystemRenderer) && !(val is LineRenderer)))
				{
					continue;
				}
				Bounds bounds = val.bounds;
				Vector3 val2 = ((Bounds)(ref bounds)).center - center;
				if (((Vector3)(ref val2)).sqrMagnitude > radius * radius)
				{
					val2 = ((Bounds)(ref bounds)).size;
					if (((Vector3)(ref val2)).magnitude < 20f)
					{
						continue;
					}
				}
				Transform val3 = ((Component)val).transform;
				while (Object.op_Implicit((Object)(object)val3.parent))
				{
					val3 = val3.parent;
				}
				StringBuilder stringBuilder2 = stringBuilder.Append('\n').Append("  ").Append(((Object)val3).name)
					.Append('/')
					.Append(((Object)val).name)
					.Append(' ')
					.Append(((object)val).GetType().Name)
					.Append(" mat=")
					.Append(Object.op_Implicit((Object)(object)val.sharedMaterial) ? ((Object)val.sharedMaterial).name : "-")
					.Append(" size=");
				val2 = ((Bounds)(ref bounds)).size;
				stringBuilder2.Append(((Vector3)(ref val2)).magnitude.ToString("0.0"));
			}
			trace.AppendLine(stringBuilder.ToString());
		}

		private IEnumerator ShotRoutine(string name)
		{
			float at = scriptTime;
			yield return (object)new WaitForEndOfFrame();
			trace.AppendLine(at.ToString("000.00") + " SHOT " + name + SpearMetrics());
			if (Object.op_Implicit((Object)(object)shotCamera) && Object.op_Implicit((Object)(object)pilot))
			{
				Vector3 corePosition = pilot.corePosition;
				Vector3 val = Vector3.Cross(Vector3.up, facing);
				Render(name + "_back", corePosition - facing * 4f + Vector3.up * 0.8f, corePosition + Vector3.up * 0.2f);
				Render(name + "_front", corePosition + facing * 3.4f + val * 1.6f + Vector3.up * 0.5f, corePosition);
				Render(name + "_side", corePosition + val * 3.8f + Vector3.up * 0.4f, corePosition);
				lastShotReal = Time.realtimeSinceStartup;
			}
		}

		private string SpearMetrics()
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: 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_00e4: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: 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_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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)
			SpearCarry spearCarry = (Object.op_Implicit((Object)(object)pilot) ? ((Component)pilot).GetComponent<SpearCarry>() : null);
			if (!Object.op_Implicit((Object)(object)spearCarry) || !spearCarry.HandVisible || !Object.op_Implicit((Object)(object)spearCarry.Tip) || !Object.op_Implicit((Object)(object)pilot.inputBank))
			{
				return "";
			}
			Vector3 aimDirection = pilot.inputBank.aimDirection;
			Vector3 normalized = ((Vector3)(ref aimDirection)).normalized;
			Vector3 shaftDirection = spearCarry.ShaftDirection;
			float num = Vector3.SignedAngle(Vector3.ProjectOnPlane(normalized, Vector3.up), Vector3.ProjectOnPlane(shaftDirection, Vector3.up), Vector3.up);
			float num2 = Mathf.Asin(Mathf.Clamp(shaftDirection.y, -1f, 1f)) * 57.29578f - Mathf.Asin(Mathf.Clamp(normalized.y, -1f, 1f)) * 57.29578f;
			Vector3 val = (Object.op_Implicit((Object)(object)spearCarry.Tail) ? spearCarry.Tail.position : spearCarry.GripPosition);
			Vector3 position = spearCarry.Tip.position;
			Vector3 val2 = KitUtil.EyePosition(pilot);
			Vector3 val3 = position - val;
			float num3 = Mathf.Clamp01(Vector3.Dot(val2 - val, val3) / Mathf.Max(0.0001f, ((Vector3)(ref val3)).sqrMagnitude));
			float num4 = Vector3.Distance(val2, val + val3 * num3);
			return " javelin yaw=" + num.ToString("0.0") + " pitch=" + num2.ToString("0.0") + " clear=" + (num4 * 100f).ToString("0") + "cm";
		}

		private void Render(string file, Vector3 from, Vector3 at)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			((Component)shotCamera).transform.SetPositionAndRotation(from, Quaternion.LookRotation(at - from, Vector3.up));
			shotCamera.targetTexture = shotTarget;
			shotCamera.Render();
			RenderTexture active = RenderTexture.active;
			RenderTexture.active = shotTarget;
			Texture2D val = new Texture2D(((Texture)shotTarget).width, ((Texture)shotTarget).height, (TextureFormat)3, false);
			val.ReadPixels(new Rect(0f, 0f, (float)((Texture)shotTarget).width, (float)((Texture)shotTarget).height), 0, 0);
			val.Apply(false);
			RenderTexture.active = active;
			shotCamera.targetTexture = null;
			File.WriteAllBytes(Path.Combine(output, file + ".png"), ImageConversion.EncodeToPNG(val));
			Object.Destroy((Object)(object)val);
		}

		private void ResetToMark()
		{
			//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_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			fire1 = (fire2 = (fire3 = (fire4 = (jump = (sprint = false)))));
			move = Vector3.zero;
			aimTarget = null;
			aimPitch = 0f;
			if (Object.op_Implicit((Object)(object)pilot))
			{
				TeleportHelper.TeleportBody(pilot, mark);
				if (Object.op_Implicit((Object)(object)pilot.characterMotor))
				{
					pilot.characterMotor.velocity = Vector3.zero;
				}
				if (Object.op_Implicit((Object)(object)pilot.characterDirection))
				{
					pilot.characterDirection.yaw = markYaw;
					pilot.characterDirection.forward = facing;
				}
			}
		}

		private Vector3 DummyChest(int index)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			if (index >= dummies.Count || !Object.op_Implicit((Object)(object)dummies[index]))
			{
				return mark + facing * 8f + Vector3.up;
			}
			return dummies[index].corePosition;
		}

		private IEnumerator Segment(string name)
		{
			segment = name;
			if (Object.op_Implicit((Object)(object)pilot) && Object.op_Implicit((Object)(object)pilot.skillLocator))
			{
				pilot.skillLocator.ResetSkills();
			}
			trace.AppendLine(scriptTime.ToString("000.00") + " SEGMENT " + name);
			AudioMark("SEGMENT " + name);
			ResetToMark();
			yield return Wait(0.6f);
		}

		private IEnumerator Press(int skill)
		{
			switch (skill)
			{
			case 1:
				fire1 = true;
				break;
			case 2:
				fire2 = true;
				break;
			case 3:
				fire3 = true;
				break;
			case 4:
				fire4 = true;
				break;
			default:
				jump = true;
				break;
			}
			yield return Wait(0.1f);
			switch (skill)
			{
			case 1:
				fire1 = false;
				break;
			case 2:
				fire2 = false;
				break;
			case 3:
				fire3 = false;
				break;
			case 4:
				fire4 = false;
				break;
			default:
				jump = false;
				break;
			}
		}

		private bool CrownOpen()
		{
			OpenCircuitPulseDriver openCircuitPulseDriver = (Object.op_Implicit((Object)(object)pilot) ? ((Component)pilot).GetComponent<OpenCircuitPulseDriver>() : null);
			if (Object.op_Implicit((Object)(object)openCircuitPulseDriver))
			{
				return openCircuitPulseDriver.CrownOpen;
			}
			return false;
		}

		private IEnumerator WaitCrownEnd()
		{
			float guard = 0f;
			while (CrownOpen() && guard < 14f)
			{
				guard += 0.1f;
				yield return Wait(0.1f);
			}
		}

		private IEnumerator Wait(float seconds)
		{
			float end = scriptTime + seconds;
			while (scriptTime < end)
			{
				yield return null;
				float num = scriptTime;
				scriptTime += Time.deltaTime;
				if (Mathf.Floor(num * 4f) != Mathf.Floor(scriptTime * 4f))
				{
					Sample();
				}
			}
		}

		private IEnumerator Script()
		{
			scripting = true;
			yield return Wait(1f);
			AudioMark("SYNC");
			if (Object.op_Implicit((Object)(object)pilot))
			{
				Util.PlaySound("Play_HS_SpearImpact", ((Component)pilot).gameObject);
			}
			yield return Wait(1.2f);
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "spear-splash")
			{
				yield return SpearSplashSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "gaze-charge")
			{
				yield return GazeChargeSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "audio-probe")
			{
				yield return AudioProbe();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "circuit-terrain")
			{
				yield return CircuitTerrainSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "gaze-release")
			{
				yield return GazeReleaseSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "javelin")
			{
				yield return JavelinSegments();
				yield return AimAssistSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "crown")
			{
				GenericSkill val = ((Object.op_Implicit((Object)(object)pilot) && Object.op_Implicit((Object)(object)pilot.skillLocator)) ? pilot.skillLocator.special : null);
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
				{
					val.SetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
				}
				yield return Segment("crown-spear");
				yield return Press(4);
				yield return Wait(1.4f);
				aimTarget = DummyChest(0);
				fire1 = true;
				fire2 = true;
				yield return Wait(0.25f);
				Shot("c-crown-25");
				yield return Wait(0.35f);
				Shot("c-crown-full");
				WideShot("c-crown-full-wide");
				aimPitch = -25f;
				aimTarget = null;
				yield return Wait(0.3f);
				Shot("c-crown-up");
				aimTarget = DummyChest(0);
				fire2 = false;
				yield return Wait(0.06f);
				Shot("c-crown-throw");
				fire1 = false;
				yield return Wait(1f);
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "heads")
			{
				yield return HeadSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "effects")
			{
				yield return EffectSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "items")
			{
				yield return ItemSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "storm")
			{
				yield return StormSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "polish")
			{
				yield return PolishSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "thunder")
			{
				yield return ThunderSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "gaze")
			{
				yield return GazeSegments();
				scripting = false;
				yield break;
			}
			if (Environment.GetEnvironmentVariable("HS_SEGMENTS") == "showcase")
			{
				yield return ShowcaseSegments();
				scripting = false;
				yield break;
			}
			GenericSkill val2 = ((Object.op_Implicit((Object)(object)pilot) && Object.op_Implicit((Object)(object)pilot.skillLocator)) ? pilot.skillLocator.special : null);
			if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
			{
				val2.SetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
				crownOverride = true;
			}
			yield return Segment("idle");
			Shot("a-idle");
			yield return Wait(0.5f);
			yield return Segment("crown");
			yield return Press(4);
			yield return Wait(0.5f);
			Shot("b-unfold");
			yield return Wait(1f);
			Shot("b-hold");
			move = -Right;
			yield return Wait(0.8f);
			move = Right;
			yield return Wait(0.8f);
			move = Vector3.zero;
			yield return WaitCrownEnd();
			yield return Wait(0.25f);
			Shot("b-close-1");
			yield return Wait(0.3f);
			Shot("b-close-2");
			yield return Wait(0.8f);
			Shot("b-closed");
			yield return Segment("bolt");
			aimTarget = DummyChest(0);
			fire1 = true;
			yield return Wait(0.3f);
			Shot("c-bolt-start");
			yield return Wait(1.4f);
			Shot("c-bolt-hold");
			fire1 = false;
			yield return Wait(0.3f);
			Shot("c-bolt-release");
			yield return Segment("spear");
			aimTarget = DummyChest(0);
			fire2 = true;
			yield return Wait(0.32f);
			Shot("d-draw");
			fire1 = true;
			yield return Wait(0.38f);
			Shot("d-charge-33");
			yield return Wait(0.65f);
			Shot("d-charge-66");
			yield return Wait(0.8f);
			Shot("d-charge-full");
			fire2 = false;
			yield return Wait(0.04f);
			Shot("d-throw-05");
			yield return Wait(0.06f);
			Shot("d-throw");
			yield return Wait(0.06f);
			Shot("d-throw-12");
			fire1 = false;
			yield return Wait(0.4f);
			Shot("d-burst");
			DumpEffects("d-burst", DummyChest(0), 12f);
			yield return Wait(5.4f);
			aimTarget = DummyChest(1);
			yield return Press(2);
			yield return Wait(0.3f);
			Shot("d-tap");
			yield return Wait(0.8f);
			Shot("d-after");
			yield return Segment("spear-slow");
			aimTarget = DummyChest(0);
			fire2 = true;
			yield return Wait(2.2f);
			Shot("s-full");
			Time.timeScale = 0.1f;
			fire2 = false;
			yield return Wait(0.02f);
			Shot("s-throw-02");
			yield return Wait(0.04f);
			Shot("s-throw-06");
			yield return Wait(0.04f);
			Shot("s-throw-10");
			yield return Wait(0.06f);
			Shot("s-throw-16");
			yield return Wait(0.08f);
			Shot("s-throw-24");
			yield return Wait(0.12f);
			Shot("s-throw-36");
			Time.timeScale = 1f;
			yield return Wait(5.5f);
			aimTarget = DummyChest(2);
			Time.timeScale = 0.1f;
			fire2 = true;
			yield return Wait(0.05f);
			fire2 = false;
			yield return Wait(0.03f);
			Shot("s-tap-03");
			yield return Wait(0.06f);
			Shot("s-tap-09");
			yield return Wait(0.1f);
			Shot("s-tap-19");
			Time.timeScale = 1f;
			yield return Wait(0.6f);
			yield return Segment("move");
			move = -Right;
			yield return Wait(0.6f);
			Shot("e-strafe");
			yield return Wait(0.4f);
			move = Right;
			yield return Press(3);
			yield return Wait(0.1f);
			Shot("e-dash");
			yield return Wait(0.6f);
			move = Vector3.zero;
			yield return Segment("jump");
			yield return Press(0);
			yield return Wait(0.3f);
			Shot("e-jump");
			yield return Wait(1f);
			Shot("e-land");
			yield return Segment("glide");
			sprint = true;
			move = facing;
			yield return Wait(1.2f);
			Shot("e-glide");
			sprint = false;
			move = Vector3.zero;
			yield return Wait(0.8f);
			Shot("e-glide-stop");
			yield return Segment("crown-combo");
			yield return Press(4);
			yield return Wait(1.4f);
			aimTarget = DummyChest(0);
			fire1 = true;
			yield return Wait(0.6f);
			Shot("f-crown-bolts");
			fire2 = true;
			yield return Wait(0.4f);
			Shot("f-crown-charge");
			yield return Wait(0.5f);
			Shot("f-crown-full");
			DumpEffects("f-crown-full", DummyChest(0), 12f);
			fire2 = false;
			yield return Wait(0.05f);
			Shot("f-crown-throw-05");
			yield return Wait(0.07f);
			Shot("f-crown-throw");
			yield return Wait(0.45f);
			Shot("f-crown-thunder");
			fire1 = false;
			yield return Wait(0.6f);
			move = facing;
			yield return Press(3);
			yield return Wait(0.5f);
			move = Vector3.zero;
			yield return WaitCrownEnd();
			yield return Wait(1.3f);
			Shot("f-after");
			yield return Segment("shock");
			BuffDef shockedBuff = StormServer.ShockedBuff;
			for (int i = 0; i < dummies.Count; i++)
			{
				if (Object.op_Implicit((Object)(object)dummies[i]) && Object.op_Implicit((Object)(object)shockedBuff))
				{
					dummies[i].AddTimedBuff(shockedBuff, 2.5f);
				}
			}
			yield return Wait(0.5f);
			Shot("i-shocked");
			yield return Wait(2.5f);
			Shot("i-unshocked");
			yield return Segment("pause");
			aimTarget = DummyChest(0);
			fire1 = true;
			yield return Wait(0.9f);
			Time.timeScale = 0f;
			yield return Real(0.5f);
			Shot("g-paused");
			yield return Real(0.5f);
			Time.timeScale = 1f;
			fire1 = false;
			yield return Wait(0.5f);
			ModelSkinController skins = ((Object.op_Implicit((Object)(object)pilot.modelLocator) && Object.op_Implicit((Object)(object)pilot.modelLocator.modelTransform)) ? ((Component)pilot.modelLocator.modelTransform).GetComponent<ModelSkinController>() : null);
			for (int skin = 0; skin < 5; skin++)
			{
				if (!Object.op_Implicit((Object)(object)skins))
				{
					break;
				}
				yield return Segment("skin" + skin);
				pilot.skinIndex = (uint)skin;
				skins.ApplySkin(skin);
				yield return Wait(0.6f);
				Shot("h-skin" + skin + "-idle");
				yield return Press(4);
				yield return Wait(1.6f);
				aimTarget = DummyChest(0);
				fire1 = true;
				yield return Wait(0.8f);
				Shot("h-skin" + skin + "-crown-bolts");
				fire1 = false;
				yield return WaitCrownEnd();
				yield return Wait(1.2f);
			}
			yield return GazeSegments();
			scripting = false;
		}

		private IEnumerator GazeSegments()
		{
			GenericSkill special = ((Object.op_Implicit((Object)(object)pilot) && Object.op_Implicit((Object)(object)pilot.skillLocator)) ? pilot.skillLocator.special : null);
			SkillDef gaze = GazeRegistration.SkillDef;
			if (!Object.op_Implicit((Object)(object)special) || !Object.op_Implicit((Object)(object)gaze))
			{
				trace.AppendLine("GAZE not available");
				yield break;
			}
			if (crownOverride && Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
			{
				special.UnsetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
				crownOverride = false;
			}
			special.SetSkillOverride((object)this, gaze, (SkillOverridePriority)3);
			yield return Segment("gaze");
			aimTarget = DummyChest(0);
			yield return Press(4);
			yield return Wait(0.25f);
			Shot("i-launch");
			yield return Wait(0.5f);
			Shot("i-windup");
			WideShot("i-windup-wide");
			yield return Wait(0.35f);
			Shot("i-ignite");
			fire1 = true;
			fire2 = true;
			yield return Wait(0.8f);
			Shot("i-beam");
			WideShot("i-beam-wide");
			aimTarget = DummyChest(1);
			yield return Wait(1f);
			Shot("i-sweep");
			WideShot("i-sweep-wide");
			aimTarget = DummyChest(2);
			yield return Wait(1.2f);
			WideShot("i-sweep2-wide");
			fire1 = false;
			fire2 = false;
			yield return Wait(1.3f);
			Shot("i-end");
			yield return Wait(1.6f);
			Shot("i-landed");
			yield return Segment("gaze-recast");
			aimTarget = DummyChest(0);
			yield return Press(4);
			yield return Wait(2f);
			yield return Press(4);
			yield return Wait(0.2f);
			Shot("j-recast");
			yield return Wait(1.5f);
			yield return Segment("gaze-step");
			aimTarget = DummyChest(0);
			yield return Press(4);
			yield return Wait(2f);
			move = Right;
			yield return Press(3);
			yield return Wait(0.2f);
			Shot("k-step");
			move = Vector3.zero;
			yield return Wait(1.5f);
			ModelSkinController skins = ((Object.op_Implicit((Object)(object)pilot.modelLocator) && Object.op_Implicit((Object)(object)pilot.modelLocator.modelTransform)) ? ((Component)pilot.modelLocator.modelTransform).GetComponent<ModelSkinController>() : null);
			if (Object.op_Implicit((Object)(object)skins))
			{
				yield return Segment("gaze-solar");
				pilot.skinIndex = 3u;
				skins.ApplySkin(3);
				aimTarget = DummyChest(0);
				yield return Press(4);
				yield return Wait(2f);
				Shot("l-solar");
				WideShot("l-solar-wide");
				yield return Wait(3.5f);
				pilot.skinIndex = 0u;
				skins.ApplySkin(0);
			}
			special.UnsetSkillOverride((object)this, gaze, (SkillOverridePriority)3);
		}

		private void WideShot(string name)
		{
			lastShotReal = Time.realtimeSinceStartup;
			((MonoBehaviour)this).StartCoroutine(WideShotRoutine(name));
		}

		private IEnumerator WideShotRoutine(string name)
		{
			trace.AppendLine(scriptTime.ToString("000.00") + " SHOT " + name);
			yield return (object)new WaitForEndOfFrame();
			if (Object.op_Implicit((Object)(object)shotCamera) && Object.op_Implicit((Object)(object)pilot))
			{
				Vector3 at = mark + facing * 5f + Vector3.up * 2.5f;
				Render(name, mark - facing * 7f + Right * 9f + Vector3.up * 6f, at);
			}
		}

		private IEnumerator Monitor()
		{
			Transform val = (Object.op_Implicit((Object)(object)pilot.modelLocator) ? pilot.modelLocator.modelTransform : null);
			Transform chest = null;
			Transform handL = null;
			Transform handR = null;
			if (Object.op_Implicit((Object)(object)val))
			{
				Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(true);
				foreach (Transform val2 in componentsInChildren)
				{
					if (((Object)val2).name == "chest")
					{
						chest = val2;
					}
					else if (((Object)val2).name == "L hand")
					{
						handL = val2;
					}
					else if (((Object)val2).name == "R hand")
					{
						handR = val2;
					}
				}
			}
			if (!Object.op_Implicit((Object)(object)chest) || !Object.op_Implicit((Object)(object)handL) || !Object.op_Implicit((Object)(object)handR))
			{
				trace.AppendLine("MONITOR missing bones");
				yield break;
			}
			Vector3 lastL = Vector3.zero;
			Vector3 lastR = Vector3.zero;
			Vector3 stepL = Vector3.zero;
			Vector3 stepR = Vector3.zero;
			bool primed = false;
			while (Object.op_Implicit((Object)(object)pilot))
			{
				yield return (object)new WaitForEndOfFrame();
				if (!Object.op_Implicit((Object)(object)chest) || Time.deltaTime <= 0f)
				{
					continue;
				}
				if (Time.realtimeSinceStartup - lastShotReal < 0.35f)
				{
					primed = false;
					continue;
				}
				Vector3 val3 = chest.InverseTransformPoint(handL.position);
				Vector3 val4 = chest.InverseTransformPoint(handR.position);
				if (primed)
				{
					Vector3 val5 = val3 - lastL;
					Vector3 val6 = val4 - lastR;
					if (((Vector3)(ref val5)).magnitude > 0.1f && ((Vector3)(ref stepL)).magnitude < 0.03f)
					{
						pops++;
						trace.AppendLine(scriptTime.ToString("000.00") + " POP [" + segment + "] L hand " + (((Vector3)(ref val5)).magnitude * 100f).ToString("0.0") + " cm");
					}
					if (((Vector3)(ref val6)).magnitude > 0.1f && ((Vector3)(ref stepR)).magnitude < 0.03f)
					{
						pops++;
						trace.AppendLine(scriptTime.ToString("000.00") + " POP [" + segment + "] R hand " + (((Vector3)(ref val6)).magnitude * 100f).ToString("0.0") + " cm");
					}
					stepL = val5;
					stepR = val6;
				}
				lastL = val3;
				lastR = val4;
				primed = true;
			}
		}

		private void Sample()
		{
			//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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: 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_01f6: Invalid comparison between Unknown and I4
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)pilot))
			{
				return;
			}
			HaloRing haloRing = HaloRing.For(pilot);
			Animator val = KitAnim.AnimatorOf(pilot);
			string text = "?";
			if (Object.op_Implicit((Object)(object)val))
			{
				int layerIndex = val.GetLayerIndex("Halo");
				if (layerIndex >= 0)
				{
					AnimatorStateInfo currentAnimatorStateInfo = val.GetCurrentAnimatorStateInfo(layerIndex);
					string[] array = new string[4] { "Halo rest", "Open Circuit", "Open Circuit hold", "Open Circuit end" };
					foreach (string text2 in array)
					{
						if (((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsName(text2))
						{
							text = text2;
						}
					}
					if (val.IsInTransition(layerIndex))
					{
						text += "*";
					}
				}
			}
			EntityStateMachine val2 = EntityStateMachine.FindByCustomName(((Component)pilot).gameObject, "Crown");
			EntityStateMachine val3 = EntityStateMachine.FindByCustomName(((Component)pilot).gameObject, "Weapon");
			if (segment.StartsWith("gaze", StringComparison.Ordinal) || segment.StartsWith("items", StringComparison.Ordinal))
			{
				trace.AppendLine(scriptTime.ToString("000.00") + " [" + segment + "] crownState=" + ((Object.op_Implicit((Object)(object)val2) && val2.state != null) ? ((object)val2.state).GetType().Name : "-") + " weapon=" + ((Object.op_Implicit((Object)(object)val3) && val3.state != null) ? ((object)val3.state).GetType().Name : "-") + " height=" + (pilot.footPosition.y - mark.y).ToString("0.0") + " fallFlag=" + (((pilot.bodyFlags & 1) > 0) ? 1 : 0) + " specialStock=" + ((Object.op_Implicit((Object)(object)pilot.skillLocator) && Object.op_Implicit((Object)(object)pilot.skillLocator.special)) ? pilot.skillLocator.special.stock : (-1)));
			}
			StormspearCharge stormspearCharge = StormspearCharge.Of(pilot);
			string text3 = ((Object.op_Implicit((Object)(object)stormspearCharge) && stormspearCharge.Charging) ? ("charging:" + stormspearCharge.Form.ToString() + ":" + stormspearCharge.Charge01.ToString("0.00")) : "idle");
			StringBuilder stringBuilder = trace;
			string[] obj = new string[13]
			{
				scriptTime.ToString("000.00"),
				" [",
				segment,
				"] crown=",
				(CrownOpen() ? 1 : 0).ToString(),
				" open=",
				(Object.op_Implicit((Object)(object)haloRing) && haloRing.Valid) ? haloRing.Openness.ToString("0.00") : "-",
				" halo=",
				text,
				" spear=",
				text3,
				" fromMark=",
				null
			};
			Vector3 val4 = pilot.footPosition - mark;
			obj[12] = ((Vector3)(ref val4)).magnitude.ToString("0.0");
			stringBuilder.AppendLine(string.Concat(obj));
		}

		private void Finish(string outcome)
		{
			scripting = false;
			Time.timeScale = 1f;
			WriteAudioLog();
			File.WriteAllText(Path.Combine(output, "trace.txt"), "outcome=" + outcome + " errors=" + errors + " pops=" + pops + " version=1.2.0\n" + trace);
			Plugin.Log.LogWarning("HOLLOW_SAINT_AUTOPILOT finished: " + outcome);
			((MonoBehaviour)this).StartCoroutine(Quit());
		}

		private IEnumerator Quit()
		{
			yield return Real(2f);
			Application.Quit();
		}

		private IEnumerator EffectSegments()
		{
			trace.AppendLine("EFFECTS hopoo=" + FoundationHopoo.Enabled);
			for (int k = 0; k < 3; k++)
			{
				string label = k switch
				{
					1 => "tap", 
					0 => "full", 
					_ => "ground", 
				};
				yield return Segment("stick-" + label);
				int index = ((k == 1) ? 1 : 0);
				Vector3 at = ((k == 2