Decompiled source of Homelander v1.0.4

Homelander.dll

Decompiled 10 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using REPOLib.Objects.Sdk;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Animations;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Discord.Sdk")]
[assembly: IgnoresAccessChecksTo("Domain_Reload")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("Homelander")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+1b010acb451d577fcdd407bd8ed35ed41cef2b16")]
[assembly: AssemblyProduct("Homelander")]
[assembly: AssemblyTitle("Homelander")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Homelander
{
	internal sealed class Clip
	{
		internal string Name;

		internal float Fps;

		internal int Frames;

		internal int[] TrackOfBone;

		internal Vector3[][] Positions;

		internal Quaternion[][] Rotations;

		internal float Length => (float)Frames / Fps;

		internal bool Sample(int bone, float t, out Vector3 position, out Quaternion rotation)
		{
			//IL_0051: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_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_000e: 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)
			int num = TrackOfBone[bone];
			if (num < 0)
			{
				position = default(Vector3);
				rotation = default(Quaternion);
				return false;
			}
			float num2 = Mathf.Repeat(t * Fps, (float)Frames);
			int num3 = (int)num2;
			int num4 = (num3 + 1) % Frames;
			float num5 = num2 - (float)num3;
			position = Vector3.Lerp(Positions[num][num3], Positions[num][num4], num5);
			rotation = Quaternion.Slerp(Rotations[num][num3], Rotations[num][num4], num5);
			return true;
		}
	}
	internal sealed class HomelanderAssets
	{
		internal string[] BoneNames;

		internal int[] Parents;

		internal Vector3[] RestPositions;

		internal Quaternion[] RestRotations;

		internal Mesh Mesh;

		internal Material[] Materials;

		internal Dictionary<string, Clip> Clips = new Dictionary<string, Clip>();

		private static HomelanderAssets cached;

		private static Shader shader;

		internal static HomelanderAssets Get()
		{
			return cached ?? (cached = Load());
		}

		private static HomelanderAssets Load()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: 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_00fa: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			HomelanderAssets homelanderAssets = new HomelanderAssets();
			using BinaryReader binaryReader = new BinaryReader(new MemoryStream(Resource("homelander.bin")));
			if (new string(binaryReader.ReadChars(4)) != "HLM1")
			{
				throw new InvalidDataException("homelander.bin has the wrong header");
			}
			int num = binaryReader.ReadInt32();
			homelanderAssets.BoneNames = new string[num];
			homelanderAssets.Parents = new int[num];
			homelanderAssets.RestPositions = (Vector3[])(object)new Vector3[num];
			homelanderAssets.RestRotations = (Quaternion[])(object)new Quaternion[num];
			for (int i = 0; i < num; i++)
			{
				homelanderAssets.BoneNames[i] = Name(binaryReader);
				homelanderAssets.Parents[i] = binaryReader.ReadInt32();
				homelanderAssets.RestPositions[i] = V3(binaryReader);
				homelanderAssets.RestRotations[i] = Q(binaryReader);
			}
			int num2 = binaryReader.ReadInt32();
			Vector3[] array = (Vector3[])(object)new Vector3[num2];
			Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num2];
			BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num2];
			for (int j = 0; j < num2; j++)
			{
				array[j] = V3(binaryReader);
			}
			for (int k = 0; k < num2; k++)
			{
				array2[k] = V3(binaryReader);
			}
			for (int l = 0; l < num2; l++)
			{
				array3[l] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle());
			}
			for (int m = 0; m < num2; m++)
			{
				((BoneWeight)(ref array4[m])).boneIndex0 = binaryReader.ReadUInt16();
				((BoneWeight)(ref array4[m])).boneIndex1 = binaryReader.ReadUInt16();
				((BoneWeight)(ref array4[m])).boneIndex2 = binaryReader.ReadUInt16();
				((BoneWeight)(ref array4[m])).boneIndex3 = binaryReader.ReadUInt16();
			}
			for (int n = 0; n < num2; n++)
			{
				((BoneWeight)(ref array4[n])).weight0 = binaryReader.ReadSingle();
				((BoneWeight)(ref array4[n])).weight1 = binaryReader.ReadSingle();
				((BoneWeight)(ref array4[n])).weight2 = binaryReader.ReadSingle();
				((BoneWeight)(ref array4[n])).weight3 = binaryReader.ReadSingle();
			}
			int num3 = binaryReader.ReadInt32();
			Mesh val = new Mesh
			{
				name = "Homelander",
				indexFormat = (IndexFormat)1
			};
			val.vertices = array;
			val.normals = array2;
			val.uv = array3;
			val.boneWeights = array4;
			val.subMeshCount = num3;
			homelanderAssets.Materials = (Material[])(object)new Material[num3];
			for (int num4 = 0; num4 < num3; num4++)
			{
				string texture = Name(binaryReader);
				bool cutout = binaryReader.ReadByte() != 0;
				int num5 = binaryReader.ReadInt32();
				int[] array5 = new int[num5];
				for (int num6 = 0; num6 < num5; num6++)
				{
					array5[num6] = binaryReader.ReadInt32();
				}
				val.SetTriangles(array5, num4);
				homelanderAssets.Materials[num4] = Material(texture, cutout);
			}
			Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num];
			Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[num];
			for (int num7 = 0; num7 < num; num7++)
			{
				Matrix4x4 val2 = Matrix4x4.TRS(homelanderAssets.RestPositions[num7], homelanderAssets.RestRotations[num7], Vector3.one);
				array6[num7] = ((homelanderAssets.Parents[num7] < 0) ? val2 : (array6[homelanderAssets.Parents[num7]] * val2));
				array7[num7] = ((Matrix4x4)(ref array6[num7])).inverse;
			}
			val.bindposes = array7;
			val.RecalculateBounds();
			homelanderAssets.Mesh = val;
			int num8 = binaryReader.ReadInt32();
			for (int num9 = 0; num9 < num8; num9++)
			{
				Clip clip = new Clip
				{
					Name = Name(binaryReader),
					Fps = binaryReader.ReadSingle(),
					Frames = binaryReader.ReadInt32()
				};
				int num10 = binaryReader.ReadInt32();
				clip.TrackOfBone = Enumerable.Repeat(-1, num).ToArray();
				clip.Positions = new Vector3[num10][];
				clip.Rotations = new Quaternion[num10][];
				for (int num11 = 0; num11 < num10; num11++)
				{
					clip.TrackOfBone[binaryReader.ReadInt32()] = num11;
					clip.Positions[num11] = (Vector3[])(object)new Vector3[clip.Frames];
					clip.Rotations[num11] = (Quaternion[])(object)new Quaternion[clip.Frames];
					for (int num12 = 0; num12 < clip.Frames; num12++)
					{
						clip.Positions[num11][num12] = V3(binaryReader);
						clip.Rotations[num11][num12] = Q(binaryReader);
					}
				}
				homelanderAssets.Clips[clip.Name] = clip;
			}
			object[] obj = new object[5]
			{
				num2,
				num,
				num3,
				string.Join(", ", homelanderAssets.Clips.Keys),
				null
			};
			Shader obj2 = shader;
			obj[4] = ((obj2 != null) ? ((Object)obj2).name : null);
			Plugin.Debug(string.Format("model: {0} vertices, {1} bones, {2} materials, clips {3}, shader {4}", obj));
			return homelanderAssets;
		}

		private static Material Material(string texture, bool cutout)
		{
			//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_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_0027: Expected O, but got Unknown
			Material val = new Material(FindShader())
			{
				name = "Homelander " + texture,
				color = Color.white
			};
			if (!string.IsNullOrEmpty(texture))
			{
				val.mainTexture = (Texture)(object)Texture(texture);
			}
			val.SetFloat("_Glossiness", 0.2f);
			if (cutout)
			{
				val.SetFloat("_Mode", 1f);
				val.SetOverrideTag("RenderType", "TransparentCutout");
				val.EnableKeyword("_ALPHATEST_ON");
				val.SetFloat("_Cutoff", 0.5f);
				val.renderQueue = 2450;
			}
			return val;
		}

		internal static Shader FindShader()
		{
			if (Object.op_Implicit((Object)(object)shader))
			{
				return shader;
			}
			shader = Shader.Find("Standard") ?? ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader s) => ((Object)s).name == "Standard")) ?? Shader.Find("Legacy Shaders/Diffuse");
			return shader;
		}

		private static Texture2D Texture(string resource)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true)
			{
				name = "Homelander " + resource,
				anisoLevel = 4
			};
			ImageConversion.LoadImage(val, Resource(resource));
			return val;
		}

		private static byte[] Resource(string name)
		{
			using Stream stream = typeof(HomelanderAssets).Assembly.GetManifestResourceStream(name) ?? throw new FileNotFoundException("missing embedded resource " + name);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static string Name(BinaryReader r)
		{
			return Encoding.UTF8.GetString(r.ReadBytes(r.ReadByte()));
		}

		private static Vector3 V3(BinaryReader r)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
		}

		private static Quaternion Q(BinaryReader r)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return new Quaternion(r.ReadSingle(), r.ReadSingle(), r.ReadSingle(), r.ReadSingle());
		}
	}
	internal sealed class Body : MonoBehaviour
	{
		internal const float Height = 1.85f;

		private const float Fade = 0.6f;

		private static int count;

		internal int Id;

		internal Laser Laser;

		internal Enemy Enemy;

		internal Transform Self;

		private HomelanderAssets assets;

		private Transform[] bones;

		private int[] animated;

		private Clip current;

		private Clip previous;

		private float time;

		private float previousTime;

		private float blend = 1f;

		private Cape cape;

		private Vector3 lastPosition;

		private Transform eyeL;

		private Transform eyeR;

		private (Transform bone, float share)[] look;

		private float lookYaw;

		private float lookPitch;

		private SkinnedMeshRenderer skin;

		private MaterialPropertyBlock tint;

		private float flash;

		internal Vector3? LookAt;

		private const float LookYawLimit = 50f;

		private const float LookDownLimit = 45f;

		private const float LookUpLimit = 30f;

		internal Vector3 Eyes => (EyeLeft + EyeRight) * 0.5f;

		internal Vector3 EyeLeft
		{
			get
			{
				//IL_0048: 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_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)eyeL))
				{
					return ((Component)this).transform.position + ((Component)this).transform.rotation * new Vector3(-0.033f, 1.72f, 0.075f);
				}
				return eyeL.position;
			}
		}

		internal Vector3 EyeRight
		{
			get
			{
				//IL_0048: 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_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				if (!Object.op_Implicit((Object)(object)eyeR))
				{
					return ((Component)this).transform.position + ((Component)this).transform.rotation * new Vector3(0.033f, 1.72f, 0.075f);
				}
				return eyeR.position;
			}
		}

		internal string ClipName => current?.Name;

		internal static Body Create(Transform physicsBody, Transform self, float floor)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003a: 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_0062: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Expected O, but got Unknown
			//IL_00f5: 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_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			HomelanderAssets assets = HomelanderAssets.Get();
			GameObject val = new GameObject("Homelander");
			val.transform.SetParent(physicsBody, false);
			val.transform.localPosition = new Vector3(0f, floor, 0f);
			Transform transform = new GameObject("Model").transform;
			transform.SetParent(val.transform, false);
			transform.localScale = Vector3.one * Plugin.Scale.Value;
			Transform[] bones = (Transform[])(object)new Transform[assets.BoneNames.Length];
			for (int i = 0; i < bones.Length; i++)
			{
				Transform transform2 = new GameObject(assets.BoneNames[i]).transform;
				transform2.SetParent((assets.Parents[i] < 0) ? transform : bones[assets.Parents[i]], false);
				transform2.localPosition = assets.RestPositions[i];
				transform2.localRotation = assets.RestRotations[i];
				bones[i] = transform2;
			}
			SkinnedMeshRenderer val2 = new GameObject("Mesh").AddComponent<SkinnedMeshRenderer>();
			((Component)val2).transform.SetParent(transform, false);
			val2.sharedMesh = assets.Mesh;
			val2.bones = bones;
			val2.rootBone = bones[0];
			((Renderer)val2).sharedMaterials = assets.Materials;
			val2.updateWhenOffscreen = true;
			Body body = val.AddComponent<Body>();
			body.Id = ++count;
			body.Self = self;
			body.assets = assets;
			body.bones = bones;
			body.skin = val2;
			body.tint = new MaterialPropertyBlock();
			Dictionary<string, Transform> byName = bones.ToDictionary((Transform b) => ((Object)b).name);
			body.look = (from l in new(string, float)[4]
				{
					("j_neck", 0.4f),
					("h_j_neck", 0.4f),
					("j_head", 0.6f),
					("h_j_head", 0.6f)
				}
				where byName.ContainsKey(l.Item1)
				select (byName[l.Item1], l.Item2)).ToArray();
			byName.TryGetValue("j_eyeball_le", out body.eyeL);
			byName.TryGetValue("j_eyeball_ri", out body.eyeR);
			HashSet<Transform> lookBones = new HashSet<Transform>(body.look.Select(((Transform bone, float share) l) => l.bone));
			body.animated = (from b in Enumerable.Range(0, bones.Length)
				where lookBones.Contains(bones[b]) || assets.Clips.Values.Any((Clip c) => c.TrackOfBone[b] >= 0)
				select b).ToArray();
			body.cape = new Cape(byName);
			body.lastPosition = val.transform.position;
			body.Laser = val.AddComponent<Laser>();
			body.Laser.Init(body);
			val.AddComponent<Theme>();
			body.Play("hover");
			return body;
		}

		internal void Flash()
		{
			flash = 1f;
		}

		internal void Play(string name)
		{
			if (!(current?.Name == name) && assets.Clips.TryGetValue(name, out var value))
			{
				previous = current;
				previousTime = time;
				current = value;
				time = 0f;
				blend = ((previous == null) ? 1f : 0f);
			}
		}

		private void LateUpdate()
		{
			Safe.Run("body", Animate);
		}

		private void Animate()
		{
			//IL_00d5: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00be: 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_00c2: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Min(Time.deltaTime, 0.05f);
			time += num;
			previousTime += num;
			blend = Mathf.MoveTowards(blend, 1f, num / 0.6f);
			float num2 = Mathf.SmoothStep(0f, 1f, blend);
			int[] array = animated;
			foreach (int num3 in array)
			{
				Pose(current, time, num3, out var position, out var rotation);
				if (num2 < 1f && previous != null)
				{
					Pose(previous, previousTime, num3, out var position2, out var rotation2);
					position = Vector3.Lerp(position2, position, num2);
					rotation = Quaternion.Slerp(rotation2, rotation, num2);
				}
				bones[num3].localPosition = position;
				bones[num3].localRotation = rotation;
			}
			Look(num);
			Vector3 val = ((num > 0f) ? ((((Component)this).transform.position - lastPosition) / num) : Vector3.zero);
			lastPosition = ((Component)this).transform.position;
			if (((Vector3)(ref val)).magnitude > 20f)
			{
				val = Vector3.zero;
			}
			cape.Step(num, -val);
			Laser.Step(num);
			Tint(num);
		}

		private void Tint(float dt)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (flash <= 0f && !tint.isEmpty)
			{
				((Renderer)skin).SetPropertyBlock((MaterialPropertyBlock)null);
				tint.Clear();
			}
			else if (!(flash <= 0f))
			{
				flash = Mathf.Max(0f, flash - dt * 4f);
				tint.SetColor("_Color", Color.Lerp(Color.white, new Color(1f, 0.15f, 0.1f), flash));
				tint.SetColor("_EmissionColor", new Color(0.6f, 0.02f, 0f) * flash);
				((Renderer)skin).SetPropertyBlock(tint);
			}
		}

		private void Look(float dt)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 0f;
			Vector3? val = ((Object.op_Implicit((Object)(object)Laser) && Laser.Busy) ? new Vector3?(Laser.Aim) : LookAt);
			if (val.HasValue)
			{
				Vector3 valueOrDefault = val.GetValueOrDefault();
				Vector3 val2 = ((Component)this).transform.InverseTransformDirection(valueOrDefault - Eyes);
				num = Mathf.Atan2(val2.x, val2.z) * 57.29578f;
				float y = val2.y;
				Vector2 val3 = new Vector2(val2.x, val2.z);
				num2 = Mathf.Atan2(y, ((Vector2)(ref val3)).magnitude) * 57.29578f;
				if (Mathf.Abs(num) > 110f)
				{
					num = (num2 = 0f);
				}
				num = Mathf.Clamp(num, -50f, 50f);
				num2 = Mathf.Clamp(num2, -45f, 30f);
			}
			float num3 = 1f - Mathf.Exp((0f - dt) * 6f);
			lookYaw = Mathf.Lerp(lookYaw, num, num3);
			lookPitch = Mathf.Lerp(lookPitch, num2, num3);
			(Transform, float)[] array = look;
			for (int i = 0; i < array.Length; i++)
			{
				(Transform, float) tuple = array[i];
				Transform item = tuple.Item1;
				float item2 = tuple.Item2;
				Quaternion val4 = ((Component)this).transform.rotation * Quaternion.Euler((0f - lookPitch) * item2, lookYaw * item2, 0f) * Quaternion.Inverse(((Component)this).transform.rotation);
				item.rotation = val4 * item.rotation;
			}
		}

		private void Pose(Clip clip, float t, int bone, out Vector3 position, out Quaternion rotation)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			if (clip == null || !clip.Sample(bone, t, out position, out rotation))
			{
				position = assets.RestPositions[bone];
				rotation = assets.RestRotations[bone];
			}
		}
	}
	internal sealed class Cape
	{
		private sealed class Strip
		{
			internal Transform[] Bones;

			internal Quaternion[] RestLocal;

			internal Vector3[] Dir;

			internal Vector3[] P;

			internal Vector3[] Prev;

			internal float[] Rest;
		}

		private readonly List<Strip> strips = new List<Strip>();

		private readonly List<(Strip a, Strip b, int i, float rest)> ties = new List<(Strip, Strip, int, float)>();

		private readonly (Transform a, Transform b, float r)[] capsules;

		private float time;

		internal Cape(Dictionary<string, Transform> bones)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: 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_0162: 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_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			if (!bones.TryGetValue("j_cape", out var value))
			{
				capsules = new(Transform, Transform, float)[0];
				return;
			}
			foreach (Transform item in value)
			{
				Transform val = item;
				List<Transform> chain = new List<Transform>();
				Transform val2 = val;
				while (Object.op_Implicit((Object)(object)val2))
				{
					chain.Add(val2);
					val2 = ((val2.childCount > 0) ? val2.GetChild(0) : null);
				}
				List<Transform> list = chain.Where((Transform b, int i) => i + 1 < chain.Count && Vector3.Distance(b.position, chain[i + 1].position) > 0.01f).ToList();
				list.Add(chain[chain.Count - 1]);
				if (list.Count < 2)
				{
					continue;
				}
				List<Vector3> list2 = list.Select((Transform b) => b.position).ToList();
				int count = list2.Count;
				Vector3 val3 = list2[count - 1];
				Vector3 val4 = list2[count - 1] - list2[count - 2];
				list2.Add(val3 + ((Vector3)(ref val4)).normalized * 0.06f);
				Strip strip = new Strip
				{
					Bones = list.ToArray(),
					RestLocal = list.Select((Transform b) => b.localRotation).ToArray(),
					P = list2.ToArray(),
					Prev = list2.ToArray(),
					Rest = new float[list2.Count - 1],
					Dir = (Vector3[])(object)new Vector3[list.Count]
				};
				for (int num = 0; num + 1 < list2.Count; num++)
				{
					strip.Rest[num] = Vector3.Distance(list2[num], list2[num + 1]);
					if (num < list.Count)
					{
						Vector3[] dir = strip.Dir;
						int num2 = num;
						val4 = list[num].InverseTransformPoint(list2[num + 1]);
						dir[num2] = ((Vector3)(ref val4)).normalized;
					}
				}
				strips.Add(strip);
			}
			Transform spine = value.parent;
			strips.Sort((Strip a, Strip b) => spine.InverseTransformPoint(a.P[0]).x.CompareTo(spine.InverseTransformPoint(b.P[0]).x));
			for (int num3 = 0; num3 + 1 < strips.Count; num3++)
			{
				Strip strip2 = strips[num3];
				Strip strip3 = strips[num3 + 1];
				for (int num4 = 1; num4 < Mathf.Min(strip2.P.Length, strip3.P.Length); num4++)
				{
					ties.Add((strip2, strip3, num4, Vector3.Distance(strip2.P[num4], strip3.P[num4])));
				}
			}
			(string, string, float)[] source = new(string, string, float)[5]
			{
				("j_mainroot", "j_neck", 0.16f),
				("j_hip_le", "j_knee_le", 0.085f),
				("j_hip_ri", "j_knee_ri", 0.085f),
				("j_knee_le", "j_ankle_le", 0.065f),
				("j_knee_ri", "j_ankle_ri", 0.065f)
			};
			capsules = (from c in source
				where bones.ContainsKey(c.a) && bones.ContainsKey(c.b)
				select (bones[c.a], bones[c.b], r: c.r)).ToArray();
		}

		internal void Step(float dt, Vector3 air)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (dt <= 0f)
			{
				return;
			}
			foreach (Strip strip in strips)
			{
				for (int i = 0; i < strip.Bones.Length; i++)
				{
					strip.Bones[i].localRotation = strip.RestLocal[i];
				}
			}
			Simulate(dt / 2f, air);
			Simulate(dt / 2f, air);
			Aim();
		}

		private void Simulate(float dt, Vector3 air)
		{
			//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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: 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_0067: 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_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_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0167: 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_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: 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_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			time += dt;
			Vector3 gravity = Physics.gravity;
			for (int i = 0; i < strips.Count; i++)
			{
				Strip strip = strips[i];
				strip.P[0] = strip.Bones[0].position;
				strip.Prev[0] = strip.P[0];
				for (int j = 1; j < strip.P.Length; j++)
				{
					Vector3 val = (strip.P[j] - strip.Prev[j]) / dt;
					float num = (float)j / (float)(strip.P.Length - 1);
					Vector3 val2 = new Vector3(Mathf.Sin(time * 7.1f + (float)j * 0.9f + (float)i * 1.3f) * 0.8f, Mathf.Sin(time * 5.3f + (float)j * 1.7f + (float)i * 0.7f) * 0.5f, Mathf.Sin(time * 6.2f + (float)j * 1.1f + (float)i * 2.1f) * 0.9f) * ((0.4f + num) * (0.35f + ((Vector3)(ref air)).magnitude * 0.45f));
					Vector3 val3 = gravity + (air + val2 - val) * 4f;
					strip.Prev[j] = strip.P[j];
					ref Vector3 reference = ref strip.P[j];
					reference += val * dt * 0.985f + val3 * dt * dt;
				}
			}
			for (int k = 0; k < 10; k++)
			{
				foreach (Strip strip2 in strips)
				{
					for (int l = 0; l + 1 < strip2.P.Length; l++)
					{
						Vector3 val4 = strip2.P[l + 1] - strip2.P[l];
						float magnitude = ((Vector3)(ref val4)).magnitude;
						if (!(magnitude < 1E-06f))
						{
							Vector3 val5 = val4 * ((magnitude - strip2.Rest[l]) / magnitude);
							if (l == 0)
							{
								ref Vector3 reference2 = ref strip2.P[l + 1];
								reference2 -= val5;
								continue;
							}
							ref Vector3 reference3 = ref strip2.P[l];
							reference3 += val5 * 0.5f;
							ref Vector3 reference4 = ref strip2.P[l + 1];
							reference4 -= val5 * 0.5f;
						}
					}
				}
				foreach (var ty in ties)
				{
					Strip item = ty.a;
					Strip item2 = ty.b;
					int item3 = ty.i;
					float item4 = ty.rest;
					Vector3 val6 = item2.P[item3] - item.P[item3];
					float magnitude2 = ((Vector3)(ref val6)).magnitude;
					if (magnitude2 > 1E-06f && (magnitude2 < item4 * 0.6f || magnitude2 > item4))
					{
						float num2 = ((magnitude2 > item4) ? item4 : (item4 * 0.6f));
						Vector3 val7 = val6 * ((magnitude2 - num2) / magnitude2 * 0.5f);
						ref Vector3 reference5 = ref item.P[item3];
						reference5 += val7;
						ref Vector3 reference6 = ref item2.P[item3];
						reference6 -= val7;
					}
				}
				foreach (Strip strip3 in strips)
				{
					for (int m = 1; m < strip3.P.Length; m++)
					{
						(Transform, Transform, float)[] array = capsules;
						for (int n = 0; n < array.Length; n++)
						{
							var (val8, val9, r) = array[n];
							strip3.P[m] = Push(strip3.P[m], val8.position, val9.position, r);
						}
					}
				}
			}
		}

		private void Aim()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_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)
			foreach (Strip strip in strips)
			{
				for (int i = 0; i < strip.Bones.Length && i + 1 < strip.P.Length; i++)
				{
					Transform val = strip.Bones[i];
					Vector3 val2 = val.rotation * strip.Dir[i];
					Vector3 val3 = strip.P[i + 1] - val.position;
					if (!(((Vector3)(ref val3)).sqrMagnitude < 1E-08f))
					{
						val.rotation = Quaternion.FromToRotation(val2, val3) * val.rotation;
					}
				}
			}
		}

		private static Vector3 Push(Vector3 p, Vector3 a, Vector3 b, float r)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = b - a;
			float num = Mathf.Clamp01(Vector3.Dot(p - a, val) / Mathf.Max(((Vector3)(ref val)).sqrMagnitude, 1E-06f));
			Vector3 val2 = a + val * num;
			Vector3 val3 = p - val2;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			if (!(magnitude < r) || !(magnitude > 1E-06f))
			{
				return p;
			}
			return val2 + val3 * (r / magnitude);
		}
	}
	internal sealed class Brain : MonoBehaviour, IPunObservable
	{
		private enum Mode
		{
			Patrol,
			Investigate,
			Engage,
			Pursue,
			Leave
		}

		private Enemy enemy;

		private EnemyParent parent;

		private PhotonView view;

		private Body body;

		private Laser laser;

		private Sight sight;

		private Transform feet;

		private Mode mode;

		private PlayerAvatar target;

		private Vector3 lastSeen;

		private Vector3 moving;

		private Vector3 lastChest;

		private readonly Queue<(float at, Vector3 where)> trail = new Queue<(float, Vector3)>();

		private float lastSeenAt = -99f;

		private Vector3? noise;

		private float nextLaser;

		private float laughReady;

		private float tipOffAt;

		private float lookAroundUntil;

		private float leaveUntil;

		private bool wasStunned;

		private Vector3 goal;

		private bool hasGoal;

		private float speed;

		private Quaternion facing;

		private bool looking;

		private Vector3 lookAt;

		private int spawns;

		internal static bool debugPending;

		private void Awake()
		{
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Expected O, but got Unknown
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			enemy = ((Component)this).GetComponent<Enemy>();
			view = ((Component)this).GetComponent<PhotonView>();
			parent = ((Component)this).GetComponentInParent<EnemyParent>(true);
			Transform val = ((Component)this).transform.parent.Find("Rigidbody");
			feet = val.Find("Feet Transform");
			body = Body.Create(val, Object.op_Implicit((Object)(object)parent) ? ((Component)parent).transform : ((Component)this).transform.parent, 0f - Shell.BodyHeight);
			body.Enemy = enemy;
			laser = body.Laser;
			sight = new Sight(Object.op_Implicit((Object)(object)parent) ? ((Component)parent).transform : ((Component)this).transform.parent);
			facing = ((Component)this).transform.rotation;
			((Component)this).GetComponent<EnemyStateSpawn>().OnSpawn.AddListener(new UnityAction(OnSpawn));
			EnemyHealth component = ((Component)this).GetComponent<EnemyHealth>();
			component.onHurt.AddListener(new UnityAction(OnHurt));
			component.onDeath.AddListener(new UnityAction(OnDeath));
			EnemyStateInvestigate ears = ((Component)this).GetComponent<EnemyStateInvestigate>();
			if (ears != null)
			{
				ears.onInvestigateTriggered.AddListener((UnityAction)delegate
				{
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					Heard(ears.onInvestigateTriggeredPosition);
				});
			}
		}

		private void OnSpawn()
		{
			//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)
			if (Net.IsHost)
			{
				SemiFunc.EnemySpawn(enemy);
				mode = Mode.Patrol;
				target = null;
				noise = null;
				hasGoal = false;
				wasStunned = false;
				facing = ((Component)this).transform.rotation;
				tipOffAt = Time.time + 8f;
				nextLaser = Time.time + 2f;
				spawns++;
				string text = (debugPending ? "by the debug key" : "naturally");
				debugPending = false;
				Log((spawns == 1) ? ("spawned " + text) : $"spawned {text} (back again, #{spawns} this level)");
			}
		}

		private void OnHurt()
		{
			body.Flash();
			if (Net.IsHost && mode == Mode.Leave)
			{
				mode = Mode.Patrol;
			}
		}

		private void OnDeath()
		{
			//IL_00a4: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			laser.Cancel();
			Transform val = (Object.op_Implicit((Object)(object)parent) ? ((Component)parent).transform.Find("Particles") : null);
			if (Object.op_Implicit((Object)(object)val))
			{
				ParticleSystem[] componentsInChildren = ((Component)val).GetComponentsInChildren<ParticleSystem>(true);
				foreach (ParticleSystem val2 in componentsInChildren)
				{
					((Component)val2).transform.position = enemy.CenterTransform.position;
					val2.Play();
				}
			}
			if (Object.op_Implicit((Object)(object)GameDirector.instance))
			{
				GameDirector.instance.CameraShake.ShakeDistance(3f, 3f, 10f, enemy.CenterTransform.position, 0.5f);
				GameDirector.instance.CameraImpact.ShakeDistance(3f, 3f, 10f, enemy.CenterTransform.position, 0.05f);
			}
			if (Net.IsHost)
			{
				Log("killed");
				parent.Despawn();
			}
		}

		private void Heard(Vector3 position)
		{
			//IL_0052: 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)
			if (Net.IsHost && mode != Mode.Engage && !laser.Busy)
			{
				if (!noise.HasValue)
				{
					Log($"heard something {Vector3.Distance(position, ((Component)this).transform.position):0} m away");
				}
				noise = position;
			}
		}

		private void Update()
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (Net.IsHost)
			{
				if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated)
				{
					Safe.Run("brain", Think);
				}
			}
			else
			{
				body.LookAt = (looking ? new Vector3?(lookAt) : ((Vector3?)null));
			}
		}

		private void Think()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_00e4: 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_00bc: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0183: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: 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_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			if ((int)enemy.CurrentState == 11)
			{
				StopLaser("despawning");
				parent.Despawn();
				return;
			}
			if (enemy.IsStunned())
			{
				if (!wasStunned)
				{
					wasStunned = true;
					StopLaser("stunned");
					Log("stunned");
				}
				enemy.NavMeshAgent.Disable(0.1f);
				((Component)this).transform.position = feet.position;
				body.LookAt = null;
				looking = false;
				return;
			}
			if (wasStunned)
			{
				wasStunned = false;
				enemy.NavMeshAgent.Warp(feet.position, false);
				enemy.NavMeshAgent.ResetPath();
				hasGoal = false;
			}
			Vector3 eyes = body.Eyes;
			float value = Plugin.LaserRange.Value;
			if (Object.op_Implicit((Object)(object)target) && target.isDisabled)
			{
				target = null;
			}
			bool flag = Object.op_Implicit((Object)(object)target) && sight.Visible(target, eyes, Mathf.Max(value, Plugin.VisionRange.Value));
			if (flag)
			{
				Vector3 val = Chest(target);
				if (Time.time - lastSeenAt < 0.5f && Time.deltaTime > 0f)
				{
					moving = Vector3.Lerp(moving, (val - lastChest) / Time.deltaTime, 1f - Mathf.Exp((0f - Time.deltaTime) * 6f));
				}
				lastChest = (lastSeen = val);
				lastSeenAt = Time.time;
			}
			else if (mode != Mode.Leave)
			{
				List<PlayerAvatar> list = sight.Look(eyes, ((Component)body).transform.forward);
				if (list.Count > 0)
				{
					target = list[0];
					flag = true;
					lastChest = (lastSeen = Chest(target));
					moving = Vector3.zero;
					lastSeenAt = Time.time;
					Log($"spotted {target.playerName}, {Vector3.Distance(eyes, lastSeen):0} m");
				}
			}
			if (laser.Busy)
			{
				Burn(flag);
			}
			else if (flag && Vector3.Distance(eyes, lastSeen) <= value)
			{
				Engage();
			}
			else if (Object.op_Implicit((Object)(object)target) && Time.time - lastSeenAt < Plugin.SearchSeconds.Value)
			{
				Pursue(flag);
			}
			else if (mode == Mode.Leave || SemiFunc.EnemyForceLeave(enemy))
			{
				target = null;
				Leave();
			}
			else if (noise.HasValue)
			{
				target = null;
				Investigate();
			}
			else
			{
				target = null;
				Patrol();
			}
			looking = Object.op_Implicit((Object)(object)target) && flag;
			lookAt = (looking ? PlayerEyes(target) : Vector3.zero);
			body.LookAt = (looking ? new Vector3?(lookAt) : ((Vector3?)null));
			Turn();
		}

		private void Engage()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			mode = Mode.Engage;
			noise = null;
			Face(lastSeen);
			float num = Vector3.Distance(body.Eyes, lastSeen);
			if (Time.time >= nextLaser)
			{
				Stop();
				bool flag = Time.time >= laughReady;
				if (flag)
				{
					laughReady = Time.time + Plugin.LaughCooldown.Value;
				}
				trail.Clear();
				Send("LaserStartRPC", flag, lastSeen, Mathf.Max(0.1f, Plugin.ChargeSeconds.Value));
				Log(string.Format("laser at {0}{1}, {2:0} m", target.playerName, flag ? ", laughing first" : "", num));
			}
			else if (num > Plugin.StopDistance.Value)
			{
				GoTo(((Component)target).transform.position, Plugin.Speed.Value);
			}
			else
			{
				Stop();
			}
		}

		private void Burn(bool seeing)
		{
			//IL_001f: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: 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)
			mode = Mode.Engage;
			Stop();
			Vector3 val = Delayed((seeing && Object.op_Implicit((Object)(object)target)) ? Chest(target) : Believed());
			float value = Plugin.TrackSpeed.Value;
			float num = Mathf.Lerp(value, Mathf.Max(value, Plugin.CatchUpSpeed.Value), Mathf.InverseLerp(1f, 3f, Vector3.Distance(laser.Aim, val)));
			laser.Aim = Vector3.MoveTowards(laser.Aim, val, num * Time.deltaTime);
			Face(laser.Aim);
			if (laser.Now == Laser.Phase.Fire && laser.FireTime >= Plugin.BeamSeconds.Value)
			{
				StopLaser(seeing ? "done" : "done, burning where he reckoned they'd gone");
			}
		}

		private Vector3 Delayed(Vector3 now)
		{
			//IL_000b: 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)
			trail.Enqueue((Time.time, now));
			float num = Time.time - Plugin.ReactionTime.Value;
			while (trail.Count > 1 && trail.Peek().at < num)
			{
				trail.Dequeue();
			}
			return trail.Peek().where;
		}

		private Vector3 Believed()
		{
			//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)
			//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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Min(Time.time - lastSeenAt, 1f);
			Vector3 val = Vector3.ClampMagnitude(new Vector3(moving.x, 0f, moving.z), 3f);
			return lastSeen + val * num;
		}

		private void StopLaser(string why)
		{
			if (laser.Busy)
			{
				Send("LaserStopRPC");
				nextLaser = Time.time + Plugin.LaserCooldown.Value;
				Log("laser off (" + why + ")");
			}
		}

		private void Pursue(bool seeing)
		{
			//IL_0054: 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_00e1: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			if (mode != Mode.Pursue)
			{
				lookAroundUntil = 0f;
				hasGoal = false;
				if (!seeing)
				{
					Log("lost " + target.playerName + "; going to where he last saw them");
				}
			}
			mode = Mode.Pursue;
			if (seeing)
			{
				GoTo(((Component)target).transform.position, Plugin.Speed.Value * 1.3f);
				return;
			}
			if (!Arrived(1f) && !Stuck())
			{
				GoTo(lastSeen, Plugin.Speed.Value * 1.3f);
				return;
			}
			Stop();
			if (lookAroundUntil == 0f)
			{
				lookAroundUntil = Time.time + 5f;
			}
			facing *= Quaternion.Euler(0f, 70f * Time.deltaTime, 0f);
			if (Time.time > lookAroundUntil)
			{
				Log("gave up on " + target.playerName);
				target = null;
				hasGoal = false;
			}
		}

		private void Investigate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (mode != Mode.Investigate)
			{
				hasGoal = false;
			}
			mode = Mode.Investigate;
			GoTo(noise.Value, Plugin.Speed.Value);
			if (Arrived(1.5f) || Stuck())
			{
				noise = null;
				hasGoal = false;
			}
		}

		private void Patrol()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			if (mode != Mode.Patrol)
			{
				hasGoal = false;
			}
			mode = Mode.Patrol;
			if (SemiFunc.EnemySpawnIdlePause())
			{
				Stop();
				return;
			}
			if (hasGoal && !Arrived(1.5f) && !Stuck())
			{
				GoTo(goal, Plugin.Speed.Value * 0.75f);
				return;
			}
			List<LevelPoint> list = (SemiFunc.LevelPointsGetAll() ?? new List<LevelPoint>()).Where((LevelPoint p) => Object.op_Implicit((Object)(object)p) && !p.Truck).ToList();
			if (list.Count == 0)
			{
				return;
			}
			Vector3 position;
			if (Time.time >= tipOffAt)
			{
				PlayerAvatar near = Nearest();
				if (near != null)
				{
					tipOffAt = Time.time + Plugin.TipOffSeconds.Value;
					position = ((Component)(from _ in list.OrderBy(delegate(LevelPoint p)
						{
							//IL_0006: 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)
							Vector3 val = ((Component)p).transform.position - ((Component)near).transform.position;
							return ((Vector3)(ref val)).sqrMagnitude;
						}).Take(4)
						orderby Random.value
						select _).First()).transform.position;
					Log("drifting toward " + near.playerName + "'s area");
					goto IL_016d;
				}
			}
			position = ((Component)list[Random.Range(0, list.Count)]).transform.position;
			goto IL_016d;
			IL_016d:
			hasGoal = false;
			GoTo(position, Plugin.Speed.Value * 0.75f);
		}

		private void Leave()
		{
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			if (mode != Mode.Leave)
			{
				LevelPoint val = SemiFunc.LevelPointGetPlayerDistance(((Component)this).transform.position, 30f, 50f, false) ?? SemiFunc.LevelPointGetFurthestFromPlayer(((Component)this).transform.position, 5f);
				if (!Object.op_Implicit((Object)(object)val))
				{
					Patrol();
					return;
				}
				mode = Mode.Leave;
				hasGoal = false;
				noise = null;
				leaveUntil = Time.time + 20f;
				SemiFunc.EnemyLeaveStart(enemy);
				GoTo(((Component)val).transform.position, Plugin.Speed.Value);
				Log("leaving");
			}
			else
			{
				GoTo(goal, Plugin.Speed.Value);
				if (Arrived(1.5f) || Stuck() || Time.time > leaveUntil)
				{
					mode = Mode.Patrol;
					hasGoal = false;
				}
			}
		}

		private void GoTo(Vector3 destination, float moveSpeed)
		{
			//IL_0030: 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_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_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_005e: Unknown result type (might be due to invalid IL or missing references)
			speed = moveSpeed;
			if (hasGoal)
			{
				Vector3 val = Flat(goal - destination);
				if (!(((Vector3)(ref val)).magnitude > 0.5f))
				{
					goto IL_0052;
				}
			}
			goal = destination;
			hasGoal = true;
			enemy.Rigidbody.notMovingTimer = 0f;
			goto IL_0052;
			IL_0052:
			enemy.NavMeshAgent.SetDestination(goal);
			enemy.NavMeshAgent.OverrideAgent(speed, enemy.NavMeshAgent.DefaultAcceleration, 0.2f);
		}

		private void Stop()
		{
			speed = 0f;
			enemy.NavMeshAgent.ResetPath();
		}

		private bool Arrived(float within)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (hasGoal)
			{
				Vector3 val = Flat(((Component)this).transform.position - goal);
				return ((Vector3)(ref val)).magnitude < within + 0.5f;
			}
			return false;
		}

		private bool Stuck()
		{
			if (hasGoal && speed > 0f)
			{
				return enemy.Rigidbody.notMovingTimer > 3f;
			}
			return false;
		}

		private void Face(Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_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)
			Vector3 val = Flat(point - ((Component)this).transform.position);
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				facing = Quaternion.LookRotation(val);
			}
		}

		private void Turn()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Flat(enemy.NavMeshAgent.AgentVelocity);
			if (mode != Mode.Engage && mode != Mode.Pursue && ((Vector3)(ref val)).sqrMagnitude > 0.04f)
			{
				facing = Quaternion.LookRotation(val);
			}
			float num = (laser.Busy ? 120f : 240f);
			((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, facing, num * Time.deltaTime);
		}

		private void Send(string rpc, params object[] args)
		{
			//IL_004e: 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_002f: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				view.RPC(rpc, (RpcTarget)0, args);
			}
			else if (rpc == "LaserStartRPC")
			{
				LaserStartRPC((bool)args[0], (Vector3)args[1], (float)args[2]);
			}
			else
			{
				LaserStopRPC();
			}
		}

		[PunRPC]
		private void LaserStartRPC(bool laugh, Vector3 aim, float charge, PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: 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)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				laser.Begin(laugh, aim, charge);
			}
		}

		[PunRPC]
		private void LaserStopRPC(PhotonMessageInfo info = default(PhotonMessageInfo))
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.MasterOnlyRPC(info))
			{
				laser.Stop();
			}
		}

		public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
		{
			//IL_0055: 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_0076: 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_0086: 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_0045: 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_009f: 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)
			if (stream.IsWriting)
			{
				stream.SendNext((object)looking);
				stream.SendNext((object)lookAt);
				stream.SendNext((object)(Object.op_Implicit((Object)(object)laser) ? laser.Aim : Vector3.zero));
			}
			else if (SemiFunc.MasterOnlyRPC(info))
			{
				looking = (bool)stream.ReceiveNext();
				lookAt = (Vector3)stream.ReceiveNext();
				Vector3 aim = (Vector3)stream.ReceiveNext();
				if (Object.op_Implicit((Object)(object)laser))
				{
					laser.Aim = aim;
				}
			}
		}

		internal static void DebugSpawn(Vector3 spot, Quaternion facing)
		{
			//IL_0036: 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_0080: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			EnemyParent val = Shell.All().FirstOrDefault();
			debugPending = !Object.op_Implicit((Object)(object)val) || !val.Spawned;
			if (!Object.op_Implicit((Object)(object)val))
			{
				ManualLogSource log = Plugin.Log;
				List<EnemyParent> list = Enemies.SpawnEnemy(Shell.Setup, spot, facing, false);
				log.LogInfo((object)((list != null && list.Count > 0) ? $"debug: spawned at {spot}" : "debug: spawn failed"));
				return;
			}
			if (!val.Spawned)
			{
				val.Spawn();
			}
			val.Enemy.EnemyTeleported(spot);
			Plugin.Log.LogInfo((object)$"debug: moved to {spot}");
		}

		internal static void DebugDespawn()
		{
			foreach (EnemyParent item in from p in Shell.All()
				where p.Spawned
				select p)
			{
				item.Despawn();
				Plugin.Log.LogInfo((object)"debug: despawned");
			}
		}

		private PlayerAvatar Nearest()
		{
			return World.Targets().OrderBy(delegate(PlayerAvatar p)
			{
				//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)
				Vector3 val = ((Component)p).transform.position - ((Component)this).transform.position;
				return ((Vector3)(ref val)).sqrMagnitude;
			}).FirstOrDefault();
		}

		private void Log(string text)
		{
			Plugin.Debug($"#{body.Id}: {text}");
		}

		private static Vector3 Flat(Vector3 v)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return new Vector3(v.x, 0f, v.z);
		}

		internal static Vector3 Chest(PlayerAvatar player)
		{
			//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)
			//IL_0020: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			if (player.isTumbling && Object.op_Implicit((Object)(object)player.tumble))
			{
				return ((Component)player.tumble).transform.position;
			}
			return ((Component)player).transform.position + Vector3.up * (player.isCrawling ? 0.3f : (player.isCrouching ? 0.6f : 1.1f));
		}

		internal static Vector3 PlayerEyes(PlayerAvatar player)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)player.PlayerVisionTarget) && Object.op_Implicit((Object)(object)player.PlayerVisionTarget.VisionTransform))
			{
				return player.PlayerVisionTarget.VisionTransform.position;
			}
			return ((Component)player).transform.position + Vector3.up * 1.5f;
		}
	}
	internal static class Fx
	{
		internal static readonly int Tint = Shader.PropertyToID("_TintColor");

		internal static Texture2D BeamTexture;

		internal static Texture2D CrackleTexture;

		internal static Texture2D GlowTexture;

		internal static Texture2D SoftTexture;

		internal static Texture2D ScorchTexture;

		internal static Material ScorchMaterial;

		private static Shader additive;

		private static Shader alpha;

		private static Shader standardParticles;

		private static Mesh quad;

		private static float sparkDebt;

		private static float smokeDebt;

		private static float emberDebt;

		internal static void Init()
		{
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: 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_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0311: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Expected O, but got Unknown
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)BeamTexture))
			{
				return;
			}
			Shader[] loaded = Resources.FindObjectsOfTypeAll<Shader>();
			additive = Find("Legacy Shaders/Particles/Additive") ?? Find("Mobile/Particles/Additive");
			standardParticles = (Object.op_Implicit((Object)(object)additive) ? null : Find("Particles/Standard Unlit"));
			if (additive == null)
			{
				additive = standardParticles ?? Shader.Find("Sprites/Default");
			}
			alpha = Find("Legacy Shaders/Particles/Alpha Blended") ?? Find("Mobile/Particles/Alpha Blended") ?? Shader.Find("Sprites/Default");
			string[] obj = new string[6] { "laser shaders: ", null, null, null, null, null };
			Shader obj2 = additive;
			obj[1] = ((obj2 != null) ? ((Object)obj2).name : null);
			obj[2] = ", ";
			Shader obj3 = alpha;
			obj[3] = ((obj3 != null) ? ((Object)obj3).name : null);
			obj[4] = "; particle shaders loaded: ";
			obj[5] = string.Join(", ", (from x in loaded
				where Object.op_Implicit((Object)(object)x) && ((Object)x).name.Contains("Particle")
				select ((Object)x).name).Distinct());
			Plugin.Debug(string.Concat(obj));
			BeamTexture = new Texture2D(4, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				name = "Homelander beam"
			};
			for (int num = 0; num < 64; num++)
			{
				float num2 = Mathf.Abs((float)num / 63f - 0.5f) * 2f;
				float num3 = Mathf.Exp((0f - num2) * num2 * 40f);
				float num4 = Mathf.Exp((0f - num2) * num2 * 4f);
				Color val = Straight(new Color(Mathf.Clamp01(num4 + num3), Mathf.Clamp01(0.05f * num4 + 0.8f * num3), Mathf.Clamp01(0.03f * num4 + 0.7f * num3)));
				for (int num5 = 0; num5 < 4; num5++)
				{
					BeamTexture.SetPixel(num5, num, val);
				}
			}
			BeamTexture.Apply();
			CrackleTexture = new Texture2D(64, 32, (TextureFormat)4, false)
			{
				wrapModeU = (TextureWrapMode)0,
				wrapModeV = (TextureWrapMode)1,
				name = "Homelander crackle"
			};
			for (int num6 = 0; num6 < 64; num6++)
			{
				float num7 = (float)num6 / 64f * MathF.PI * 2f;
				float num8 = 0.55f + 0.45f * Mathf.Sin(num7 * 3f) * Mathf.Sin(num7 * 7f + 1.3f) + 0.15f * Mathf.Sin(num7 * 13f);
				for (int num9 = 0; num9 < 32; num9++)
				{
					float num10 = Mathf.Abs((float)num9 / 31f - 0.5f) * 2f;
					float num11 = Mathf.Exp((0f - num10) * num10 * 5f) * Mathf.Clamp01(num8);
					CrackleTexture.SetPixel(num6, num9, Straight(new Color(num11, num11 * 0.25f, num11 * 0.15f)));
				}
			}
			CrackleTexture.Apply();
			GlowTexture = Radial("glow", delegate(float d)
			{
				//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)
				float num12 = Mathf.Pow(Mathf.Clamp01(1f - d), 2.2f);
				return Straight(new Color(num12, Mathf.Exp((0f - d) * d * 30f) * num12, Mathf.Exp((0f - d) * d * 40f) * num12));
			});
			SoftTexture = Radial("soft", (float d) => new Color(1f, 1f, 1f, Mathf.Pow(Mathf.Clamp01(1f - d), 2f)));
			ScorchTexture = Radial("scorch", (float d) => new Color(0f, 0f, 0f, 0.9f * Mathf.Pow(Mathf.Clamp01(1f - d), 1.2f)));
			ScorchMaterial = new Material(alpha)
			{
				mainTexture = (Texture)(object)ScorchTexture,
				renderQueue = 3000
			};
			ScorchMaterial.SetColor(Tint, new Color(0.5f, 0.5f, 0.5f, 0.5f));
			Shader Find(string name)
			{
				return Shader.Find(name) ?? Array.Find(loaded, (Shader x) => Object.op_Implicit((Object)(object)x) && ((Object)x).name == name);
			}
		}

		private static Color Straight(Color glow)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0035: 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)
			float num = Mathf.Max(glow.r, Mathf.Max(glow.g, glow.b));
			if (!(num < 0.0001f))
			{
				return new Color(glow.r / num, glow.g / num, glow.b / num, num);
			}
			return new Color(0f, 0f, 0f, 0f);
		}

		private static Texture2D Radial(string name, Func<float, Color> colour)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//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_0062: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false)
			{
				wrapMode = (TextureWrapMode)1,
				name = "Homelander " + name
			};
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					Vector2 val2 = new Vector2((float)j / 63f - 0.5f, (float)i / 63f - 0.5f);
					float arg = ((Vector2)(ref val2)).magnitude * 2f;
					val.SetPixel(j, i, colour(arg));
				}
			}
			val.Apply();
			return val;
		}

		internal static Material Additive(Texture texture, float tint = 0.5f)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_002b: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(additive)
			{
				mainTexture = texture,
				renderQueue = 3100
			};
			val.SetColor(Tint, new Color(tint, tint, tint, 0.5f));
			if (Object.op_Implicit((Object)(object)additive) && ((Object)additive).name == "Sprites/Default")
			{
				val.color = new Color(tint * 2f, tint * 2f, tint * 2f, 1f);
			}
			if ((Object)(object)additive == (Object)(object)standardParticles)
			{
				val.SetOverrideTag("RenderType", "Transparent");
				val.SetFloat("_Mode", 4f);
				val.SetInt("_BlendOp", 0);
				val.SetInt("_SrcBlend", 5);
				val.SetInt("_DstBlend", 1);
				val.SetInt("_ZWrite", 0);
				val.EnableKeyword("_ALPHABLEND_ON");
				val.SetColor("_Color", new Color(tint * 2f, tint * 2f, tint * 2f, 1f));
			}
			return val;
		}

		internal static void SetTint(Material m, Color c)
		{
			//IL_0006: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			m.SetColor(Tint, c);
			if ((Object)(object)additive == (Object)(object)standardParticles)
			{
				m.SetColor("_Color", c * 2f);
			}
			else if (Object.op_Implicit((Object)(object)additive) && ((Object)additive).name == "Sprites/Default")
			{
				m.color = c * 2f;
			}
		}

		internal static GameObject Quad(string name, Transform parent, Material material)
		{
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0076: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)quad))
			{
				quad = new Mesh
				{
					name = "Homelander quad"
				};
				quad.vertices = (Vector3[])(object)new Vector3[4]
				{
					new Vector3(-0.5f, -0.5f, 0f),
					new Vector3(0.5f, -0.5f, 0f),
					new Vector3(-0.5f, 0.5f, 0f),
					new Vector3(0.5f, 0.5f, 0f)
				};
				quad.uv = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(0f, 0f),
					new Vector2(1f, 0f),
					new Vector2(0f, 1f),
					new Vector2(1f, 1f)
				};
				quad.triangles = new int[6] { 0, 2, 1, 1, 2, 3 };
				quad.RecalculateBounds();
			}
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			val.AddComponent<MeshFilter>().sharedMesh = quad;
			MeshRenderer val2 = val.AddComponent<MeshRenderer>();
			((Renderer)val2).sharedMaterial = material;
			((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val2).receiveShadows = false;
			return val;
		}

		internal static ParticleSystem Sparks(Transform parent)
		{
			//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_002e: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0065: 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_008a: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0101: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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)
			ParticleSystem val = System(parent, "Sparks", Additive((Texture)(object)SoftTexture), 600);
			MainModule main = val.main;
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1f);
			ColorOverLifetimeModule colorOverLifetime = val.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val2 = new Gradient();
			val2.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(new Color(1f, 0.95f, 0.7f), 0f),
				new GradientColorKey(new Color(1f, 0.45f, 0.1f), 0.3f),
				new GradientColorKey(new Color(0.8f, 0.05f, 0.02f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(0.8f, 0.6f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
			CollisionModule collision = val.collision;
			((CollisionModule)(ref collision)).enabled = true;
			((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
			((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(0.6f);
			((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0.3f);
			((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(0.2f);
			((CollisionModule)(ref collision)).quality = (ParticleSystemCollisionQuality)2;
			return val;
		}

		internal static ParticleSystem Smoke(Transform parent)
		{
			//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_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_003b: 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_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_0093: 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_00a3: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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_00ee: 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_0115: 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_0128: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(alpha)
			{
				mainTexture = (Texture)(object)SoftTexture,
				renderQueue = 3050
			};
			val.SetColor(Tint, new Color(0.12f, 0.1f, 0.1f, 0.35f));
			ParticleSystem val2 = System(parent, "Smoke", val, 80);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 0.4f, 1f, 1.6f));
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey(0.8f, 0.2f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			return val2;
		}

		private static ParticleSystem System(Transform parent, string name, Material material, int max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(parent, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = max;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = false;
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = material;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows