Decompiled source of QTGJactor v1.4.0

Jactor.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using DM;
using HarmonyLib;
using Landfall.TABC;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.GameMode;
using Landfall.TABS.GameState;
using Landfall.TABS.Services;
using Landfall.TABS.WinConditions;
using LevelCreator;
using Microsoft.CodeAnalysis;
using Photon.Bolt;
using TFBGames;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[BepInPlugin("lol.jactor", "Jactor", "1.0.0")]
public sealed class Main : BaseUnityPlugin
{
	internal sealed class JactorMeshLock
	{
		internal readonly Unit Unit;

		internal JactorMeshLock(Unit unit)
		{
			Unit = unit;
		}
	}

	[HarmonyPatch]
	[HarmonyPriority(800)]
	private static class RigidbodyImpulsePatch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			return from x in typeof(Rigidbody).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where x.Name == "AddForce" || x.Name == "AddForceAtPosition" || x.Name == "AddRelativeForce" || x.Name == "AddTorque" || x.Name == "AddRelativeTorque" || x.Name == "AddExplosionForce" || x.Name == "set_velocity" || x.Name == "set_angularVelocity"
				select x;
		}

		private static bool Prefix(Rigidbody __instance)
		{
			if (!IsBattle() || !IsJactorImpulseBody(__instance) || Depth != 0)
			{
				return true;
			}
			return IsAllowedImpulseCaller();
		}
	}

	[HarmonyPatch]
	[HarmonyPriority(800)]
	private static class Rigidbody2DImpulsePatch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			return from x in typeof(Rigidbody2D).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where x.Name == "AddForce" || x.Name == "AddTorque" || x.Name == "set_velocity" || x.Name == "set_angularVelocity"
				select x;
		}

		private static bool Prefix(Rigidbody2D __instance)
		{
			if (!IsBattle() || !IsJactorImpulseBody(__instance) || Depth != 0)
			{
				return true;
			}
			return IsAllowedImpulseCaller();
		}
	}

	internal sealed class JactorAnchor : MonoBehaviour
	{
		public Vector3 Spawn;

		public Quaternion Rot;

		public bool HasSpawn;
	}

	internal sealed class JactorBan : MonoBehaviour
	{
		public Team Team;

		public UnitBlueprint Blueprint;

		public DatabaseID BlueprintId;

		public DatabaseID EntityId;

		public short InstanceId;

		public ushort SmallNetworkId;

		public ushort CopyOfSmallNetworkId;

		public short RemoteInstanceId;

		public ulong NetworkId;

		public bool AlreadyRevived;

		public bool SuppressUpdates;

		public bool SuppressGameObject;

		private void OnEnable()
		{
			if (!SuppressGameObject)
			{
				return;
			}
			try
			{
				((Component)this).gameObject.SetActive(false);
			}
			catch
			{
			}
		}
	}

	internal sealed class JactorVanillaModelMarker : MonoBehaviour
	{
		internal GameObject Replacement;

		internal GameObject HitGameObject;
	}

	internal sealed class JactorBanRecord
	{
		public Team Team;

		public UnitBlueprint Blueprint;

		public DatabaseID BlueprintIdValue;

		public DatabaseID EntityIdValue;

		public string BlueprintId;

		public string EntityId;

		public short InstanceId;

		public ushort SmallNetworkId;

		public ushort CopyOfSmallNetworkId;

		public short RemoteInstanceId;

		public ulong NetworkId;
	}

	internal sealed class JactorIdentity : MonoBehaviour
	{
		public UnitBlueprint Blueprint;

		public DatabaseID BlueprintId;

		public DatabaseID EntityId;

		public short InstanceId;

		public ushort SmallNetworkId;

		public ulong NetworkId;
	}

	internal sealed class JactorNameAnimator : MonoBehaviour
	{
		private LocalizeText label;

		private bool active;

		private float next;

		private UnitBlueprint blueprint;

		internal void SetState(bool enabled, UnitBlueprint unitBlueprint)
		{
			blueprint = unitBlueprint;
			active = enabled;
			if ((Object)(object)label == (Object)null)
			{
				label = ((Component)this).GetComponentInChildren<LocalizeText>(true);
			}
			if ((Object)(object)label == (Object)null)
			{
				return;
			}
			if (!enabled)
			{
				label.Localized = true;
				if ((Object)(object)unitBlueprint != (Object)null)
				{
					label.LocaleID = unitBlueprint.Name;
				}
			}
			else
			{
				label.Localized = false;
				((TMP_Text)label.Text).text = names[Random.Range(0, names.Length)];
				next = 0f;
			}
		}

		private void Update()
		{
			if (active && !((Object)(object)label == (Object)null) && !((Object)(object)blueprint == (Object)null) && !(Time.unscaledTime < next))
			{
				next = Time.unscaledTime + 0.035f;
				label.Localized = false;
				((TMP_Text)label.Text).text = names[Random.Range(0, names.Length)];
			}
		}
	}

	internal sealed class JactorFactionNameAnimator : MonoBehaviour
	{
		private TextMeshProUGUI label;

		private bool active;

		private float next;

		internal void SetState(bool enabled)
		{
			active = enabled;
			if ((Object)(object)label == (Object)null)
			{
				label = ((Component)this).GetComponent<TextMeshProUGUI>();
			}
			if ((Object)(object)label == (Object)null)
			{
				label = ((Component)this).GetComponentInChildren<TextMeshProUGUI>(true);
			}
			if (!((Object)(object)label == (Object)null) && enabled)
			{
				((TMP_Text)label).text = names[Random.Range(0, names.Length)];
				next = 0f;
			}
		}

		private void Update()
		{
			if (active && !((Object)(object)label == (Object)null) && !(Time.unscaledTime < next))
			{
				next = Time.unscaledTime + 0.035f;
				((TMP_Text)label).text = names[Random.Range(0, names.Length)];
			}
		}
	}

	internal sealed class JactorHat : MonoBehaviour
	{
		internal void Attach(Transform head)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_0037: 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_0057: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			if ((Object)(object)head == (Object)null)
			{
				return;
			}
			GameObject val = new GameObject("Jactor Hat");
			val.transform.SetParent(head, false);
			val.transform.localPosition = new Vector3(0f, 0.22f, -0.02f);
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one * 1.45f;
			Mesh val2 = BuildMesh();
			if ((Object)(object)val2 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return;
			}
			MeshFilter val3 = val.AddComponent<MeshFilter>();
			MeshRenderer val4 = val.AddComponent<MeshRenderer>();
			val3.sharedMesh = val2;
			Shader val5 = Shader.Find("Standard");
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = Shader.Find("Unlit/Texture");
			}
			if ((Object)(object)val5 != (Object)null)
			{
				Material val6 = new Material(val5);
				Texture2D val7 = LoadTexture();
				if ((Object)(object)val7 != (Object)null)
				{
					val6.mainTexture = (Texture)(object)val7;
					((Texture)val7).wrapMode = (TextureWrapMode)1;
					((Texture)val7).filterMode = (FilterMode)1;
					((Texture)val7).anisoLevel = 4;
				}
				if (val6.HasProperty("_Glossiness"))
				{
					val6.SetFloat("_Glossiness", 0.2f);
				}
				if (val6.HasProperty("_Metallic"))
				{
					val6.SetFloat("_Metallic", 0f);
				}
				((Renderer)val4).sharedMaterial = val6;
			}
		}

		private static byte[] ReadResource(string name)
		{
			using Stream stream = typeof(Main).Assembly.GetManifestResourceStream(name);
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Texture2D LoadTexture()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			byte[] array = ReadResource("Hat.png");
			if (array == null)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array, false))
			{
				return null;
			}
			return val;
		}

		private static Mesh BuildMesh()
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_01b7: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			byte[] array = ReadResource("Hat.obj");
			if (array == null)
			{
				return null;
			}
			string s = Encoding.UTF8.GetString(array);
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> list3 = new List<Vector3>();
			List<Vector2> list4 = new List<Vector2>();
			List<int> list5 = new List<int>();
			using (StringReader stringReader = new StringReader(s))
			{
				string text;
				while ((text = stringReader.ReadLine()) != null)
				{
					if (text.StartsWith("v ", StringComparison.Ordinal))
					{
						string[] array2 = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
						if (array2.Length >= 4)
						{
							list.Add(new Vector3(Parse(array2[1]), Parse(array2[2]), Parse(array2[3])));
						}
					}
					else if (text.StartsWith("vt ", StringComparison.Ordinal))
					{
						string[] array3 = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
						if (array3.Length >= 3)
						{
							list2.Add(new Vector2(Parse(array3[1]), Parse(array3[2])));
						}
					}
					else
					{
						if (!text.StartsWith("f ", StringComparison.Ordinal))
						{
							continue;
						}
						string[] array4 = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
						if (array4.Length >= 4)
						{
							int item = AddVertex(array4[1], list, list2, list3, list4);
							for (int i = 2; i < array4.Length - 1; i++)
							{
								int item2 = AddVertex(array4[i], list, list2, list3, list4);
								int item3 = AddVertex(array4[i + 1], list, list2, list3, list4);
								list5.Add(item);
								list5.Add(item2);
								list5.Add(item3);
							}
						}
					}
				}
			}
			if (list3.Count == 0 || list5.Count == 0)
			{
				return null;
			}
			Mesh val = new Mesh
			{
				name = "Jactor Hat Mesh",
				vertices = list3.ToArray(),
				uv = list4.ToArray(),
				triangles = list5.ToArray()
			};
			val.RecalculateBounds();
			val.RecalculateNormals();
			return val;
		}

		private static int AddVertex(string token, List<Vector3> sourceVertices, List<Vector2> sourceUvs, List<Vector3> vertices, List<Vector2> uvs)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			string[] array = token.Split(new char[1] { '/' });
			int num = ResolveIndex((array.Length != 0) ? array[0] : string.Empty, sourceVertices.Count);
			int num2 = ResolveIndex((array.Length > 1) ? array[1] : string.Empty, sourceUvs.Count);
			vertices.Add((num >= 0 && num < sourceVertices.Count) ? sourceVertices[num] : Vector3.zero);
			uvs.Add((num2 >= 0 && num2 < sourceUvs.Count) ? sourceUvs[num2] : Vector2.zero);
			return vertices.Count - 1;
		}

		private static int ResolveIndex(string value, int count)
		{
			if (string.IsNullOrEmpty(value))
			{
				return -1;
			}
			if (!int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return -1;
			}
			if (result <= 0)
			{
				return count + result;
			}
			return result - 1;
		}

		private static float Parse(string value)
		{
			if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return result;
		}
	}

	internal sealed class JactorHyperCubeProjectile : MonoBehaviour
	{
		internal static readonly List<JactorHyperCubeProjectile> Active = new List<JactorHyperCubeProjectile>();

		private static readonly Vector4[] Cube4 = BuildCube4();

		private static readonly int[,] Edges = BuildEdges();

		private readonly List<LineRenderer> lines = new List<LineRenderer>();

		private Unit owner;

		private Unit targetUnit;

		private Vector3 start;

		private Vector3 target;

		private Vector3 control1;

		private Vector3 control2;

		private float elapsed;

		private float life;

		private float speed;

		private float baseSize;

		private bool impacted;

		private Material material;

		internal static bool TryLaunch(Unit source, Unit liveTarget, Vector3 fallbackTarget)
		{
			//IL_008f: 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_00f2: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if ((Object)(object)source == (Object)null || !IsJactor(source) || IsJactor(liveTarget))
			{
				return false;
			}
			if (Active.Count != 0)
			{
				return false;
			}
			if ((Object)(object)((Component)source).GetComponent<JactorHyperCubeCooldown>() == (Object)null)
			{
				((Component)source).gameObject.AddComponent<JactorHyperCubeCooldown>();
			}
			JactorHyperCubeCooldown component = ((Component)source).GetComponent<JactorHyperCubeCooldown>();
			if ((Object)(object)component != (Object)null && Time.time < component.NextAllowed)
			{
				return false;
			}
			if ((Object)(object)component != (Object)null)
			{
				component.NextAllowed = Time.time + 1.35f;
			}
			HandRight componentInChildren = ((Component)source).GetComponentInChildren<HandRight>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			Vector3 val = fallbackTarget;
			if ((Object)(object)liveTarget != (Object)null && (Object)(object)liveTarget.data != (Object)null)
			{
				if ((Object)(object)liveTarget.data.torso != (Object)null)
				{
					val = liveTarget.data.torso.position;
				}
				else if ((Object)(object)liveTarget.data.mainRig != (Object)null)
				{
					val = liveTarget.data.mainRig.worldCenterOfMass;
				}
			}
			if (val == Vector3.zero)
			{
				val = ((Component)componentInChildren).transform.position + ((Component)source).transform.forward * 14f;
			}
			GameObject val2 = new GameObject("Jactor Hypercube 4D");
			val2.transform.position = ((Component)componentInChildren).transform.position;
			val2.AddComponent<JactorHyperCubeProjectile>().Initialize(source, liveTarget, ((Component)componentInChildren).transform.position, val);
			return true;
		}

		private static Vector4[] BuildCube4()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Vector4[] array = (Vector4[])(object)new Vector4[16];
			int num = 0;
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					for (int k = -1; k <= 1; k += 2)
					{
						for (int l = -1; l <= 1; l += 2)
						{
							array[num++] = new Vector4((float)i, (float)j, (float)k, (float)l);
						}
					}
				}
			}
			return array;
		}

		private static int[,] BuildEdges()
		{
			List<int[]> list = new List<int[]>();
			for (int i = 0; i < 16; i++)
			{
				for (int j = i + 1; j < 16; j++)
				{
					int num = 0;
					for (int k = 0; k < 4; k++)
					{
						if (((i >> k) & 1) != ((j >> k) & 1))
						{
							num++;
						}
					}
					if (num == 1)
					{
						list.Add(new int[2] { i, j });
					}
				}
			}
			int[,] array = new int[list.Count, 2];
			for (int l = 0; l < list.Count; l++)
			{
				array[l, 0] = list[l][0];
				array[l, 1] = list[l][1];
			}
			return array;
		}

		private void Initialize(Unit source, Unit liveTarget, Vector3 spawn, Vector3 destination)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_006b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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)
			owner = source;
			targetUnit = liveTarget;
			start = spawn;
			target = destination;
			float num = Vector3.Distance(spawn, destination);
			speed = Mathf.Clamp(num * 0.9f, 7f, 18f);
			life = 5f;
			baseSize = Mathf.Clamp(num * 0.055f, 0.55f, 1.6f);
			Vector3 val = destination - spawn;
			Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, Vector3.up);
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.right;
			}
			((Vector3)(ref val2)).Normalize();
			control1 = spawn + (destination - spawn) * 0.28f + val2 * Mathf.Clamp(num * 0.35f, 1f, 5f);
			control2 = spawn + (destination - spawn) * 0.72f - val2 * Mathf.Clamp(num * 0.28f, 1f, 4f);
			BuildVisual();
			Active.Add(this);
		}

		private void BuildVisual()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_004f: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Color");
			}
			if (!((Object)(object)val == (Object)null))
			{
				material = new Material(val);
				material.color = new Color(0.7f, 0.95f, 1f, 0.9f);
				for (int i = 0; i < Edges.GetLength(0); i++)
				{
					GameObject val2 = new GameObject("Hypercube Edge");
					val2.transform.SetParent(((Component)this).transform, false);
					LineRenderer val3 = val2.AddComponent<LineRenderer>();
					val3.positionCount = 14;
					val3.useWorldSpace = false;
					val3.widthMultiplier = 0.018f;
					((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
					((Renderer)val3).receiveShadows = false;
					((Renderer)val3).material = material;
					val3.startColor = new Color(0.65f, 0.95f, 1f, 0.95f);
					val3.endColor = new Color(1f, 0.3f, 1f, 0.65f);
					lines.Add(val3);
				}
			}
		}

		private void Update()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: 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_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: 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_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			if (impacted)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			elapsed += deltaTime;
			life -= deltaTime;
			if (life <= 0f)
			{
				Impact(((Component)this).transform.position);
				return;
			}
			if ((Object)(object)targetUnit != (Object)null && !IsJactor(targetUnit) && (Object)(object)targetUnit.data != (Object)null && !targetUnit.data.Dead)
			{
				if ((Object)(object)targetUnit.data.torso != (Object)null)
				{
					target = targetUnit.data.torso.position;
				}
				else if ((Object)(object)targetUnit.data.mainRig != (Object)null)
				{
					target = targetUnit.data.mainRig.worldCenterOfMass;
				}
			}
			else if ((Object)(object)owner != (Object)null && (Object)(object)owner.data != (Object)null && (Object)(object)owner.data.targetData != (Object)null && (Object)(object)owner.data.targetData.unit != (Object)null)
			{
				Unit unit = owner.data.targetData.unit;
				if ((Object)(object)unit != (Object)(object)owner && !IsJactor(unit) && (Object)(object)unit.data != (Object)null && !unit.data.Dead)
				{
					targetUnit = unit;
					if ((Object)(object)unit.data.torso != (Object)null)
					{
						target = unit.data.torso.position;
					}
				}
			}
			Vector3 val = target - ((Component)this).transform.position;
			float num = Mathf.Max(Vector3.Distance(start, target), 0.01f);
			float t = Mathf.Clamp01(elapsed * speed / num);
			control1 = Vector3.Lerp(control1, Vector3.Lerp(start, target, 0.32f) + Vector3.up * Mathf.Sin(elapsed * 2.4f) * num * 0.15f, deltaTime * 2.2f);
			control2 = Vector3.Lerp(control2, Vector3.Lerp(start, target, 0.72f) + Vector3.right * Mathf.Cos(elapsed * 1.8f) * num * 0.12f, deltaTime * 1.8f);
			((Component)this).transform.position = Bezier(start, control1, control2, target, t);
			((Component)this).transform.rotation = Quaternion.LookRotation((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? val : ((Component)this).transform.forward, Vector3.up);
			((Component)this).transform.localScale = Vector3.one * (baseSize * (1f + 0.18f * Mathf.Sin(elapsed * 7f)));
			UpdateTesseract(elapsed);
			if (((Vector3)(ref val)).magnitude < Mathf.Max(baseSize * 0.8f, 0.55f))
			{
				Impact(((Component)this).transform.position);
			}
		}

		private static Vector3 Bezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f - t;
			return num * num * num * a + 3f * num * num * t * b + 3f * num * t * t * c + t * t * t * d;
		}

		private void UpdateTesseract(float time)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_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_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.AngleAxis(time * 83f, Vector3.forward);
			Quaternion val2 = Quaternion.AngleAxis(time * 57f, Vector3.up);
			float num = time * 71f;
			Vector3 val3 = new Vector3(1f, 0.35f, 0.2f);
			Quaternion val4 = Quaternion.AngleAxis(num, ((Vector3)(ref val3)).normalized);
			float num2 = time * 49f;
			val3 = new Vector3(0.2f, 1f, 0.4f);
			Quaternion val5 = Quaternion.AngleAxis(num2, ((Vector3)(ref val3)).normalized);
			Vector3[] array = (Vector3[])(object)new Vector3[16];
			Vector3 val7 = default(Vector3);
			Vector3 val8 = default(Vector3);
			for (int i = 0; i < 16; i++)
			{
				Vector4 val6 = Cube4[i];
				((Vector3)(ref val7))..ctor(val6.x, val6.y, val6.z);
				((Vector3)(ref val8))..ctor(val6.w, val6.w * 0.55f, val6.w * 0.25f);
				val7 = val * val7;
				val7 = val2 * val7;
				val7 += val8 * 0.35f;
				float num3 = ((Quaternion)(ref val4)).eulerAngles.x * 0.0008f + ((Quaternion)(ref val5)).eulerAngles.y * 0.0005f + val6.w * 0.25f;
				float num4 = 1f / Mathf.Max(0.22f, 1.65f - num3);
				array[i] = val7 * num4;
			}
			for (int j = 0; j < Edges.GetLength(0); j++)
			{
				LineRenderer val9 = lines[j];
				if (!((Object)(object)val9 == (Object)null))
				{
					int num5 = Edges[j, 0];
					int num6 = Edges[j, 1];
					Vector3 val10 = array[num5];
					Vector3 val11 = array[num6];
					for (int k = 0; k < val9.positionCount; k++)
					{
						float num7 = (float)k / (float)(val9.positionCount - 1);
						float num8 = Mathf.Sin(time * 5.2f + num7 * (float)Math.PI * 6f + (float)j * 0.31f) * 0.08f;
						val9.SetPosition(k, Vector3.Lerp(val10, val11, num7) + ((Component)this).transform.up * num8);
					}
				}
			}
		}

		private void Impact(Vector3 point)
		{
			//IL_00bd: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (impacted)
			{
				return;
			}
			if ((Object)(object)owner == (Object)null || IsJactor(owner))
			{
				Cleanup();
				return;
			}
			impacted = true;
			Unit unit = targetUnit;
			if ((Object)(object)unit == (Object)null && (Object)(object)owner != (Object)null && (Object)(object)owner.data != (Object)null && (Object)(object)owner.data.targetData != (Object)null)
			{
				unit = owner.data.targetData.unit;
			}
			if ((Object)(object)unit != (Object)null && !IsJactor(unit))
			{
				Banish(unit, owner, point);
				JactorMeshFracture.Create(unit, point, owner);
			}
			JactorFractalBurst.Spawn(point, baseSize * 2.4f);
			Cleanup();
		}

		private void Cleanup()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			Active.Remove(this);
			if ((Object)(object)material != (Object)null)
			{
				Object.Destroy((Object)(object)material);
			}
		}
	}

	internal sealed class JactorHyperCubeCooldown : MonoBehaviour
	{
		internal float NextAllowed;
	}

	internal static class JactorMeshFracture
	{
		private sealed class SourceMesh
		{
			internal Vector3[] Vertices;

			internal Vector2[] UV;

			internal int[] Triangles;

			internal Material Material;
		}

		private sealed class FragmentTriangle
		{
			internal Vector3 A;

			internal Vector3 B;

			internal Vector3 C;

			internal Vector2 UvA;

			internal Vector2 UvB;

			internal Vector2 UvC;

			internal Material Material;
		}

		internal static void Create(Unit unit, Vector3 impactPoint, Unit owner)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)unit == (Object)null || IsJactor(unit))
			{
				return;
			}
			try
			{
				List<SourceMesh> list = Collect(unit);
				if (list.Count == 0)
				{
					return;
				}
				DisableVisualsAndColliders(unit);
				List<FragmentTriangle> list2 = BuildTriangles(list, 1800);
				if (list2.Count != 0)
				{
					int num = Mathf.Max(1, list2.Count / 42);
					for (int i = 0; i < list2.Count; i += num)
					{
						SpawnChunk(list2, i, Mathf.Min(num, list2.Count - i), impactPoint, owner, unit);
					}
				}
			}
			catch
			{
			}
		}

		private static List<SourceMesh> Collect(Unit unit)
		{
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			List<SourceMesh> list = new List<SourceMesh>();
			MeshFilter[] componentsInChildren = ((Component)unit).GetComponentsInChildren<MeshFilter>(true);
			foreach (MeshFilter val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sharedMesh == (Object)null))
				{
					Renderer component = ((Component)val).GetComponent<Renderer>();
					if (!((Object)(object)component == (Object)null) && component.enabled)
					{
						Mesh sharedMesh = val.sharedMesh;
						list.Add(new SourceMesh
						{
							Vertices = TransformVertices(sharedMesh.vertices, ((Component)val).transform.localToWorldMatrix),
							UV = sharedMesh.uv,
							Triangles = sharedMesh.triangles,
							Material = (((Object)(object)((Component)val).GetComponent<Renderer>() != (Object)null) ? ((Component)val).GetComponent<Renderer>().sharedMaterial : null)
						});
					}
				}
			}
			SkinnedMeshRenderer[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.sharedMesh == (Object)null) && ((Renderer)val2).enabled)
				{
					Mesh val3 = new Mesh();
					val2.BakeMesh(val3);
					list.Add(new SourceMesh
					{
						Vertices = TransformVertices(val3.vertices, ((Component)val2).transform.localToWorldMatrix),
						UV = val3.uv,
						Triangles = val3.triangles,
						Material = ((Renderer)val2).sharedMaterial
					});
					Object.Destroy((Object)(object)val3);
				}
			}
			return list;
		}

		private static Vector3[] TransformVertices(Vector3[] vertices, Matrix4x4 matrix)
		{
			//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_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length];
			for (int i = 0; i < vertices.Length; i++)
			{
				array[i] = ((Matrix4x4)(ref matrix)).MultiplyPoint3x4(vertices[i]);
			}
			return array;
		}

		private static List<FragmentTriangle> BuildTriangles(List<SourceMesh> sources, int maxCount)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			List<FragmentTriangle> list = new List<FragmentTriangle>();
			for (int i = 0; i < sources.Count; i++)
			{
				SourceMesh sourceMesh = sources[i];
				if (sourceMesh.Vertices == null || sourceMesh.Triangles == null)
				{
					continue;
				}
				int num = sourceMesh.Triangles.Length / 3;
				for (int j = 0; j < num; j++)
				{
					if (list.Count >= maxCount)
					{
						return list;
					}
					int num2 = sourceMesh.Triangles[j * 3];
					int num3 = sourceMesh.Triangles[j * 3 + 1];
					int num4 = sourceMesh.Triangles[j * 3 + 2];
					if (num2 >= 0 && num3 >= 0 && num4 >= 0 && num2 < sourceMesh.Vertices.Length && num3 < sourceMesh.Vertices.Length && num4 < sourceMesh.Vertices.Length)
					{
						Vector2 uvA = ((sourceMesh.UV != null && num2 < sourceMesh.UV.Length) ? sourceMesh.UV[num2] : Vector2.zero);
						Vector2 uvB = ((sourceMesh.UV != null && num3 < sourceMesh.UV.Length) ? sourceMesh.UV[num3] : Vector2.zero);
						Vector2 uvC = ((sourceMesh.UV != null && num4 < sourceMesh.UV.Length) ? sourceMesh.UV[num4] : Vector2.zero);
						list.Add(new FragmentTriangle
						{
							A = sourceMesh.Vertices[num2],
							B = sourceMesh.Vertices[num3],
							C = sourceMesh.Vertices[num4],
							UvA = uvA,
							UvB = uvB,
							UvC = uvC,
							Material = sourceMesh.Material
						});
					}
				}
			}
			return list;
		}

		private static void SpawnChunk(List<FragmentTriangle> triangles, int start, int count, Vector3 impactPoint, Unit owner, Unit originalUnit)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0080: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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_00cb: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			if (count <= 0)
			{
				return;
			}
			List<Vector3> list = new List<Vector3>(count * 3);
			List<Vector2> list2 = new List<Vector2>(count * 3);
			List<int> list3 = new List<int>(count * 3);
			Material val = null;
			Vector3 val2 = Vector3.zero;
			for (int i = 0; i < count; i++)
			{
				FragmentTriangle fragmentTriangle = triangles[start + i];
				if ((Object)(object)val == (Object)null)
				{
					val = fragmentTriangle.Material;
				}
				int count2 = list.Count;
				list.Add(fragmentTriangle.A);
				list.Add(fragmentTriangle.B);
				list.Add(fragmentTriangle.C);
				list2.Add(fragmentTriangle.UvA);
				list2.Add(fragmentTriangle.UvB);
				list2.Add(fragmentTriangle.UvC);
				list3.Add(count2);
				list3.Add(count2 + 1);
				list3.Add(count2 + 2);
				val2 += (fragmentTriangle.A + fragmentTriangle.B + fragmentTriangle.C) / 3f;
			}
			val2 /= (float)Mathf.Max(1, count);
			GameObject val3 = new GameObject("Jactor Mesh Fragment");
			val3.transform.position = val2;
			Mesh val4 = new Mesh();
			val4.vertices = ToLocal(list, val2);
			val4.uv = list2.ToArray();
			val4.triangles = list3.ToArray();
			val4.RecalculateNormals();
			val4.RecalculateBounds();
			val3.AddComponent<MeshFilter>().sharedMesh = val4;
			MeshRenderer val5 = val3.AddComponent<MeshRenderer>();
			if ((Object)(object)val != (Object)null)
			{
				((Renderer)val5).sharedMaterial = val;
			}
			MeshCollider val6 = val3.AddComponent<MeshCollider>();
			val6.sharedMesh = val4;
			val6.convex = true;
			Rigidbody obj = val3.AddComponent<Rigidbody>();
			obj.mass = Mathf.Clamp(0.08f + (float)count * 0.006f, 0.08f, 2.5f);
			obj.useGravity = true;
			val3.AddComponent<JactorFractureFragment>().Initialize(impactPoint, originalUnit, owner);
			Collider[] array = (((Object)(object)Current != (Object)null) ? ((Component)Current).GetComponentsInChildren<Collider>(true) : null);
			if (array == null)
			{
				return;
			}
			for (int j = 0; j < array.Length; j++)
			{
				if ((Object)(object)array[j] != (Object)null)
				{
					Physics.IgnoreCollision((Collider)(object)val6, array[j], true);
				}
			}
		}

		private static Vector3[] ToLocal(List<Vector3> world, Vector3 origin)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[world.Count];
			for (int i = 0; i < world.Count; i++)
			{
				array[i] = world[i] - origin;
			}
			return array;
		}

		private static void DisableVisualsAndColliders(Unit unit)
		{
			Renderer[] componentsInChildren = ((Component)unit).GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if ((Object)(object)componentsInChildren[i] != (Object)null)
				{
					componentsInChildren[i].enabled = false;
				}
			}
			Collider[] componentsInChildren2 = ((Component)unit).GetComponentsInChildren<Collider>(true);
			for (int j = 0; j < componentsInChildren2.Length; j++)
			{
				if ((Object)(object)componentsInChildren2[j] != (Object)null)
				{
					componentsInChildren2[j].enabled = false;
				}
			}
		}
	}

	internal sealed class JactorFractureFragment : MonoBehaviour
	{
		private Rigidbody body;

		private Vector3 targetCompact;

		private float age;

		private bool exploded;

		private Unit owner;

		private Unit sourceUnit;

		internal void Initialize(Vector3 impactPoint, Unit source, Unit projectileOwner)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			body = ((Component)this).GetComponent<Rigidbody>();
			sourceUnit = source;
			owner = projectileOwner;
			targetCompact = impactPoint;
			if ((Object)(object)body != (Object)null)
			{
				body.isKinematic = true;
			}
			float value = Random.value;
			Transform transform = ((Component)this).transform;
			transform.localScale *= Mathf.Lerp(0.75f, 1.15f, value);
		}

		private void Update()
		{
			//IL_003b: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			age += Time.deltaTime;
			if (!exploded)
			{
				float num = Mathf.Clamp01(age / 0.22f);
				((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, targetCompact, num * 0.35f);
				if (age >= 0.24f)
				{
					exploded = true;
					if ((Object)(object)body != (Object)null)
					{
						body.isKinematic = false;
						Vector3 val = ((Component)this).transform.position - targetCompact;
						Vector3 normalized = ((Vector3)(ref val)).normalized;
						if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f)
						{
							val = Random.onUnitSphere;
							normalized = ((Vector3)(ref val)).normalized;
						}
						body.AddForce(normalized * Random.Range(4f, 12f) + Vector3.up * Random.Range(1f, 5f), (ForceMode)1);
						body.AddTorque(Random.onUnitSphere * Random.Range(2f, 8f), (ForceMode)1);
					}
				}
			}
			if (age >= 3.2f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			Unit val = ((collision != null && (Object)(object)collision.collider != (Object)null) ? ((Component)collision.collider).GetComponentInParent<Unit>() : null);
			if ((Object)(object)val != (Object)null && IsJactor(val))
			{
				Physics.IgnoreCollision(((Component)this).GetComponent<Collider>(), collision.collider, true);
			}
		}
	}

	internal static class JactorFractalBurst
	{
		internal static void Spawn(Vector3 center, float radius)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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)
			GameObject val = new GameObject("Jactor Fractal Burst");
			val.transform.position = center;
			val.AddComponent<JactorFractalBurstController>().Initialize(radius);
		}
	}

	internal sealed class JactorFractalBurstController : MonoBehaviour
	{
		private readonly List<LineRenderer> lines = new List<LineRenderer>();

		private Material material;

		private float age;

		private float radius;

		internal void Initialize(float size)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			radius = Mathf.Max(size, 0.5f);
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val == (Object)null)
			{
				val = Shader.Find("Unlit/Color");
			}
			if ((Object)(object)val != (Object)null)
			{
				material = new Material(val);
				material.color = new Color(0.8f, 0.95f, 1f, 0.85f);
			}
			BuildFractal(3, radius);
		}

		private void BuildFractal(int depth, float size)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			if (depth <= 0)
			{
				return;
			}
			for (int i = 0; i < 4; i++)
			{
				GameObject val = new GameObject("Fractal Branch");
				val.transform.SetParent(((Component)this).transform, false);
				float num = (float)i * (float)Math.PI * 0.5f + (float)depth * 0.37f;
				Vector3 val2 = new Vector3(Mathf.Cos(num), Mathf.Sin((float)(depth + i)), Mathf.Sin(num));
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				LineRenderer val3 = val.AddComponent<LineRenderer>();
				val3.positionCount = 2;
				val3.useWorldSpace = false;
				val3.widthMultiplier = Mathf.Max(0.008f, size * 0.012f);
				((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val3).receiveShadows = false;
				if ((Object)(object)material != (Object)null)
				{
					((Renderer)val3).material = material;
				}
				val3.SetPosition(0, Vector3.zero);
				val3.SetPosition(1, normalized * size);
				lines.Add(val3);
			}
			if (depth > 1)
			{
				BuildFractal(depth - 1, size * 0.55f);
			}
		}

		private void Update()
		{
			//IL_0083: 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_0094: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
			age += Time.deltaTime;
			float num = Mathf.Clamp01(age / 0.7f);
			float num2 = Mathf.Clamp01(age / 0.22f);
			float num3 = Mathf.Clamp01((age - 0.22f) / 0.48f);
			float num4 = Mathf.Lerp(1.25f, 0.12f, num2);
			if (age > 0.22f)
			{
				num4 = Mathf.Lerp(0.12f, 1.45f, num3);
			}
			((Component)this).transform.localScale = Vector3.one * radius * num4;
			((Component)this).transform.Rotate(new Vector3(37f, 61f, 83f) * Time.deltaTime, (Space)1);
			for (int i = 0; i < lines.Count; i++)
			{
				if ((Object)(object)lines[i] != (Object)null)
				{
					lines[i].widthMultiplier = Mathf.Max(0.004f, radius * 0.015f * (1f - num * 0.8f));
				}
			}
			if (age >= 0.78f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)material != (Object)null)
			{
				Object.Destroy((Object)(object)material);
			}
		}
	}

	internal static class QTGKillFeed
	{
		private static QTGKillFeedRoot root;

		private static Sprite icon;

		private static Font font;

		internal static void Add(Unit victim)
		{
			if (!((Object)(object)victim == (Object)null) && !IsJactor(victim) && IsBattle())
			{
				Ensure();
				if (!((Object)(object)root == (Object)null))
				{
					string attacker = names[Random.Range(0, names.Length)];
					string victim2 = names[Random.Range(0, names.Length)];
					root.Add(attacker, victim2);
				}
			}
		}

		private static void Ensure()
		{
			//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_001e: Expected O, but got Unknown
			//IL_001e: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)root != (Object)null))
			{
				GameObject val = new GameObject("QTG Kill Feed");
				Object.DontDestroyOnLoad((Object)val);
				Canvas obj = val.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 5000;
				CanvasScaler obj2 = val.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.screenMatchMode = (ScreenMatchMode)1;
				root = val.AddComponent<QTGKillFeedRoot>();
				root.Initialize(LoadIcon(), GetFont());
			}
		}

		private static Font GetFont()
		{
			if ((Object)(object)font != (Object)null)
			{
				return font;
			}
			try
			{
				font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			}
			catch
			{
				font = null;
			}
			if ((Object)(object)font != (Object)null)
			{
				return font;
			}
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			foreach (Font val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string text = ((Object)val).name ?? string.Empty;
					if (text.IndexOf("Tahoma", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Trebuchet", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Arial", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return font = val;
					}
				}
			}
			return font;
		}

		private static Sprite LoadIcon()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0098: 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)
			if ((Object)(object)icon != (Object)null)
			{
				return icon;
			}
			using Stream stream = typeof(Main).Assembly.GetManifestResourceStream("qtg_hacker_killicon.png");
			if (stream == null)
			{
				return null;
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			byte[] array = memoryStream.ToArray();
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array, false))
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			icon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)icon).name = "QTG Hacker Killicon";
			return icon;
		}
	}

	internal sealed class QTGKillFeedRoot : MonoBehaviour
	{
		private readonly List<QTGKillNotice> notices = new List<QTGKillNotice>();

		private RectTransform panel;

		private Sprite icon;

		private Font font;

		internal void Initialize(Sprite killIcon, Font killFont)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			icon = killIcon;
			font = killFont;
			GameObject val = new GameObject("Death Notice");
			val.transform.SetParent(((Component)this).transform, false);
			panel = val.AddComponent<RectTransform>();
			panel.anchorMin = new Vector2(1f, 1f);
			panel.anchorMax = new Vector2(1f, 1f);
			panel.pivot = new Vector2(1f, 1f);
			panel.anchoredPosition = new Vector2(-24f, -24f);
			panel.sizeDelta = new Vector2(520f, 380f);
		}

		internal void Add(string attacker, string victim)
		{
			if ((Object)(object)panel == (Object)null)
			{
				return;
			}
			QTGKillNotice item = CreateNotice(attacker, victim);
			notices.Insert(0, item);
			for (int i = 0; i < notices.Count; i++)
			{
				if ((Object)(object)notices[i] != (Object)null)
				{
					notices[i].SetIndex(i);
				}
			}
			while (notices.Count > 6)
			{
				QTGKillNotice qTGKillNotice = notices[notices.Count - 1];
				notices.RemoveAt(notices.Count - 1);
				if ((Object)(object)qTGKillNotice != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)qTGKillNotice).gameObject);
				}
			}
		}

		private QTGKillNotice CreateNotice(string attacker, string victim)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Kill");
			val.transform.SetParent((Transform)(object)panel, false);
			val.AddComponent<RectTransform>().sizeDelta = new Vector2(520f, 42f);
			QTGKillNotice qTGKillNotice = val.AddComponent<QTGKillNotice>();
			qTGKillNotice.Initialize(icon, font, attacker, victim, this);
			return qTGKillNotice;
		}

		internal void Remove(QTGKillNotice notice)
		{
			notices.Remove(notice);
			for (int i = 0; i < notices.Count; i++)
			{
				if ((Object)(object)notices[i] != (Object)null)
				{
					notices[i].SetIndex(i);
				}
			}
		}
	}

	internal sealed class QTGKillNotice : MonoBehaviour
	{
		private Text attacker;

		private Text victim;

		private Image iconImage;

		private QTGKillFeedRoot owner;

		private float age;

		private float nextName;

		private CanvasGroup group;

		internal void Initialize(Sprite icon, Font font, string attackerName, string victimName, QTGKillFeedRoot root)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00a5: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			owner = root;
			group = ((Component)this).gameObject.AddComponent<CanvasGroup>();
			RectTransform component = ((Component)this).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(1f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(1f, 1f);
			component.sizeDelta = new Vector2(520f, 42f);
			attacker = CreateText("Attacker", font);
			attacker.alignment = (TextAnchor)5;
			((Graphic)attacker).rectTransform.anchorMin = new Vector2(0f, 0f);
			((Graphic)attacker).rectTransform.anchorMax = new Vector2(0f, 1f);
			((Graphic)attacker).rectTransform.pivot = new Vector2(1f, 0.5f);
			((Graphic)attacker).rectTransform.anchoredPosition = new Vector2(182f, 0f);
			((Graphic)attacker).rectTransform.sizeDelta = new Vector2(250f, 0f);
			GameObject val = new GameObject("Icon");
			val.transform.SetParent(((Component)this).transform, false);
			iconImage = val.AddComponent<Image>();
			iconImage.sprite = icon;
			iconImage.preserveAspect = true;
			((Graphic)iconImage).color = Color.white;
			((Graphic)iconImage).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)iconImage).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0.5f);
			rectTransform.anchorMax = new Vector2(0f, 0.5f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.anchoredPosition = new Vector2(270f, 0f);
			rectTransform.sizeDelta = new Vector2(26f, 26f);
			victim = CreateText("Victim", font);
			victim.alignment = (TextAnchor)3;
			((Graphic)victim).rectTransform.anchorMin = new Vector2(0f, 0f);
			((Graphic)victim).rectTransform.anchorMax = new Vector2(0f, 1f);
			((Graphic)victim).rectTransform.pivot = new Vector2(0f, 0.5f);
			((Graphic)victim).rectTransform.anchoredPosition = new Vector2(292f, 0f);
			((Graphic)victim).rectTransform.sizeDelta = new Vector2(215f, 0f);
			attacker.text = attackerName;
			victim.text = victimName;
			nextName = 0f;
		}

		private Text CreateText(string objectName, Font font)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0036: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(objectName);
			val.transform.SetParent(((Component)this).transform, false);
			Text obj = val.AddComponent<Text>();
			obj.font = font;
			obj.fontSize = 19;
			obj.fontStyle = (FontStyle)0;
			((Graphic)obj).color = Color.white;
			obj.supportRichText = false;
			obj.horizontalOverflow = (HorizontalWrapMode)1;
			obj.verticalOverflow = (VerticalWrapMode)1;
			((Graphic)obj).raycastTarget = false;
			Shadow obj2 = val.AddComponent<Shadow>();
			obj2.effectColor = new Color(0f, 0f, 0f, 0.9f);
			obj2.effectDistance = new Vector2(2f, -2f);
			return obj;
		}

		internal void SetIndex(int index)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, (float)(-index) * 45f);
		}

		private void Update()
		{
			age += Time.unscaledDeltaTime;
			if (Time.unscaledTime >= nextName)
			{
				nextName = Time.unscaledTime + 0.035f;
				if ((Object)(object)attacker != (Object)null)
				{
					attacker.text = names[Random.Range(0, names.Length)];
				}
				if ((Object)(object)victim != (Object)null)
				{
					victim.text = names[Random.Range(0, names.Length)];
				}
			}
			if ((Object)(object)group != (Object)null)
			{
				group.alpha = 1f - Mathf.InverseLerp(4f, 4.5f, age);
			}
			if (age >= 4.5f)
			{
				if ((Object)(object)owner != (Object)null)
				{
					owner.Remove(this);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}

	internal static class JactorAttackAI
	{
		private sealed class Skill
		{
			internal readonly Action<Unit, Unit> skill;

			internal readonly Func<Unit, Unit, bool> allowed;

			internal Skill(Action<Unit, Unit> skill, Func<Unit, Unit, bool> allowed)
			{
				this.skill = skill;
				this.allowed = allowed;
			}
		}

		private static Skill[] skillset;

		private static readonly Dictionary<Unit, float> skilltimes = new Dictionary<Unit, float>();

		private static readonly HashSet<Unit> isqtginre = new HashSet<Unit>();

		private static readonly Dictionary<Unit, float> speed = new Dictionary<Unit, float>();

		internal static void Tick()
		{
			try
			{
				Unit current = Current;
				if (!IsBattle() || (Object)(object)current == (Object)null || !IsJactor(current))
				{
					Reset();
					return;
				}
				if (skillset == null)
				{
					skillset = new Skill[4]
					{
						new Skill(Laser, (Unit <p0>, Unit <p1>) => true),
						new Skill(delegate(Unit self2, Unit e)
						{
							//IL_000a: Unknown result type (might be due to invalid IL or missing references)
							//IL_000f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0016: 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_0059: 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)
							if (isentitygood(e))
							{
								Vector3 position = headpos(self2);
								((Component)e).transform.position = position;
								if ((Object)(object)e.data != (Object)null && (Object)(object)e.data.mainRig != (Object)null)
								{
									e.data.mainRig.position = position;
									e.data.mainRig.velocity = Vector3.zero;
									e.data.mainRig.angularVelocity = Vector3.zero;
								}
								Physics.SyncTransforms();
							}
						}, (Unit <p0>, Unit <p1>) => true),
						new Skill(delegate(Unit self2, Unit e)
						{
							//IL_000a: Unknown result type (might be due to invalid IL or missing references)
							//IL_000f: Unknown result type (might be due to invalid IL or missing references)
							//IL_0016: 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_0059: 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)
							if (isentitygood(e))
							{
								Vector3 position = headpos(e);
								((Component)self2).transform.position = position;
								if ((Object)(object)self2.data != (Object)null && (Object)(object)self2.data.mainRig != (Object)null)
								{
									self2.data.mainRig.position = position;
									self2.data.mainRig.velocity = Vector3.zero;
									self2.data.mainRig.angularVelocity = Vector3.zero;
								}
								Physics.SyncTransforms();
							}
						}, (Unit self2, Unit e) => (Object)(object)e != (Object)null),
						new Skill(delegate(Unit self2, Unit e)
						{
							//IL_0017: Unknown result type (might be due to invalid IL or missing references)
							if (isentitygood(e) && JactorHyperCubeProjectile.Active.Count == 0)
							{
								JactorHyperCubeProjectile.TryLaunch(self2, e, headpos(e));
							}
						}, (Unit self2, Unit e) => (Object)(object)e != (Object)null && JactorHyperCubeProjectile.Active.Count == 0)
					};
				}
				HackerThink(current);
			}
			catch
			{
			}
		}

		internal static void Wake(Unit self, Rigidbody targetRig)
		{
			if (IsBattle() && !((Object)(object)self == (Object)null) && IsJactor(self))
			{
				Unit e = (((Object)(object)targetRig != (Object)null) ? ((Component)targetRig).GetComponentInParent<Unit>() : null);
				if (isentitygood(e))
				{
					set(self, e);
				}
			}
		}

		private static void Reset()
		{
			skilltimes.Clear();
			isqtginre.Clear();
			speed.Clear();
			skillset = null;
		}

		private static void set(Unit self, Unit e)
		{
			if (!((Object)(object)self == (Object)null))
			{
				JactorEnemy orAdd = Main.GetOrAdd<JactorEnemy>(((Component)self).gameObject);
				if (orAdd.Enemy != e)
				{
					speed[self] = 2f;
				}
				orAdd.Enemy = e;
			}
		}

		private static Unit get(Unit self)
		{
			JactorEnemy jactorEnemy = (((Object)(object)self != (Object)null) ? ((Component)self).GetComponent<JactorEnemy>() : null);
			if (!((Object)(object)jactorEnemy != (Object)null))
			{
				return null;
			}
			return jactorEnemy.Enemy;
		}

		private static bool isentitygood(Unit e)
		{
			if ((Object)(object)e != (Object)null && !IsJactor(e) && (Object)(object)e.data != (Object)null)
			{
				return !e.data.Dead;
			}
			return false;
		}

		private static Vector3 headpos(Unit e)
		{
			//IL_0009: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)e == (Object)null)
			{
				return Vector3.zero;
			}
			Head componentInChildren = ((Component)e).GetComponentInChildren<Head>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				return ((Component)componentInChildren).transform.position;
			}
			if ((Object)(object)e.data != (Object)null && (Object)(object)e.data.torso != (Object)null)
			{
				return e.data.torso.position;
			}
			return ((Component)e).transform.position + Vector3.up * 1.2f;
		}

		private static void createRagdoll(Unit self, Unit e, Vector3 force)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (isentitygood(e) && !IsJactor(e))
			{
				isqtginre.Add(e);
				JactorQTGRagdoll.Create(e, force);
				Banish(e, self, ((Component)e).transform.position);
			}
		}

		private static void hkill(Unit self, Unit e, Vector3 force)
		{
			//IL_0045: 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_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)
			if (isentitygood(e) && !IsJactor(e) && !isqtginre.Contains(e))
			{
				if (((Vector3)(ref force)).sqrMagnitude <= 0.0001f)
				{
					force = ((Component)self).transform.forward * 1E+09f;
				}
				createRagdoll(self, e, force);
				NotifyKill(e);
				set(self, null);
			}
		}

		private static void Laser(Unit self, Unit e)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_0152: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			Vector3 val = headpos(self);
			Vector3 val2 = headpos(e) - val;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude <= 0.01f)
			{
				return;
			}
			val2 /= magnitude;
			RaycastHit[] array;
			try
			{
				array = Physics.RaycastAll(val, val2, magnitude + 1f, -1, (QueryTriggerInteraction)1);
			}
			catch
			{
				return;
			}
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			Unit val3 = null;
			Vector3 val4 = headpos(e);
			for (int num = 0; num < array.Length; num++)
			{
				Collider collider = ((RaycastHit)(ref array[num])).collider;
				if (!((Object)(object)collider == (Object)null))
				{
					Unit componentInParent = ((Component)collider).GetComponentInParent<Unit>();
					if (isentitygood(componentInParent) && !((Object)(object)componentInParent == (Object)(object)self) && !IsJactor(componentInParent))
					{
						val3 = componentInParent;
						val4 = ((RaycastHit)(ref array[num])).point;
						break;
					}
				}
			}
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = e;
			}
			if (!isentitygood(val3))
			{
				return;
			}
			for (int num2 = 0; num2 < 10; num2++)
			{
				GameObject val5 = new GameObject("qtg_hacker_laser");
				LineRenderer val6 = val5.AddComponent<LineRenderer>();
				Shader val7 = Shader.Find("Sprites/Default");
				if ((Object)(object)val7 != (Object)null)
				{
					((Renderer)val6).material = new Material(val7);
				}
				val6.positionCount = 2;
				val6.startWidth = 0.045f;
				val6.endWidth = 0.012f;
				val6.startColor = Color.red;
				val6.endColor = new Color(1f, 0f, 0f, 0.55f);
				val6.SetPosition(0, val);
				val6.SetPosition(1, val4);
				Object.Destroy((Object)val5, 0.09f);
			}
			hkill(self, val3, headpos(val3) + val2 * 1E+09f);
		}

		private static bool ShouldPull(Unit self, Unit e)
		{
			//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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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 (!isentitygood(e))
			{
				return false;
			}
			Vector3 position = ((Component)self).transform.position;
			Vector3 position2 = ((Component)e).transform.position;
			float num = (position2.x - position.x) * (position2.x - position.x) + (position2.z - position.z) * (position2.z - position.z);
			float num2 = position2.y - position.y;
			if (num <= 90000f)
			{
				return num2 >= 0.8f;
			}
			return false;
		}

		private static void Pull(Unit self, Unit e)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0070: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)self).transform.position - ((Component)e).transform.position;
			float num = Mathf.Max(((Vector3)(ref val)).magnitude, 0.01f);
			val /= num;
			float num2 = 25f + num * 1.5f;
			if ((Object)(object)e.data != (Object)null && (Object)(object)e.data.mainRig != (Object)null)
			{
				e.data.mainRig.AddForce(val * num2, (ForceMode)2);
			}
			Rigidbody[] componentsInChildren = ((Component)e).GetComponentsInChildren<Rigidbody>(true);
			foreach (Rigidbody val2 in componentsInChildren)
			{
				if (!((Object)(object)val2 == (Object)null) && (!((Object)(object)e.data != (Object)null) || !((Object)(object)val2 == (Object)(object)e.data.mainRig)))
				{
					val2.AddForce(val * (num2 * 0.45f), (ForceMode)2);
				}
			}
		}

		private static bool ability(Unit self, Unit e, int tries = 0)
		{
			if (skillset == null || skillset.Length == 0 || !isentitygood(e))
			{
				return false;
			}
			int num = skillset.Length;
			int num2 = num * 2;
			if (tries > num2)
			{
				return false;
			}
			Skill skill = skillset[Random.Range(0, num)];
			if (skill.allowed != null && !skill.allowed(self, e))
			{
				return ability(self, e, tries + 1);
			}
			skill.skill(self, e);
			return true;
		}

		private static bool HaveEnemy(Unit self)
		{
			if (isentitygood(get(self)))
			{
				return true;
			}
			return FindEnemy(self);
		}

		private static bool FindEnemy(Unit self)
		{
			Unit[] array = Object.FindObjectsOfType<Unit>();
			foreach (Unit val in array)
			{
				if (!((Object)(object)val == (Object)(object)self) && isentitygood(val))
				{
					set(self, val);
					return true;
				}
			}
			set(self, null);
			return false;
		}

		private static void HackerThink(Unit self)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if (!HaveEnemy(self))
			{
				return;
			}
			Unit e = get(self);
			if (!isentitygood(e))
			{
				return;
			}
			if (ShouldPull(self, e))
			{
				Pull(self, e);
			}
			Vector3 val = headpos(e);
			approach(self, val);
			Vector3 val2 = val - ((Component)self).transform.position;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (magnitude > 0.0001f)
			{
				val2 /= magnitude;
			}
			if (magnitude / 1000f < 0.1f)
			{
				if (!speed.TryGetValue(self, out var value))
				{
					value = 2f;
				}
				hkill(self, e, val2 * value * 1E+09f);
				return;
			}
			if (!skilltimes.TryGetValue(self, out var value2))
			{
				value2 = Time.time + Random.Range(0f, 8f);
			}
			if (Time.time >= value2)
			{
				skilltimes[self] = Time.time + Random.Range(0f, 6f);
				ability(self, e);
			}
		}

		private static float approach(Unit self, Vector3 pos)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_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_0090: 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_00a4: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)self == (Object)null)
			{
				return 0f;
			}
			Vector3 val = pos - ((Component)self).transform.position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 0.0001f)
			{
				return 0f;
			}
			Vector3 val2 = val / magnitude;
			if (!speed.TryGetValue(self, out var value))
			{
				value = 2f;
			}
			value = Mathf.Clamp(value + 0.4f * Time.deltaTime * 60f, 2f, 25f);
			speed[self] = value;
			Vector3 position = ((Component)self).transform.position + val2 * value * Time.deltaTime * 60f;
			((Component)self).transform.position = position;
			if ((Object)(object)self.data != (Object)null && (Object)(object)self.data.mainRig != (Object)null)
			{
				self.data.mainRig.position = position;
				self.data.mainRig.velocity = val2 * value * 60f;
				self.data.mainRig.angularVelocity = Vector3.zero;
			}
			Physics.SyncTransforms();
			return magnitude;
		}
	}

	internal sealed class JactorQTGRagdoll : MonoBehaviour
	{
		private sealed class Bone
		{
			internal Transform source;

			internal Transform clone;

			internal Rigidbody body;
		}

		internal static void Create(Unit unit, Vector3 force)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0037: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)unit == (Object)null) && !IsJactor(unit) && !((Object)(object)((Component)unit).gameObject == (Object)null))
			{
				GameObject val = new GameObject("QTG Ragdoll");
				val.transform.position = ((Component)unit).transform.position;
				val.transform.rotation = ((Component)unit).transform.rotation;
				val.transform.localScale = ((Component)unit).transform.lossyScale;
				val.layer = ((Component)unit).gameObject.layer;
				Dictionary<Transform, Transform> map = new Dictionary<Transform, Transform>();
				List<Bone> bones = new List<Bone>();
				CloneTree(((Component)unit).transform, val.transform, map);
				CopyRenderers(((Component)unit).transform, map);
				CollectBones(unit, val.transform, map, bones);
				SetupPhysics(val.transform, bones);
				Throw(bones, force);
				Object.Destroy((Object)(object)val, 7f);
			}
		}

		private static void CloneTree(Transform source, Transform target, Dictionary<Transform, Transform> map)
		{
			//IL_001d: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)source == (Object)null) && !((Object)(object)target == (Object)null))
			{
				map[source] = target;
				target.localPosition = source.localPosition;
				target.localRotation = source.localRotation;
				target.localScale = source.localScale;
				for (int i = 0; i < source.childCount; i++)
				{
					Transform child = source.GetChild(i);
					Transform transform = new GameObject(((Object)child).name).transform;
					transform.SetParent(target, false);
					CloneTree(child, transform, map);
				}
			}
		}

		private static void CopyRenderers(Transform source, Dictionary<Transform, Transform> map)
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)source == (Object)null || !map.TryGetValue(source, out var value) || (Object)(object)value == (Object)null)
			{
				return;
			}
			MeshFilter component = ((Component)source).GetComponent<MeshFilter>();
			MeshRenderer component2 = ((Component)source).GetComponent<MeshRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null)
			{
				((Component)value).gameObject.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh;
				if ((Object)(object)component2 != (Object)null)
				{
					MeshRenderer obj = ((Component)value).gameObject.AddComponent<MeshRenderer>();
					((Renderer)obj).sharedMaterials = ((Renderer)component2).sharedMaterials;
					((Renderer)obj).shadowCastingMode = (ShadowCastingMode)1;
					((Renderer)obj).receiveShadows = true;
				}
			}
			SkinnedMeshRenderer component3 = ((Component)source).GetComponent<SkinnedMeshRenderer>();
			if ((Object)(object)component3 != (Object)null && (Object)(object)component3.sharedMesh != (Object)null)
			{
				SkinnedMeshRenderer val = ((Component)value).gameObject.AddComponent<SkinnedMeshRenderer>();
				val.sharedMesh = component3.sharedMesh;
				((Renderer)val).sharedMaterials = ((Renderer)component3).sharedMaterials;
				val.localBounds = component3.localBounds;
				val.updateWhenOffscreen = true;
				Transform[] bones = component3.bones;
				Transform[] array = (Transform[])(object)new Transform[(bones != null) ? bones.Length : 0];
				for (int i = 0; i < array.Length; i++)
				{
					if ((Object)(object)bones[i] != (Object)null && map.TryGetValue(bones[i], out var value2))
					{
						array[i] = value2;
					}
				}
				val.bones = array;
				if ((Object)(object)component3.rootBone != (Object)null && map.TryGetValue(component3.rootBone, out var value3))
				{
					val.rootBone = value3;
				}
			}
			for (int j = 0; j < source.childCount; j++)
			{
				CopyRenderers(source.GetChild(j), map);
			}
		}

		private static void CollectBones(Unit unit, Transform root, Dictionary<Transform, Transform> map, List<Bone> bones)
		{
			HashSet<Transform> hashSet = new HashSet<Transform>();
			SkinnedMeshRenderer[] componentsInChildren = ((Component)unit).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				if ((Object)(object)val == (Object)null || val.bones == null)
				{
					continue;
				}
				for (int j = 0; j < val.bones.Length; j++)
				{
					Transform val2 = val.bones[j];
					if ((Object)(object)val2 != (Object)null && hashSet.Add(val2) && map.TryGetValue(val2, out var value))
					{
						bones.Add(new Bone
						{
							source = val2,
							clone = value
						});
					}
				}
			}
			if (bones.Count == 0 && map.TryGetValue(((Component)unit).transform, out var value2))
			{
				bones.Add(new Bone
				{
					source = ((Component)unit).transform,
					clone = value2
				});
			}
		}

		private static void SetupPhysics(Transform root, List<Bone> bones)
		{
			Dictionary<Transform, Bone> dictionary = new Dictionary<Transform, Bone>();
			for (int i = 0; i < bones.Count; i++)
			{
				dictionary[bones[i].source] = bones[i];
			}
			Rigidbody val = ((Component)root).gameObject.GetComponent<Rigidbody>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)root).gameObject.AddComponent<Rigidbody>();
			}
			val.mass = 2f;
			val.interpolation = (RigidbodyInterpolation)1;
			val.collisionDetectionMode = (CollisionDetectionMode)2;
			AddCollider(((Component)root).gameObject, 0.2f);
			for (int j = 0; j < bones.Count; j++)
			{
				Bone bone = bones[j];
				if ((Object)(object)bone.clone == (Object)(object)root)
				{
					bone.body = val;
					continue;
				}
				Rigidbody val2 = ((Component)bone.clone).gameObject.GetComponent<Rigidbody>();
				if ((Object)(object)val2 == (Object)null)
				{
					val2 = ((Component)bone.clone).gameObject.AddComponent<Rigidbody>();
				}
				val2.mass = 0.35f;
				val2.interpolation = (RigidbodyInterpolation)1;
				val2.collisionDetectionMode = (CollisionDetectionMode)2;
				bone.body = val2;
				AddCollider(((Component)bone.clone).gameObject, 0.09f);
				Transform parent = bone.source.parent;
				Bone value = null;
				while ((Object)(object)parent != (Object)null && !dictionary.TryGetValue(parent, out value))
				{
					parent = parent.parent;
				}
				Rigidbody connectedBody = ((value != null) ? value.body : val);
				CharacterJoint obj = ((Component)bone.clone).gameObject.AddComponent<CharacterJoint>();
				((Joint)obj).connectedBody = connectedBody;
				((Joint)obj).enableCollision = false;
				((Joint)obj).enablePreprocessing = true;
			}
		}

		private static void AddCollider(GameObject go, float radius)
		{
			if (!((Object)(object)go.GetComponent<Collider>() != (Object)null))
			{
				go.AddComponent<SphereCollider>().radius = radius;
			}
		}

		private static void Throw(List<Bone> bones, Vector3 force)
		{
			//IL_0017: 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_001c: 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_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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			Vector3 val = ((((Vector3)(ref force)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref force)).normalized : Vector3.forward);
			float num = Mathf.Clamp(((Vector3)(ref force)).magnitude * 5E-07f, 35f, 260f);
			Vector3 velocity = val * num;
			for (int i = 0; i < bones.Count; i++)
			{
				Rigidbody body = bones[i].body;
				if (!((Object)(object)body == (Object)null))
				{
					body.velocity = velocity;
					body.angularVelocity = new Vector3(Random.Rang