Decompiled source of Hollow Saint v1.1.0

plugins/HollowSaint/HollowSaint.dll

Decompiled 6 hours 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.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 Rewired;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.CameraModes;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
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("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+2309d7590737ba1d834c6e03a6fd9d3de5c0cfeb")]
[assembly: AssemblyProduct("HollowSaint")]
[assembly: AssemblyTitle("HollowSaint")]
[assembly: AssemblyVersion("0.1.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 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 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 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);
			}
		}

		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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Application.logMessageReceived += new LogCallback(OnLog);
			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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			Application.logMessageReceived -= new LogCallback(OnLog);
			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 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);
			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;
			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");
			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");
			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;
			File.WriteAllText(Path.Combine(output, "trace.txt"), "outcome=" + outcome + " errors=" + errors + " pops=" + pops + " version=1.1.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) ? (mark + facing * 5f) : DummyChest(index));
				aimTarget = at;
				fire2 = true;
				yield return Wait((k == 1) ? 0.05f : 2.2f);
				fire2 = false;
				yield return Wait(0.12f);
				Time.timeScale = 0.15f;
				yield return Wait(0.03f);
				TargetShot("stick-" + label + "-a", at);
				yield return Wait(0.08f);
				TargetShot("stick-" + label + "-b", at);
				yield return Wait(0.12f);
				TargetShot("stick-" + label + "-c", at);
				yield return Wait(0.1f);
				TargetShot("stick-" + label + "-burst", at);
				Time.timeScale = 1f;
				yield return Wait(5.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 k = 0; k < 5; k++)
			{
				if (!Object.op_Implicit((Object)(object)skins))
				{
					break;
				}
				yield return Segment("fx-skin" + k);
				pilot.skinIndex = (uint)k;
				skins.ApplySkin(k);
				yield return Wait(0.8f);
				Shot("fx-skin" + k);
				yield return Wait(0.4f);
			}
			if (Object.op_Implicit((Object)(object)skins))
			{
				pilot.skinIndex = 0u;
				skins.ApplySkin(0);
			}
			yield return Segment("fx-boss");
			SpawnDummy("TitanMaster", mark + facing * 18f);
			yield return Wait(2.5f);
			CharacterBody titan = ((dummies.Count > 3) ? dummies[dummies.Count - 1] : null);
			if (Object.op_Implicit((Object)(object)titan))
			{
				Vector3 at = titan.corePosition;
				aimTarget = at;
				fire2 = true;
				yield return Wait(2.2f);
				fire2 = false;
				yield return Wait(0.13f);
				Time.timeScale = 0.15f;
				yield return Wait(0.04f);
				TargetShot("fx-boss-stick", at);
				yield return Wait(0.12f);
				TargetShot("fx-boss-burst", at);
				Time.timeScale = 1f;
				yield return Wait(1f);
				aimTarget = at;
				yield return Press(4);
				yield return Wait(2.2f);
				WideShot("fx-boss-gaze");
				Shot("fx-boss-gaze");
				yield return Wait(3.5f);
				titan.healthComponent.godMode = false;
				titan.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
				yield return Wait(2f);
			}
			else
			{
				trace.AppendLine("EFFECTS no titan");
			}
			yield return Segment("fx-shield");
			List<KeyValuePair<ItemIndex, int>> shield = Give("PersonalShield", 6);
			yield return Wait(0.5f);
			if (Object.op_Implicit((Object)(object)pilot.healthComponent))
			{
				pilot.healthComponent.RechargeShieldFull();
			}
			yield return Wait(0.5f);
			Shot("fx-shield");
			yield return Wait(0.3f);
			Take(shield);
			yield return Buffed("fx-cloak", Buffs.Cloak);
			yield return Buffed("fx-immune", Buffs.Immune);
			yield return Buffed("fx-fullcrit", Buffs.FullCrit);
			yield return Buffed("fx-energized", Buffs.Energized);
			yield return Buffed("fx-warcry", Buffs.WarCryBuff);
			string[] array = new string[8] { "EliteFireEquipment", "EliteLightningEquipment", "EliteIceEquipment", "ElitePoisonEquipment", "EliteHauntedEquipment", "EliteLunarEquipment", "EliteEarthEquipment", "EliteVoidEquipment" };
			foreach (string label in array)
			{
				yield return Segment("fx-" + label);
				EquipmentIndex val = EquipmentCatalog.FindEquipmentIndex(label);
				if ((int)val == -1)
				{
					trace.AppendLine("EFFECTS missing " + label);
					continue;
				}
				pilot.inventory.SetEquipmentIndex(val);
				yield return Wait(1f);
				Shot("fx-" + label);
				aimTarget = DummyChest(0);
				fire1 = true;
				yield return Wait(0.8f);
				Shot("fx-" + label + "-firing");
				fire1 = false;
				yield return Wait(0.3f);
				yield return Wait(0.5f);
			}
		}

		private void TargetShot(string name, Vector3 at)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			lastShotReal = Time.realtimeSinceStartup;
			((MonoBehaviour)this).StartCoroutine(TargetShotRoutine(name, at));
		}

		private IEnumerator TargetShotRoutine(string name, Vector3 at)
		{
			//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)
			yield return (object)new WaitForEndOfFrame();
			trace.AppendLine(scriptTime.ToString("000.00") + " SHOT " + name);
			if (Object.op_Implicit((Object)(object)shotCamera))
			{
				Render(name, at + Right * 2.6f - facing * 2.2f + Vector3.up * 1.1f, at);
				lastShotReal = Time.realtimeSinceStartup;
			}
		}

		private IEnumerator Buffed(string name, BuffDef buff)
		{
			yield return Segment(name);
			if (!Object.op_Implicit((Object)(object)buff))
			{
				trace.AppendLine("EFFECTS missing buff for " + name);
				yield break;
			}
			pilot.AddTimedBuff(buff, 3f);
			yield return Wait(0.6f);
			Shot(name);
			yield return Wait(0.4f);
			pilot.ClearTimedBuffs(buff);
			yield return Wait(0.4f);
		}

		private unsafe IEnumerator HeadSegments()
		{
			CharacterModel val = ((Object.op_Implicit((Object)(object)pilot.modelLocator) && Object.op_Implicit((Object)(object)pilot.modelLocator.modelTransform)) ? ((Component)pilot.modelLocator.modelTransform).GetComponent<CharacterModel>() : null);
			ItemDisplayRuleSet val2 = (Object.op_Implicit((Object)(object)val) ? val.itemDisplayRuleSet : null);
			StringBuilder stringBuilder = new StringBuilder();
			if (!Object.op_Implicit((Object)(object)val2))
			{
				trace.AppendLine("HEADS no rule set");
				yield break;
			}
			List<ItemDef> items = new List<ItemDef>();
			List<EquipmentDef> equipment = new List<EquipmentDef>();
			KeyAssetRuleGroup[] keyAssetRuleGroups = val2.keyAssetRuleGroups;
			foreach (KeyAssetRuleGroup val3 in keyAssetRuleGroups)
			{
				if (val3.displayRuleGroup.rules == null)
				{
					continue;
				}
				bool flag = false;
				ItemDisplayRule[] rules = val3.displayRuleGroup.rules;
				foreach (ItemDisplayRule val4 in rules)
				{
					if (val4.childName == "Head" || val4.childName == "Halo")
					{
						flag = true;
					}
				}
				if (flag)
				{
					rules = val3.displayRuleGroup.rules;
					foreach (ItemDisplayRule val5 in rules)
					{
						string[] obj = new string[11]
						{
							Object.op_Implicit(val3.keyAsset) ? val3.keyAsset.name : "?",
							" child=",
							val5.childName,
							" pos=",
							null,
							null,
							null,
							null,
							null,
							null,
							null
						};
						Vector3 val6 = val5.localPos;
						obj[4] = ((Vector3)(ref val6)).ToString("F3");
						obj[5] = " ang=";
						val6 = val5.localAngles;
						obj[6] = ((Vector3)(ref val6)).ToString("F1");
						obj[7] = " scale=";
						val6 = val5.localScale;
						obj[8] = ((Vector3)(ref val6)).ToString("F3");
						obj[9] = " type=";
						ItemDisplayRuleType ruleType = val5.ruleType;
						obj[10] = ((object)(*(ItemDisplayRuleType*)(&ruleType))/*cast due to .constrained prefix*/).ToString();
						stringBuilder.AppendLine(string.Concat(obj));
					}
					Object keyAsset = val3.keyAsset;
					ItemDef val7 = (ItemDef)(object)((keyAsset is ItemDef) ? keyAsset : null);
					Object keyAsset2 = val3.keyAsset;
					EquipmentDef val8 = (EquipmentDef)(object)((keyAsset2 is EquipmentDef) ? keyAsset2 : null);
					if (Object.op_Implicit((Object)(object)val7) && (int)val7.itemIndex != -1)
					{
						items.Add(val7);
					}
					else if (Object.op_Implicit((Object)(object)val8) && (int)val8.equipmentIndex != -1)
					{
						equipment.Add(val8);
					}
				}
			}
			File.WriteAllText(Path.Combine(output, "heads.txt"), stringBuilder.ToString());
			trace.AppendLine("HEADS items=" + items.Count + " equipment=" + equipment.Count);
			yield return Segment("heads");
			foreach (ItemDef item in items)
			{
				pilot.inventory.GiveItemPermanent(item.itemIndex, 1);
				yield return Wait(0.35f);
				HeadShot("h-" + ((Object)item).name);
				yield return Wait(0.3f);
				pilot.inventory.RemoveItemPermanent(item.itemIndex, 1);
				yield return Wait(0.1f);
			}
			foreach (EquipmentDef equip in equipment)
			{
				pilot.inventory.SetEquipmentIndex(equip.equipmentIndex);
				yield return Wait(0.35f);
				HeadShot("h-" + ((Object)equip).name);
				yield return Wait(0.3f);
			}
		}

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

		private IEnumerator HeadShotRoutine(string name)
		{
			yield return (object)new WaitForEndOfFrame();
			if (Object.op_Implicit((Object)(object)shotCamera) && Object.op_Implicit((Object)(object)pilot))
			{
				Vector3 val = KitUtil.EyePosition(pilot);
				Render(name + "_front", val + facing * 1.7f + Right * 0.7f + Vector3.up * 0.15f, val);
				Render(name + "_back", val - facing * 2.2f + Vector3.up * 0.6f, val + Vector3.up * 0.1f);
				lastShotReal = Time.realtimeSinceStartup;
			}
		}

		private IEnumerator ItemSegments()
		{
			GlobalEventManager.onServerDamageDealt += OnDamageDealt;
			GlobalEventManager.onCharacterDeathGlobal += OnDeath;
			GlobalEventManager.OnHitEnemy += new hook_OnHitEnemy(CountHitEnemy);
			GlobalEventManager.OnHitAll += new hook_OnHitAll(CountHitAll);
			((MonoBehaviour)this).StartCoroutine(FrameWatch());
			try
			{
				foreach (CharacterBody dummy in dummies)
				{
					if (Object.op_Implicit((Object)(object)dummy) && Object.op_Implicit((Object)(object)dummy.healthComponent))
					{
						dummy.healthComponent.godMode = false;
						dummy.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
					}
				}
				dummies.Clear();
				SpawnTank();
				yield return Wait(1.5f);
				items.AppendLine("ITEMS version=1.1.0 level=" + (Object.op_Implicit((Object)(object)pilot) ? pilot.level : 0f) + " baseDamage=" + (Object.op_Implicit((Object)(object)pilot) ? pilot.damage.ToString("0.0") : "-"));
				yield return DisplaySegment();
				yield return Loadout("base", false);
				yield return Loadout("onhit", false, "Missile", 3, "ChainLightning", 3, "StickyBomb", 3, "BleedOnHit", 3, "BounceNearby", 2, "StunChanceOnHit", 2);
				yield return Loadout("behemoth", false, "Behemoth", 2);
				yield return Loadout("bands", false, "IceRing", 1, "FireRing", 1);
				yield return Loadout("singularity", false, "ElementalRingVoid", 1);
				yield return Loadout("void", false, "ChainLightningVoid", 3, "MissileVoid", 3, "BleedOnHitVoid", 3, "CritGlassesVoid", 3);
				yield return Loadout("primary-items", false, "PrimarySkillShuriken", 3, "IncreasePrimaryDamage", 3, "LightningStrikeOnHit", 2, "StunAndPierce", 2);
				yield return Loadout("crit", false, "CritGlasses", 10, "AttackSpeedOnCrit", 2, "HealOnCrit", 2);
				yield return Loadout("onkill", false, "ExplodeOnDeath", 3, "IgniteOnKill", 3, "BarrierOnKill", 3, "ExplodeOnDeathVoid", 2);
				yield return Loadout("atkspd", false, "Syringe", 15, "AttackSpeedAndMoveSpeed", 5);
				yield return Loadout("lightflux", false, "HalfAttackSpeedHalfCooldowns", 2);
				yield return Loadout("stocks", false, "SecondarySkillMagazine", 4, "AlienHead", 3, "UtilitySkillMagazine", 2, "EquipmentMagazineVoid", 2, "LunarBadLuck", 1);
				string[] late = new string[36]
				{
					"Missile", "3", "ChainLightning", "3", "StickyBomb", "2", "BleedOnHit", "3", "BounceNearby", "2",
					"Behemoth", "1", "IceRing", "1", "FireRing", "1", "ChainLightningVoid", "2", "LightningStrikeOnHit", "2",
					"Syringe", "20", "CritGlasses", "8", "SecondarySkillMagazine", "3", "AlienHead", "2", "ExplodeOnDeath", "2",
					"IgniteOnKill", "2", "PrimarySkillShuriken", "2", "LunarDagger", "1"
				};
				yield return Loadout("late-gaze", crown: false, Pairs(late));
				yield return Loadout("late-crown", crown: true, Pairs(late));
				yield return HereticSegment();
				yield return MovementSegment();
				yield return NoCooldownSegment();
				yield return DiosSegment();
			}
			finally
			{
				DevAutopilot devAutopilot = this;
				GlobalEventManager.onServerDamageDealt -= devAutopilot.OnDamageDealt;
				GlobalEventManager.onCharacterDeathGlobal -= devAutopilot.OnDeath;
				GlobalEventManager.OnHitEnemy -= new hook_OnHitEnemy(devAutopilot.CountHitEnemy);
				GlobalEventManager.OnHitAll -= new hook_OnHitAll(devAutopilot.CountHitAll);
				devAutopilot.tallying = false;
				try
				{
					File.WriteAllText(Path.Combine(devAutopilot.output, "items.txt"), devAutopilot.items.ToString());
				}
				catch (Exception data)
				{
					Plugin.Log.LogError(data);
				}
			}
		}

		private static object[] Pairs(string[] flat)
		{
			List<object> list = new List<object>();
			for (int i = 0; i + 1 < flat.Length; i += 2)
			{
				list.Add(flat[i]);
				list.Add(int.Parse(flat[i + 1]));
			}
			return list.ToArray();
		}

		private IEnumerator Loadout(string name, bool crown, params object[] spec)
		{
			yield return Segment("items-" + name);
			List<KeyValuePair<ItemIndex, int>> given = Give(spec);
			if (crown && Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
			{
				pilot.skillLocator.special.SetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
			}
			yield return Wait(0.4f);
			pilot.skillLocator.ResetSkills();
			SpawnPack();
			yield return Wait(0.8f);
			string stats = BodyStats();
			BeginTally();
			Vector3 aim = (Object.op_Implicit((Object)(object)tank) ? tank.corePosition : TankAim());
			aimTarget = aim;
			fire1 = true;
			yield return Wait(1.2f);
			ShotBack("items-" + name + "-bolt");
			yield return Wait(1.3f);
			if (crown)
			{
				yield return Press(4);
				yield return Wait(1.4f);
				aimTarget = aim;
			}
			fire2 = true;
			yield return Wait(crown ? 0.9f : 2.2f);
			ShotBack("items-" + name + "-charged");
			fire2 = false;
			yield return Wait(0.5f);
			int dumps = (Object.op_Implicit((Object)(object)pilot.skillLocator.secondary) ? pilot.skillLocator.secondary.stock : 0);
			for (int i = 0; i < Mathf.Min(dumps, 6); i++)
			{
				yield return Press(2);
				yield return Wait(0.15f);
			}
			yield return Wait(0.5f);
			fire1 = false;
			move = Right;
			yield return Press(3);
			yield return Wait(0.6f);
			move = -Right;
			yield return Press(3);
			yield return Wait(0.6f);
			move = Vector3.zero;
			if (!crown)
			{
				aimTarget = aim;
				yield return Press(4);
				yield return Wait(1.6f);
				fire1 = true;
				yield return Wait(1f);
				ShotBack("items-" + name + "-gaze");
				if (Object.op_Implicit((Object)(object)pilot.skillLocator.special) && pilot.skillLocator.special.stock > 0)
				{
					trace.AppendLine(scriptTime.ToString("000.00") + " GAZE_RECAST_WITH_STOCK stock=" + pilot.skillLocator.special.stock);
					yield return Press(4);
					yield return Wait(0.6f);
					trace.AppendLine(scriptTime.ToString("000.00") + " GAZE_AFTER_RECAST stock=" + pilot.skillLocator.special.stock);
					yield return Wait(2.4f);
				}
				else
				{
					yield return Wait(3f);
				}
				fire1 = false;
			}
			else
			{
				aimTarget = aim;
				fire1 = true;
				yield return Wait(2.5f);
				ShotBack("items-" + name + "-crown");
				fire1 = false;
				yield return WaitCrownEnd();
			}
			yield return Wait(1.2f);
			EndTally(name, stats, given);
			if (crown && Object.op_Implicit((Object)(object)KitRegistration.OpenCircuitDef))
			{
				pilot.skillLocator.special.UnsetSkillOverride((object)this, KitRegistration.OpenCircuitDef, (SkillOverridePriority)3);
			}
			Take(given);
			ClearPack();
			yield return Wait(0.6f);
		}

		private IEnumerator DisplaySegment()
		{
			string[][] batches = new string[4][]
			{
				new string[12]
				{
					"Syringe", "Hoof", "Feather", "CritGlasses", "Bear", "Mushroom", "Crowbar", "Tooth", "SprintBonus", "StickyBomb",
					"FlatHealth", "Medkit"
				},
				new string[12]
				{
					"Missile", "ChainLightning", "Behemoth", "IceRing", "FireRing", "BleedOnHit", "AttackSpeedOnCrit", "HealOnCrit", "Seed", "BounceNearby",
					"WardOnLevel", "Firework"
				},
				new string[12]
				{
					"SecondarySkillMagazine", "AlienHead", "UtilitySkillMagazine", "ExtraLife", "Infusion", "Bandolier", "ShockNearby", "Thorns", "NovaOnHeal", "Clover",
					"Dagger", "Icicle"
				},
				new string[12]
				{
					"ChainLightningVoid", "MissileVoid", "CritGlassesVoid", "EquipmentMagazineVoid", "ElementalRingVoid", "AttackSpeedAndMoveSpeed", "PrimarySkillShuriken", "StunAndPierce", "IncreasePrimaryDamage", "LunarDagger",
					"Pearl", "ShinyPearl"
				}
			};
			for (int b = 0; b < batches.Length; b++)
			{
				yield return Segment("items-display" + b);
				List<object> list = new List<object>();
				string[] array = batches[b];
				foreach (string item in array)
				{
					list.Add(item);
					list.Add(1);
				}
				List<KeyValuePair<ItemIndex, int>> given = Give(list.ToArray());
				yield return Wait(1f);
				Shot("x-display" + b);
				yield return Wait(0.6f);
				aimTarget = TankAim();
				fire2 = true;
				yield return Wait(1.6f);
				Shot("x-display" + b + "-charge");
				fire2 = false;
				yield return Wait(0.8f);
				Take(given);
			}
			yield return Wait(5f);
		}

		private IEnumerator HereticSegment()
		{
			yield return Segment("items-heretic");
			List<KeyValuePair<ItemIndex, int>> given = Give("LunarPrimaryReplacement", 1, "LunarSecondaryReplacement", 1, "LunarSpecialReplacement", 1);
			yield return Wait(0.5f);
			SpawnPack();
			yield return Wait(0.6f);
			BeginTally();
			aimTarget = (Object.op_Implicit((Object)(object)tank) ? tank.corePosition : TankAim());
			fire1 = true;
			yield return Wait(1.5f);
			ShotBack("items-heretic-primary");
			fire2 = true;
			yield return Wait(1f);
			fire2 = false;
			yield return Wait(0.6f);
			fire1 = false;
			yield return Press(3);
			yield return Wait(3.5f);
			ShotBack("items-heretic-utility");
			ResetToMark();
			aimTarget = (Object.op_Implicit((Object)(object)tank) ? tank.corePosition : TankAim());
			yield return Press(4);
			yield return Wait(1.5f);
			fire1 = true;
			yield return Wait(1f);
			fire1 = false;
			EndTally("heretic", BodyStats(), given);
			Take(given);
			ClearPack();
			yield return Wait(1f);
			yield return Segment("items-heretic-after");
			aimTarget = TankAim();
			fire1 = true;
			yield return Wait(0.8f);
			fire2 = true;
			yield return Wait(1f);
			ShotBack("items-heretic-after-charge");
			fire2 = false;
			yield return Wait(0.6f);
			fire1 = false;
			items.AppendLine("HERETIC_AFTER " + SkillNames());
		}

		private IEnumerator MovementSegment()
		{
			yield return Segment("items-move");
			List<KeyValuePair<ItemIndex, int>> given = Give("Feather", 3, "Hoof", 12, "SprintBonus", 5, "JumpBoost", 2);
			yield return Wait(0.5f);
			int popsBefore = pops;
			sprint = true;
			move = facing;
			yield return Wait(1f);
			ShotBack("items-move-sprint");
			jump = true;
			yield return Wait(0.1f);
			jump = false;
			yield return Wait(0.3f);
			jump = true;
			yield return Wait(0.1f);
			jump = false;
			yield return Wait(0.3f);
			ShotBack("items-move-doublejump");
			jump = true;
			yield return Wait(0.1f);
			jump = false;
			yield return Wait(0.3f);
			jump = true;
			yield return Wait(0.1f);
			jump = false;
			yield return Wait(1.6f);
			sprint = false;
			move = Vector3.zero;
			yield return Wait(0.6f);
			ShotBack("items-move-land");
			fire2 = true;
			move = Right;
			yield return Wait(1.2f);
			ShotBack("items-move-strafe-charge");
			fire2 = false;
			move = Vector3.zero;
			yield return Wait(0.8f);
			items.AppendLine("MOVE moveSpeed=" + pilot.moveSpeed.ToString("0.0") + " jumps=" + pilot.maxJumpCount + " pops=" + (pops - popsBefore));
			Take(given);
		}

		private IEnumerator NoCooldownSegment()
		{
			yield return Segment("items-nocooldowns");
			BuffDef buff = Buffs.NoCooldowns;
			if (Object.op_Implicit((Object)(object)buff))
			{
				pilot.AddTimedBuff(buff, 9f);
			}
			SpawnPack();
			yield return Wait(0.5f);
			BeginTally();
			aimTarget = (Object.op_Implicit((Object)(object)tank) ? tank.corePosition : TankAim());
			fire1 = true;
			for (int i = 0; i < 12; i++)
			{
				yield return Press(2);
				yield return Wait(0.12f);
			}
			ShotBack("items-nocd-spam");
			for (int i = 0; i < 4; i++)
			{
				move = ((i % 2 == 0) ? Right : (-Right));
				yield return Press(3);
				yield return Wait(0.3f);
			}
			move = Vector3.zero;
			aimTarget = (Object.op_Implicit((Object)(object)tank) ? tank.corePosition : TankAim());
			yield return Press(4);
			yield return Wait(2f);
			yield return Press(4);
			yield return Wait(0.3f);
			yield return Press(4);
			yield return Wait(2.5f);
			ShotBack("items-nocd-gaze");
			fire1 = false;
			yield return Wait(1.5f);
			EndTally("nocooldowns", BodyStats(), new List<KeyValuePair<ItemIndex, int>>());
			ClearPack();
			if (Object.op_Implicit((Object)(object)buff))
			{
				pilot.ClearTimedBuffs(buff);
			}
			yield return Wait(4f);
		}

		private IEnumerator DiosSegment()
		{
			yield return Segment("items-dios");
			CharacterMaster master = pilot.master;
			List<KeyValuePair<ItemIndex, int>> given = Give("ExtraLife", 1);
			yield return Wait(0.4f);
			aimTarget = TankAim();
			fire2 = true;
			fire1 = true;
			yield return Wait(1f);
			if (Object.op_Implicit((Object)(object)pilot.healthComponent))
			{
				pilot.healthComponent.godMode = false;
			}
			CharacterBody old = pilot;
			pilot.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
			DevAutopilot devAutopilot = this;
			DevAutopilot devAutopilot2 = this;
			bool flag = false;
			devAutopilot2.fire2 = false;
			devAutopilot.fire1 = flag;
			yield return Wait(0.5f);
			ShotBack("items-dios-dead");
			float t = 0f;
			while ((!Object.op_Implicit((Object)(object)master.GetBody()) || (Object)(object)master.GetBody() == (Object)(object)old) && t < 8f)
			{
				t += 0.1f;
				yield return Wait(0.1f);
			}
			CharacterBody body = master.GetBody();
			if (!Object.op_Implicit((Object)(object)body) || (Object)(object)body == (Object)(object)old)
			{
				errors++;
				items.AppendLine("DIOS_FAIL no respawned body");
				yield break;
			}
			pilot = body;
			if (Object.op_Implicit((Object)(object)pilot.healthComponent))
			{
				pilot.healthComponent.godMode = true;
			}
			((MonoBehaviour)this).StartCoroutine(Monitor());
			yield return Wait(2f);
			yield return Segment("items-dios-respawned");
			ShotBack("items-dios-respawn-idle");
			aimTarget = TankAim();
			fire1 = true;
			yield return Wait(0.8f);
			fire2 = true;
			yield return Wait(1.2f);
			ShotBack("items-dios-respawn-charge");
			fire2 = false;
			yield return Wait(0.6f);
			fire1 = false;
			move = Right;
			yield return Press(3);
			yield return Wait(0.6f);
			move = Vector3.zero;
			aimTarget = TankAim();
			yield return Press(4);
			yield return Wait(2.6f);
			ShotBack("items-dios-respawn-gaze");
			yield return Wait(3f);
			int num = 0;
			SpearCarry[] array = Object.FindObjectsOfType<SpearCarry>();
			foreach (SpearCarry spearCarry in array)
			{
				if (Object.op_Implicit((Object)(object)spearCarry) && (Object)(object)((Component)spearCarry).gameObject != (Object)(object)((Component)pilot).gameObject)
				{
					num++;
				}
			}
			items.AppendLine("DIOS respawned=1 strayCarries=" + num + " skills=" + SkillNames());
			Take(given);
		}

		private Vector3 TankAim()
		{
			//IL_0039: 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_0014: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)tank))
			{
				return mark + facing * 14f + Vector3.up;
			}
			return tank.corePosition;
		}

		private void SpawnTank()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = MasterCatalog.FindMasterPrefab("GolemMaster");
			if (!Object.op_Implicit((Object)(object)val))
			{
				items.AppendLine("TANK missing");
				return;
			}
			Vector3 val2 = Ground(mark + facing * 14f);
			CharacterMaster val3 = new MasterSummon
			{
				masterPrefab = val,
				position = val2,
				rotation = Quaternion.LookRotation(-facing),
				teamIndexOverride = (TeamIndex)2,
				ignoreTeamMemberLimit = true
			}.Perform();
			if (!Object.op_Implicit((Object)(object)val3))
			{
				items.AppendLine("TANK failed");
				return;
			}
			BaseAI[] components = ((Component)val3).GetComponents<BaseAI>();
			for (int i = 0; i < components.Length; i++)
			{
				((Behaviour)components[i]).enabled = false;
			}
			val3.inventory.GiveItemPermanent(Items.BoostHp, 400);
			((MonoBehaviour)this).StartCoroutine(HoldTarget(val3, val2, isTank: true));
		}

		private void SpawnPack()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			ClearPack();
			GameObject val = MasterCatalog.FindMasterPrefab("LemurianMaster");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Vector3 val2 = mark + facing * 14f;
			for (int i = 0; i < 5; i++)
			{
				float num = ((i % 2 == 0) ? 1f : (-1f)) * (3.5f + 1.5f * (float)(i / 2));
				Vector3 val3 = Ground(val2 + Right * num - facing * ((i == 4) ? 3f : 0f));
				CharacterMaster val4 = new MasterSummon
				{
					masterPrefab = val,
					position = val3,
					rotation = Quaternion.LookRotation(-facing),
					teamIndexOverride = (TeamIndex)2,
					ignoreTeamMemberLimit = true
				}.Perform();
				if (Object.op_Implicit((Object)(object)val4))
				{
					BaseAI[] components = ((Component)val4).GetComponents<BaseAI>();
					for (int j = 0; j < components.Length; j++)
					{
						((Behaviour)components[j]).enabled = false;
					}
					((MonoBehaviour)this).StartCoroutine(HoldTarget(val4, val3, isTank: false));
				}
			}
		}

		private void ClearPack()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody[] array = pack.ToArray();
			foreach (CharacterBody val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
				{
					val.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
				}
			}
			pack.Clear();
		}

		private Vector3 Ground(Vector3 near)
		{
			//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_0026: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(near + Vector3.up * 6f, Vector3.down, ref val, 20f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
			{
				return near;
			}
			return ((RaycastHit)(ref val)).point;
		}

		private IEnumerator HoldTarget(CharacterMaster master, Vector3 spot, bool isTank)
		{
			//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 (isTank)
			{
				tank = body;
			}
			else
			{
				pack.Add(body);
			}
			TeleportHelper.TeleportBody(body, spot);
			while (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive && 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);
				}
				if (isTank && body.healthComponent.combinedHealthFraction < 0.6f)
				{
					body.healthComponent.Heal(body.healthComponent.fullHealth, default(ProcChainMask), false);
				}
				yield return (object)new WaitForSeconds(0.1f);
			}
		}

		private List<KeyValuePair<ItemIndex, int>> Give(params object[] spec)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Invalid comparison between Unknown and I4
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			List<KeyValuePair<ItemIndex, int>> list = new List<KeyValuePair<ItemIndex, int>>();
			for (int i = 0; i + 1 < spec.Length; i += 2)
			{
				string text = (string)spec[i];
				int num = (int)spec[i + 1];
				ItemIndex val = ItemCatalog.FindItemIndex(text);
				if ((int)val == -1)
				{
					items.AppendLine("ITEM_MISSING " + text);
					continue;
				}
				pilot.inventory.GiveItemPermanent(val, num);
				list.Add(new KeyValuePair<ItemIndex, int>(val, num));
			}
			return list;
		}

		private void Take(List<KeyValuePair<ItemIndex, int>> given)
		{
			//IL_003d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)pilot) || !Object.op_Implicit((Object)(object)pilot.inventory))
			{
				return;
			}
			ItemIndex[] array = pilot.inventory.itemAcquisitionOrder.ToArray();
			foreach (ItemIndex val in array)
			{
				int itemCountPermanent = pilot.inventory.GetItemCountPermanent(val);
				if (itemCountPermanent > 0)
				{
					pilot.inventory.RemoveItemPermanent(val, itemCountPermanent);
				}
			}
		}

		private string BodyStats()
		{
			SkillLocator skillLocator = pilot.skillLocator;
			return "dmg=" + pilot.damage.ToString("0.0") + " atkspd=" + pilot.attackSpeed.ToString("0.00") + " crit=" + pilot.crit.ToString("0") + " stocks=" + (Object.op_Implicit((Object)(object)skillLocator.primary) ? skillLocator.primary.maxStock : 0) + "/" + (Object.op_Implicit((Object)(object)skillLocator.secondary) ? skillLocator.secondary.maxStock : 0) + "/" + (Object.op_Implicit((Object)(object)skillLocator.utility) ? skillLocator.utility.maxStock : 0) + "/" + (Object.op_Implicit((Object)(object)skillLocator.special) ? skillLocator.special.maxStock : 0) + " cdScale=" + (Object.op_Implicit((Object)(object)skillLocator.secondary) ? skillLocator.secondary.cooldownScale.ToString("0.00") : "-");
		}

		private string SkillNames()
		{
			SkillLocator skillLocator = pilot.skillLocator;
			Func<GenericSkill, string> func = (GenericSkill g) => (!Object.op_Implicit((Object)(object)g) || !Object.op_Implicit((Object)(object)g.skillDef)) ? "-" : g.skillDef.skillName;
			return func(skillLocator.primary) + "/" + func(skillLocator.secondary) + "/" + func(skillLocator.utility) + "/" + func(skillLocator.special);
		}

		private void BeginTally()
		{
			//IL_00ed: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: 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_02ca: 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_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			tally.Clear();
			maxHitDepth = 0;
			onHitCalls = 0;
			kills = 0;
			slowFrames = 0;
			worstFrame = 0f;
			statsErrors = errors;
			tallyStart = scriptTime;
			tallying = true;
			if (!Object.op_Implicit((Object)(object)tank) || !Object.op_Implicit((Object)(object)tank.healthComponent) || !tank.healthComponent.alive)
			{
				items.AppendLine("  TANK_RESPAWN (died last loadout)");
				SpawnTank();
			}
			int num = 0;
			StringBuilder stringBuilder = new StringBuilder();
			Vector3 val;
			foreach (CharacterBody item in pack)
			{
				if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.healthComponent) && item.healthComponent.alive)
				{
					num++;
					val = item.corePosition - mark;
					stringBuilder.Append(" " + ((Vector3)(ref val)).magnitude.ToString("0") + "m/" + ((object)item.teamComponent.teamIndex/*cast due to .constrained prefix*/).ToString());
				}
			}
			int num2 = 0;
			if (Object.op_Implicit((Object)(object)pilot) && Object.op_Implicit((Object)(object)pilot.inventory))
			{
				foreach (ItemIndex item2 in pilot.inventory.itemAcquisitionOrder)
				{
					num2 += pilot.inventory.GetItemCountPermanent(item2);
				}
			}
			ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers((TeamIndex)2);
			StringBuilder stringBuilder2 = items;
			string[] obj = new string[12]
			{
				"  ARENA packAlive=",
				num.ToString(),
				stringBuilder?.ToString(),
				" tank=",
				null,
				null,
				null,
				null,
				null,
				null,
				null,
				null
			};
			object obj2;
			if (!Object.op_Implicit((Object)(object)tank) || !Object.op_Implicit((Object)(object)tank.healthComponent) || !tank.healthComponent.alive)
			{
				obj2 = "dead";
			}
			else
			{
				val = tank.corePosition - mark;
				obj2 = ((Vector3)(ref val)).magnitude.ToString("0") + "m";
			}
			obj[4] = (string)obj2;
			obj[5] = " monsters=";
			obj[6] = teamMembers.Count.ToString();
			obj[7] = " saintItems=";
			obj[8] = num2.ToString();
			obj[9] = " saintAt=";
			val = pilot.footPosition - mark;
			obj[10] = ((Vector3)(ref val)).magnitude.ToString("0.0");
			obj[11] = "m";
			stringBuilder2.AppendLine(string.Concat(obj));
		}

		private void EndTally(string name, string stats, List<KeyValuePair<ItemIndex, int>> given)
		{
			tallying = false;
			float num = Mathf.Max(0.1f, scriptTime - tallyStart);
			float num2 = tally.Values.Sum((Tally v) => v.damage);
			float num3 = tally.Where((KeyValuePair<string, Tally> kv) => kv.Key.StartsWith("skill:", StringComparison.Ordinal)).Sum((KeyValuePair<string, Tally> kv) => kv.Value.damage);
			float num4 = (Object.op_Implicit((Object)(object)pilot) ? Mathf.Max(0.01f, pilot.damage) : 1f);
			items.AppendLine("LOADOUT " + name + " items=" + string.Join(",", given.Select((KeyValuePair<ItemIndex, int> p) => ((Object)ItemCatalog.GetItemDef(p.Key)).name + "x" + p.Value)));
			items.AppendLine("  " + stats);
			items.AppendLine("  total=" + num2.ToString("0") + " (" + (num2 / num4 * 100f / num).ToString("0") + "%/s over " + num.ToString("0.0") + "s) skillShare=" + ((num2 > 0f) ? (num3 / num2) : 0f).ToString("0.00") + " kills=" + kills + " onHitCalls=" + onHitCalls + " maxProcDepth=" + maxHitDepth + " slowFrames=" + slowFrames + " worstFrameMs=" + (worstFrame * 1000f).ToString("0") + " newErrors=" + (errors - statsErrors));
			foreach (KeyValuePair<string, Tally> item in tally.OrderByDescending((KeyValuePair<string, Tally> kv) => kv.Value.damage))
			{
				items.AppendLine("    " + item.Key.PadRight(44) + " dmg=" + item.Value.damage.ToString("0").PadLeft(7) + " (" + (item.Value.damage / Mathf.Max(1f, num2) * 100f).ToString("0").PadLeft(3) + "%) hits=" + item.Value.hits + " onHitEnemy=" + item.Value.onHit + " onHitAll=" + item.Value.onHitAll);
			}
			trace.AppendLine(scriptTime.ToString("000.00") + " ITEMS " + name + " total=" + num2.ToString("0") + " depth=" + maxHitDepth + " slow=" + slowFrames);
		}

		private string Bucket(DamageInfo info)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to