Decompiled source of Slayer from Guilty Gear v1.0.15

plugins/Slayer/Slayer.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Loader;
using HarmonyLib;
using KinematicCharacterController;
using RoR2;
using RoR2.CameraModes;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Networking;
using RoR2.Skills;
using RoR2.UI;
using SimpleJSON;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace SlayerMod;

public static class Balance
{
	public static readonly BalanceFile File = new BalanceFile(Path.Combine(Path.GetDirectoryName(typeof(Balance).Assembly.Location), "data", "balance.json"), "Slayer");

	public static float Number(string path, float fallback)
	{
		return File.Number(path, fallback);
	}

	public static float Percent(string path, float fallback)
	{
		return File.Percent(path, fallback);
	}

	public static int Count(string path, int fallback)
	{
		return File.Count(path, fallback);
	}

	public static bool Flag(string path, bool fallback)
	{
		return File.Flag(path, fallback);
	}

	public static string Text(string path)
	{
		return File.Text(path);
	}
}
public class BalanceFile
{
	private readonly JSONNode _root;

	private readonly string _owner;

	public readonly Dictionary<string, float> Numbers = new Dictionary<string, float>();

	public BalanceFile(string path, string owner)
	{
		_owner = owner;
		try
		{
			_root = JSON.Parse(File.ReadAllText(path));
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("[" + owner + "] couldn't read " + path + ", using built-in values: " + ex.Message));
		}
	}

	public JSONNode Find(string path)
	{
		JSONNode val = _root;
		string[] array = path.Split('.');
		foreach (string text in array)
		{
			if (val == (object)null)
			{
				return null;
			}
			int num = text.IndexOf('[');
			val = ((num < 0) ? val[text] : val[text.Substring(0, num)]);
			if (num >= 0 && !(val == (object)null))
			{
				val = val[int.Parse(text.Substring(num + 1, text.Length - num - 2), CultureInfo.InvariantCulture)];
			}
		}
		return val;
	}

	public float Number(string path, float fallback)
	{
		if (Numbers.TryGetValue(path, out var value))
		{
			return value;
		}
		JSONNode val = Find(path);
		if (val == (object)null || !float.TryParse(val.Value, NumberStyles.Float, CultureInfo.InvariantCulture, out value))
		{
			Debug.LogWarning((object)$"[{_owner}] balance.json has no number at {path}, using {fallback}");
			value = fallback;
		}
		Numbers[path] = value;
		return value;
	}

	public float Percent(string path, float fallback)
	{
		return Number(path, fallback * 100f) / 100f;
	}

	public int Count(string path, int fallback)
	{
		return Mathf.RoundToInt(Number(path, fallback));
	}

	public bool Flag(string path, bool fallback)
	{
		JSONNode val = Find(path);
		if (val != (object)null && bool.TryParse(val.Value, out var result))
		{
			return result;
		}
		Debug.LogWarning((object)$"[{_owner}] balance.json has no true/false at {path}, using {fallback}");
		return fallback;
	}

	public string Text(string path)
	{
		JSONNode val = Find(path);
		if (val != (object)null)
		{
			return val.Value;
		}
		Debug.LogWarning((object)("[" + _owner + "] balance.json has no text at " + path));
		return path;
	}
}
public class BatSwarm : MonoBehaviour
{
	private struct Bat
	{
		public Transform Transform;

		public float Speed;

		public float Phase;

		public float Radius;

		public float Bob;

		public float Size;

		public Vector3 Away;
	}

	private const int Count = 32;

	private const float Height = 1.35f;

	private const float Radius = 0.7f;

	private const float Length = 1.25f;

	private const float Bob = 0.45f;

	private const float FormTime = 0.15f;

	private const float FlyAwayTime = 0.7f;

	private const float ShrinkTime = 0.3f;

	private static readonly Color32 Fur = new Color32((byte)7, (byte)4, (byte)5, byte.MaxValue);

	private static readonly Color32 WingInner = new Color32((byte)16, (byte)4, (byte)6, byte.MaxValue);

	private static readonly Color32 WingMiddle = new Color32((byte)34, (byte)5, (byte)8, byte.MaxValue);

	private static readonly Color32 WingTip = new Color32((byte)56, (byte)6, (byte)11, byte.MaxValue);

	private static Mesh _mesh;

	private Bat[] _bats;

	private float _form;

	private float _awayLeft;

	private bool _leaving;

	public static readonly Vector2[] WingOutline = (Vector2[])(object)new Vector2[9]
	{
		new Vector2(0.035f, 0.055f),
		new Vector2(0.13f, 0.085f),
		new Vector2(0.21f, 0.06f),
		new Vector2(0.31f, -0.02f),
		new Vector2(0.2f, -0.03f),
		new Vector2(0.175f, -0.095f),
		new Vector2(0.115f, -0.05f),
		new Vector2(0.085f, -0.125f),
		new Vector2(0.035f, -0.065f)
	};

	public const float WingSpan = 0.31f;

	public static BatSwarm Spawn(Transform model, int count = 32)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)SlayerVfx.BatMaterial))
		{
			return null;
		}
		GameObject val = new GameObject("BatSwarm");
		val.transform.SetParent(model, false);
		BatSwarm batSwarm = val.AddComponent<BatSwarm>();
		batSwarm.Build(count);
		return batSwarm;
	}

	public static void Burst(Transform model, int count)
	{
		BatSwarm batSwarm = Spawn(model, count);
		if (Object.op_Implicit((Object)(object)batSwarm))
		{
			batSwarm.Dismiss();
		}
	}

	public static void BurstAt(Vector3 feet, int count)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		BatSwarm batSwarm = Spawn(null, count);
		if (Object.op_Implicit((Object)(object)batSwarm))
		{
			((Component)batSwarm).transform.position = feet;
			batSwarm.Dismiss();
		}
	}

	public void Dismiss()
	{
		//IL_002b: 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_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)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		_leaving = true;
		_awayLeft = 0.7f;
		Bat[] bats = _bats;
		for (int i = 0; i < bats.Length; i++)
		{
			Bat bat = bats[i];
			bat.Transform.localScale = Vector3.one * bat.Size;
		}
		Vector3 val = ((Component)this).transform.TransformPoint(Vector3.up * 1.35f);
		((Component)this).transform.SetParent((Transform)null, true);
		for (int j = 0; j < _bats.Length; j++)
		{
			Vector3 val2 = _bats[j].Transform.position - val;
			Vector3 val3 = ((Vector3)(ref val2)).normalized + Vector3.up * Random.Range(0.1f, 0.9f);
			_bats[j].Away = ((Vector3)(ref val3)).normalized * Random.Range(5f, 11f);
		}
	}

	private void Build(int count)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		_mesh = (Object.op_Implicit((Object)(object)_mesh) ? _mesh : BuildMesh());
		_bats = new Bat[count];
		MaterialPropertyBlock val = new MaterialPropertyBlock();
		for (int i = 0; i < count; i++)
		{
			GameObject val2 = new GameObject("Bat");
			val2.transform.SetParent(((Component)this).transform, false);
			val2.AddComponent<MeshFilter>().sharedMesh = _mesh;
			MeshRenderer obj = val2.AddComponent<MeshRenderer>();
			((Renderer)obj).sharedMaterial = SlayerVfx.BatMaterial;
			((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)obj).receiveShadows = false;
			val.SetFloat("_Phase", Random.value * MathF.PI * 2f);
			((Renderer)obj).SetPropertyBlock(val);
			_bats[i] = new Bat
			{
				Transform = val2.transform,
				Speed = Random.Range(2.5f, 4.5f) * ((Random.value < 0.5f) ? (-1f) : 1f),
				Phase = Random.value * MathF.PI * 2f,
				Radius = 0.7f * Mathf.Sqrt(Random.Range(0.05f, 1f)),
				Bob = 0.45f * Random.Range(0.4f, 1f),
				Size = Random.Range(0.75f, 1.15f)
			};
		}
		Update();
	}

	private void Update()
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		float deltaTime = Time.deltaTime;
		if (_leaving)
		{
			FlyAway(deltaTime);
			return;
		}
		_form = Mathf.MoveTowards(_form, 1f, deltaTime / 0.15f);
		float time = Time.time;
		Bat[] bats = _bats;
		Vector3 val = default(Vector3);
		for (int i = 0; i < bats.Length; i++)
		{
			Bat bat = bats[i];
			float num = time * bat.Speed + bat.Phase;
			((Vector3)(ref val))..ctor(Mathf.Cos(num) * bat.Radius, Mathf.Sin(num * 1.7f + bat.Phase) * bat.Bob, Mathf.Sin(num) * bat.Radius * 1.25f);
			Vector3 val2 = new Vector3(0f - Mathf.Sin(num), 0f, Mathf.Cos(num)) * Mathf.Sign(bat.Speed);
			bat.Transform.localPosition = Vector3.up * 1.35f + val * _form;
			bat.Transform.localRotation = Quaternion.LookRotation(Vector3.forward * 1.2f + val2, Vector3.up);
			bat.Transform.localScale = Vector3.one * (bat.Size * _form);
		}
	}

	private void FlyAway(float dt)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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)
		_awayLeft -= dt;
		if (_awayLeft <= 0f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float num = Mathf.Clamp01(_awayLeft / 0.3f);
		Bat[] bats = _bats;
		for (int i = 0; i < bats.Length; i++)
		{
			Bat bat = bats[i];
			Transform transform = bat.Transform;
			transform.position += bat.Away * dt;
			bat.Transform.rotation = Quaternion.LookRotation(bat.Away, Vector3.up);
			bat.Transform.localScale = Vector3.one * (bat.Size * num);
		}
	}

	private static Mesh BuildMesh()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: 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_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Expected O, but got Unknown
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_045d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: Unknown result type (might be due to invalid IL or missing references)
		//IL_0466: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: 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_047a: Unknown result type (might be due to invalid IL or missing references)
		//IL_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		//IL_0405: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		Vector2[] wingOutline = WingOutline;
		List<Vector3> list = new List<Vector3>
		{
			new Vector3(0f, 0.012f, 0.125f),
			new Vector3(-0.03f, 0.065f, 0.095f),
			new Vector3(0.03f, 0.065f, 0.095f),
			new Vector3(-0.045f, 0.03f, 0.05f),
			new Vector3(0.045f, 0.03f, 0.05f),
			new Vector3(0f, 0.05f, 0.03f),
			new Vector3(-0.045f, -0.025f, 0.05f),
			new Vector3(0.045f, -0.025f, 0.05f),
			new Vector3(0f, -0.04f, 0f),
			new Vector3(0f, 0f, -0.13f)
		};
		List<int> list2 = new List<int>
		{
			0, 1, 3, 0, 4, 2, 0, 3, 5, 0,
			5, 4, 3, 9, 5, 4, 5, 9, 0, 6,
			3, 0, 4, 7, 0, 7, 8, 0, 8, 6,
			6, 8, 9, 7, 9, 8, 3, 6, 9, 4,
			9, 7
		};
		float[] array = new float[2] { 1f, -1f };
		foreach (float num in array)
		{
			int count = list.Count;
			Vector2[] array2 = wingOutline;
			foreach (Vector2 val in array2)
			{
				float num2 = Mathf.Lerp(0.02f, 0.004f, val.x / 0.31f);
				list.Add(new Vector3(val.x * num, num2, val.y));
				list.Add(new Vector3(val.x * num, 0f - num2, val.y));
			}
			for (int k = 1; k < wingOutline.Length - 1; k++)
			{
				int num3 = count + k * 2;
				int num4 = num3 + 1;
				list2.AddRange(new int[6]
				{
					count,
					num3,
					num3 + 2,
					count + 1,
					num4 + 2,
					num4
				});
			}
			for (int l = 0; l < wingOutline.Length; l++)
			{
				int num5 = count + l * 2;
				int num6 = count + (l + 1) % wingOutline.Length * 2;
				list2.AddRange(new int[6]
				{
					num5,
					num6,
					num5 + 1,
					num6,
					num6 + 1,
					num5 + 1
				});
			}
		}
		Color32[] array3 = (Color32[])(object)new Color32[list.Count];
		for (int m = 0; m < array3.Length; m++)
		{
			float num7 = Mathf.Abs(list[m].x);
			array3[m] = ((m < 10) ? Fur : ((num7 > 0.25f) ? WingTip : ((num7 > 0.14f) ? WingMiddle : WingInner)));
		}
		Mesh val2 = new Mesh
		{
			name = "meshSlayerBat"
		};
		val2.SetVertices(list);
		val2.colors32 = array3;
		val2.SetTriangles(list2, 0);
		val2.RecalculateBounds();
		Bounds bounds = val2.bounds;
		Vector3 center = ((Bounds)(ref bounds)).center;
		bounds = val2.bounds;
		val2.bounds = new Bounds(center, ((Bounds)(ref bounds)).size + Vector3.up * 0.6f);
		val2.UploadMeshData(true);
		return val2;
	}
}
[DefaultExecutionOrder(1000)]
public abstract class GlideLook : MonoBehaviour
{
	private const float Smoothing = 0.15f;

	protected static readonly Vector4 Energy = new Vector4(30f, 3f, 24f, 1f);

	protected Transform Body;

	protected Vector3 Heading;

	protected Vector3 Up;

	protected bool Closing;

	protected float Age;

	private Vector3 _last;

	private Vector3 _velocity;

	private static string Kind => Balance.Text("secondary_options[1].in_air.glide_effect");

	public float Pitch { get; private set; }

	public static GlideLook Spawn(Transform body)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)body))
		{
			return null;
		}
		GameObject val = new GameObject("GlideLook");
		GlideLook glideLook = ((Kind == "boost") ? ((GlideLook)val.AddComponent<HandBoost>()) : ((GlideLook)val.AddComponent<EnergyWings>()));
		glideLook.Body = body;
		glideLook._last = body.position;
		glideLook.Heading = body.forward;
		if (!glideLook.Build())
		{
			Object.Destroy((Object)(object)val);
			return null;
		}
		glideLook.LateUpdate();
		return glideLook;
	}

	public void Release()
	{
		Closing = true;
	}

	protected abstract bool Build();

	protected abstract bool Show(float dt);

	private void LateUpdate()
	{
		//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_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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_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_0074: 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_00d0: 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_008f: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Body))
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float num = Mathf.Max(Time.deltaTime, 0.0001f);
		Age += num;
		Vector3 position = Body.position;
		_velocity = Vector3.Lerp(_velocity, (position - _last) / num, Mathf.Clamp01(num / 0.15f));
		_last = position;
		float magnitude = ((Vector3)(ref _velocity)).magnitude;
		if (magnitude > 1f)
		{
			Heading = _velocity / magnitude;
		}
		Pitch = Mathf.Asin(Mathf.Clamp(Heading.y, -1f, 1f)) * 57.29578f;
		Vector3 val = Vector3.Cross(Vector3.up, Heading);
		if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
		{
			val = Body.right;
		}
		Up = Vector3.Cross(Heading, ((Vector3)(ref val)).normalized);
		if (!Show(num))
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
}
public class EnergyWings : GlideLook
{
	private const string Effect = "sly_233_attack01";

	private const string Texture = "sly_233_attack01";

	private const int Columns = 3;

	private const int Rows = 4;

	private const int Frame = 4;

	private const int CellsX = 100;

	private const int CellsY = 75;

	private const float Span = 1.7f;

	private const float ChordScale = 0.8f;

	private const float Thickness = 0.08f;

	private const float Bend = 0.55f;

	private const float RootAt = 0.45f;

	private const float AttackAngle = 12f;

	private const float Shoulders = 0.25f;

	private const float Back = 0.22f;

	private const float Height = 1.25f;

	private const float Unfold = 0.16f;

	private const float FoldAway = 0.2f;

	private const float Flash = 0.35f;

	private const float FlashLevel = 4f;

	private static Mesh _mesh;

	private static Material _material;

	private MeshRenderer _renderer;

	private MaterialPropertyBlock _block;

	private Vector4 _tint;

	private float _open;

	protected override bool Build()
	{
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		//IL_009e: 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)
		if (!Object.op_Implicit((Object)(object)_material))
		{
			_material = SlayerVfx.EmitterMaterial("sly_233_attack01", "sly_233_attack01");
		}
		if (!Object.op_Implicit((Object)(object)_material))
		{
			return false;
		}
		if (!Object.op_Implicit((Object)(object)_mesh))
		{
			_mesh = BuildMesh();
		}
		((Component)this).gameObject.AddComponent<MeshFilter>().sharedMesh = _mesh;
		_renderer = ((Component)this).gameObject.AddComponent<MeshRenderer>();
		((Renderer)_renderer).sharedMaterial = _material;
		((Renderer)_renderer).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)_renderer).receiveShadows = false;
		_block = new MaterialPropertyBlock();
		_tint = GlideLook.Energy;
		BatSwarm.Burst(Body, 12);
		return true;
	}

	protected override bool Show(float dt)
	{
		//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_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		_open = Mathf.MoveTowards(_open, Closing ? 0f : 1f, dt / (Closing ? 0.2f : 0.16f));
		if (Closing && _open <= 0f)
		{
			return false;
		}
		float num = 1f - (1f - _open) * (1f - _open);
		float num2 = (Closing ? num : (num * (1f + 0.15f * Mathf.Sin(Mathf.Clamp01(Age / 0.32f) * MathF.PI))));
		((Component)this).transform.SetPositionAndRotation(Body.position + Vector3.up * 1.25f + Heading * 0.25f + Up * 0.22f, Quaternion.LookRotation(Heading, Up));
		((Component)this).transform.localScale = new Vector3(num2, Mathf.Max(num2, 0.2f), Mathf.Max(num2, 0.2f));
		float num3 = 1f + 3f * Mathf.Clamp01(1f - Age / 0.35f);
		_block.SetVector("_Tint", new Vector4(_tint.x * num3, _tint.y * num3, _tint.z * num3, 1f));
		((Renderer)_renderer).SetPropertyBlock(_block);
		return true;
	}

	private static Mesh BuildMesh()
	{
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: 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_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0401: Unknown result type (might be due to invalid IL or missing references)
		//IL_040d: Unknown result type (might be due to invalid IL or missing references)
		//IL_041c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0437: Expected O, but got Unknown
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: 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)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = SlayerVfx.ReadTexture("sly_233_attack01");
		float sheetWidth = ((Texture)val).width;
		float sheetHeight = ((Texture)val).height;
		int width = ((Texture)val).width / 3;
		int height = ((Texture)val).height / 4;
		int left = width;
		int bottom = 2 * height;
		Color32[] pixels = val.GetPixels32();
		bool[,] solid = new bool[100, 75];
		for (int i = 0; i < 100; i++)
		{
			for (int j = 0; j < 75; j++)
			{
				solid[i, j] = pixels[(bottom + (int)(((float)j + 0.5f) * (float)height / 75f)) * ((Texture)val).width + left + (int)(((float)i + 0.5f) * (float)width / 100f)].a > 128;
			}
		}
		Object.Destroy((Object)(object)val);
		float chord = 1.36f * (float)width / (float)height;
		Quaternion pitch = Quaternion.Euler(-12f, 0f, 0f);
		List<Vector4> uvs = new List<Vector4>();
		List<Vector3> vertices = new List<Vector3>();
		List<int> triangles = new List<int>();
		float[] array = new float[2] { 1f, -1f };
		foreach (float side in array)
		{
			for (int l = 0; l < 75; l++)
			{
				for (int m = 0; m < 100; m++)
				{
					if (!solid[m, l])
					{
						continue;
					}
					if (!Solid(m - 1, l))
					{
						int n;
						for (n = m; Solid(n + 1, l); n++)
						{
						}
						float[] array2 = new float[2] { 1f, -1f };
						foreach (float face in array2)
						{
							Quad(Point(m, l, face, side), Point(n + 1, l, face, side), Point(n + 1, l + 1, face, side), Point(m, l + 1, face, side), Uv(m, l), Uv(n + 1, l), Uv(n + 1, l + 1), Uv(m, l + 1));
						}
					}
					Vector2 centre = Uv((float)m + 0.5f, (float)l + 0.5f);
					if (!Solid(m - 1, l))
					{
						Wall(m, l, m, l + 1);
					}
					if (!Solid(m + 1, l))
					{
						Wall(m + 1, l, m + 1, l + 1);
					}
					if (!Solid(m, l - 1))
					{
						Wall(m, l, m + 1, l);
					}
					if (!Solid(m, l + 1))
					{
						Wall(m, l + 1, m + 1, l + 1);
					}
					void Wall(float ax, float ay, float bx, float by)
					{
						//IL_0010: 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_003a: 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_0056: 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_0064: 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)
						Quad(Point(ax, ay, 1f, side), Point(bx, by, 1f, side), Point(bx, by, -1f, side), Point(ax, ay, -1f, side), centre, centre, centre, centre);
					}
				}
			}
		}
		Mesh val2 = new Mesh
		{
			name = "meshSlayerEnergyWings",
			indexFormat = (IndexFormat)1
		};
		val2.SetVertices(vertices);
		val2.SetUVs(0, uvs);
		val2.SetUVs(1, Enumerable<Vector2>(vertices.Count, new Vector2(1f, 0f)));
		val2.SetColors(Enumerable<Color>(vertices.Count, Color.white));
		val2.SetTriangles(triangles, 0);
		val2.RecalculateBounds();
		val2.UploadMeshData(true);
		return val2;
		Vector3 Point(float x, float y, float num4, float num3)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			float num2 = y / 75f;
			return pitch * new Vector3(num3 * num2 * 1.7f, 0.55f * num2 * num2 + num4 * 0.08f / 2f, (0.45f - x / 100f) * chord);
		}
		void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector2 ua, Vector2 ub, Vector2 uc, Vector2 ud)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0047: 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_0050: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			int count = vertices.Count;
			vertices.AddRange((IEnumerable<Vector3>)(object)new Vector3[4] { a, b, c, d });
			Vector2[] array3 = (Vector2[])(object)new Vector2[4] { ua, ub, uc, ud };
			foreach (Vector2 val3 in array3)
			{
				uvs.Add(new Vector4(val3.x, val3.y, 0f, 1f));
			}
			triangles.AddRange(new int[6]
			{
				count,
				count + 1,
				count + 2,
				count,
				count + 2,
				count + 3
			});
		}
		bool Solid(int x, int y)
		{
			if (x >= 0 && y >= 0 && x < 100 && y < 75)
			{
				return solid[x, y];
			}
			return false;
		}
		Vector2 Uv(float x, float y)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(((float)left + x * (float)width / 100f) / sheetWidth, ((float)bottom + y * (float)height / 75f) / sheetHeight);
		}
	}

	private static List<T> Enumerable<T>(int count, T value)
	{
		List<T> list = new List<T>(count);
		for (int i = 0; i < count; i++)
		{
			list.Add(value);
		}
		return list;
	}
}
public class HandBoost : GlideLook
{
	private const float Linger = 0.4f;

	private readonly List<(Transform hand, ParticleSystem jet)> _jets = new List<(Transform, ParticleSystem)>();

	private float _closedAt = -1f;

	protected override bool Build()
	{
		//IL_0049: 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)
		ChildLocator component = ((Component)Body).GetComponent<ChildLocator>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			return false;
		}
		string[] array = new string[2] { "HandL", "HandR" };
		foreach (string text in array)
		{
			Transform val = component.FindChild(text);
			Transform transform = new GameObject("jet_" + text).transform;
			transform.SetParent(((Component)this).transform, false);
			ParticleSystem val2 = SlayerVfx.NewJet(transform, GlideLook.Energy);
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val2))
			{
				_jets.Add((val, val2));
			}
		}
		if (_jets.Count == 0)
		{
			return false;
		}
		BatSwarm.Burst(Body, 12);
		foreach (var jet in _jets)
		{
			jet.jet.Emit(14);
		}
		return true;
	}

	protected override bool Show(float dt)
	{
		//IL_007a: 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_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_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		if (Closing && _closedAt < 0f)
		{
			_closedAt = Age;
			foreach (var jet in _jets)
			{
				jet.jet.Stop(true, (ParticleSystemStopBehavior)1);
			}
		}
		if (Closing && Age - _closedAt > 0.4f)
		{
			return false;
		}
		Quaternion val = Quaternion.LookRotation(Heading, Up);
		foreach (var (val2, val3) in _jets)
		{
			if (Object.op_Implicit((Object)(object)val2))
			{
				((Component)val3).transform.parent.SetPositionAndRotation(val2.position, val);
			}
		}
		return true;
	}
}
public class HoverColumns : MonoBehaviour
{
	private const float MaxHeight = 380f;

	private const float Widen = 130f;

	private const float Gap = 28f;

	private static readonly float[] Sizes = new float[4] { 1f, 0.92f, 0.84f, 0.76f };

	private TMP_Text _text;

	private TextMeshProUGUI _second;

	private RectTransform _panel;

	private LayoutElement _layout;

	private float _fontSize;

	private float _panelRight;

	private string _laidOut;

	private bool _split;

	public static void Hook()
	{
		//IL_0005: 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_003e: Expected O, but got Unknown
		new Harmony("com.adik.slayer.hovercolumns").Patch((MethodBase)AccessTools.Method(typeof(CharacterSelectController), "RebuildStrip", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(HoverColumns), "Attach", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
	}

	private static void Attach(RectTransform skillStrip)
	{
		LanguageTextMeshController val = ((Component)skillStrip).GetComponent<HGButton>()?.hoverLanguageTextMeshController;
		if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<TMP_Text>()) && !Object.op_Implicit((Object)(object)((Component)val).GetComponent<HoverColumns>()))
		{
			((Component)val).gameObject.AddComponent<HoverColumns>();
		}
	}

	private void Awake()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		_text = ((Component)this).GetComponent<TMP_Text>();
		ref RectTransform panel = ref _panel;
		Transform parent = ((Component)this).transform.parent;
		panel = (RectTransform)(object)((parent is RectTransform) ? parent : null);
		_fontSize = _text.fontSize;
		if (Object.op_Implicit((Object)(object)_panel))
		{
			_panelRight = _panel.offsetMax.x;
		}
		_layout = ((Component)this).gameObject.AddComponent<LayoutElement>();
		_layout.layoutPriority = 2;
		((Behaviour)_layout).enabled = false;
	}

	private void LateUpdate()
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)_text) || _text.text == _laidOut)
		{
			return;
		}
		_laidOut = _text.text;
		if (_split)
		{
			Join();
		}
		if (!string.IsNullOrEmpty(_laidOut))
		{
			TMP_Text text = _text;
			string laidOut = _laidOut;
			Rect rect = _text.rectTransform.rect;
			if (text.GetPreferredValues(laidOut, ((Rect)(ref rect)).width, 0f).y > 380f)
			{
				Split();
			}
		}
	}

	private void Split()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		_split = true;
		Rect rect = _text.rectTransform.rect;
		float num = ((Rect)(ref rect)).width + 130f;
		float num2 = (num - 28f) / 2f;
		float num3 = 0f;
		float num4 = 0f;
		float[] sizes = Sizes;
		foreach (float num5 in sizes)
		{
			_text.fontSize = _fontSize * num5;
			(num3, num4) = Columns(num2);
			if (num4 <= 380f)
			{
				break;
			}
		}
		TextMeshProUGUI val = Second();
		((TMP_Text)val).fontSize = _text.fontSize;
		((TMP_Text)val).margin = new Vector4(num2 + 28f, 0f, 0f, 0f);
		((Component)val).gameObject.SetActive(true);
		_text.margin = new Vector4(0f, 0f, num2 + 28f, num4 - num3);
		_text.overflowMode = (TextOverflowModes)6;
		_text.linkedTextComponent = (TMP_Text)(object)val;
		_layout.preferredWidth = num;
		_layout.preferredHeight = num4;
		((Behaviour)_layout).enabled = true;
		if (Object.op_Implicit((Object)(object)_panel))
		{
			_panel.offsetMax = new Vector2(_panelRight + 130f, _panel.offsetMax.y);
		}
	}

	private (float first, float box) Columns(float column)
	{
		float num = Height("A\nA") - Height("A");
		float num2 = Height(_laidOut);
		string[] array = _laidOut.TrimEnd('\n').Split(new string[1] { "\n\n" }, StringSplitOptions.None);
		(float, float) result = (num2 / 2f + num * 1.5f, num2 / 2f + num * 1.5f);
		for (int i = 1; i < array.Length; i++)
		{
			float num3 = Height(string.Join("\n\n", array, 0, i)) + num * 1.5f;
			float num4 = Mathf.Max(num3, num2 - num3 + num * 1.5f);
			if (i == 1 || num4 < result.Item2)
			{
				result = (num3, num4);
			}
		}
		return result;
		float Height(string text)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			return _text.GetPreferredValues(text, column, 0f).y;
		}
	}

	private void Join()
	{
		//IL_0025: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		_split = false;
		_text.linkedTextComponent = null;
		_text.overflowMode = (TextOverflowModes)0;
		_text.margin = Vector4.zero;
		_text.fontSize = _fontSize;
		((Behaviour)_layout).enabled = false;
		if (Object.op_Implicit((Object)(object)_second))
		{
			((Component)_second).gameObject.SetActive(false);
		}
		if (Object.op_Implicit((Object)(object)_panel))
		{
			_panel.offsetMax = new Vector2(_panelRight, _panel.offsetMax.y);
		}
	}

	private TextMeshProUGUI Second()
	{
		//IL_002c: 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_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: 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_00b7: 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)
		if (Object.op_Implicit((Object)(object)_second))
		{
			return _second;
		}
		RectTransform component = new GameObject("SecondColumn", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>();
		((Transform)component).SetParent(((Component)this).transform, false);
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		Vector2 offsetMin = (component.offsetMax = Vector2.zero);
		component.offsetMin = offsetMin;
		_second = ((Component)component).gameObject.AddComponent<TextMeshProUGUI>();
		((TMP_Text)_second).font = _text.font;
		((TMP_Text)_second).fontSharedMaterial = _text.fontSharedMaterial;
		((Graphic)_second).color = ((Graphic)_text).color;
		((TMP_Text)_second).styleSheet = _text.styleSheet;
		((TMP_Text)_second).spriteAsset = _text.spriteAsset;
		((TMP_Text)_second).alignment = _text.alignment;
		((TMP_Text)_second).lineSpacing = _text.lineSpacing;
		((TMP_Text)_second).paragraphSpacing = _text.paragraphSpacing;
		((TMP_Text)_second).richText = true;
		((TMP_Text)_second).enableWordWrapping = true;
		((Graphic)_second).raycastTarget = false;
		return _second;
	}
}
public static class SlayerAudio
{
	private class Clip
	{
		public short[] Samples;

		public int Channels;

		public int Rate;
	}

	private class Voice
	{
		public Clip Clip;

		public double Position;

		public float Left;

		public float Right;
	}

	private struct WaveFormat
	{
		public ushort Tag;

		public ushort Channels;

		public uint SamplesPerSec;

		public uint AvgBytesPerSec;

		public ushort BlockAlign;

		public ushort BitsPerSample;

		public ushort ExtraSize;
	}

	private const int OutputRate = 44100;

	private const int BufferFrames = 1024;

	private const int BufferCount = 4;

	private const int HeaderSize = 48;

	private const int FlagsOffset = 24;

	private const int WhdrDone = 1;

	private const uint WaveMapper = uint.MaxValue;

	private static volatile Dictionary<string, Clip> Clips = new Dictionary<string, Clip>();

	private static readonly List<Clip> Variants = new List<Clip>();

	private static readonly List<Voice> Voices = new List<Voice>();

	private static BaseConVar _masterVolume;

	private static BaseConVar _sfxVolume;

	private static IntPtr _device;

	private static volatile bool _running;

	private static volatile float _peak;

	private static readonly object LoadLock = new object();

	public static int ActiveVoices
	{
		get
		{
			lock (Voices)
			{
				return Voices.Count;
			}
		}
	}

	public static bool DeviceOpen => _running;

	public static float ReadPeak()
	{
		float peak = _peak;
		_peak = 0f;
		return peak;
	}

	[DllImport("winmm.dll")]
	private static extern int waveOutOpen(out IntPtr device, uint id, ref WaveFormat format, IntPtr callback, IntPtr instance, uint flags);

	[DllImport("winmm.dll")]
	private static extern int waveOutPrepareHeader(IntPtr device, IntPtr header, int size);

	[DllImport("winmm.dll")]
	private static extern int waveOutWrite(IntPtr device, IntPtr header, int size);

	[DllImport("winmm.dll")]
	private static extern int waveOutReset(IntPtr device);

	[DllImport("winmm.dll")]
	private static extern int waveOutClose(IntPtr device);

	public static void LoadAll(string dir)
	{
		if (!_running && _device == IntPtr.Zero)
		{
			OpenDevice();
		}
		Task.Run(delegate
		{
			try
			{
				Stopwatch stopwatch = Stopwatch.StartNew();
				Dictionary<string, Clip> dictionary = new Dictionary<string, Clip>();
				string[] files = Directory.GetFiles(dir, "*.pcm");
				foreach (string path in files)
				{
					byte[] array = File.ReadAllBytes(path);
					Clip clip = new Clip
					{
						Rate = BitConverter.ToInt32(array, 0),
						Channels = BitConverter.ToInt32(array, 4),
						Samples = new short[(array.Length - 8) / 2]
					};
					Buffer.BlockCopy(array, 8, clip.Samples, 0, clip.Samples.Length * 2);
					dictionary[Path.GetFileNameWithoutExtension(path)] = clip;
				}
				lock (LoadLock)
				{
					foreach (KeyValuePair<string, Clip> clip2 in Clips)
					{
						if (!dictionary.ContainsKey(clip2.Key))
						{
							dictionary[clip2.Key] = clip2.Value;
						}
					}
					Clips = dictionary;
				}
				SlayerPlugin.Log.LogInfo((object)$"audio: {dictionary.Count} clips in {stopwatch.ElapsedMilliseconds} ms on a worker, device open: {_running}");
			}
			catch (Exception arg)
			{
				SlayerPlugin.Log.LogError((object)$"audio: couldn't load clips: {arg}");
			}
		});
	}

	private static void OpenDevice()
	{
		WaveFormat format = new WaveFormat
		{
			Tag = 1,
			Channels = 2,
			SamplesPerSec = 44100u,
			AvgBytesPerSec = 176400u,
			BlockAlign = 4,
			BitsPerSample = 16
		};
		int num = waveOutOpen(out _device, uint.MaxValue, ref format, IntPtr.Zero, IntPtr.Zero, 0u);
		if (num != 0)
		{
			SlayerPlugin.Log.LogWarning((object)$"waveOutOpen failed ({num}); Slayer's sounds are disabled");
			return;
		}
		_running = true;
		Application.quitting += Close;
		Thread thread = new Thread(MixLoop);
		thread.IsBackground = true;
		thread.Name = "SlayerAudio";
		thread.Start();
	}

	private static void Close()
	{
		_running = false;
		if (!(_device == IntPtr.Zero))
		{
			waveOutReset(_device);
			waveOutClose(_device);
			_device = IntPtr.Zero;
		}
	}

	private static void MixLoop()
	{
		int num = 4096;
		IntPtr[] array = new IntPtr[4];
		float[] mix = new float[2048];
		short[] array2 = new short[2048];
		for (int i = 0; i < 4; i++)
		{
			array[i] = Marshal.AllocHGlobal(48);
			for (int j = 0; j < 48; j++)
			{
				Marshal.WriteByte(array[i], j, 0);
			}
			Marshal.WriteIntPtr(array[i], 0, Marshal.AllocHGlobal(num));
			Marshal.WriteInt32(array[i], 8, num);
			waveOutPrepareHeader(_device, array[i], 48);
			Marshal.WriteInt32(array[i], 24, Marshal.ReadInt32(array[i], 24) | 1);
		}
		while (_running)
		{
			bool flag = false;
			IntPtr[] array3 = array;
			foreach (IntPtr intPtr in array3)
			{
				if ((Marshal.ReadInt32(intPtr, 24) & 1) != 0)
				{
					Mix(mix, array2);
					Marshal.Copy(array2, 0, Marshal.ReadIntPtr(intPtr, 0), array2.Length);
					Marshal.WriteInt32(intPtr, 24, Marshal.ReadInt32(intPtr, 24) & -2);
					if (_running)
					{
						waveOutWrite(_device, intPtr, 48);
					}
					flag = true;
				}
			}
			if (!flag)
			{
				Thread.Sleep(3);
			}
		}
	}

	private static void Mix(float[] mix, short[] output)
	{
		Array.Clear(mix, 0, mix.Length);
		lock (Voices)
		{
			for (int num = Voices.Count - 1; num >= 0; num--)
			{
				if (MixVoice(Voices[num], mix))
				{
					Voices.RemoveAt(num);
				}
			}
		}
		float num2 = 0f;
		for (int i = 0; i < mix.Length; i++)
		{
			float num3 = Math.Max(-1f, Math.Min(1f, mix[i]));
			num2 = Math.Max(num2, Math.Abs(num3));
			output[i] = (short)(num3 * 32767f);
		}
		if (num2 > _peak)
		{
			_peak = num2;
		}
	}

	private static bool MixVoice(Voice voice, float[] mix)
	{
		Clip clip = voice.Clip;
		int num = clip.Samples.Length / clip.Channels;
		double num2 = (double)clip.Rate / 44100.0;
		for (int i = 0; i < mix.Length / 2; i++)
		{
			int num3 = (int)voice.Position;
			if (num3 + 1 >= num)
			{
				return true;
			}
			float num4 = (float)(voice.Position - (double)num3);
			int num5 = num3 * clip.Channels;
			int num6 = num5 + clip.Channels;
			int num7 = ((clip.Channels > 1) ? 1 : 0);
			mix[i * 2] += ((float)clip.Samples[num5] + (float)(clip.Samples[num6] - clip.Samples[num5]) * num4) / 32768f * voice.Left;
			mix[i * 2 + 1] += ((float)clip.Samples[num5 + num7] + (float)(clip.Samples[num6 + num7] - clip.Samples[num5 + num7]) * num4) / 32768f * voice.Right;
			voice.Position += num2;
		}
		return false;
	}

	private static float Setting(ref BaseConVar convar, string name)
	{
		if (convar == null)
		{
			Console instance = Console.instance;
			convar = ((instance != null) ? instance.FindConVar(name) : null);
		}
		if (convar == null || !float.TryParse(convar.GetString(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
		{
			return 1f;
		}
		return Mathf.Clamp01(result * 0.01f);
	}

	public static float Length(string name)
	{
		if (!Clips.TryGetValue(name, out var value))
		{
			return 0f;
		}
		return (float)value.Samples.Length / (float)(value.Channels * value.Rate);
	}

	public static void Play(string name, Vector3 position, float volume = 1f)
	{
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: 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_0090: 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)
		if (!_running)
		{
			return;
		}
		Clip clip = Pick(name);
		if (clip == null)
		{
			return;
		}
		float num = volume * Setting(ref _masterVolume, "volume_master") * Setting(ref _sfxVolume, "volume_sfx");
		float num2 = 0f;
		Camera main = Camera.main;
		if ((Object)(object)main != (Object)null)
		{
			Vector3 val = position - ((Component)main).transform.position;
			num *= Mathf.Clamp01(1f - (((Vector3)(ref val)).magnitude - 12f) / 90f);
			if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
			{
				num2 = Vector3.Dot(((Vector3)(ref val)).normalized, ((Component)main).transform.right) * 0.5f;
			}
		}
		if (num <= 0.001f)
		{
			return;
		}
		lock (Voices)
		{
			Voices.Add(new Voice
			{
				Clip = clip,
				Left = num * Mathf.Min(1f, 1f - num2),
				Right = num * Mathf.Min(1f, 1f + num2)
			});
		}
	}

	private static Clip Pick(string name)
	{
		if (Clips.TryGetValue(name, out var value))
		{
			return value;
		}
		Variants.Clear();
		for (char c = 'a'; c <= 'f'; c = (char)(c + 1))
		{
			if (Clips.TryGetValue(name + c, out var value2))
			{
				Variants.Add(value2);
			}
		}
		if (Variants.Count == 0)
		{
			string[] array = new string[2] { "_a", "_b" };
			foreach (string text in array)
			{
				if (Clips.TryGetValue(name + text, out var value3))
				{
					Variants.Add(value3);
				}
			}
		}
		if (Variants.Count <= 0)
		{
			return null;
		}
		return Variants[Random.Range(0, Variants.Count)];
	}
}
public class SlayerContent : IContentPackProvider
{
	public const string SuperSlotName = "SlayerSuperChoice";

	public const float ModelScale = 1.08f;

	public static GameObject BodyPrefab;

	public static GameObject DisplayPrefab;

	public static GameObject MasterPrefab;

	public static BuffDef UniverseBuff;

	public static BuffDef RiscBuff;

	public static SkillDef PilebunkerSkill;

	public static SkillDef ItsLateSkill;

	public static SkillDef SweepSkill;

	public static SkillDef MastersHammerSkill;

	public static SkillDef SuperSkill;

	public static SkillDef WingsSkill;

	private static readonly Dictionary<SkillDef, SkillDef> SuperOffers = new Dictionary<SkillDef, SkillDef>();

	private readonly ContentPack _pack = new ContentPack();

	private readonly List<SkillDef> _skills = new List<SkillDef>();

	private readonly List<SkillFamily> _families = new List<SkillFamily>();

	private string _dataDir;

	private static Transform _holder;

	public static float HammerRadius => Balance.Number("utility.follow_ups[3].radius_metres", 12.12f) / 1.08f;

	public static float DiveRadius => Balance.Number("secondary_options[1].in_air.landing_radius_metres", 5f) / 1.08f;

	public static float BlastRadius => LastHorizon.BlastRadiusMetres / 1.08f;

	public static float UniverseDamage => 1f + Balance.Percent("universe_buff.damage_bonus_percent", 0.3f);

	public static float UniverseStun => Balance.Number("universe_buff.stun_seconds", 1f);

	public static bool UniverseCrits => Balance.Flag("universe_buff.always_critical", fallback: true);

	public static bool EngineReady { get; private set; }

	public string identifier => "com.adik.slayer";

	public static float UniverseCritFactor(CharacterBody body)
	{
		if (!(body.critMultiplier > 0f))
		{
			return 1f;
		}
		return 1f + body.crit * 0.01f * Balance.Percent("universe_buff.crit_chance_to_crit_damage_percent", 1f) / body.critMultiplier;
	}

	public SlayerContent(string dataDir)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		_dataDir = dataDir;
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		Stopwatch clock = Stopwatch.StartNew();
		SlayerData.Load(_dataDir);
		long data = clock.ElapsedMilliseconds;
		args.ReportProgress(0.2f);
		clock.Stop();
		yield return null;
		clock.Start();
		SlayerAudio.LoadAll(Path.Combine(_dataDir, "audio"));
		long audio = clock.ElapsedMilliseconds;
		args.ReportProgress(0.5f);
		clock.Stop();
		yield return null;
		clock.Start();
		GameObject val = new GameObject("SlayerPrefabs");
		val.SetActive(false);
		((Object)val).hideFlags = (HideFlags)61;
		Object.DontDestroyOnLoad((Object)val);
		_holder = val.transform;
		SlayerVfx.Load(Path.Combine(_dataDir, "vfx"), _holder);
		EngineReady = true;
		long vfx = clock.ElapsedMilliseconds;
		args.ReportProgress(0.65f);
		clock.Stop();
		yield return null;
		clock.Start();
		GameObject merc = Load("RoR2/Base/Merc/MercBody.prefab");
		SlayerModel.Init(_dataDir, Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Merc/matMerc.mat").WaitForCompletion());
		UniverseBuff = ScriptableObject.CreateInstance<BuffDef>();
		((Object)UniverseBuff).name = "bdSlayerUniverse";
		UniverseBuff.buffColor = new Color(0.9f, 0.1f, 0.2f);
		UniverseBuff.canStack = false;
		UniverseBuff.isDebuff = false;
		UniverseBuff.iconSprite = SlayerModel.LoadSprite("icon_buff");
		RiscBuff = ScriptableObject.CreateInstance<BuffDef>();
		((Object)RiscBuff).name = "bdSlayerRisc";
		RiscBuff.buffColor = new Color(1f, 0.55f, 0.1f);
		RiscBuff.canStack = true;
		RiscBuff.isDebuff = true;
		RiscBuff.iconSprite = SlayerModel.LoadSprite("icon_risc");
		_pack.buffDefs.Add((BuffDef[])(object)new BuffDef[2] { UniverseBuff, RiscBuff });
		BuildBody(merc);
		args.ReportProgress(0.8f);
		clock.Stop();
		yield return null;
		clock.Start();
		BuildDisplay();
		BuildMaster();
		BuildSkills();
		BuildSkins();
		BuildSurvivor();
		_pack.bodyPrefabs.Add((GameObject[])(object)new GameObject[1] { BodyPrefab });
		_pack.masterPrefabs.Add((GameObject[])(object)new GameObject[1] { MasterPrefab });
		_pack.skillDefs.Add(_skills.ToArray());
		_pack.skillFamilies.Add(_families.ToArray());
		_pack.entityStateTypes.Add(new Type[21]
		{
			typeof(SlayerMain),
			typeof(SlayerDeath),
			typeof(Gentleman),
			typeof(MappaHunch),
			typeof(DandyStep),
			typeof(Pilebunker),
			typeof(ItsLate),
			typeof(DandySweep),
			typeof(MastersHammer),
			typeof(BloodsuckingUniverse),
			typeof(UniverseBite),
			typeof(SuperMappaCharge),
			typeof(SuperMappaPunch),
			typeof(WingsOrDive),
			typeof(EternalWings),
			typeof(StraightDownDandy),
			typeof(CrosswiseHeel),
			typeof(AllDeadAim),
			typeof(AllDead),
			typeof(LastHorizon),
			typeof(SlayerBatEntry)
		});
		SlayerPlugin.Log.LogInfo((object)$"loaded in {clock.ElapsedMilliseconds} ms: data {data}, audio {audio - data}, effects {vfx - audio}, character {clock.ElapsedMilliseconds - vfx}");
		args.ReportProgress(1f);
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(_pack, args.output);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}

	private static GameObject Load(string path)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		return Addressables.LoadAssetAsync<GameObject>((object)path).WaitForCompletion();
	}

	private static GameObject ClonePrefab(GameObject source, string name)
	{
		return ClonePrefab(source, name, _holder, "com.adik.slayer");
	}

	public static GameObject ClonePrefab(GameObject source, string name, Transform holder, string owner)
	{
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		GameObject obj = Object.Instantiate<GameObject>(source, holder);
		((Object)obj).name = name;
		NetworkIdentity component = obj.GetComponent<NetworkIdentity>();
		if (Object.op_Implicit((Object)(object)component))
		{
			string text = string.Concat(from b in MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(owner + name))
				select b.ToString("x2"));
			AccessTools.Field(typeof(NetworkIdentity), "m_AssetId").SetValue(component, NetworkHash128.Parse(text));
		}
		return obj;
	}

	private void BuildBody(GameObject merc)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: 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_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		BodyPrefab = ClonePrefab(merc, "SlayerBody");
		CharacterBody component = BodyPrefab.GetComponent<CharacterBody>();
		component.baseNameToken = "SLAYER_BODY_NAME";
		component.subtitleNameToken = "SLAYER_BODY_SUBTITLE";
		component.bodyColor = new Color(0.62f, 0.09f, 0.14f);
		component.portraitIcon = (Texture)(object)SlayerModel.LoadTexture("portrait", linear: false, compress: false);
		component.baseMaxHealth = Balance.Number("character.stats.max_health", 125f);
		component.levelMaxHealth = Balance.Number("character.stats.max_health_per_level", 38f);
		component.baseRegen = Balance.Number("character.stats.regen", 1.5f);
		component.levelRegen = Balance.Number("character.stats.regen_per_level", 0.3f);
		component.baseDamage = Balance.Number("character.stats.damage", 13f);
		component.levelDamage = Balance.Number("character.stats.damage_per_level", 2.6f);
		component.baseArmor = Balance.Number("character.stats.armor", 15f);
		component.baseMoveSpeed = Balance.Number("character.stats.move_speed", 7f);
		component.baseCrit = Balance.Number("character.stats_inherited_from_mercenary.crit_percent", 1f);
		component.baseAttackSpeed = Balance.Number("character.stats_inherited_from_mercenary.attack_speed", 1f);
		component.levelArmor = Balance.Number("character.stats_inherited_from_mercenary.armor_per_level", 0f);
		component.levelMoveSpeed = Balance.Number("character.stats_inherited_from_mercenary.move_speed_per_level", 0f);
		component.sprintingSpeedMultiplier = Balance.Number("character.stats_inherited_from_mercenary.sprint_multiplier", 1.45f);
		component.baseJumpPower = Balance.Number("character.stats_inherited_from_mercenary.jump_power", 15f);
		component.baseJumpCount = Balance.Count("character.stats_inherited_from_mercenary.jumps", 2);
		component.baseAcceleration = Balance.Number("character.stats_inherited_from_mercenary.acceleration", 80f);
		component.baseMaxShield = Balance.Number("character.stats_inherited_from_mercenary.shield", 0f);
		if (Balance.Flag("character.immune_to_executes", fallback: true))
		{
			component.bodyFlags = (BodyFlags)(component.bodyFlags | 0x10);
		}
		if (Balance.Flag("character.immune_to_fall_damage", fallback: true))
		{
			component.bodyFlags = (BodyFlags)(component.bodyFlags | 1);
		}
		component.spreadBloomCurve = Load("RoR2/Base/Loader/LoaderBody.prefab").GetComponent<CharacterBody>().spreadBloomCurve;
		EntityStateMachine[] components = BodyPrefab.GetComponents<EntityStateMachine>();
		foreach (EntityStateMachine val in components)
		{
			if (val.customName == "Body")
			{
				val.mainStateType = new SerializableEntityStateType(typeof(SlayerMain));
			}
		}
		BodyPrefab.GetComponent<CharacterDeathBehavior>().deathState = new SerializableEntityStateType(typeof(SlayerDeath));
		BodyPrefab.AddComponent<SlayerPassive>();
		component.preferredPodPrefab = null;
		component.preferredInitialStateType = new SerializableEntityStateType(typeof(SlayerBatEntry));
		ModelLocator component2 = BodyPrefab.GetComponent<ModelLocator>();
		Transform modelTransform = component2.modelTransform;
		List<RendererInfo> list = new List<RendererInfo>();
		GameObject val2 = SlayerModel.Build("mdlSlayer", component2.modelBaseTransform, list);
		component2.modelTransform = val2.transform;
		val2.transform.localScale = Vector3.one * 1.08f;
		Object.DestroyImmediate((Object)(object)((Component)modelTransform).gameObject);
		AddModelComponents(val2, list, BodyPrefab.GetComponent<HealthComponent>());
	}

	private static void AddModelComponents(GameObject model, List<RendererInfo> infos, HealthComponent health)
	{
		//IL_024a: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0326: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: 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)
		//IL_038e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: 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_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: 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)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_049e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04af: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0503: Unknown result type (might be due to invalid IL or missing references)
		//IL_0514: Unknown result type (might be due to invalid IL or missing references)
		//IL_0534: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0550: Unknown result type (might be due to invalid IL or missing references)
		//IL_0562: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_0581: Unknown result type (might be due to invalid IL or missing references)
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
		model.AddComponent<SlayerRig>();
		CharacterModel val = model.AddComponent<CharacterModel>();
		val.baseRendererInfos = infos.ToArray();
		val.baseLightInfos = Array.Empty<LightInfo>();
		val.autoPopulateLightInfos = false;
		val.itemDisplayRuleSet = ScriptableObject.CreateInstance<ItemDisplayRuleSet>();
		if (Object.op_Implicit((Object)(object)health))
		{
			val.body = ((Component)health).GetComponent<CharacterBody>();
		}
		ChildLocator obj = model.AddComponent<ChildLocator>();
		List<NameTransformPair> list = new List<NameTransformPair>();
		(string, string)[] array = new(string, string)[19]
		{
			("Base", "G_body_root"),
			("Pelvis", "G_pelvis"),
			("Stomach", "G_stomach"),
			("Chest", "G_chest"),
			("Head", "G_Head_Attach"),
			("HandL", "G_hand_L"),
			("HandR", "G_hand_R"),
			("MuzzleHandL", "G_fist_L"),
			("MuzzleHandR", "G_fist_R"),
			("UpperArmL", "G_uparm_L"),
			("UpperArmR", "G_uparm_R"),
			("LowerArmL", "G_lowarm_L"),
			("LowerArmR", "G_lowarm_R"),
			("ThighL", "G_thigh_L"),
			("ThighR", "G_thigh_R"),
			("CalfL", "G_calf_L"),
			("CalfR", "G_calf_R"),
			("FootL", "G_foot_L"),
			("FootR", "G_foot_R")
		};
		for (int i = 0; i < array.Length; i++)
		{
			(string, string) tuple = array[i];
			string item = tuple.Item1;
			string item2 = tuple.Item2;
			Transform val2 = SlayerModel.FindBone(model, "sly_body." + item2);
			if (Object.op_Implicit((Object)(object)val2))
			{
				list.Add(new NameTransformPair
				{
					name = item,
					transform = val2
				});
			}
		}
		AccessTools.Field(typeof(ChildLocator), "transformPairs").SetValue(obj, list.ToArray());
		if (Object.op_Implicit((Object)(object)health))
		{
			Transform transform = new GameObject("AimPivot").transform;
			transform.SetParent(model.transform, false);
			transform.localPosition = Vector3.up;
			AddHitBoxGroup(model, transform, "Melee", new Vector3(0f, 0f, 1.6f), new Vector3(4f, 4f, 4.2f));
			AddHitBoxGroup(model, transform, "Long", new Vector3(0f, 0f, 2.6f), new Vector3(5f, 4.5f, 6.5f));
			AddHitBoxGroup(model, transform, "Reach", new Vector3(0f, 0f, 3.4f), new Vector3(7f, 5f, 8.5f));
			AddHitBoxGroup(model, transform, "Stomp", new Vector3(0f, -0.2f, 2.6f), new Vector3(7f, 5f, 7f));
			AddHitBoxGroup(model, transform, "Wings", new Vector3(0f, 2f, 1.5f), new Vector3(8f, 9f, 7f));
			AddHitBoxGroup(model, transform, "Dive", new Vector3(0f, -0.5f, 0f), new Vector3(DiveRadius * 2f, 6f, DiveRadius * 2f));
			AddHitBoxGroup(model, transform, "Pile", new Vector3(0f, 0f, 3.6f), new Vector3(7f, 6f, 9f));
			AddHitBoxGroup(model, transform, "Sweep", new Vector3(0f, -0.3f, 1.8f), new Vector3(6f, 3f, 6f));
			AddHitBoxGroup(model, transform, "Tall", new Vector3(0f, 7.5f, 5.5f), new Vector3(16f, 21f, 14f));
			AddHitBoxGroup(model, transform, "Huge", Vector3.zero, new Vector3(HammerRadius * 2f, 10f, HammerRadius * 2f));
			AddHitBoxGroup(model, transform, "Massive", new Vector3(0f, 0f, 4f), new Vector3(12f, 8f, 13f));
			AddHitBoxGroup(model, transform, "Blast", Vector3.zero, new Vector3(BlastRadius * 2f, 14f, BlastRadius * 2f));
			HurtBoxGroup val3 = model.AddComponent<HurtBoxGroup>();
			GameObject val4 = new GameObject("MainHurtBox");
			val4.transform.SetParent(model.transform, false);
			val4.transform.localPosition = new Vector3(0f, 0.95f, 0f);
			val4.layer = LayerIndex.entityPrecise.intVal;
			CapsuleCollider obj2 = val4.AddComponent<CapsuleCollider>();
			obj2.radius = 0.5f;
			obj2.height = 1.9f;
			HurtBox val5 = val4.AddComponent<HurtBox>();
			val5.healthComponent = health;
			val5.hurtBoxGroup = val3;
			val5.isBullseye = true;
			val5.damageModifier = (DamageModifier)0;
			val5.indexInGroup = 0;
			val3.hurtBoxes = (HurtBox[])(object)new HurtBox[1] { val5 };
			val3.mainHurtBox = val5;
			val3.bullseyeCount = 1;
		}
	}

	public static void AddHitBoxGroup(GameObject model, Transform pivot, string name, Vector3 center, Vector3 size)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//IL_0024: 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)
		GameObject val = new GameObject("HitBox" + name);
		val.transform.SetParent(pivot, false);
		val.transform.localPosition = center;
		val.transform.localScale = size;
		HitBoxGroup obj = model.AddComponent<HitBoxGroup>();
		obj.groupName = name;
		obj.hitBoxes = (HitBox[])(object)new HitBox[1] { val.AddComponent<HitBox>() };
	}

	private void BuildDisplay()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		DisplayPrefab = new GameObject("SlayerDisplay");
		DisplayPrefab.transform.SetParent(_holder, false);
		List<RendererInfo> list = new List<RendererInfo>();
		GameObject obj = SlayerModel.Build("mdlSlayer", DisplayPrefab.transform, list);
		obj.transform.localRotation = Quaternion.Euler(0f, 300f, 0f);
		obj.transform.localScale = Vector3.one * 1.0098001f;
		AddModelComponents(obj, list, null);
		obj.AddComponent<SlayerDisplayIntro>();
	}

	private void BuildMaster()
	{
		MasterPrefab = ClonePrefab(Load("RoR2/Base/Merc/MercMonsterMaster.prefab"), "SlayerMonsterMaster");
		MasterPrefab.GetComponent<CharacterMaster>().bodyPrefab = BodyPrefab;
	}

	private SkillDef NewSkill(string name, Type state, string machine, float cooldown, int stocks = 1, bool mustPress = false, Sprite icon = null, SkillDef def = null)
	{
		//IL_008c: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
		if (def == null)
		{
			def = ScriptableObject.CreateInstance<SkillDef>();
		}
		((Object)def).name = "Slayer" + name;
		def.skillName = "Slayer" + name;
		def.skillNameToken = "SLAYER_" + name.ToUpperInvariant() + "_NAME";
		def.skillDescriptionToken = "SLAYER_" + name.ToUpperInvariant() + "_DESC";
		def.icon = icon ?? SlayerModel.LoadSprite("icon_" + name.ToLowerInvariant());
		def.activationState = new SerializableEntityStateType(state);
		def.activationStateMachineName = machine;
		def.baseRechargeInterval = cooldown;
		def.baseMaxStock = stocks;
		def.rechargeStock = 1;
		def.requiredStock = 1;
		def.stockToConsume = 1;
		def.fullRestockOnAssign = false;
		def.mustKeyPress = mustPress;
		def.interruptPriority = (InterruptPriority)((machine == "Body") ? 2 : 0);
		def.cancelSprintingOnActivation = true;
		def.isCombatSkill = true;
		def.beginSkillCooldownOnSkillEnd = cooldown > 0f;
		_skills.Add(def);
		return def;
	}

	private void BindFamily(GenericSkill slot, string name, params SkillDef[] variants)
	{
		SkillFamily val = ScriptableObject.CreateInstance<SkillFamily>();
		((Object)val).name = "SlayerBody" + name + "Family";
		val.variants = variants.Select(delegate(SkillDef v)
		{
			//IL_0002: 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_0024: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Variant result = new Variant
			{
				skillDef = v
			};
			((Variant)(ref result)).viewableNode = new Node(v.skillNameToken, false, (Node)null);
			return result;
		}).ToArray();
		val.defaultVariantIndex = 0u;
		_families.Add(val);
		AccessTools.Field(typeof(GenericSkill), "_skillFamily").SetValue(slot, val);
	}

	private void BuildSkills()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Expected O, but got Unknown
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		SkillLocator component = BodyPrefab.GetComponent<SkillLocator>();
		GenericSkill[] components = BodyPrefab.GetComponents<GenericSkill>();
		foreach (GenericSkill val in components)
		{
			if ((Object)(object)val != (Object)(object)component.primary && (Object)(object)val != (Object)(object)component.secondary && (Object)(object)val != (Object)(object)component.utility && (Object)(object)val != (Object)(object)component.special)
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}
		component.passiveSkill = new PassiveSkill
		{
			enabled = true,
			skillNameToken = "SLAYER_PASSIVE_NAME",
			skillDescriptionToken = "SLAYER_PASSIVE_DESC",
			icon = SlayerModel.LoadSprite("icon_passive")
		};
		SteppedSkillDef val2 = (SteppedSkillDef)NewSkill("Gentleman", typeof(Gentleman), "Weapon", Balance.Number("primary.cooldown_seconds", 0f), 1, mustPress: false, null, (SkillDef)(object)ScriptableObject.CreateInstance<SteppedSkillDef>());
		val2.stepCount = 3;
		val2.stepGraceDuration = Balance.Number("primary.seconds_to_continue_combo", 0.4f);
		((SkillDef)val2).interruptPriority = (InterruptPriority)0;
		((SkillDef)val2).beginSkillCooldownOnSkillEnd = false;
		((SkillDef)val2).isCombatSkill = true;
		((SkillDef)val2).hideStockCount = true;
		SkillDef val3 = NewSkill("Mappa", typeof(MappaHunch), "Body", Balance.Number("secondary_options[0].cooldown_seconds", 5f), Balance.Count("secondary_options[0].charges", 2));
		SkillDef val4 = NewSkill("Dandy", typeof(DandyStep), "Body", Balance.Number("utility.cooldown_seconds", 7f), Balance.Count("utility.charges", 1), mustPress: true);
		val4.isCombatSkill = false;
		SkillDef val5 = NewSkill("Universe", typeof(BloodsuckingUniverse), "Body", Balance.Number("special.cooldown_seconds", 14f), Balance.Count("special.charges", 1), mustPress: true);
		BindFamily(component.primary, "Primary", (SkillDef)val2);
		WingsSkill = NewSkill("Wings", typeof(WingsOrDive), "Body", Balance.Number("secondary_options[1].cooldown_seconds", 5f), Balance.Count("secondary_options[1].charges", 2));
		BindFamily(component.secondary, "Secondary", val3, WingsSkill);
		BindFamily(component.utility, "Utility", val4);
		BindFamily(component.special, "Special", val5);
		PilebunkerSkill = TemporarySkill("Pilebunker", typeof(Pilebunker));
		ItsLateSkill = TemporarySkill("ItsLate", typeof(ItsLate));
		SweepSkill = TemporarySkill("Sweep", typeof(DandySweep));
		MastersHammerSkill = TemporarySkill("Hammer", typeof(MastersHammer));
		SuperSkill = TemporarySkill("Super", typeof(SuperMappaCharge));
		SkillDef val6 = TemporarySkill("AllDead", typeof(AllDeadAim), "Weapon");
		val6.interruptPriority = (InterruptPriority)2;
		SkillDef val7 = TemporarySkill("LastHorizon", typeof(LastHorizon));
		((SkillDef)val2).keywordTokens = new string[1] { "SLAYER_KEYWORD_RISC" };
		val4.keywordTokens = new string[4] { "SLAYER_KEYWORD_PILEBUNKER", "SLAYER_KEYWORD_ITSLATE", "SLAYER_KEYWORD_SWEEP", "SLAYER_KEYWORD_HAMMER" };
		val5.keywordTokens = new string[2] { "KEYWORD_STUNNING", "SLAYER_KEYWORD_UNIVERSE" };
		WingsSkill.keywordTokens = new string[1] { "KEYWORD_STUNNING" };
		val6.keywordTokens = new string[1] { "KEYWORD_STUNNING" };
		val7.keywordTokens = new string[1] { "KEYWORD_STUNNING" };
		GenericSkill val8 = BodyPrefab.AddComponent<GenericSkill>();
		val8.skillName = "SlayerSuperChoice";
		val8.loadoutTitleToken = "SLAYER_LOADOUT_SUPER";
		BindFamily(val8, "Super", SuperPick(SuperSkill, Balance.Number("super_options[0].cooldown_seconds", 20f), Balance.Count("super_options[0].charges", 1)), SuperPick(val6, Balance.Number("super_options[1].cooldown_seconds", 15f), Balance.Count("super_options[1].charges", 1)), SuperPick(val7, Balance.Number("super_options[2].cooldown_seconds", 20f), Balance.Count("super_options[2].charges", 1)));
	}

	private SkillDef SuperPick(SkillDef offered, float cooldown, int charges)
	{
		SkillDef val = NewSkill(offered.skillName.Substring("Slayer".Length) + "Pick", ((SerializableEntityStateType)(ref offered.activationState)).stateType, offered.activationStateMachineName, cooldown, charges, mustPress: false, offered.icon);
		val.skillNameToken = offered.skillNameToken;
		val.skillDescriptionToken = offered.skillDescriptionToken;
		val.keywordTokens = offered.keywordTokens;
		val.fullRestockOnAssign = true;
		val.beginSkillCooldownOnSkillEnd = false;
		offered.requiredStock = 1;
		offered.baseMaxStock = charges;
		offered.baseRechargeInterval = cooldown;
		offered.rechargeStock = 1;
		offered.hideCooldown = false;
		offered.hideStockCount = charges <= 1;
		SuperOffers[val] = offered;
		return val;
	}

	public static SkillDef SuperOffer(SkillDef pick)
	{
		if (!SuperOffers.TryGetValue(pick, out var value))
		{
			return SuperSkill;
		}
		return value;
	}

	private SkillDef TemporarySkill(string name, Type state, string machine = "Body")
	{
		SkillDef obj = NewSkill(name, state, machine, 0f, 1, mustPress: true);
		obj.requiredStock = 0;
		obj.stockToConsume = 0;
		obj.rechargeStock = 0;
		obj.beginSkillCooldownOnSkillEnd = false;
		obj.hideCooldown = true;
		obj.hideStockCount = true;
		return obj;
	}

	private void BuildSkins()
	{
		AddSkins(((Component)BodyPrefab.GetComponent<ModelLocator>().modelTransform).gameObject);
		AddSkins(((Component)DisplayPrefab.GetComponentInChildren<CharacterModel>(true)).gameObject);
	}

	private static void AddSkins(GameObject model)
	{
		CharacterModel characterModel = model.GetComponent<CharacterModel>();
		model.AddComponent<ModelSkinController>().skins = SlayerModel.Palettes.Select(delegate((string texture, string token) palette)
		{
			Material material = SlayerModel.Skin(palette.texture);
			SkinDefParams val = ScriptableObject.CreateInstance<SkinDefParams>();
			((Object)val).name = "params" + palette.texture;
			val.rendererInfos = characterModel.baseRendererInfos.Select(delegate(RendererInfo info)
			{
				//IL_0000: 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)
				if (((Object)info.defaultMaterial).name.StartsWith("matSlayer_"))
				{
					info.defaultMaterial = material;
				}
				return info;
			}).ToArray();
			SkinDef obj = ScriptableObject.CreateInstance<SkinDef>();
			((Object)obj).name = "skinSlayer_" + palette.texture;
			obj.nameToken = palette.token;
			obj.icon = SlayerModel.LoadSprite("icon_skin_" + palette.texture.Replace("albedo_", ""));
			obj.rootObject = model;
			obj.skinDefParams = val;
			return obj;
		}).ToArray();
	}

	private void BuildSurvivor()
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		SurvivorDef val = ScriptableObject.CreateInstance<SurvivorDef>();
		val.cachedName = "Slayer";
		val.bodyPrefab = BodyPrefab;
		val.displayPrefab = DisplayPrefab;
		val.displayNameToken = "SLAYER_BODY_NAME";
		val.descriptionToken = "SLAYER_DESCRIPTION";
		val.outroFlavorToken = "SLAYER_OUTRO_FLAVOR";
		val.mainEndingEscapeFailureFlavorToken = "SLAYER_OUTRO_FAILURE";
		val.primaryColor = BodyPrefab.GetComponent<CharacterBody>().bodyColor;
		val.desiredSortPosition = 100f;
		_pack.survivorDefs.Add((SurvivorDef[])(object)new SurvivorDef[1] { val });
	}
}
public class SlayerDisplayIntro : MonoBehaviour
{
	private void Start()
	{
		((Component)this).GetComponent<SlayerRig>().PlayAction("entry");
	}
}
public class PartData
{
	public string Name;

	public string[] BoneNames;

	public Vector3[] BindT;

	public Quaternion[] BindR;

	public Matrix4x4[] BindPoses;

	public Vector3[] Positions;

	public Vector3[] Normals;

	public Vector4[] Tangents;

	public Vector2[] Uv0;

	public Vector2[] Uv1;

	public Color32[] Colors;

	public BoneWeight[] Weights;

	public List<(string material, int[] indices)> Sections = new List<(string, int[])>();
}
public class ClipData
{
	public string Name;

	public Dictionary<string, float[]> PartPoses = new Dictionary<string, float[]>();

	public int[] TimelinePose;

	public int[] TimelineEnd;

	public int TotalFrames => TimelineEnd[TimelineEnd.Length - 1];

	public float BaseDuration => (float)TotalFrames / 60f;

	public int PoseAtFrame(float frame)
	{
		for (int i = 0; i < TimelineEnd.Length; i++)
		{
			if (frame < (float)TimelineEnd[i])
			{
				return TimelinePose[i];
			}
		}
		return TimelinePose[TimelinePose.Length - 1];
	}

	public int FrameOfPose(int pose)
	{
		int result = 0;
		for (int i = 0; i < TimelinePose.Length; i++)
		{
			if (TimelinePose[i] >= pose)
			{
				return result;
			}
			result = TimelineEnd[i];
		}
		return result;
	}
}
public static class SlayerData
{
	public static CharacterData Slayer { get; private set; }

	public static Dictionary<string, PartData> Parts => Slayer.Parts;

	public static Dictionary<string, ClipData> Clips => Slayer.Clips;

	public static void Load(string dataDir)
	{
		Slayer = CharacterData.Load(dataDir);
	}
}
public class CharacterData
{
	public readonly Dictionary<string, PartData> Parts = new Dictionary<string, PartData>();

	public readonly Dictionary<string, ClipData> Clips = new Dictionary<string, ClipData>();

	private static readonly Dictionary<string, CharacterData> ByPart = new Dictionary<string, CharacterData>();

	public static CharacterData OfPart(string part)
	{
		return ByPart[part];
	}

	public static CharacterData Load(string dataDir)
	{
		CharacterData characterData = new CharacterData();
		characterData.Read(dataDir);
		foreach (string key in characterData.Parts.Keys)
		{
			ByPart[key] = characterData;
		}
		return characterData;
	}

	private void Read(string dataDir)
	{
		string[] files = Directory.GetFiles(Path.Combine(dataDir, "parts"), "*.bin");
		for (int i = 0; i < files.Length; i++)
		{
			PartData partData = ReadPart(files[i]);
			Parts[partData.Name] = partData;
		}
		Dictionary<string, Dictionary<string, (int, float[])>> dictionary = new Dictionary<string, Dictionary<string, (int, float[])>>();
		files = File.ReadAllLines(Path.Combine(dataDir, "clips.txt"));
		for (int i = 0; i < files.Length; i++)
		{
			string[] array = files[i].Split(' ');
			if (array.Length < 3)
			{
				continue;
			}
			if (!dictionary.TryGetValue(array[1], out var value))
			{
				value = (dictionary[array[1]] = ReadAnim(Path.Combine(dataDir, "anims", array[1] + ".bin")));
			}
			ClipData clipData = new ClipData
			{
				Name = array[0],
				TimelinePose = new int[array.Length - 2],
				TimelineEnd = new int[array.Length - 2]
			};
			int num = 0;
			for (int j = 2; j < array.Length; j++)
			{
				string[] array2 = array[j].Split(':');
				clipData.TimelinePose[j - 2] = int.Parse(array2[0]);
				num += int.Parse(array2[1]);
				clipData.TimelineEnd[j - 2] = num;
			}
			foreach (KeyValuePair<string, (int, float[])> item in value)
			{
				clipData.PartPoses[item.Key] = item.Value.Item2;
			}
			Clips[clipData.Name] = clipData;
		}
	}

	private static float[] ReadFloats(BinaryReader r, int count)
	{
		byte[] array = r.ReadBytes(count * 4);
		float[] array2 = new float[count];
		Buffer.BlockCopy(array, 0, array2, 0, array.Length);
		return array2;
	}

	private static PartData ReadPart(string path)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: 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)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0340: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
		PartData partData = new PartData
		{
			Name = binaryReader.ReadString()
		};
		int num = binaryReader.ReadInt32();
		partData.BoneNames = new string[num];
		partData.BindT = (Vector3[])(object)new Vector3[num];
		partData.BindR = (Quaternion[])(object)new Quaternion[num];
		partData.BindPoses = (Matrix4x4[])(object)new Matrix4x4[num];
		for (int i = 0; i < num; i++)
		{
			partData.BoneNames[i] = binaryReader.ReadString();
			float[] array = ReadFloats(binaryReader, 10);
			partData.BindT[i] = new Vector3(array[0], array[1], array[2]);
			partData.BindR[i] = new Quaternion(array[3], array[4], array[5], array[6]);
			Matrix4x4[] bindPoses = partData.BindPoses;
			int num2 = i;
			Matrix4x4 val = Matrix4x4.TRS(partData.BindT[i], partData.BindR[i], new Vector3(array[7], array[8], array[9]));
			bindPoses[num2] = ((Matrix4x4)(ref val)).inverse;
		}
		int num3 = binaryReader.ReadInt32();
		float[] array2 = ReadFloats(binaryReader, num3 * 3);
		float[] array3 = ReadFloats(binaryReader, num3 * 3);
		float[] array4 = ReadFloats(binaryReader, num3 * 4);
		float[] array5 = ReadFloats(binaryReader, num3 * 2);
		float[] array6 = ReadFloats(binaryReader, num3 * 2);
		byte[] array7 = binaryReader.ReadBytes(num3 * 4);
		partData.Positions = (Vector3[])(object)new Vector3[num3];
		partData.Normals = (Vector3[])(object)new Vector3[num3];
		partData.Tangents = (Vector4[])(object)new Vector4[num3];
		partData.Uv0 = (Vector2[])(object)new Vector2[num3];
		partData.Uv1 = (Vector2[])(object)new Vector2[num3];
		partData.Colors = (Color32[])(object)new Color32[num3];
		for (int j = 0; j < num3; j++)
		{
			partData.Positions[j] = new Vector3(array2[j * 3], array2[j * 3 + 1], array2[j * 3 + 2]);
			partData.Normals[j] = new Vector3(array3[j * 3], array3[j * 3 + 1], array3[j * 3 + 2]);
			partData.Tangents[j] = new Vector4(array4[j * 4], array4[j * 4 + 1], array4[j * 4 + 2], array4[j * 4 + 3]);
			partData.Uv0[j] = new Vector2(array5[j * 2], array5[j * 2 + 1]);
			partData.Uv1[j] = new Vector2(array6[j * 2], array6[j * 2 + 1]);
			partData.Colors[j] = new Color32(array7[j * 4], array7[j * 4 + 1], array7[j * 4 + 2], array7[j * 4 + 3]);
		}
		partData.Weights = (BoneWeight[])(object)new BoneWeight[num3];
		for (int k = 0; k < num3; k++)
		{
			BoneWeight val2 = default(BoneWeight);
			((BoneWeight)(ref val2)).boneIndex0 = binaryReader.ReadUInt16();
			((BoneWeight)(ref val2)).weight0 = binaryReader.ReadSingle();
			((BoneWeight)(ref val2)).boneIndex1 = binaryReader.ReadUInt16();
			((BoneWeight)(ref val2)).weight1 = binaryReader.ReadSingle();
			((BoneWeight)(ref val2)).boneIndex2 = binaryReader.ReadUInt16();
			((BoneWeight)(ref val2)).weight2 = binaryReader.ReadSingle();
			((BoneWeight)(ref val2)).boneIndex3 = binaryReader.ReadUInt16();
			((BoneWeight)(ref val2)).weight3 = binaryReader.ReadSingle();
			partData.Weights[k] = val2;
		}
		int num4 = binaryReader.ReadInt32();
		for (int l = 0; l < num4; l++)
		{
			string item = binaryReader.ReadString();
			int num5 = binaryReader.ReadInt32();
			byte[] array8 = binaryReader.ReadBytes(num5 * 4);
			int[] array9 = new int[num5];
			Buffer.BlockCopy(array8, 0, array9, 0, array8.Length);
			partData.Sections.Add((item, array9));
		}
		return partData;
	}

	private Dictionary<string, (int poses, float[] data)> ReadAnim(string path)
	{
		using BinaryReader binaryReader = new BinaryReader(File.OpenRead(path));
		binaryReader.ReadString();
		Dictionary<string, (int, float[])> dictionary = new Dictionary<string, (int, float[])>();
		int num = binaryReader.ReadInt32();
		for (int i = 0; i < num; i++)
		{
			string key = binaryReader.ReadString();
			int num2 = binaryReader.ReadInt32();
			int num3 = Parts[key].BoneNames.Length;
			dictionary[key] = (num2, ReadFloats(binaryReader, num2 * num3 * 10));
		}
		return dictionary;
	}
}
public class SlayerHaiku : MonoBehaviour
{
	private struct Glyph
	{
		public Rect Uv;

		public float Width;

		public float Height;
	}

	private const int Lines = 3;

	private const float LineGap = 0.25f;

	private const float FadeIn = 0.25f;

	private const float Hold = 1.5f;

	private const float FadeOut = 0.7f;

	private const float VoiceVolume = 0.9f;

	private const string SignOff = "xvsly041";

	private const float SignOffLength = 2.5f;

	private const float FirstColumn = 0.77f;

	private const float ColumnGap = 0.115f;

	private const float Top = 0.06f;

	private const float GlyphHeight = 0.105f;

	private const float GlyphSpacing = 0.93f;

	private const float Outline = 0.0035f;

	private const float SubtitleY = 0.89f;

	private const float SubtitleHeight = 0.05f;

	private const float SubtitleSize = 0.03f;

	private static readonly Color Ink = new Color(1f, 0.27f, 0.05f);

	private static readonly Color Edge = new Color(0.12f, 0.01f, 0f);

	private static readonly Dictionary<char, Glyph> Glyphs = new Dictionary<char, Glyph>();

	private static readonly List<string[]> Haikus = new List<string[]>();

	private static Texture2D _page;

	private static float _tallest = 1f;

	private static SlayerHaiku _instance;

	private readonly float[] _lineAt = new float[4];

	private readonly string[][] _from = new string[3][];

	private bool _showing;

	private bool _warm;

	private float _shownAt;

	private float _endsAt;

	private int _spoken;

	private GUIStyle _style;

	public static bool Showing
	{
		get
		{
			if (Object.op_Implicit((Object)(object)_instance))
			{
				return _instance._showing;
			}
			return false;
		}
	}

	public static void Load(string dataDir)
	{
		//IL_007b: 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_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		string path = Path.Combine(dataDir, "haiku.txt");
		string path2 = Path.Combine(dataDir, "haiku_font.txt");
		string path3 = Path.Combine(dataDir, "haiku_font.png");
		if (!File.Exists(path) || !File.Exists(path2) || !File.Exists(path3))
		{
			return;
		}
		string[] array = File.ReadAllLines(path);
		for (int i = 0; i < array.Length; i++)
		{
			string[] array2 = array[i].Split('\t');
			if (array2.Length == 7)
			{
				Haikus.Add(array2);
			}
		}
		_page = new Texture2D(2, 2, (TextureFormat)4, false)
		{
			name = "texSlayerHaikuFont",
			wrapMode = (TextureWrapMode)1
		};
		ImageConversion.LoadImage(_page, File.ReadAllBytes(path3));
		array = File.ReadAllLines(path2);
		foreach (string text in array)
		{
			string[] f = text.Split(' ');
			float num = At(1);
			float num2 = At(2);
			float num3 = At(3);
			float num4 = At(4);
			Glyphs[(char)int.Parse(f[0], CultureInfo.InvariantCulture)] = new Glyph
			{
				Uv = new Rect(num / (float)((Texture)_page).width, 1f - (num2 + num4) / (float)((Texture)_page).height, num3 / (float)((Texture)_page).width, num4 / (float)((Texture)_page).height),
				Width = num3,
				Height = num4
			};
			_tallest = Mathf.Max(_tallest, num4);
			float At(int num5)
			{
				return float.Parse(f[num5], CultureInfo.InvariantCulture);
			}
		}
		Instance();
	}

	private static SlayerHaiku Instance()
	{
		//IL_0017: 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_0022: Expected O, but got Unknown
		if (Object.op_Implicit((Object)(object)_instance))
		{
			return _instance;
		}
		GameObject val = new GameObject("SlayerHaiku");
		Object.DontDestroyOnLoad((Object)val);
		return _instance = val.AddComponent<SlayerHaiku>();
	}

	public static void Show(float delay = 0.3f)
	{
		if (Haikus.Count != 0)
		{
			Instance().Begin(delay);
		}
	}

	private void Begin(float delay)
	{
		for (int i = 0; i < 3; i++)
		{
			_from[i] = Haikus[Random.Range(0, Haikus.Count)];
		}
		_showing = true;
		((Behaviour)this).enabled = true;
		_shownAt = Time.unscaledTime;
		_spoken = 0;
		float num = delay;
		for (int j = 0; j < 3; j++)
		{
			_lineAt[j] = num;
			num += SlayerAudio.Length(LineClip(j)) + 0.25f;
		}
		_lineAt[3] = num;
		_endsAt = num + 2.5f + 1.5f + 0.7f;
	}

	private string LineClip(int line)
	{
		return "xh" + ((line + 1) * 100 + int.Parse(_from[line][0], CultureInfo.InvariantCulture));
	}

	private void Update()
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		if (_showing && _spoken <= 3 && !(Time.unscaledTime - _shownAt < _lineAt[_spoken]))
		{
			Camera main = Camera.main;
			Vector3 position = (Object.op_Implicit((Object)(object)main) ? ((Component)main).transform.position : ((Component)this).transform.position);
			SlayerAudio.Play((_spoken < 3) ? LineClip(_spoken) : "xvsly041", position, 0.9f * SlayerPassive.Loudness);
			_spoken++;
		}
	}

	private void OnGUI()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Invalid comparison between Unknown and I4
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		if (!_warm)
		{
			if ((int)Event.current.type == 7)
			{
				Warm();
			}
		}
		else
		{
			if (!_showing)
			{
				return;
			}
			float num = Time.unscaledTime - _shownAt;
			if (num > _endsAt)
			{
				_showing = false;
				((Behaviour)this).enabled = false;
				return;
			}
			float num2 = Mathf.Clamp01((_endsAt - num) / 0.7f);
			int num3 = -1;
			for (int i = 0; i < 3; i++)
			{
				float num4 = Mathf.Clamp01((num - _lineAt[i]) / 0.25f) * num2;
				if (!(num4 <= 0f))
				{
					num3 = i;
					DrawColumn(_from[i][1 + i], (float)Screen.width * 0.77f - (float)Screen.height * 0.115f * (float)i, num4);
				}
			}
			if (num3 >= 0)
			{
				DrawSubtitle(_from[num3][4 + num3], num2);
			}
			GUI.color = Color.white;
		}
	}

	private void Warm()
	{
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		_warm = true;
		((Behaviour)this).enabled = _showing;
		if (Haikus.Count == 0)
		{
			return;
		}
		HashSet<char> hashSet = new HashSet<char>();
		foreach (string[] haiku in Haikus)
		{
			for (int i = 4; i < haiku.Length; i++)
			{
				hashSet.UnionWith(haiku[i]);
			}
		}
		DrawSubtitle(new string(new List<char>(hashSet).ToArray()), 0f);
		DrawColumn(Haikus[0][1], (float)Screen.width * 0.77f, 0f);
		GUI.color = Color.white;
	}

	private static void DrawColumn(string line, float x, float alpha)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might