plugins/Sven.dll

Decompiled an hour 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;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using DotaItemDisplays;
using EntityStates;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using SvenMod.Modules;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Sven")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyInformationalVersion("0.3.0+10c4231efb8e86318977ec4205abbfdd64741fe1")]
[assembly: AssemblyProduct("Sven")]
[assembly: AssemblyTitle("Sven")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.3.0.0")]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DotaItemDisplays
{
	public sealed class ItemDisplayRig : MonoBehaviour
	{
		[Serializable]
		public struct Pose
		{
			public Transform bone;

			public Vector3 position;

			public Vector3 scale;

			public Quaternion rotation;
		}

		[Serializable]
		public sealed class Binding
		{
			public string alias;

			public Transform anchor;

			public Pose[] skins;
		}

		private sealed class BindSkeleton
		{
			private readonly Transform root;

			private readonly Dictionary<Transform, Matrix4x4> matrices = new Dictionary<Transform, Matrix4x4>();

			private readonly Dictionary<string, Transform> bones = new Dictionary<string, Transform>(StringComparer.Ordinal);

			public BindSkeleton(Transform model, Dictionary<SkinnedMeshRenderer, Mesh> overrides = null)
			{
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				root = model;
				Transform[] componentsInChildren = ((Component)model).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (!bones.ContainsKey(((Object)val).name))
					{
						bones.Add(((Object)val).name, val);
					}
				}
				SkinnedMeshRenderer[] componentsInChildren2 = ((Component)model).GetComponentsInChildren<SkinnedMeshRenderer>(true);
				foreach (SkinnedMeshRenderer val2 in componentsInChildren2)
				{
					Mesh value;
					Mesh val3 = ((overrides != null && overrides.TryGetValue(val2, out value)) ? value : val2.sharedMesh);
					if (!Object.op_Implicit((Object)(object)val3))
					{
						continue;
					}
					Matrix4x4[] bindposes = val3.bindposes;
					Matrix4x4 val4 = model.worldToLocalMatrix * ((Component)val2).transform.localToWorldMatrix;
					for (int j = 0; j < val2.bones.Length && j < bindposes.Length; j++)
					{
						if (Object.op_Implicit((Object)(object)val2.bones[j]) && !matrices.ContainsKey(val2.bones[j]))
						{
							matrices.Add(val2.bones[j], val4 * ((Matrix4x4)(ref bindposes[j])).inverse);
						}
					}
				}
			}

			public Transform Find(string name)
			{
				if (!bones.TryGetValue(name, out var value))
				{
					throw new InvalidOperationException("Missing item attachment bone: " + ((Object)root).name + "/" + name);
				}
				return value;
			}

			public Matrix4x4 Get(Transform bone)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				if (matrices.TryGetValue(bone, out var value))
				{
					return value;
				}
				if ((Object)(object)bone == (Object)(object)root)
				{
					return Matrix4x4.identity;
				}
				if (!Object.op_Implicit((Object)(object)bone) || !bone.IsChildOf(root))
				{
					throw new InvalidOperationException("Item attachment is outside model");
				}
				return Get(bone.parent) * Matrix4x4.TRS(bone.localPosition, bone.localRotation, bone.localScale);
			}
		}

		public Binding[] bindings = Array.Empty<Binding>();

		public int currentSkin;

		public void Apply(int skin)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			currentSkin = ((skin == 1) ? 1 : 0);
			Binding[] array = bindings;
			foreach (Binding obj in array)
			{
				Pose pose = obj.skins[currentSkin];
				obj.anchor.SetParent(pose.bone, false);
				obj.anchor.localPosition = pose.position;
				obj.anchor.localRotation = pose.rotation;
				obj.anchor.localScale = pose.scale;
			}
		}

		public static ItemDisplayRig Build(Transform root, Transform[] skins, Transform donorRoot, Dictionary<string, Transform> sourceAnchors, IEnumerable<string> aliases, bool sven, Dictionary<SkinnedMeshRenderer, Mesh> donorMeshes)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: 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)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRig itemDisplayRig = ((Component)root).gameObject.AddComponent<ItemDisplayRig>();
			BindSkeleton bindSkeleton = new BindSkeleton(donorRoot, donorMeshes);
			BindSkeleton[] array = new BindSkeleton[2]
			{
				new BindSkeleton(skins[0]),
				new BindSkeleton(skins[1])
			};
			List<Binding> list = new List<Binding>();
			float num = Height(bindSkeleton, sourceAnchors["Head"], sourceAnchors["FootL"], sourceAnchors["FootR"]);
			foreach (string alias in aliases)
			{
				if (!sourceAnchors.TryGetValue(alias, out var value) || !Object.op_Implicit((Object)(object)value))
				{
					throw new InvalidOperationException("Missing native item anchor: " + alias);
				}
				Transform transform = new GameObject("ItemDisplay_" + alias).transform;
				transform.SetParent(root, false);
				Binding binding = new Binding
				{
					alias = alias,
					anchor = transform,
					skins = new Pose[2]
				};
				for (int i = 0; i < 2; i++)
				{
					BindSkeleton bindSkeleton2 = array[i];
					string sourceOrigin;
					Transform bone = Map(bindSkeleton2, alias, sven, i == 1, out sourceOrigin);
					Transform bone2 = (sourceAnchors.ContainsKey(sourceOrigin) ? sourceAnchors[sourceOrigin] : value);
					Matrix4x4 val = bindSkeleton.Get(value);
					Vector4 column = ((Matrix4x4)(ref val)).GetColumn(3);
					Matrix4x4 val2 = bindSkeleton.Get(bone2);
					Vector4 val3 = column - ((Matrix4x4)(ref val2)).GetColumn(3);
					float num2 = Height(bindSkeleton2, bindSkeleton2.Find("head"), bindSkeleton2.Find("ankle_L"), bindSkeleton2.Find("ankle_R")) / num;
					float num3 = ((!alias.StartsWith("Head", StringComparison.Ordinal)) ? ((alias == "Chest") ? 1.1f : 1f) : ((!sven) ? 0.8f : ((i == 1) ? 1.15f : 1f)));
					float num4 = num2 * num3;
					Matrix4x4 val4 = bindSkeleton2.Get(bone);
					Quaternion val5 = AnatomicalAlignment(alias, bindSkeleton, sourceAnchors, bindSkeleton2);
					Vector3 val6 = Vector4.op_Implicit(((Matrix4x4)(ref val4)).GetColumn(3)) + val5 * Vector4.op_Implicit(val3) * num2;
					if (alias.StartsWith("Head", StringComparison.Ordinal))
					{
						val6 += new Vector3(0f, (!sven) ? (-0.1f) : ((i == 1) ? 0.01f : (-0.05f)), (sven && i == 1) ? 0.04f : 0f);
					}
					if (alias == "Chest" || alias == "LeftJet")
					{
						val6 += new Vector3(0f, sven ? (-0.06f) : (-0.2f), -0.1f);
					}
					if (sven && i == 1 && alias.StartsWith("UpperArm", StringComparison.Ordinal))
					{
						val6 += new Vector3(Mathf.Sign(val4.m03) * 0.15f, 0.05f, 0f);
					}
					Matrix4x4 val7 = Matrix4x4.TRS(val6, val5 * ((Matrix4x4)(ref val)).rotation, ((Matrix4x4)(ref val)).lossyScale * num4);
					Matrix4x4 val8 = ((Matrix4x4)(ref val4)).inverse * val7;
					binding.skins[i] = new Pose
					{
						bone = bone,
						position = Vector4.op_Implicit(((Matrix4x4)(ref val8)).GetColumn(3)),
						rotation = ((Matrix4x4)(ref val8)).rotation,
						scale = ((Matrix4x4)(ref val8)).lossyScale
					};
				}
				list.Add(binding);
			}
			itemDisplayRig.bindings = list.ToArray();
			itemDisplayRig.Apply(0);
			return itemDisplayRig;
		}

		private static float Height(BindSkeleton skeleton, Transform head, Transform left, Transform right)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			float num = skeleton.Get(head).m13 - (skeleton.Get(left).m13 + skeleton.Get(right).m13) * 0.5f;
			if (float.IsNaN(num) || float.IsInfinity(num) || num < 0.1f)
			{
				throw new InvalidOperationException("Invalid item display bind-pose height: " + num);
			}
			return num;
		}

		private static Quaternion AnatomicalAlignment(string alias, BindSkeleton donor, Dictionary<string, Transform> anchors, BindSkeleton target)
		{
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: 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_02aa: 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_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			string key;
			string key2;
			string name;
			string name2;
			switch (alias)
			{
			case "UpperArmL":
				key = "UpperArmL";
				key2 = "LowerArmL";
				name = "bicep_L";
				name2 = "elbow_L";
				break;
			case "UpperArmR":
				key = "UpperArmR";
				key2 = "LowerArmR";
				name = "bicep_R";
				name2 = "elbow_R";
				break;
			case "LowerArmL":
			case "HandL":
				key = "LowerArmL";
				key2 = "HandL";
				name = "elbow_L";
				name2 = "wrist_L";
				break;
			case "Finger22R":
			case "Finger42R":
			case "LowerArmR":
			case "HandR":
				key = "LowerArmR";
				key2 = "HandR";
				name = "elbow_R";
				name2 = "wrist_R";
				break;
			case "ThighL":
				key = "ThighL";
				key2 = "CalfL";
				name = "thigh_L";
				name2 = "knee_L";
				break;
			case "ThighR":
				key = "ThighR";
				key2 = "CalfR";
				name = "thigh_R";
				name2 = "knee_R";
				break;
			case "CalfL":
			case "FootL":
				key = "CalfL";
				key2 = "FootL";
				name = "knee_L";
				name2 = "ankle_L";
				break;
			case "CalfR":
			case "FootR":
				key = "CalfR";
				key2 = "FootR";
				name = "knee_R";
				name2 = "ankle_R";
				break;
			default:
				return Quaternion.identity;
			}
			Matrix4x4 val = donor.Get(anchors[key2]);
			Vector4 column = ((Matrix4x4)(ref val)).GetColumn(3);
			val = donor.Get(anchors[key]);
			Vector3 along = Vector4.op_Implicit(column - ((Matrix4x4)(ref val)).GetColumn(3));
			val = target.Get(target.Find(name2));
			Vector4 column2 = ((Matrix4x4)(ref val)).GetColumn(3);
			val = target.Get(target.Find(name));
			return LimbFrame(Vector4.op_Implicit(column2 - ((Matrix4x4)(ref val)).GetColumn(3))) * Quaternion.Inverse(LimbFrame(along));
		}

		private static Quaternion LimbFrame(Vector3 along)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref along)).Normalize();
			Vector3 val = Vector3.ProjectOnPlane(Vector3.forward, along);
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = Vector3.ProjectOnPlane(Vector3.up, along);
			}
			return Quaternion.LookRotation(((Vector3)(ref val)).normalized, along);
		}

		private static Transform Map(BindSkeleton target, string alias, bool sven, bool alternate, out string sourceOrigin)
		{
			sourceOrigin = alias;
			switch (alias)
			{
			case "Head":
				return target.Find("head");
			case "HeadCenter":
				sourceOrigin = "Head";
				return target.Find("head");
			case "Chest":
				return target.Find("spine2");
			case "Stomach":
				return target.Find("spine1");
			case "Pelvis":
				return target.Find("root");
			case "Base":
				sourceOrigin = "Pelvis";
				return target.Find("root");
			case "ThighL":
				return target.Find("thigh_L");
			case "ThighR":
				return target.Find("thigh_R");
			case "CalfL":
				return target.Find("knee_L");
			case "CalfR":
				return target.Find("knee_R");
			case "FootL":
				return target.Find("ankle_L");
			case "FootR":
				return target.Find("ankle_R");
			case "UpperArmL":
				return target.Find("bicep_L");
			case "UpperArmR":
				return target.Find("bicep_R");
			case "LowerArmL":
				return target.Find("elbow_L");
			case "LowerArmR":
				return target.Find("elbow_R");
			case "HandL":
				return target.Find("wrist_L");
			case "HandR":
				return target.Find("wrist_R");
			case "Finger22R":
			case "Finger42R":
				sourceOrigin = "HandR";
				return target.Find("wrist_R");
			case "GunL":
			case "GunR":
				sourceOrigin = ((alias == "GunL") ? "HandL" : "HandR");
				return target.Find(sven ? "sword_1" : (alternate ? "drow_arcana_weapon_0" : "Bow1_0"));
			case "LeftJet":
				sourceOrigin = "Chest";
				return target.Find("spine2");
			case "BowHinge1L":
			case "BowHinge1R":
			case "BowHinge2L":
			case "BowHinge2R":
			case "BowBase":
			case "Muzzle":
				sourceOrigin = "BowBase";
				return target.Find(alternate ? "drow_arcana_weapon_0" : "Bow1_0");
			default:
				throw new InvalidOperationException("Unmapped native item attachment: " + alias);
			}
		}
	}
	internal static class ItemDisplaySetup
	{
		internal static void Install(CharacterModel model, GameObject normal, GameObject alternate, CharacterModel donor, bool sven, Dictionary<SkinnedMeshRenderer, Mesh> meshes)
		{
			//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_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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)donor) || !Object.op_Implicit((Object)(object)donor.itemDisplayRuleSet))
			{
				throw new InvalidOperationException("Native survivor item display rules missing");
			}
			ChildLocator component = ((Component)donor).GetComponent<ChildLocator>();
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(StringComparer.Ordinal);
			NameTransformPair[] transformPairs = component.transformPairs;
			foreach (NameTransformPair val in transformPairs)
			{
				dictionary[val.name] = val.transform;
			}
			ItemDisplayRuleSet val2 = Object.Instantiate<ItemDisplayRuleSet>(donor.itemDisplayRuleSet);
			((Object)val2).name = ((Object)model).name + "ItemDisplayRules";
			HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
			KeyAssetRuleGroup[] array = (KeyAssetRuleGroup[])val2.keyAssetRuleGroups.Clone();
			for (int j = 0; j < array.Length; j++)
			{
				KeyAssetRuleGroup val3 = array[j];
				ItemDisplayRule[] rules = val3.displayRuleGroup.rules;
				if (rules == null)
				{
					continue;
				}
				rules = (ItemDisplayRule[])rules.Clone();
				for (int k = 0; k < rules.Length; k++)
				{
					if (!string.IsNullOrEmpty(rules[k].childName))
					{
						hashSet.Add(rules[k].childName);
						rules[k].childName = "ItemDisplay_" + rules[k].childName;
					}
				}
				val3.displayRuleGroup.rules = rules;
				array[j] = val3;
			}
			val2.keyAssetRuleGroups = array;
			if (meshes == null || meshes.Count == 0)
			{
				throw new InvalidOperationException("Native item display calibration meshes missing");
			}
			ItemDisplayRig itemDisplayRig = ItemDisplayRig.Build(((Component)model).transform, (Transform[])(object)new Transform[2] { normal.transform, alternate.transform }, ((Component)donor).transform, dictionary, hashSet, sven, meshes);
			ChildLocator component2 = ((Component)model).GetComponent<ChildLocator>();
			List<NameTransformPair> list = new List<NameTransformPair>(component2.transformPairs);
			ItemDisplayRig.Binding[] bindings = itemDisplayRig.bindings;
			foreach (ItemDisplayRig.Binding binding in bindings)
			{
				list.Add(new NameTransformPair
				{
					name = "ItemDisplay_" + binding.alias,
					transform = binding.anchor
				});
				if (!(binding.alias == "Muzzle"))
				{
					int num = list.FindIndex((NameTransformPair p) => p.name == binding.alias);
					NameTransformPair val4 = new NameTransformPair
					{
						name = binding.alias,
						transform = binding.anchor
					};
					if (num >= 0)
					{
						list[num] = val4;
					}
					else
					{
						list.Add(val4);
					}
				}
			}
			component2.transformPairs = list.ToArray();
			model.itemDisplayRuleSet = val2;
			Debug.Log((object)("[" + ((Object)model).name + "] item displays: " + array.Length + " native groups, " + itemDisplayRig.bindings.Length + " animated anchors, two skins"));
		}
	}
	internal static class ItemDisplayAssets
	{
		internal static IEnumerator Load(SkinDefParams skin, Dictionary<SkinnedMeshRenderer, Mesh> meshes)
		{
			if (!Object.op_Implicit((Object)(object)skin))
			{
				throw new InvalidOperationException("Native item display calibration skin missing");
			}
			MeshReplacement[] meshReplacements = skin.meshReplacements;
			foreach (MeshReplacement val in meshReplacements)
			{
				Renderer renderer = val.renderer;
				SkinnedMeshRenderer renderer2 = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null);
				if (renderer2 != null)
				{
					Mesh val2 = val.mesh;
					if (!Object.op_Implicit((Object)(object)val2))
					{
						AsyncOperationHandle<Mesh> handle = Addressables.LoadAssetAsync<Mesh>((object)val.meshAddress);
						yield return handle;
						val2 = handle.Result;
					}
					if (!Object.op_Implicit((Object)(object)val2))
					{
						throw new InvalidOperationException("Native item display bind mesh missing: " + ((Object)renderer2).name);
					}
					meshes[renderer2] = val2;
				}
			}
		}
	}
}
namespace SvenMod
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void ErrorAssetBundle(string assetName, string bundleName)
		{
			Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("DDL.Sven", "Sven", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public sealed class SvenPlugin : BaseUnityPlugin
	{
		public const string MODUID = "DDL.Sven";

		public const string MODVERSION = "0.3.0";

		public static AssetBundle bundle;

		public static SvenPlugin instance;

		public static ConfigEntry<float> SoundVolume;

		private void Awake()
		{
			//IL_002c: 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_0063: Expected O, but got Unknown
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			SoundVolume = new ConfigFile(Path.Combine(Paths.ConfigPath, "Sven.cfg"), true, ((BaseUnityPlugin)this).Info.Metadata).Bind<float>("Audio", "Volume", 0.75f, new ConfigDescription("Sven weapon and skill sound volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "AssetBundles", "sven"));
			if (!Object.op_Implicit((Object)(object)bundle))
			{
				Log.Error("Sven asset bundle missing. Reinstall the complete package.");
				return;
			}
			SvenTokens.Init();
			SvenHooks.Init();
			SvenEffects.RegisterNetwork();
			SvenAudio.Init();
			new ContentPacks().Initialize();
			Log.Info("Sven 0.3.0 initialized; independent content pack loading.");
		}

		private void OnDestroy()
		{
			SvenHooks.Shutdown();
			SvenLookingGlass.Shutdown();
			SvenAudio.Shutdown();
		}
	}
	public sealed class SvenDisplayMarker : MonoBehaviour
	{
	}
	public sealed class SvenAnimator : MonoBehaviour
	{
		private Animator animator;

		private CharacterBody body;

		private float actionUntil;

		private string locomotion;

		private bool display;

		private bool dead;

		private bool hasStrength;

		private bool hasPlayback;

		private bool lastBkb;

		private float introUntil;

		private Vector3 baseScale;

		private Renderer[] renderers;

		private readonly HashSet<string> missingStates = new HashSet<string>();

		private readonly Dictionary<string, float> clipLengths = new Dictionary<string, float>();

		private SvenBuffVisuals buffVisuals;

		private SvenSurfaceVariants surfaces;

		private void Awake()
		{
			//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)
			animator = ((Component)this).GetComponent<Animator>();
			baseScale = ((Component)this).transform.localScale;
			renderers = ((Component)this).GetComponentsInChildren<Renderer>(true);
		}

		private void OnEnable()
		{
			if (!Object.op_Implicit((Object)(object)animator))
			{
				animator = ((Component)this).GetComponent<Animator>();
			}
			ResolveBody();
			display = Object.op_Implicit((Object)(object)((Component)this).GetComponent<SvenDisplayMarker>());
			dead = false;
			lastBkb = false;
			locomotion = null;
			actionUntil = 0f;
			if (!Object.op_Implicit((Object)(object)animator) || !Object.op_Implicit((Object)(object)animator.runtimeAnimatorController))
			{
				Log.Error("Sven visual has no animator controller: " + ((Object)this).name);
				return;
			}
			((Behaviour)animator).enabled = true;
			animator.applyRootMotion = false;
			animator.cullingMode = (AnimatorCullingMode)0;
			hasStrength = animator.parameters.Any((AnimatorControllerParameter p) => p.name == "GodStrengthActive");
			hasPlayback = animator.parameters.Any((AnimatorControllerParameter p) => p.name == "PlaybackRate");
			clipLengths.Clear();
			AnimationClip[] animationClips = animator.runtimeAnimatorController.animationClips;
			foreach (AnimationClip val in animationClips)
			{
				clipLengths[((Object)val).name] = val.length;
			}
			if (!display)
			{
				buffVisuals = ((Component)this).GetComponent<SvenBuffVisuals>() ?? ((Component)this).gameObject.AddComponent<SvenBuffVisuals>();
			}
			if (display)
			{
				Play("DisplayIntro", 1f);
				introUntil = Time.time + ClipLength("DisplayIntro");
			}
			else
			{
				Play("Idle", 1f);
			}
		}

		private void ResolveBody()
		{
			if (!Object.op_Implicit((Object)(object)body))
			{
				body = ((Component)this).GetComponentInParent<CharacterModel>()?.body;
			}
			if (!Object.op_Implicit((Object)(object)body))
			{
				body = ((Component)this).GetComponentInParent<CharacterBody>();
			}
		}

		private float ClipLength(string state)
		{
			foreach (KeyValuePair<string, float> clipLength in clipLengths)
			{
				if (clipLength.Key.EndsWith("_" + state, StringComparison.Ordinal))
				{
					return clipLength.Value;
				}
			}
			return 1f;
		}

		private bool State(string state, out int hash)
		{
			hash = Animator.StringToHash("Base Layer." + state);
			if (Object.op_Implicit((Object)(object)animator) && animator.HasState(0, hash))
			{
				return true;
			}
			if (missingStates.Add(state))
			{
				Log.Error("Sven animation state missing: " + state + " on " + ((Object)this).name);
			}
			return false;
		}

		private void Play(string state, float speed)
		{
			if (State(state, out var hash))
			{
				SetSpeed(speed);
				animator.CrossFadeInFixedTime(hash, 0.08f, 0, 0f);
				locomotion = state;
			}
		}

		private void SetSpeed(float speed)
		{
			if (hasPlayback)
			{
				animator.speed = 1f;
				animator.SetFloat("PlaybackRate", speed);
			}
			else
			{
				animator.speed = speed;
			}
		}

		public void Action(string state, float duration)
		{
			ResolveBody();
			if (State(state, out var hash))
			{
				SetSpeed(Mathf.Max(0.1f, ClipLength(state) / Mathf.Max(0.05f, duration)));
				animator.CrossFadeInFixedTime(hash, Mathf.Min(0.05f, duration * 0.12f), 0, 0f);
				actionUntil = Time.time + duration;
				locomotion = null;
			}
		}

		private void Update()
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return;
			}
			if (display)
			{
				if (Time.time >= introUntil && locomotion != "DisplayIdle")
				{
					Play("DisplayIdle", 1f);
				}
				return;
			}
			ResolveBody();
			if (!Object.op_Implicit((Object)(object)body))
			{
				return;
			}
			bool flag = body.HasBuff(SvenBuffs.Strength);
			bool flag2 = body.HasBuff(SvenBuffs.Bkb);
			if (flag2 && !lastBkb)
			{
				SvenEffects.Local(SvenEffect.Bkb, body, body.corePosition, Vector3.up, 1f);
				SvenAudio.Play("sven_bkb", body.corePosition, 0.8f);
			}
			lastBkb = flag2;
			if (hasStrength)
			{
				animator.SetBool("GodStrengthActive", flag);
			}
			((Component)this).transform.localScale = Vector3.Lerp(((Component)this).transform.localScale, baseScale * (flag2 ? 1.2f : 1f), 1f - Mathf.Exp((0f - Time.deltaTime) * 15f));
			if (surfaces == null)
			{
				surfaces = new SvenSurfaceVariants(renderers);
			}
			surfaces.Apply(flag, flag2);
			SvenController component = ((Component)body).GetComponent<SvenController>();
			if (Object.op_Implicit((Object)(object)buffVisuals))
			{
				buffVisuals.Tick(body, flag, flag2, body.HasBuff(SvenBuffs.Warcry), body.HasBuff(SvenBuffs.Shard), Object.op_Implicit((Object)(object)component) && component.flying);
			}
			if (Object.op_Implicit((Object)(object)body.healthComponent) && !body.healthComponent.alive)
			{
				if (!dead)
				{
					dead = true;
					Play("Death", 1f);
				}
			}
			else if (Object.op_Implicit((Object)(object)component) && component.flying && Time.time >= actionUntil)
			{
				if (locomotion != "Flight")
				{
					Play("Flight", 1f);
				}
			}
			else if (!(Time.time < actionUntil))
			{
				CharacterMotor characterMotor = body.characterMotor;
				float num;
				if (!Object.op_Implicit((Object)(object)characterMotor))
				{
					num = 0f;
				}
				else
				{
					Vector3 val = Vector3.ProjectOnPlane(characterMotor.velocity, Vector3.up);
					num = ((Vector3)(ref val)).magnitude;
				}
				float num2 = num;
				string text = ((!Object.op_Implicit((Object)(object)characterMotor) || characterMotor.isGrounded) ? ((num2 > 0.15f) ? "Run" : "Idle") : ((characterMotor.velocity.y > 0f) ? "Jump" : "Fall"));
				if (text != locomotion)
				{
					Play(text, (text == "Run") ? Mathf.Clamp(num2 / 7f, 0.6f, 2f) : 1f);
				}
			}
		}
	}
	internal static class SvenAssets
	{
		internal static T Load<T>(string name) where T : Object
		{
			AssetBundle bundle = SvenPlugin.bundle;
			T val = bundle.LoadAsset<T>(name);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			string[] allAssetNames = bundle.GetAllAssetNames();
			foreach (string text in allAssetNames)
			{
				if (Path.GetFileNameWithoutExtension(text).Equals(name, StringComparison.OrdinalIgnoreCase))
				{
					T val2 = bundle.LoadAsset<T>(text);
					if (Object.op_Implicit((Object)(object)val2))
					{
						return val2;
					}
				}
			}
			return default(T);
		}

		internal static Sprite Icon(string name)
		{
			//IL_003b: 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)
			Sprite val = SvenAssets.Load<Sprite>(name);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			Texture2D val2 = SvenAssets.Load<Texture2D>(name);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return null;
			}
			return Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f));
		}
	}
	internal static class SvenAudio
	{
		private sealed class PositionedVoice
		{
			internal SvenPcmOutput.Voice voice;

			internal Vector3 position;

			internal Transform parent;

			internal float gain;
		}

		private static readonly Dictionary<string, float[]> clips = new Dictionary<string, float[]>();

		private static readonly List<PositionedVoice> voices = new List<PositionedVoice>();

		private static SvenPcmOutput output;

		private static float nextVolumeUpdate;

		private static float gameVolume = 1f;

		private static readonly string[] warcryVoices = new string[4] { "sven_warcry_voice_01", "sven_warcry_voice_02", "sven_warcry_voice_03", "sven_warcry_voice_04" };

		private static int lastWarcryVoice = -1;

		private static float Volume
		{
			get
			{
				if (Time.unscaledTime >= nextVolumeUpdate)
				{
					nextVolumeUpdate = Time.unscaledTime + 0.25f;
					gameVolume = ReadVolume("volume_master") * ReadVolume("volume_sfx");
					BaseConVar val = (Object.op_Implicit((Object)(object)Console.instance) ? Console.instance.FindConVar("audio_focused_only") : null);
					if (!Application.isFocused && val != null && val.GetString() != "0")
					{
						gameVolume = 0f;
					}
				}
				return gameVolume * SvenPlugin.SoundVolume.Value;
			}
		}

		public static void Init()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			if (Application.isBatchMode || (int)Application.platform != 2)
			{
				return;
			}
			try
			{
				Assembly assembly = typeof(SvenAudio).Assembly;
				foreach (string item in from n in assembly.GetManifestResourceNames()
					where n.StartsWith("SvenAudio.")
					select n)
				{
					clips[item.Substring(10, item.Length - 14)] = SvenPcmOutput.ReadWave(assembly.GetManifestResourceStream(item));
				}
				output = new SvenPcmOutput();
				((Component)SvenPlugin.instance).gameObject.AddComponent<SvenAudioDriver>();
				Log.Info($"Dota audio: {clips.Count} original WAV samples; Windows PCM output ready.");
			}
			catch (Exception arg)
			{
				Shutdown();
				Log.Error($"Dota audio unavailable: {arg}");
			}
		}

		public static SvenPcmOutput.Voice Play(string sound, Vector3 position, float volume = 1f, Transform parent = null)
		{
			//IL_00ab: 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)
			Transform val = Listener();
			if (output == null || !Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			string key = sound switch
			{
				"impact" => "arrow_impact_" + Random.Range(1, 4), 
				"frost" => "frost_arrow" + Random.Range(1, 5), 
				"arrow" => "arrow_" + Random.Range(1, 5), 
				_ => sound, 
			};
			if (!clips.TryGetValue(key, out var value))
			{
				return null;
			}
			PositionedVoice positionedVoice = new PositionedVoice
			{
				position = position,
				parent = parent,
				gain = volume
			};
			Gains(positionedVoice, val, out var left, out var right);
			positionedVoice.voice = output.Play(value, left, right);
			voices.Add(positionedVoice);
			return positionedVoice.voice;
		}

		public static SvenPcmOutput.Voice PlayVariant(string prefix, Vector3 position, float volume, Transform parent)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			string[] array = clips.Keys.Where((string k) => k.StartsWith(prefix, StringComparison.Ordinal)).ToArray();
			if (array.Length != 0)
			{
				return Play(array[Random.Range(0, array.Length)], position, volume, parent);
			}
			return null;
		}

		public static void PlayWarcry(bool shard, bool immortal, Vector3 position, Transform parent)
		{
			//IL_0019: 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)
			Play(shard ? "sven_warcry_shield" : (immortal ? "sven_warcry_signet" : "sven_warcry"), position, 0.85f, parent);
			int num = Random.Range(0, warcryVoices.Length - ((lastWarcryVoice >= 0) ? 1 : 0));
			if (lastWarcryVoice >= 0 && num >= lastWarcryVoice)
			{
				num++;
			}
			if (Play(warcryVoices[num], position, 0.9f, parent) != null)
			{
				lastWarcryVoice = num;
			}
		}

		internal static void Tick()
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (output == null)
			{
				return;
			}
			if (output.Error != null)
			{
				Log.Error(output.Error);
				Shutdown();
				return;
			}
			Transform listener = Listener();
			voices.RemoveAll((PositionedVoice v) => !v.voice.IsPlaying);
			foreach (PositionedVoice voice in voices)
			{
				if (Object.op_Implicit((Object)(object)voice.parent))
				{
					voice.position = voice.parent.position;
				}
				Gains(voice, listener, out var left, out var right);
				output.SetGain(voice.voice, left, right);
			}
		}

		private static Transform Listener()
		{
			foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
			{
				if (Object.op_Implicit((Object)(object)readOnlyInstances.sceneCam) && ((Behaviour)readOnlyInstances.sceneCam).isActiveAndEnabled)
				{
					return ((Component)readOnlyInstances.sceneCam).transform;
				}
			}
			return null;
		}

		private static void Gains(PositionedVoice voice, Transform listener, out float left, out float right)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			left = (right = 0f);
			if (Object.op_Implicit((Object)(object)listener))
			{
				Vector3 val = voice.position - listener.position;
				float magnitude = ((Vector3)(ref val)).magnitude;
				float num = voice.gain * Volume * Mathf.Clamp01(1f - magnitude / 70f) * Mathf.Min(1f, 8f / Mathf.Max(1f, magnitude));
				float num2 = Mathf.Clamp(Vector3.Dot(listener.right, ((Vector3)(ref val)).normalized), -1f, 1f);
				left = num * Mathf.Sqrt((1f - num2) * 0.5f);
				right = num * Mathf.Sqrt((1f + num2) * 0.5f);
			}
		}

		private static float ReadVolume(string name)
		{
			BaseConVar val = (Object.op_Implicit((Object)(object)Console.instance) ? Console.instance.FindConVar(name) : null);
			if (val == null || !float.TryParse(val.GetString(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 1f;
			}
			return Mathf.Clamp01(result / 100f);
		}

		internal static void Shutdown()
		{
			foreach (PositionedVoice voice in voices)
			{
				voice.voice.Stop();
			}
			voices.Clear();
			lastWarcryVoice = -1;
			output?.Dispose();
			output = null;
		}
	}
	public sealed class SvenAudioDriver : MonoBehaviour
	{
		private void Update()
		{
			SvenAudio.Tick();
		}

		private void OnDestroy()
		{
			SvenAudio.Shutdown();
		}

		private void OnApplicationQuit()
		{
			SvenAudio.Shutdown();
		}
	}
	public class SvenEffectSound : MonoBehaviour
	{
		public string sound;

		public float volume = 1f;

		private void OnEnable()
		{
			((MonoBehaviour)this).StartCoroutine(PlayNextFrame());
		}

		private IEnumerator PlayNextFrame()
		{
			yield return null;
			SvenAudio.Play(sound, ((Component)this).transform.position, volume);
		}
	}
	internal static class SvenBalance
	{
		internal const float ModelScale = 1.3f;

		internal const float MomentumCooldown = 7f;

		internal const float AghanimHammer = 3f;

		internal const float Primary = 5f;

		internal const float PrimaryInterval = 0.9f;

		internal const float EchoCooldown = 3f;

		internal const float Hammer = 6f;

		internal const float HammerRange = 80f;

		internal const float HammerSpeed = 40f;

		internal const float HammerRadius = 8f;

		internal const float Stun = 1.75f;

		internal const float StrengthDuration = 10f;

		internal const float AghanimRange = 40f;

		internal const float BlinkRange = 30f;

		internal const float HammerEnemyRadius = 4f;

		internal const float HammerWorldRadius = 0.3f;

		internal const float HammerLifetime = 2.5f;

		internal const float FlightTimeout = 1.5f;

		internal const float MomentumBase = 20f;

		internal const float MomentumPerSpeed = 0.6f;

		internal const float MomentumWindup = 0.2f;

		internal const float SpeedMemory = 0.2f;

		internal const float SpinEntry = 0.15f;

		internal const float SpinTurnDuration = 0.4f;

		internal const float SpinDuration = 1.1f;

		internal const float SpinStartDegrees = -25.3f;

		internal const float PrimaryRadius = 10f;

		internal const float PrimaryAngle = 120f;

		internal const float MomentumRadius = 20f;

		internal const float MomentumRearRadius = 3f;

		internal const float PrimaryRadiusPerBonusHealth = 0.01f;

		internal const float PrimaryHalfHeight = 5f;

		internal const float MomentumHalfHeight = 6f;

		internal const float PrimaryHalfThickness = 2f;

		internal const float MomentumHalfThickness = 3f;

		internal const float StrengthCastDuration = 0.8f;

		internal const float StrengthCastPoint = 0.55f;

		internal const float MomentumAnimationHit = 0.29411766f;

		internal static float SpinHitTime(int index)
		{
			return 0.15f + (float)(index + 1) * 0.4f;
		}

		internal static float SpinDamage(float speed)
		{
			return Momentum(speed) * 0.5f;
		}

		internal static float GrowthHealth(float maximumBonusHealth, float baseHealth, float healthPerLevel, float level)
		{
			float num = maximumBonusHealth - (baseHealth + healthPerLevel * (level - 1f));
			if (!float.IsNaN(num) && !float.IsInfinity(num))
			{
				return Math.Max(0f, num);
			}
			return 0f;
		}

		internal static float PrimaryGrowthScale(float bonusHealth)
		{
			return 1f + ((float.IsNaN(bonusHealth) || float.IsInfinity(bonusHealth)) ? 0f : Math.Max(0f, bonusHealth)) * 0.01f / 10f;
		}

		internal static float SwingDirection(int attackIndex)
		{
			return (attackIndex % 3 != 0) ? ((attackIndex % 3 == 1) ? 1 : (-1)) : 0;
		}

		internal static float SweepRadius(bool heavy)
		{
			if (!heavy)
			{
				return 10f;
			}
			return 20f;
		}

		internal static float SweepAngle(bool heavy)
		{
			if (!heavy)
			{
				return 120f;
			}
			return 180f;
		}

		internal static float SweepHalfHeight(bool heavy)
		{
			if (!heavy)
			{
				return 5f;
			}
			return 6f;
		}

		internal static float SweepHalfThickness(bool heavy)
		{
			if (!heavy)
			{
				return 2f;
			}
			return 3f;
		}

		internal static float SweepBroadphase(bool heavy)
		{
			return (float)Math.Sqrt(SweepRadius(heavy) * SweepRadius(heavy) + SweepHalfThickness(heavy) * SweepHalfThickness(heavy));
		}

		internal static float Momentum(float speed)
		{
			return 20f + 0.6f * ((float.IsNaN(speed) || float.IsInfinity(speed)) ? 0f : Math.Max(0f, speed));
		}
	}
	internal sealed class SpeedRecord
	{
		private float speed;

		private float expires = -1f;

		internal void Save(float value, float now)
		{
			speed = Math.Max(0f, value);
			expires = now + 0.2f;
		}

		internal float Consume(float now)
		{
			float result = ((now <= expires) ? speed : 0f);
			Clear();
			return result;
		}

		internal void Clear()
		{
			speed = 0f;
			expires = -1f;
		}
	}
	internal static class SvenBlinkEffects
	{
		private static GameObject effect;

		private static Material bright;

		private static Material expanded;

		internal static void Initialize(GameObject prefab, Material flash, Material outerFlash)
		{
			effect = prefab;
			bright = flash;
			expanded = outerFlash;
		}

		internal static bool Play(CharacterBody body, Vector3 departure, Vector3 arrival)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)effect))
			{
				return false;
			}
			Vector3 val = (Object.op_Implicit((Object)(object)body) ? (body.corePosition - body.transform.position) : Vector3.up);
			Vector3 val2 = arrival - departure;
			Quaternion rotation = Util.QuaternionSafeLookRotation((((Vector3)(ref val2)).sqrMagnitude > 0.001f) ? ((Vector3)(ref val2)).normalized : Vector3.forward);
			EffectManager.SpawnEffect(effect, new EffectData
			{
				origin = departure + val,
				rotation = rotation
			}, false);
			EffectManager.SpawnEffect(effect, new EffectData
			{
				origin = arrival + val,
				rotation = rotation
			}, false);
			Transform val3 = ((Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.modelLocator)) ? body.modelLocator.modelTransform : null);
			CharacterModel val4 = (Object.op_Implicit((Object)(object)val3) ? ((Component)val3).GetComponent<CharacterModel>() : null);
			if (Object.op_Implicit((Object)(object)val4))
			{
				Flash(val4, bright, 0.6f);
				Flash(val4, expanded, 0.7f);
			}
			return true;
		}

		private static void Flash(CharacterModel model, Material material, float duration)
		{
			if (Object.op_Implicit((Object)(object)material))
			{
				TemporaryOverlayInstance obj = TemporaryOverlayManager.AddOverlay(((Component)model).gameObject);
				obj.duration = duration;
				obj.animateShaderAlpha = true;
				obj.alphaCurve = AnimationCurve.EaseInOut(0f, 1f, 1f, 0f);
				obj.destroyComponentOnEnd = true;
				obj.originalMaterial = material;
				obj.AddToCharacterModel(model);
			}
		}
	}
	internal static class SvenBuffs
	{
		internal static BuffDef Strength;

		internal static BuffDef Warcry;

		internal static BuffDef Shard;

		internal static BuffDef Bkb;

		internal static BuffDef Flight;

		internal static BuffDef EchoReady;

		internal static BuffDef EchoCooldown;

		internal static void Init()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Strength = New("Strength", "buffGodStrength", Color.white);
			Warcry = New("Warcry", "buffWarcry", Color.white);
			Shard = New("Shard", "buffWarcryImmortal", Color.white);
			Bkb = New("BKB", "buffBkb", Color.white);
			Flight = New("Flight", "iconHammer", Color.white);
			Flight.isHidden = true;
			EchoReady = New("EchoReady", "buffEcho", Color.white);
			EchoReady.ignoreGrowthNectar = true;
			EchoCooldown = New("EchoCooldown", "buffEchoCooldown", new Color(0.32f, 0.32f, 0.32f, 1f));
			EchoCooldown.isCooldown = true;
			EchoCooldown.canStack = false;
			EchoCooldown.ignoreGrowthNectar = true;
		}

		private static BuffDef New(string name, string icon, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Content.CreateAndAddBuff("Sven" + name, SvenAssets.Icon(icon), color, canStack: false, isDebuff: false);
		}

		internal static void Refresh(CharacterBody body, BuffDef buff, float time)
		{
			body.ClearTimedBuffs(buff);
			body.AddTimedBuff(buff, time);
		}
	}
	public sealed class SvenBuffVisuals : MonoBehaviour
	{
		private Transform head;

		private Transform left;

		private Transform right;

		private Transform elbowLeft;

		private Transform elbowRight;

		private Transform sword;

		private Transform flightTorso;

		private Transform flightPelvis;

		private GameObject strengthRoot;

		private GameObject armorRoot;

		private GameObject avatarRoot;

		private GameObject weaponRoot;

		private GameObject flightRoot;

		private readonly List<SvenVfxLayer> sprites = new List<SvenVfxLayer>();

		private readonly List<Material> ownedMaterials = new List<Material>();

		private LineRenderer[] armEnergy;

		private LineRenderer[] weaponEnergy;

		private LineRenderer[] armorEdges;

		private LineRenderer[] avatarArcs;

		private LineRenderer[] flightLines;

		private SvenFlightVisual flightVisual;

		private SvenVfxLayer[] embers;

		private SvenVfxLayer[] eyeGlows;

		private SvenVfxLayer[] avatarGlints;

		private Renderer[] shell;

		private Transform shield;

		private bool initialized;

		private bool strength;

		private bool bkb;

		private bool warcry;

		private bool shard;

		private bool flying;

		private bool immortal;

		private bool preview;

		private CharacterBody owner;

		private float clock;

		private MaterialPropertyBlock properties;

		private Transform Find(params string[] names)
		{
			return ((IEnumerable<Transform>)((Component)this).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform t) => names.Contains(((Object)t).name)));
		}

		private GameObject Group(string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = ((Component)this).gameObject.layer
			};
			val.transform.SetParent(((Component)this).transform, false);
			return val;
		}

		private SvenVfxLayer Sprite(Transform parent, string name, string texture, Color tint)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SvenVfxLayer svenVfxLayer = SvenVfx.Layer(parent, name, texture, tint, SvenVfx.Quad(vertical: true), billboard: true);
			sprites.Add(svenVfxLayer);
			return svenVfxLayer;
		}

		private LineRenderer[] Lines(Transform parent, string name, string texture, int count, float width, Color tint)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer[] array = (LineRenderer[])(object)new LineRenderer[count];
			for (int i = 0; i < count; i++)
			{
				array[i] = SvenVfx.Line(parent, name + " " + i, texture, tint, width, 17);
				array[i].useWorldSpace = true;
			}
			return array;
		}

		private void Initialize(bool isImmortal)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_0507: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Expected O, but got Unknown
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_056b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Expected O, but got Unknown
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			if (initialized)
			{
				return;
			}
			properties = new MaterialPropertyBlock();
			initialized = true;
			immortal = isImmortal;
			head = Find("head");
			left = Find("wrist_L");
			right = Find("wrist_R");
			elbowLeft = Find("elbow_L", "lowerarm_L");
			elbowRight = Find("elbow_R", "lowerarm_R");
			flightTorso = Find("spine2") ?? Find("spine3");
			flightPelvis = Find("root");
			sword = Find(immortal ? "sven_ti7_blade_tip" : "sword_1");
			SkinnedMeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<SkinnedMeshRenderer>(true);
			strengthRoot = Group("God's Strength source ambient");
			weaponRoot = Group("Sven source weapon energy");
			armorRoot = Group("Warcry armor protection");
			avatarRoot = Group("Black King Bar avatar");
			flightRoot = Group("Storm Hammer flight current");
			armEnergy = Lines(strengthRoot.transform, "Strength arm current", "ribbon_electric2", 4, 0.052f, SvenEffects.Red);
			weaponEnergy = Lines(weaponRoot.transform, "Blade plasma", "ribbon_electric2", immortal ? 3 : 2, 0.055f, SvenEffects.Red);
			eyeGlows = new SvenVfxLayer[2]
			{
				Sprite(strengthRoot.transform, "Left eye glow", "particle_glow_05", SvenEffects.Red),
				Sprite(strengthRoot.transform, "Right eye glow", "particle_glow_05", SvenEffects.Red)
			};
			embers = new SvenVfxLayer[12];
			for (int i = 0; i < embers.Length; i++)
			{
				embers[i] = Sprite(strengthRoot.transform, "Strength rising ember " + i, (i % 3 == 0) ? "flame_omni_seq0_18" : "spark_glow_01", SvenEffects.Red);
			}
			armorEdges = Lines(armorRoot.transform, "Warcry shield contour", "beam_hotwhite", 3, 0.038f, SvenEffects.Ivory);
			avatarArcs = Lines(avatarRoot.transform, "Avatar ascending energy", "beam_hotwhite", 3, 0.034f, SvenEffects.Ivory);
			avatarGlints = new SvenVfxLayer[8];
			for (int j = 0; j < avatarGlints.Length; j++)
			{
				avatarGlints[j] = Sprite(avatarRoot.transform, "Avatar gold mote " + j, "particle_glow_05", SvenEffects.Ivory);
			}
			flightLines = Lines(flightRoot.transform, "Flight lightning", "ribbon_electric2", 3, 0.05f, SvenEffects.Ivory);
			flightVisual = new SvenFlightVisual(flightRoot.transform);
			if (immortal)
			{
				GameObject val = SvenAssets.Load<GameObject>("SvenImmortalShieldModel");
				if (Object.op_Implicit((Object)(object)val))
				{
					shield = Object.Instantiate<GameObject>(val, armorRoot.transform, false).transform;
					((Object)shield).name = "Source TI5 armor shield";
					Renderer[] componentsInChildren2 = ((Component)shield).GetComponentsInChildren<Renderer>();
					foreach (Renderer val2 in componentsInChildren2)
					{
						Material[] sharedMaterials = val2.sharedMaterials;
						Material[] array = (Material[])(object)new Material[sharedMaterials.Length];
						for (int l = 0; l < sharedMaterials.Length; l++)
						{
							Material val3 = new Material(SvenEffects.Material("particle_glow_05"));
							if (Object.op_Implicit((Object)(object)sharedMaterials[l]) && Object.op_Implicit((Object)(object)sharedMaterials[l].mainTexture))
							{
								val3.mainTexture = sharedMaterials[l].mainTexture;
							}
							array[l] = val3;
							ownedMaterials.Add(val3);
						}
						val2.sharedMaterials = array;
						val2.shadowCastingMode = (ShadowCastingMode)0;
						properties.Clear();
						properties.SetColor("_TintColor", new Color(1f, 0.85f, 0.4f, 0.35f));
						val2.SetPropertyBlock(properties);
					}
				}
			}
			Shader val4 = SvenAssets.Load<Shader>("SvenRim") ?? Shader.Find("Sven/SourceRim");
			List<Renderer> list = new List<Renderer>();
			if (Object.op_Implicit((Object)(object)val4))
			{
				Material val5 = new Material(val4)
				{
					name = "Sven avatar edge shell"
				};
				ownedMaterials.Add(val5);
				SkinnedMeshRenderer[] array2 = componentsInChildren;
				foreach (SkinnedMeshRenderer val6 in array2)
				{
					if (Object.op_Implicit((Object)(object)val6.sharedMesh))
					{
						GameObject val7 = new GameObject("Avatar rim / " + ((Object)val6).name)
						{
							layer = ((Component)this).gameObject.layer
						};
						val7.transform.SetParent(((Component)val6).transform, false);
						SkinnedMeshRenderer val8 = val7.AddComponent<SkinnedMeshRenderer>();
						val8.sharedMesh = val6.sharedMesh;
						val8.bones = val6.bones;
						val8.rootBone = val6.rootBone;
						((Renderer)val8).localBounds = ((Renderer)val6).localBounds;
						((Renderer)val8).sharedMaterials = Enumerable.Repeat<Material>(val5, val6.sharedMesh.subMeshCount).ToArray();
						((Renderer)val8).shadowCastingMode = (ShadowCastingMode)0;
						((Renderer)val8).receiveShadows = false;
						((Renderer)val8).enabled = false;
						list.Add((Renderer)(object)val8);
					}
				}
			}
			shell = list.ToArray();
			ApplyVisibility();
		}

		public void Tick(CharacterBody body, bool strengthActive, bool bkbActive, bool warcryActive, bool shardActive, bool flightActive)
		{
			owner = body;
			Initialize(Object.op_Implicit((Object)(object)body) && body.skinIndex == 1);
			bool flag = Object.op_Implicit((Object)(object)body) && (!Object.op_Implicit((Object)(object)body.healthComponent) || body.healthComponent.alive);
			strength = flag && strengthActive;
			bkb = flag && bkbActive;
			warcry = flag && warcryActive;
			shard = flag && shardActive;
			flying = flag && flightActive;
			ApplyVisibility(flag);
		}

		private void ApplyVisibility(bool alive = true)
		{
			if (!initialized)
			{
				return;
			}
			strengthRoot.SetActive(alive && strength);
			weaponRoot.SetActive(alive && (strength || immortal));
			armorRoot.SetActive(alive && (warcry || shard));
			avatarRoot.SetActive(alive && bkb);
			object obj;
			if (!Object.op_Implicit((Object)(object)owner))
			{
				obj = null;
			}
			else
			{
				EntityStateMachine obj2 = EntityStateMachine.FindByCustomName(((Component)owner).gameObject, "Body");
				obj = ((obj2 != null) ? obj2.state : null) as SvenFlight;
			}
			SvenFlight svenFlight = (SvenFlight)obj;
			flightRoot.SetActive(alive && flying && (preview || (svenFlight?.travelActive ?? false)));
			Renderer[] array = shell;
			foreach (Renderer val in array)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.enabled = alive && bkb;
				}
			}
		}

		public void Preview(bool strengthActive, bool bkbActive, bool warcryActive, bool shardActive, bool flightActive, bool isImmortal, float seconds)
		{
			preview = true;
			Initialize(isImmortal);
			strength = strengthActive;
			bkb = bkbActive;
			warcry = warcryActive;
			shard = shardActive;
			flying = flightActive;
			ApplyVisibility();
			Sample(seconds);
		}

		private void LateUpdate()
		{
			if (!preview && initialized)
			{
				clock += Time.deltaTime;
				Sample(clock);
			}
		}

		private Vector3 Point(Transform bone, Vector3 fallback)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)bone))
			{
				return ((Component)this).transform.TransformPoint(fallback);
			}
			return bone.position;
		}

		public void Sample(float time)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Unknown result type (might be due to invalid IL or missing references)
			//IL_0638: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_085f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0864: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: 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_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: 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_0460: 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_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_074d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0752: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_06da: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0702: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_071a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: 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_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Unknown result type (might be due to invalid IL or missing references)
			//IL_0598: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_078b: Unknown result type (might be due to invalid IL or missing references)
			//IL_078d: Unknown result type (might be due to invalid IL or missing references)
			//IL_078e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0900: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0924: Unknown result type (might be due to invalid IL or missing references)
			//IL_0929: Unknown result type (might be due to invalid IL or missing references)
			//IL_0966: Unknown result type (might be due to invalid IL or missing references)
			//IL_096d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a28: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a50: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0add: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c26: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ced: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cfe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d18: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d34: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2c: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			Vector3 up = ((Component)this).transform.up;
			float x = ((Component)this).transform.lossyScale.x;
			Vector3 val = Point(head, new Vector3(0f, 2.2f, 0f));
			Vector3 val2 = val - up * 0.55f * x;
			Vector3 val3 = Point(left, new Vector3(-0.7f, 1.1f, 0f));
			Vector3 val4 = Point(right, new Vector3(0.7f, 1.1f, 0f));
			Vector3 val5 = (Object.op_Implicit((Object)(object)sword) ? sword.TransformPoint(immortal ? new Vector3(-0.447167f, 0.167242f, -3.4E-05f) : new Vector3(1.662024f, -0.218142f, -0.243191f)) : (val3 + up * 1.7f));
			Vector3 val8;
			Color val9 = default(Color);
			if (strength || immortal)
			{
				Color val6 = (strength ? SvenEffects.Red : SvenEffects.Blue);
				for (int i = 0; i < weaponEnergy.Length; i++)
				{
					LineRenderer val7 = weaponEnergy[i];
					float num = time * 7f + (float)i * MathF.PI * 2f / (float)weaponEnergy.Length;
					val8 = val5 - val3;
					val8 = Vector3.Cross(((Vector3)(ref val8)).normalized, ((Component)this).transform.forward);
					Vector3 normalized = ((Vector3)(ref val8)).normalized;
					for (int j = 0; j < val7.positionCount; j++)
					{
						float num2 = (float)j / (float)(val7.positionCount - 1);
						float num3 = num + num2 * 10f;
						val7.SetPosition(j, Vector3.Lerp(val3, val5, num2) + (normalized * Mathf.Sin(num3) + ((Component)this).transform.forward * Mathf.Cos(num3)) * (immortal ? 0.09f : 0.055f) * x * Mathf.Sin(num2 * MathF.PI));
					}
					val6.a = (strength ? 0.65f : 0.35f) * (0.8f + 0.2f * Mathf.Sin(time * 17f + (float)i));
					val9 = (val7.startColor = (val7.endColor = val6));
					val7.widthMultiplier = (strength ? 0.075f : 0.04f) * x;
				}
			}
			if (strength)
			{
				for (int k = 0; k < armEnergy.Length; k++)
				{
					Vector3 start = ((k % 2 == 0) ? (Object.op_Implicit((Object)(object)elbowLeft) ? elbowLeft.position : val2) : (Object.op_Implicit((Object)(object)elbowRight) ? elbowRight.position : val2));
					Vector3 end = ((k % 2 == 0) ? val3 : val4);
					SvenVfx.Bolt(armEnergy[k], start, end, time, k, 0.06f * x);
					Color val12 = (Color)((k < 2) ? SvenEffects.Red : new Color(1f, 0.45f, 0.16f));
					val12.a = ((k < 2) ? 0.45f : 0.22f);
					val9 = (armEnergy[k].startColor = (armEnergy[k].endColor = val12));
				}
				Color tint = default(Color);
				for (int l = 0; l < embers.Length; l++)
				{
					float num4 = Mathf.Repeat(time * 0.9f + (float)l * 0.173f, 1f);
					float num5 = (float)l * 2.399963f + time * 0.4f;
					Vector3 val15 = ((l % 3 == 0) ? Vector3.Lerp(val3, val5, 0.3f + (float)(l % 5) * 0.12f) : ((l % 3 == 1) ? val3 : val4));
					embers[l].go.transform.position = val15 + (((Component)this).transform.right * Mathf.Cos(num5) + ((Component)this).transform.forward * Mathf.Sin(num5)) * 0.13f * x + up * num4 * 0.65f * x;
					embers[l].go.transform.localScale = Vector3.one * ((l % 3 == 0) ? 0.13f : 0.035f) * (1f - num4 * 0.6f);
					((Color)(ref tint))..ctor(1f, 0.13f + 0.2f * (1f - num4), 0.025f, Mathf.Sin(num4 * MathF.PI) * 0.4f);
					embers[l].Tint(tint);
				}
				for (int m = 0; m < 2; m++)
				{
					eyeGlows[m].go.transform.position = val + ((Component)this).transform.forward * 0.14f * x + ((Component)this).transform.right * ((m == 0) ? (-0.075f) : 0.075f) * x;
					eyeGlows[m].go.transform.localScale = Vector3.one * 0.085f;
					eyeGlows[m].Tint(new Color(1f, 0.3f, 0.06f, 0.45f));
				}
			}
			if (warcry || shard)
			{
				float num6 = (warcry ? 0.65f : 0.23f);
				Vector3 val16 = val2 + ((Component)this).transform.forward * 0.36f * x;
				for (int n = 0; n < armorEdges.Length; n++)
				{
					LineRenderer val17 = armorEdges[n];
					for (int num7 = 0; num7 < val17.positionCount; num7++)
					{
						float num8 = (float)num7 / (float)(val17.positionCount - 1) * MathF.PI * 2f;
						float num9 = Mathf.Sin(num8) * (0.46f + (float)n * 0.035f);
						float num10 = Mathf.Cos(num8) * 0.6f;
						if (num10 < 0f)
						{
							num9 *= 0.65f + 0.35f * (1f + num10 / 0.6f);
						}
						val17.SetPosition(num7, val16 + ((Component)this).transform.right * num9 * x + up * num10 * x + ((Component)this).transform.forward * (float)n * 0.025f * x);
					}
					Color ivory = SvenEffects.Ivory;
					ivory.a = num6 * ((n == 0) ? 1f : 0.3f) * (0.85f + 0.15f * Mathf.Sin(time * 3f));
					val9 = (val17.startColor = (val17.endColor = ivory));
				}
				if (Object.op_Implicit((Object)(object)shield))
				{
					shield.position = val16 + ((Component)this).transform.forward * 0.06f * x;
					shield.rotation = ((Component)this).transform.rotation * Quaternion.Euler(90f, 0f, 0f);
					shield.localScale = Vector3.one * 0.72f;
				}
			}
			if (bkb)
			{
				Vector3 val20 = (Object.op_Implicit((Object)(object)owner) ? owner.footPosition : ((Component)this).transform.position);
				for (int num11 = 0; num11 < avatarArcs.Length; num11++)
				{
					LineRenderer val21 = avatarArcs[num11];
					for (int num12 = 0; num12 < val21.positionCount; num12++)
					{
						float num13 = (float)num12 / (float)(val21.positionCount - 1);
						float num14 = time * 1.7f + (float)num11 * 2.0944f + num13 * 3f;
						val21.SetPosition(num12, val20 + up * (0.15f + num13 * 2.25f) * x + (((Component)this).transform.right * Mathf.Cos(num14) + ((Component)this).transform.forward * Mathf.Sin(num14)) * (0.43f + 0.13f * Mathf.Sin(num13 * MathF.PI)) * x);
					}
					((Color)(ref val9))..ctor(1f, 0.73f, 0.18f, 0.25f);
					val21.endColor = val9;
					val21.startColor = val9;
				}
				for (int num15 = 0; num15 < avatarGlints.Length; num15++)
				{
					float num16 = Mathf.Repeat(time * 0.65f + (float)num15 * 0.137f, 1f);
					float num17 = (float)num15 * 2.4f + num16;
					avatarGlints[num15].go.transform.position = val20 + up * (0.2f + num16 * 2f) * x + (((Component)this).transform.right * Mathf.Cos(num17) + ((Component)this).transform.forward * Mathf.Sin(num17)) * 0.6f * x;
					avatarGlints[num15].go.transform.localScale = Vector3.one * 0.07f;
					avatarGlints[num15].Tint(new Color(1f, 0.83f, 0.3f, Mathf.Sin(num16 * MathF.PI) * 0.55f));
				}
				properties.Clear();
				properties.SetColor("_TintColor", new Color(1f, 0.7f, 0.13f, 1f));
				properties.SetFloat("_Opacity", 0.48f + 0.05f * Mathf.Sin(time * 3f));
				properties.SetFloat("_RimPower", 3.2f);
				Renderer[] array = shell;
				for (int num18 = 0; num18 < array.Length; num18++)
				{
					array[num18].SetPropertyBlock(properties);
				}
			}
			if (!flying)
			{
				return;
			}
			object obj;
			if (!Object.op_Implicit((Object)(object)owner))
			{
				obj = null;
			}
			else
			{
				EntityStateMachine obj2 = EntityStateMachine.FindByCustomName(((Component)owner).gameObject, "Body");
				obj = ((obj2 != null) ? obj2.state : null) as SvenFlight;
			}
			SvenFlight svenFlight = (SvenFlight)obj;
			bool flag = preview || (svenFlight?.travelActive ?? false);
			flightRoot.SetActive(flag);
			if (flag)
			{
				Vector3 val22 = svenFlight?.travelDirection ?? ((Component)this).transform.forward;
				if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)owner.characterMotor) && ((Vector3)(ref owner.characterMotor.velocity)).sqrMagnitude > 25f)
				{
					val22 = ((Vector3)(ref owner.characterMotor.velocity)).normalized;
				}
				if (((Vector3)(ref val22)).sqrMagnitude < 0.0001f)
				{
					val22 = ((Component)this).transform.forward;
				}
				Vector3 val23 = (Object.op_Implicit((Object)(object)flightTorso) ? flightTorso.position : (Object.op_Implicit((Object)(object)flightPelvis) ? Vector3.Lerp(flightPelvis.position, val, 0.55f) : val2));
				flightVisual.Sample(val23, val22, x, time);
				val8 = Vector3.Cross(val22, (Mathf.Abs(val22.y) > 0.92f) ? Vector3.right : Vector3.up);
				Vector3 normalized2 = ((Vector3)(ref val8)).normalized;
				for (int num19 = 0; num19 < flightLines.Length; num19++)
				{
					Vector3 end2 = val23 - val22 * (1.3f + (float)num19 * 0.35f) * x + normalized2 * (float)(num19 - 1) * 0.3f * x;
					SvenVfx.Bolt(flightLines[num19], (Vector3)(num19 switch
					{
						1 => val4, 
						0 => val3, 
						_ => val23, 
					}), end2, time, num19, 0.1f * x);
					flightLines[num19].widthMultiplier = 0.045f * x;
				}
			}
		}

		private void OnDisable()
		{
			ApplyVisibility(alive: false);
			clock = 0f;
		}

		private void OnDestroy()
		{
			foreach (SvenVfxLayer sprite in sprites)
			{
				SvenVfx.Dispose((Object)(object)sprite.mesh);
			}
			foreach (Material ownedMaterial in ownedMaterials)
			{
				SvenVfx.Dispose((Object)(object)ownedMaterial);
			}
			flightVisual?.Dispose();
			if (shell != null)
			{
				Renderer[] array = shell;
				foreach (Renderer val in array)
				{
					if (Object.op_Implicit((Object)(object)val))
					{
						SvenVfx.Dispose((Object)(object)((Component)val).gameObject);
					}
				}
			}
			SvenVfx.Dispose((Object)(object)strengthRoot);
			SvenVfx.Dispose((Object)(object)weaponRoot);
			SvenVfx.Dispose((Object)(object)armorRoot);
			SvenVfx.Dispose((Object)(object)avatarRoot);
			SvenVfx.Dispose((Object)(object)flightRoot);
		}
	}
	public sealed class SvenCastLedger<T>
	{
		private sealed class Cast
		{
			public int kind;

			public int count;

			public int mask;

			public float expires;
		}

		private struct Request
		{
			public uint cast;

			public int kind;

			public int index;

			public float expires;

			public T payload;
		}

		private readonly Dictionary<uint, Cast> casts = new Dictionary<uint, Cast>();

		private readonly List<Request> pending = new List<Request>();

		public int PendingCount => pending.Count;

		public void Begin(uint id, int kind, int count, float now, float duration, Action<T> deliver)
		{
			Expire(now);
			if (id == 0 || casts.ContainsKey(id))
			{
				return;
			}
			casts[id] = new Cast
			{
				kind = kind,
				count = count,
				expires = now + duration + 3f
			};
			int num = 0;
			while (num < pending.Count)
			{
				Request request = pending[num];
				if (request.cast != id)
				{
					num++;
					continue;
				}
				pending.RemoveAt(num);
				Dispatch(request, deliver);
			}
		}

		public void Submit(uint id, int kind, int index, float now, T payload, Action<T> deliver)
		{
			Expire(now);
			if (id != 0 && index >= 0 && index < 3)
			{
				Request request = new Request
				{
					cast = id,
					kind = kind,
					index = index,
					expires = now + 3f,
					payload = payload
				};
				if (casts.ContainsKey(id))
				{
					Dispatch(request, deliver);
				}
				else if (pending.Count < 12 && !pending.Exists((Request p) => p.cast == id && p.kind == kind && p.index == index))
				{
					pending.Add(request);
				}
			}
		}

		private void Dispatch(Request request, Action<T> deliver)
		{
			Cast cast = casts[request.cast];
			if (request.kind == cast.kind && request.index < cast.count && (cast.mask & (1 << request.index)) == 0)
			{
				cast.mask |= 1 << request.index;
				deliver(request.payload);
			}
		}

		public void Cancel(uint id, float now)
		{
			if (id != 0)
			{
				Expire(now);
				if (casts.TryGetValue(id, out var value))
				{
					value.mask = 7;
				}
				else
				{
					casts[id] = new Cast
					{
						mask = 7,
						count = 0,
						expires = now + 3f
					};
				}
				pending.RemoveAll((Request p) => p.cast == id);
			}
		}

		public void Expire(float now)
		{
			pending.RemoveAll((Request p) => p.expires < now);
			List<uint> list = new List<uint>();
			foreach (KeyValuePair<uint, Cast> cast in casts)
			{
				if (cast.Value.expires < now)
				{
					list.Add(cast.Key);
				}
			}
			foreach (uint item in list)
			{
				casts.Remove(item);
			}
		}
	}
	internal sealed class SvenCleaveVisual : MonoBehaviour
	{
		internal const float SectorLifetime = 0.55f;

		internal const float SweepDelay = 0.15f;

		internal const float Lifetime = 0.8f;

		private const int Steps = 80;

		private const int Across = 9;

		private const int StreakSteps = 7;

		private const int StreaksPerSheet = 12;

		private SvenSpatialMesh[] crests;

		private SvenSpatialMesh[] streaks;

		private float radius;

		private float degrees;

		private float transverseScale;

		private Vector3 cutAxis;

		private Vector3 planeNormal;

		private bool empowered;

		private bool heavy;

		private Material hotCoreMaterial;

		private SvenVfxLayer[] tips;

		private SvenRearCleaveVisual rear;

		internal void Initialize(bool heavyStrike, bool strength, bool immortal, float mirror)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			heavy = heavyStrike;
			empowered = strength;
			radius = SvenBalance.SweepRadius(heavy);
			degrees = SvenBalance.SweepAngle(heavy);
			cutAxis = SvenSwingProfiles.Axis(heavy, immortal, strength, mirror);
			Vector3 val = Vector3.Cross(Vector3.forward, cutAxis);
			planeNormal = ((Vector3)(ref val)).normalized;
			transverseScale = SvenSweepGeometry.TransverseScale(heavy, cutAxis);
			crests = new SvenSpatialMesh[4]
			{
				new SvenSpatialMesh(((Component)this).transform, "Cleave plasma volume", strength ? "beam_plasma_05" : "beam_plasma_06", 1, 80, 9),
				new SvenSpatialMesh(((Component)this).transform, "Cleave hot curved blade", strength ? "beam_hotwhite" : "beam_hotblue", 1, 80, 9),
				new SvenSpatialMesh(((Component)this).transform, "Cleave electric edge", strength ? "beam_jagged_01" : "ribbon_electric2", 1, 80, 9),
				new SvenSpatialMesh(((Component)this).transform, "Cleave swept residual", "beam_plasma_06", 1, 80, 9)
			};
			if (strength)
			{
				MeshRenderer component = crests[1].gameObject.GetComponent<MeshRenderer>();
				hotCoreMaterial = new Material(((Renderer)component).sharedMaterial);
				hotCoreMaterial.SetFloat("_DstBlend", 10f);
				((Renderer)component).sharedMaterial = hotCoreMaterial;
				tips = new SvenVfxLayer[2];
				for (int i = 0; i < 2; i++)
				{
					tips[i] = SvenVfx.Layer