Decompiled source of GanyuHuntressSkin v1.0.0

GanyuHuntressSkin.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using H1xl.Shared.Skins;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Orbs;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GanyuHuntressSkin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0ae6e55c4e4254d9055f99122046c90eccb9c389")]
[assembly: AssemblyProduct("GanyuHuntressSkin")]
[assembly: AssemblyTitle("GanyuHuntressSkin")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace H1xl.Shared
{
	internal abstract class GameMember
	{
		internal const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		internal readonly Type Type;

		internal readonly string Name;

		protected GameMember(Type type, string name)
		{
			Type = type;
			Name = name;
		}

		internal abstract MemberInfo FindMember();

		internal static Type Nested(Type outer, string name)
		{
			return outer.GetNestedType(name, BindingFlags.Public | BindingFlags.NonPublic);
		}

		public override string ToString()
		{
			return (Type?.Name ?? "<missing type>") + "." + Name;
		}
	}
	internal sealed class GameMethod : GameMember
	{
		internal readonly Type[] Args;

		internal GameMethod(Type type, string name, params Type[] args)
			: base(type, name)
		{
			Args = args;
		}

		internal MethodInfo Find()
		{
			try
			{
				return Type?.GetMethod(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, null, Args, null);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal sealed class GameField : GameMember
	{
		internal GameField(Type type, string name)
			: base(type, name)
		{
		}

		internal FieldInfo Find()
		{
			try
			{
				return Type?.GetField(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal sealed class GameProperty : GameMember
	{
		internal GameProperty(Type type, string name)
			: base(type, name)
		{
		}

		internal PropertyInfo Find()
		{
			try
			{
				return Type?.GetProperty(Name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal override MemberInfo FindMember()
		{
			return Find();
		}
	}
	internal static class SharedGameMembers
	{
		internal static readonly GameField PickupTransferOrb_orbEffectPrefab = new GameField(typeof(PickupTransferOrb), "orbEffectPrefab");

		internal static readonly GameMethod DynamicBone_SetupParticles = new GameMethod(typeof(DynamicBone), "SetupParticles");

		internal static readonly GameMethod DynamicBone_InitTransforms = new GameMethod(typeof(DynamicBone), "InitTransforms");

		internal static readonly GameMethod DynamicBone_ResetParticlesPosition = new GameMethod(typeof(DynamicBone), "ResetParticlesPosition");

		internal static readonly GameMethod DynamicBone_UpdateDynamicBones = new GameMethod(typeof(DynamicBone), "UpdateDynamicBones", typeof(float));
	}
}
namespace H1xl.Shared.Skins
{
	internal static class SkinAssets
	{
		internal static GameObject LoadTemplate(string pluginLocation, string bundleName, string modelNode, out Transform tplModel)
		{
			AssetBundle obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginLocation), bundleName));
			if ((Object)(object)obj == (Object)null)
			{
				throw new Exception("asset bundle '" + bundleName + "' not found next to the dll");
			}
			GameObject val = ((IEnumerable<GameObject>)obj.LoadAllAssets<GameObject>()).FirstOrDefault((Func<GameObject, bool>)((GameObject g) => Object.op_Implicit((Object)(object)g.GetComponentInChildren<SkinnedMeshRenderer>(true))));
			if ((Object)(object)val == (Object)null)
			{
				throw new Exception("no model in the asset bundle");
			}
			tplModel = val.transform.Find(modelNode);
			if ((Object)(object)tplModel == (Object)null)
			{
				throw new Exception("model has no '" + modelNode + "' node");
			}
			return val;
		}

		internal static void ReadRestPose(Transform tplModel, Dictionary<string, Quaternion> rot, Dictionary<string, Vector3> pos)
		{
			//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_005b: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			Transform[] componentsInChildren = ((Component)tplModel).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!rot.ContainsKey(((Object)val).name))
				{
					Quaternion val2 = Quaternion.identity;
					Transform val3 = val;
					while ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)tplModel)
					{
						val2 = val3.localRotation * val2;
						val3 = val3.parent;
					}
					rot[((Object)val).name] = val2;
					pos[((Object)val).name] = tplModel.InverseTransformPoint(val.position);
				}
			}
		}

		internal static Shader LoadHGStandard()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Shader>((object)"RoR2/Base/Shaders/HGStandard.shader").WaitForCompletion();
		}

		internal static Material NewHG(Shader hg, string name, Material src)
		{
			//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_000e: Expected O, but got Unknown
			Material val = new Material(hg)
			{
				name = name
			};
			if ((Object)(object)src != (Object)null && src.HasProperty("_MainTex"))
			{
				val.SetTexture("_MainTex", src.GetTexture("_MainTex"));
			}
			return val;
		}

		internal static void CopyColor(Material m, Material src)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)src != (Object)null && src.HasProperty("_Color"))
			{
				m.SetColor("_Color", src.GetColor("_Color"));
			}
		}

		internal static void CopyNormal(Material m, Material src)
		{
			if (!((Object)(object)src == (Object)null) && src.HasProperty("_BumpMap") && !((Object)(object)src.GetTexture("_BumpMap") == (Object)null))
			{
				m.SetTexture("_NormalTex", src.GetTexture("_BumpMap"));
				m.SetFloat("_NormalStrength", 1f);
			}
		}

		internal static Texture EmissionMap(Material src)
		{
			if (!((Object)(object)src != (Object)null) || !src.HasProperty("_EmissionMap"))
			{
				return null;
			}
			return src.GetTexture("_EmissionMap");
		}

		internal static void SetGlow(Material m, Texture tex, float power)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			m.SetTexture("_EmTex", tex);
			m.SetColor("_EmColor", Color.white);
			m.SetFloat("_EmPower", power);
		}

		internal static void SetSurface(Material m, float gloss, bool twoSided)
		{
			m.SetFloat("_Smoothness", gloss);
			m.SetFloat("_SpecularStrength", gloss);
			m.SetFloat("_SpecularExponent", 3f);
			m.SetFloat("_DitherOn", 1f);
			m.EnableKeyword("DITHER");
			m.SetFloat("_Cull", twoSided ? 0f : 2f);
		}

		internal static Material LobbyVariant(Material m, bool selfLit)
		{
			//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_001d: Expected O, but got Unknown
			Material val = new Material(m)
			{
				name = ((Object)m).name + "_Lobby"
			};
			if (selfLit)
			{
				SetGlow(val, val.GetTexture("_MainTex"), 0.15f);
			}
			return val;
		}
	}
	internal static class SkinRegistration
	{
		internal static SkinDef Register(string bodyPath, string displayPath, Func<GameObject, RendererInfo[]> attach, string skinName, string token, string displayName, Sprite icon)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)bodyPath).WaitForCompletion();
			GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)displayPath).WaitForCompletion();
			GameObject gameObject = ((Component)val.GetComponent<ModelLocator>().modelTransform).gameObject;
			RendererInfo[] rendererInfos = attach(gameObject);
			GameObject gameObject2 = ((Component)val2.GetComponentInChildren<CharacterModel>(true)).gameObject;
			attach(gameObject2);
			LanguageAPI.Add(token, displayName);
			ModelSkinController component = gameObject.GetComponent<ModelSkinController>();
			SkinDef val3 = Skins.CreateNewSkinDef(new SkinDefParamsInfo
			{
				Name = skinName,
				NameToken = token,
				Icon = icon,
				RootObject = gameObject,
				BaseSkins = (SkinDef[])((!((Object)(object)component != (Object)null) || component.skins.Length == 0) ? ((Array)Array.Empty<SkinDef>()) : ((Array)new SkinDef[1] { component.skins[0] })),
				RendererInfos = rendererInfos,
				GameObjectActivations = Array.Empty<GameObjectActivation>(),
				MeshReplacements = Array.Empty<MeshReplacement>(),
				ProjectileGhostReplacements = Array.Empty<ProjectileGhostReplacement>(),
				MinionSkinReplacements = Array.Empty<MinionSkinReplacement>()
			});
			Skins.AddSkinToCharacter(val, val3);
			ModelSkinController val4 = gameObject2.GetComponent<ModelSkinController>() ?? val2.GetComponentInChildren<ModelSkinController>(true);
			if ((Object)(object)val4 != (Object)null && (Object)(object)component != (Object)null && !val4.skins.Contains(val3))
			{
				val4.skins = (SkinDef[])component.skins.Clone();
			}
			return val3;
		}
	}
	internal sealed class SkinModel
	{
		private static int ourLocalIndex = -2;

		internal readonly CharacterModel characterModel;

		private readonly ModelSkinController msc;

		private readonly Transform root;

		internal readonly Dictionary<string, Transform> bones = new Dictionary<string, Transform>();

		internal readonly List<Renderer> ours = new List<Renderer>();

		private readonly HashSet<Renderer> oursSet = new HashSet<Renderer>();

		private readonly List<Renderer> hidden = new List<Renderer>();

		private readonly Dictionary<Renderer, Material> lobbyMats = new Dictionary<Renderer, Material>();

		private bool wasInGame;

		internal bool InLobby
		{
			get
			{
				if (!wasInGame && (Object)(object)characterModel != (Object)null)
				{
					return (Object)(object)characterModel.body == (Object)null;
				}
				return false;
			}
		}

		internal bool Attached => ours.Count > 0;

		internal SkinModel(Component host, ICollection<string> ourRenderers, ICollection<string> hiddenRenderers, IDictionary<string, Material> lobbyMaterials)
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Expected O, but got Unknown
			root = host.transform;
			characterModel = host.GetComponent<CharacterModel>();
			wasInGame = (Object)(object)host.GetComponentInParent<CharacterBody>() != (Object)null;
			msc = host.GetComponent<ModelSkinController>() ?? host.GetComponentInChildren<ModelSkinController>(true) ?? host.GetComponentInParent<ModelSkinController>();
			Transform[] componentsInChildren = host.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!bones.ContainsKey(((Object)val).name))
				{
					bones[((Object)val).name] = val;
				}
			}
			foreach (Transform item in root)
			{
				Transform val2 = item;
				Renderer component = ((Component)val2).GetComponent<Renderer>();
				if ((Object)(object)component == (Object)null)
				{
					continue;
				}
				if (ourRenderers.Contains(((Object)val2).name))
				{
					ours.Add(component);
					oursSet.Add(component);
					if (lobbyMaterials.TryGetValue(((Object)val2).name, out var value))
					{
						lobbyMats[component] = value;
					}
				}
				else if (hiddenRenderers.Contains(((Object)val2).name))
				{
					hidden.Add(component);
				}
			}
		}

		internal Transform B(string name)
		{
			if (!bones.TryGetValue(name, out var value))
			{
				return null;
			}
			return value;
		}

		internal void Track()
		{
			if (!wasInGame && (Object)(object)characterModel != (Object)null && Object.op_Implicit((Object)(object)characterModel.body))
			{
				wasInGame = true;
			}
		}

		internal bool IsOn(SkinDef skin, string bodyName)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)characterModel != (Object)null && characterModel.baseRendererInfos != null)
			{
				RendererInfo[] baseRendererInfos = characterModel.baseRendererInfos;
				foreach (RendererInfo val in baseRendererInfos)
				{
					if ((Object)(object)val.renderer != (Object)null && oursSet.Contains(val.renderer))
					{
						return true;
					}
				}
			}
			if ((Object)(object)msc == (Object)null || (Object)(object)skin == (Object)null)
			{
				return false;
			}
			int currentSkinIndex = msc.currentSkinIndex;
			if (currentSkinIndex >= 0 && currentSkinIndex < msc.skins.Length && (Object)(object)msc.skins[currentSkinIndex] == (Object)(object)skin)
			{
				return true;
			}
			if (ourLocalIndex == -2 && SkinCatalog.skinCount > 0)
			{
				ourLocalIndex = SkinCatalog.FindLocalSkinIndexForBody(BodyCatalog.FindBodyIndex(bodyName), skin);
			}
			if (ourLocalIndex >= 0)
			{
				return currentSkinIndex == ourLocalIndex;
			}
			return false;
		}

		internal void Show(bool on)
		{
			foreach (Renderer our in ours)
			{
				if (Object.op_Implicit((Object)(object)our))
				{
					our.forceRenderingOff = !on;
				}
			}
			foreach (Renderer item in hidden)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					item.forceRenderingOff = on;
				}
			}
		}

		internal void UseLobbyMaterials()
		{
			RendererInfo[] baseRendererInfos = characterModel.baseRendererInfos;
			if (baseRendererInfos == null)
			{
				return;
			}
			for (int i = 0; i < baseRendererInfos.Length; i++)
			{
				Renderer renderer = baseRendererInfos[i].renderer;
				if (!((Object)(object)renderer == (Object)null) && lobbyMats.TryGetValue(renderer, out var value) && (!((Object)(object)baseRendererInfos[i].defaultMaterial == (Object)(object)value) || !((Object)(object)renderer.sharedMaterial == (Object)(object)value)))
				{
					baseRendererInfos[i].defaultMaterial = value;
					renderer.sharedMaterial = value;
				}
			}
		}
	}
	internal static class SkinAttach
	{
		internal static RendererInfo[] Attach(GameObject model, GameObject template, Transform tplModel, IDictionary<string, Material> mats, string[] rendererOrder, ICollection<string> skipped, float boundsExpand, out Dictionary<Transform, Transform> map)
		{
			//IL_01f1: 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_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: 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_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: 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_02e5: 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_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			Transform root = model.transform;
			Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>();
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!dictionary.ContainsKey(((Object)val).name))
				{
					dictionary[((Object)val).name] = val;
				}
			}
			map = new Dictionary<Transform, Transform> { [tplModel] = root };
			HashSet<Transform> hashSet = new HashSet<Transform>();
			componentsInChildren = ((Component)tplModel).GetComponentsInChildren<Transform>(true);
			foreach (Transform val2 in componentsInChildren)
			{
				if (!((Object)(object)val2 == (Object)(object)tplModel))
				{
					if (dictionary.TryGetValue(((Object)val2).name, out var value) && (Object)(object)value != (Object)(object)root)
					{
						map[val2] = value;
						continue;
					}
					Transform val3 = map[val2.parent];
					float num = (hashSet.Contains(val3) ? 1f : (RelScale(val2.parent, tplModel) / RelScale(val3, root)));
					Transform transform = new GameObject(((Object)val2).name).transform;
					transform.SetParent(val3, false);
					transform.localPosition = val2.localPosition * num;
					transform.localRotation = val2.localRotation;
					transform.localScale = val2.localScale * num;
					map[val2] = transform;
					hashSet.Add(transform);
				}
			}
			Dictionary<Transform, Transform> bones = map;
			List<RendererInfo> list = new List<RendererInfo>();
			foreach (SkinnedMeshRenderer item in from r in template.GetComponentsInChildren<SkinnedMeshRenderer>(true)
				where skipped == null || !skipped.Contains(((Object)r).name)
				orderby Array.IndexOf(rendererOrder, ((Object)r).name)
				select r)
			{
				GameObject val4 = new GameObject(((Object)item).name);
				val4.transform.SetParent(root, false);
				val4.transform.localPosition = ((Component)item).transform.localPosition;
				val4.transform.localRotation = ((Component)item).transform.localRotation;
				val4.transform.localScale = ((Component)item).transform.localScale;
				SkinnedMeshRenderer val5 = val4.AddComponent<SkinnedMeshRenderer>();
				val5.sharedMesh = item.sharedMesh;
				val5.bones = item.bones.Select((Transform b) => (!((Object)(object)b != (Object)null) || !bones.TryGetValue(b, out var value3)) ? root : value3).ToArray();
				val5.rootBone = (((Object)(object)item.rootBone != (Object)null && bones.TryGetValue(item.rootBone, out var value2)) ? value2 : root);
				Bounds localBounds = ((Renderer)item).localBounds;
				((Bounds)(ref localBounds)).Expand(boundsExpand);
				((Renderer)val5).localBounds = localBounds;
				((Renderer)val5).sharedMaterial = mats[((Object)item).name];
				((Renderer)val5).forceRenderingOff = true;
				list.Add(new RendererInfo
				{
					renderer = (Renderer)(object)val5,
					defaultMaterial = mats[((Object)item).name],
					defaultShadowCastingMode = (ShadowCastingMode)1,
					ignoreOverlays = false,
					hideOnDeath = false
				});
			}
			return list.ToArray();
			static float RelScale(Transform x, Transform top)
			{
				//IL_0001: 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)
				return Mathf.Abs(x.lossyScale.x / top.lossyScale.x);
			}
		}
	}
	internal sealed class ModelSpace
	{
		private readonly Transform root;

		internal ModelSpace(Transform root)
		{
			this.root = root;
		}

		internal Vector3 P(Transform t)
		{
			//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)
			return root.InverseTransformPoint(t.position);
		}

		internal Quaternion R(Transform t)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.identity;
			Transform val2 = t;
			while ((Object)(object)val2 != (Object)null && (Object)(object)val2 != (Object)(object)root)
			{
				val = val2.localRotation * val;
				val2 = val2.parent;
			}
			return val;
		}

		internal void SetR(Transform t, Quaternion q)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			t.localRotation = Quaternion.Inverse(R(t.parent)) * q;
		}

		internal float Scale(Transform t)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			return Mathf.Abs(t.lossyScale.x / root.lossyScale.x);
		}

		internal void IK(Transform a, Transform b, Transform c, Vector3 target, Vector3 pole)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = P(a);
			Vector3 val2 = P(b);
			Vector3 val3 = P(c);
			Vector3 val4 = val2 - val;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			val4 = val3 - val2;
			float magnitude2 = ((Vector3)(ref val4)).magnitude;
			Vector3 val5 = target - val;
			if (!(((Vector3)(ref val5)).sqrMagnitude < 1E-10f) && !(magnitude < 1E-05f) && !(magnitude2 < 1E-05f))
			{
				float num = Mathf.Clamp(((Vector3)(ref val5)).magnitude, Mathf.Abs(magnitude - magnitude2) + 0.0001f, magnitude + magnitude2 - 0.0001f);
				Vector3 normalized = ((Vector3)(ref val5)).normalized;
				Vector3 val6 = Vector3.ProjectOnPlane(pole - val, normalized);
				if (((Vector3)(ref val6)).sqrMagnitude < 1E-10f)
				{
					val6 = Vector3.ProjectOnPlane(val2 - val, normalized);
				}
				((Vector3)(ref val6)).Normalize();
				float num2 = Mathf.Clamp((magnitude * magnitude + num * num - magnitude2 * magnitude2) / (2f * magnitude * num), -1f, 1f);
				float num3 = Mathf.Sqrt(1f - num2 * num2);
				Vector3 val7 = val + normalized * (num2 * magnitude) + val6 * (num3 * magnitude);
				SetR(a, Quaternion.FromToRotation(val2 - val, val7 - val) * R(a));
				val2 = P(b);
				val3 = P(c);
				SetR(b, Quaternion.FromToRotation(val3 - val2, val + normalized * num - val2) * R(b));
			}
		}
	}
	internal sealed class SkinPhysics
	{
		private static Action<DynamicBone> dbSetup;

		private static Action<DynamicBone> dbInit;

		private static Action<DynamicBone> dbReset;

		private static Action<DynamicBone, float> dbStep;

		private static bool resolved;

		private static bool ok;

		internal readonly List<DynamicBone> chains = new List<DynamicBone>();

		private readonly GameObject holder;

		private bool on;

		internal bool On => on;

		internal static bool Available(string skinName, Action<string> logError)
		{
			if (resolved)
			{
				return ok;
			}
			resolved = true;
			try
			{
				dbSetup = Db<Action<DynamicBone>>(SharedGameMembers.DynamicBone_SetupParticles);
				dbInit = Db<Action<DynamicBone>>(SharedGameMembers.DynamicBone_InitTransforms);
				dbReset = Db<Action<DynamicBone>>(SharedGameMembers.DynamicBone_ResetParticlesPosition);
				dbStep = Db<Action<DynamicBone, float>>(SharedGameMembers.DynamicBone_UpdateDynamicBones);
				ok = true;
			}
			catch (Exception ex)
			{
				logError(skinName + " hair/cloth physics turned off: DynamicBone has changed (" + ex.Message + "). The skin works without physics.");
			}
			return ok;
			static T Db<T>(GameMethod method) where T : Delegate
			{
				MethodInfo methodInfo = method.Find();
				if (methodInfo == null)
				{
					throw new MissingMethodException("DynamicBone", method.Name);
				}
				return (T)Delegate.CreateDelegate(typeof(T), methodInfo);
			}
		}

		internal static bool IsMirrored(Transform t)
		{
			//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_0007: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			Vector3 lossyScale = t.lossyScale;
			return lossyScale.x * lossyScale.y * lossyScale.z < 0f;
		}

		internal static List<Transform> ChainRoots(Dictionary<string, Transform> bones)
		{
			List<Transform> list = new List<Transform>();
			foreach (Transform value in bones.Values)
			{
				if (((Object)value).name.StartsWith("dyn_") && !((Object)value.parent).name.StartsWith("dyn_"))
				{
					list.Add(value);
				}
			}
			return list;
		}

		internal static void Tune(DynamicBone d, float damping, float elasticity, float stiffness, float inert, float radius)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			d.m_Damping = damping;
			d.m_Elasticity = elasticity;
			d.m_Stiffness = stiffness;
			d.m_Inert = inert;
			d.m_Radius = radius;
			d.m_Gravity = new Vector3(0f, -0.001f, 0f);
		}

		internal static bool IsBreast(Transform root)
		{
			return ((Object)root).name.StartsWith("dyn_Breast");
		}

		internal static bool AddBreastTips(Transform modelRoot, Transform left, Transform right, string chest, string neck, Dictionary<string, Vector3> restPos, Dictionary<string, Quaternion> restRot, float lengthOfSpacing)
		{
			//IL_0067: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if (!restPos.TryGetValue(((Object)left).name, out var value) || !restPos.TryGetValue(((Object)right).name, out var value2) || !restPos.TryGetValue(chest, out var value3) || !restPos.TryGetValue(neck, out var value4) || !restRot.TryGetValue(((Object)left).name, out var value5) || !restRot.TryGetValue(((Object)right).name, out var value6))
			{
				return false;
			}
			Vector3 val = value2 - value;
			Vector3 val2 = value4 - value3;
			if (((Vector3)(ref val)).sqrMagnitude < 1E-08f || ((Vector3)(ref val2)).sqrMagnitude < 1E-08f)
			{
				return false;
			}
			Vector3 val3 = Vector3.Cross(val, val2);
			Vector3 val4 = ((Vector3)(ref val3)).normalized;
			if (Vector3.Dot(val4, (value + value2) * 0.5f - value3) < 0f)
			{
				val4 = -val4;
			}
			Vector3 offset = ((Vector3)(ref val4)).normalized * (((Vector3)(ref val)).magnitude * lengthOfSpacing);
			Tip(left, value5);
			Tip(right, value6);
			return true;
			void Tip(Transform bone, Quaternion rest)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: 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_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: 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)
				GameObject val5 = new GameObject(((Object)bone).name + "_tip");
				val5.transform.SetParent(bone, false);
				float num = Mathf.Abs(bone.lossyScale.x / modelRoot.lossyScale.x);
				val5.transform.localPosition = Quaternion.Inverse(rest) * offset / Mathf.Max(1E-05f, num);
			}
		}

		internal static void TuneBreast(DynamicBone d, float strength)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			Tune(d, 0.2f, 0.1f, 1f - 0.56f * strength, 0.4f, 0f);
			d.m_Gravity = Vector3.zero;
			d.m_Colliders = new List<DynamicBoneCollider>();
		}

		internal SkinPhysics(Transform modelRoot, string holderName)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			holder = new GameObject(holderName);
			holder.SetActive(false);
			holder.transform.SetParent(modelRoot, false);
		}

		internal DynamicBone Add(Transform root)
		{
			DynamicBone val = holder.AddComponent<DynamicBone>();
			((Behaviour)val).enabled = false;
			val.m_Root = root;
			val.m_UpdateRate = 0f;
			val.m_DistantDisable = false;
			val.m_Exclusions = new List<Transform>();
			chains.Add(val);
			return val;
		}

		internal void Finish()
		{
			holder.SetActive(true);
			foreach (DynamicBone chain in chains)
			{
				dbSetup(chain);
			}
			holder.AddComponent<SkinPhysicsDriver>().physics = this;
		}

		internal void SetOn(bool value)
		{
			if (value == on)
			{
				return;
			}
			on = value;
			foreach (DynamicBone chain in chains)
			{
				if (Object.op_Implicit((Object)(object)chain))
				{
					if (value)
					{
						dbReset(chain);
					}
					else
					{
						dbInit(chain);
					}
				}
			}
		}

		internal void Pre()
		{
			if (!on)
			{
				return;
			}
			foreach (DynamicBone chain in chains)
			{
				if (Object.op_Implicit((Object)(object)chain))
				{
					dbInit(chain);
				}
			}
		}

		internal void Step(float deltaTime)
		{
			if (!on)
			{
				return;
			}
			foreach (DynamicBone chain in chains)
			{
				if (Object.op_Implicit((Object)(object)chain))
				{
					dbStep(chain, deltaTime);
				}
			}
		}
	}
	[DefaultExecutionOrder(-500)]
	internal sealed class SkinPhysicsDriver : MonoBehaviour
	{
		internal SkinPhysics physics;

		private void Update()
		{
			physics?.Pre();
		}
	}
	internal static class RecommendedModsNotice
	{
		private static readonly (string guid, string en, string ru)[] Mods = new(string, string, string)[2]
		{
			("com.H1xl.OverlayLayerFix", "<b>OverlayLayerFix</b>: barrier, shield and cloak effects as one clean layer on layered hair and clothes", "<b>OverlayLayerFix</b>: барьер, щит и невидимость одним чистым слоем на многослойных волосах и одежде"),
			("RiskOfResources.ItemDisplayRemoval", "<b>ItemDisplayRemoval</b>: removes item models from characters' bodies (they float or clip on custom models)", "<b>ItemDisplayRemoval</b>: убирает предметы с тела персонажей (на нестандартных моделях они висят в воздухе или проваливаются)")
		};

		private const string FlagFile = "H1xl.SkinMods.cfg";

		private const string TitleToken = "H1XL_SKINS_RECOMMENDED_TITLE";

		private const string TextToken = "H1XL_SKINS_RECOMMENDED_TEXT";

		private static ManualLogSource log;

		private static readonly List<(string bodyName, Func<SkinDef> skin)> skins = new List<(string, Func<SkinDef>)>();

		private static ConfigFile flagConfig;

		private static ConfigEntry<bool> shown;

		internal static void Init(ManualLogSource logger, string bodyName, Func<SkinDef> skin)
		{
			log = logger;
			skins.Add((bodyName, skin));
			if (skins.Count <= 1)
			{
				LanguageAPI.Add("H1XL_SKINS_RECOMMENDED_TITLE", "Recommended mods");
				LanguageAPI.Add("H1XL_SKINS_RECOMMENDED_TITLE", "Рекомендуемые моды", "RU");
				LanguageAPI.Add("H1XL_SKINS_RECOMMENDED_TEXT", "For the best look of this skin, install these mods (optional):\n\n{0}\n\nThis notice is shown only once.");
				LanguageAPI.Add("H1XL_SKINS_RECOMMENDED_TEXT", "Для лучшего вида этого облика установите эти моды (необязательно):\n\n{0}\n\nЭто сообщение показывается один раз.", "RU");
				UserProfile.onLoadoutChangedGlobal += OnLoadoutChanged;
			}
		}

		private static void OnLoadoutChanged(UserProfile profile)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_0149: 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)
			try
			{
				if (profile == null || !skins.Any(((string bodyName, Func<SkinDef> skin) s) => IsSelected(profile, s.bodyName, s.skin())))
				{
					return;
				}
				(string, string, string)[] array = Mods.Where(((string guid, string en, string ru) m) => !Chainloader.PluginInfos.ContainsKey(m.guid)).ToArray();
				if (array.Length == 0)
				{
					Done();
					return;
				}
				if (flagConfig == null)
				{
					flagConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "H1xl.SkinMods.cfg"), true);
					shown = flagConfig.Bind<bool>("Notice", "RecommendedModsShown", false, "The one-time 'recommended mods' notice of H1xl's skins was shown. Set to false to see it again.");
				}
				else
				{
					flagConfig.Reload();
				}
				Done();
				if (!shown.Value)
				{
					shown.Value = true;
					bool ru = Language.currentLanguageName == "RU";
					string text = string.Join("\n", array.Select(((string guid, string en, string ru) m) => "• " + (ru ? m.ru : m.en)));
					LocalUser? obj = ((IEnumerable<LocalUser>)LocalUserManager.readOnlyLocalUsersList).FirstOrDefault((Func<LocalUser, bool>)((LocalUser u) => u.userProfile == profile));
					SimpleDialogBox val = SimpleDialogBox.Create((obj != null) ? obj.eventSystem : null);
					val.headerToken = new TokenParamsPair("H1XL_SKINS_RECOMMENDED_TITLE", Array.Empty<object>());
					val.descriptionToken = new TokenParamsPair("H1XL_SKINS_RECOMMENDED_TEXT", new object[1] { text });
					val.AddCancelButton("OK", Array.Empty<object>());
				}
			}
			catch (Exception ex)
			{
				UserProfile.onLoadoutChangedGlobal -= OnLoadoutChanged;
				ManualLogSource obj2 = log;
				if (obj2 != null)
				{
					obj2.LogWarning((object)("recommended mods notice failed, turned off: " + ex.Message));
				}
			}
		}

		private static void Done()
		{
			UserProfile.onLoadoutChangedGlobal -= OnLoadoutChanged;
		}

		private static bool IsSelected(UserProfile profile, string bodyName, SkinDef skin)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0018: 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)
			if ((Object)(object)skin == (Object)null)
			{
				return false;
			}
			BodyIndex val = BodyCatalog.FindBodyIndex(bodyName);
			if ((int)val == -1)
			{
				return false;
			}
			int num = SkinCatalog.FindLocalSkinIndexForBody(val, skin);
			if (num >= 0)
			{
				return profile.loadout.bodyLoadoutManager.GetSkinIndex(val) == (uint)num;
			}
			return false;
		}
	}
}
namespace GanyuSkin
{
	[BepInPlugin("com.H1xl.GanyuHuntressSkin", "GanyuHuntressSkin", "1.0.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class GanyuSkinPlugin : BaseUnityPlugin
	{
		public const string GUID = "com.H1xl.GanyuHuntressSkin";

		private const string OldGUID = "com.ganyuskin.huntress";

		public const string NAME = "GanyuHuntressSkin";

		public const string VERSION = "1.0.0";

		private const string TOKEN = "GANYUSKIN_HUNTRESS_GANYU_NAME";

		internal static ManualLogSource Log;

		internal static SkinDef Skin;

		internal static ConfigEntry<bool> Physics;

		internal static ConfigEntry<float> BreastJiggle;

		internal static ConfigEntry<float> EyesGlow;

		internal static ConfigEntry<float> BowGlow;

		internal static ConfigEntry<float> GemGlow;

		internal const float BowScale = 0.73f;

		internal static GameObject Template;

		internal static Transform TplArmature;

		internal static readonly Dictionary<string, Quaternion> RestRot = new Dictionary<string, Quaternion>();

		internal static readonly Dictionary<string, Vector3> RestPos = new Dictionary<string, Vector3>();

		internal static readonly Dictionary<string, Vector3> RestLocalPos = new Dictionary<string, Vector3>();

		internal static readonly Dictionary<string, Quaternion> RestLocalRot = new Dictionary<string, Quaternion>();

		internal static bool HasBowMap;

		private static Quaternion bowMapPlus;

		private static Quaternion bowMapMinus;

		internal static float StringHalfLength;

		internal static readonly List<string> OurRenderers = new List<string>();

		internal static readonly Dictionary<string, Material> LobbyMats = new Dictionary<string, Material>();

		internal static readonly string[] HiddenRenderers = new string[3] { "HuntressMesh", "HuntressScarfMesh", "BowMesh" };

		private static readonly HashSet<string> Skipped = new HashSet<string> { "AmosString" };

		private static readonly string[] RendererOrder = new string[7] { "AmosBow", "Ganyu_Eyes", "Ganyu_Gem", "Ganyu_Face", "Ganyu_Hair", "Ganyu_Skirt", "Ganyu_Body" };

		private const float EyesPower = 0.8f;

		private const float BowPower = 3f;

		private const float GemPower = 0.6f;

		internal static Quaternion BowMap(int sign)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (sign < 0)
			{
				return bowMapMinus;
			}
			return bowMapPlus;
		}

		private void Awake()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			string text = Path.Combine(Paths.ConfigPath, "com.ganyuskin.huntress.cfg");
			if (File.Exists(text) && !File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath))
			{
				try
				{
					File.Move(text, ((BaseUnityPlugin)this).Config.ConfigFilePath);
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("could not move the old config " + text + ", using default settings: " + ex.Message));
				}
			}
			Physics = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Physics", true, "Hair and clothes physics (DynamicBone).");
			BreastJiggle = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BreastJiggle", 0.5f, new ConfigDescription("Breast jiggle while moving (needs Physics). 0.5 = default, 1 = twice as strong, 0 = off. Applies after a restart.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			EyesGlow = GlowSetting("Eyes", "Glow of Ganyu's eyes.");
			BowGlow = GlowSetting("Bow", "Glow of the Amos Bow's crystal spike and charms.");
			GemGlow = GlowSetting("Gem", "Glow of the Cryo Vision gem on Ganyu's hip.");
			try
			{
				Setup();
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Ganyu skin setup failed: " + ex2));
			}
			RecommendedModsNotice.Init(Log, "HuntressBody", () => Skin);
		}

		private ConfigEntry<float> GlowSetting(string key, string what)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			return ((BaseUnityPlugin)this).Config.Bind<float>("Glow", key, 0.5f, new ConfigDescription(what + " 0.5 = default, 1 = twice as bright, 0 = no glow.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		}

		private static float Power(ConfigEntry<float> setting, float atDefault)
		{
			return atDefault * setting.Value / 0.5f;
		}

		private void Setup()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			Template = SkinAssets.LoadTemplate(((BaseUnityPlugin)this).Info.Location, "ganyuskin", "mdlHuntress", out TplArmature);
			SkinAssets.ReadRestPose(TplArmature, RestRot, RestPos);
			Transform[] componentsInChildren = ((Component)TplArmature).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (!RestLocalPos.ContainsKey(((Object)val).name))
				{
					RestLocalPos[((Object)val).name] = val.localPosition;
					RestLocalRot[((Object)val).name] = val.localRotation;
				}
			}
			SetupBowMap();
			SkinnedMeshRenderer val2 = ((IEnumerable<SkinnedMeshRenderer>)Template.GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => ((Object)r).name == "AmosString"));
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2.sharedMesh != (Object)null)
			{
				Bounds bounds = val2.sharedMesh.bounds;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				StringHalfLength = ((Vector3)(ref extents)).magnitude;
			}
			Shader hg = SkinAssets.LoadHGStandard();
			Dictionary<string, Material> mats = new Dictionary<string, Material>();
			SkinnedMeshRenderer[] componentsInChildren2 = Template.GetComponentsInChildren<SkinnedMeshRenderer>(true);
			foreach (SkinnedMeshRenderer val3 in componentsInChildren2)
			{
				if (!Skipped.Contains(((Object)val3).name))
				{
					mats[((Object)val3).name] = ConvertMaterial(((Renderer)val3).sharedMaterial, hg, ((Object)val3).name);
					OurRenderers.Add(((Object)val3).name);
					LobbyMats[((Object)val3).name] = SkinAssets.LobbyVariant(mats[((Object)val3).name], ((Object)val3).name.StartsWith("Ganyu_") && ((Object)val3).name != "Ganyu_Eyes" && ((Object)val3).name != "Ganyu_Gem");
				}
			}
			Sprite icon = Skins.CreateSkinIcon(new Color(0.56f, 0.73f, 0.96f), new Color(0.92f, 0.95f, 1f), new Color(0.12f, 0.16f, 0.38f), new Color(0.85f, 0.69f, 0.4f), new Color(0.08f, 0.08f, 0.12f));
			Skin = SkinRegistration.Register("RoR2/Base/Huntress/HuntressBody.prefab", "RoR2/Base/Huntress/HuntressDisplay.prefab", (GameObject model) => Attach(model, mats), "skinHuntressGanyu", "GANYUSKIN_HUNTRESS_GANYU_NAME", "Ganyu", icon);
			Log.LogInfo((object)"GanyuHuntressSkin 1.0.0 ready.");
		}

		private static void SetupBowMap()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			if (new string[5] { "BowBase", "BowString.L", "BowString.R", "BowStringIKTarget", "gy_bow" }.Any((string n) => !RestRot.ContainsKey(n)))
			{
				Log.LogWarning((object)"bow bones not found, the Amos Bow follows the hand only");
				return;
			}
			Quaternion val = Quaternion.Inverse(RestRot["BowBase"]);
			Vector3 val2 = val * (RestPos["BowString.L"] - RestPos["BowString.R"]);
			Vector3 pull = val * (RestPos["BowStringIKTarget"] - RestPos["BowBase"]);
			Vector3 up = Vector3.up;
			Vector3 forward = Vector3.forward;
			Quaternion val3 = Quaternion.Inverse(Frame(up, forward));
			bowMapPlus = Frame(val2, pull) * val3;
			bowMapMinus = Frame(-val2, pull) * val3;
			HasBowMap = true;
			static Quaternion Frame(Vector3 axis, Vector3 val4)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				return Quaternion.LookRotation(Vector3.ProjectOnPlane(val4, axis), axis);
			}
		}

		private static RendererInfo[] Attach(GameObject model, Dictionary<string, Material> mats)
		{
			Dictionary<Transform, Transform> map;
			RendererInfo[] result = SkinAttach.Attach(model, Template, TplArmature, mats, RendererOrder, Skipped, 0.5f, out map);
			if (!Object.op_Implicit((Object)(object)model.GetComponent<GanyuState>()))
			{
				model.AddComponent<GanyuState>();
			}
			return result;
		}

		private static Material ConvertMaterial(Material src, Shader hg, string part)
		{
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			Material val = SkinAssets.NewHG(hg, "matGanyuSkin_" + part, src);
			bool flag = part.StartsWith("Ganyu_");
			SkinAssets.CopyColor(val, src);
			SkinAssets.CopyNormal(val, src);
			Texture val2 = SkinAssets.EmissionMap(src);
			if ((Object)(object)val2 != (Object)null)
			{
				SkinAssets.SetGlow(val, val2, (part == "AmosBow") ? Power(BowGlow, 3f) : ((part == "Ganyu_Gem") ? Power(GemGlow, 0.6f) : 1f));
			}
			if (!(part == "Ganyu_Gem"))
			{
				if (part == "Ganyu_Eyes")
				{
					SkinAssets.SetGlow(val, val.GetTexture("_MainTex"), Power(EyesGlow, 0.8f));
				}
				else if (flag)
				{
					float num = ((part == "Ganyu_Hair") ? 0.85f : 0.95f);
					val.SetColor("_Color", new Color(num, num, num));
				}
			}
			SkinAssets.SetSurface(val, flag ? 0.05f : 0.3f, part != "AmosBow");
			return val;
		}
	}
	[DefaultExecutionOrder(10000)]
	public class GanyuState : MonoBehaviour
	{
		private struct Pair
		{
			public Transform gy;

			public Transform hun;

			public Quaternion offset;
		}

		private SkinModel model;

		private ModelSpace ms;

		private SkinPhysics physics;

		private bool physicsBuilt;

		private bool active;

		private bool broken;

		private static bool brokenLogged;

		private Transform bowBase;

		private Transform gyBow;

		private int bowSign;

		private LineRenderer stringLine;

		private Transform stringL;

		private Transform stringMid;

		private Transform amosNock;

		private float idleDraw = -1f;

		private Vector3 rightHandShift;

		private const float ReachSoft = 0.85f;

		private const float ReachHard = 1f;

		private readonly Pair[] upperArm = new Pair[2];

		private readonly Pair[] lowerArm = new Pair[2];

		private readonly Pair[] hand = new Pair[2];

		private readonly Pair[] foot = new Pair[2];

		private Quaternion bowRestLocalRot;

		private Vector3 bowRestLocalPos;

		private Transform chest;

		private Pair neck;

		private Pair head;

		private Quaternion chestRest;

		private Quaternion headRestInv = Quaternion.identity;

		private Quaternion neckRest = Quaternion.identity;

		private const float NeckShare = 0.5f;

		private void Awake()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			model = new SkinModel((Component)(object)this, GanyuSkinPlugin.OurRenderers, GanyuSkinPlugin.HiddenRenderers, GanyuSkinPlugin.LobbyMats);
			ms = new ModelSpace(((Component)this).transform);
			bowBase = B("BowBase");
			gyBow = B("gy_bow");
			if ((Object)(object)gyBow != (Object)null)
			{
				gyBow.localScale = Vector3.one * 0.73f;
			}
			stringL = B("BowString.L");
			stringMid = B("BowStringIKTarget");
			amosNock = B("gy_bow_nock");
			stringLine = ((IEnumerable<LineRenderer>)((Component)((Component)this).transform.root).GetComponentsInChildren<LineRenderer>(true)).FirstOrDefault((Func<LineRenderer, bool>)((LineRenderer l) => ((Object)l).name == "BowString"));
			broken = !CheckBones();
			Apply(on: false);
		}

		private bool CheckBones()
		{
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			if (!model.Attached)
			{
				return true;
			}
			List<string> missing = new List<string>();
			for (int i = 0; i < 2; i++)
			{
				string text = ((i == 0) ? "l" : "r");
				upperArm[i] = P("upper_arm." + text);
				lowerArm[i] = P("lower_arm." + text);
				hand[i] = P("hand." + text);
				foot[i] = P("foot." + text);
			}
			neck = Proxy("gy_neck", "head");
			head = Proxy("gy_head", "head");
			if (GanyuSkinPlugin.RestRot.TryGetValue("head", out var value))
			{
				headRestInv = Quaternion.Inverse(value);
			}
			if ((Object)(object)neck.gy != (Object)null)
			{
				GanyuSkinPlugin.RestRot.TryGetValue(((Object)neck.gy).name, out neckRest);
			}
			chest = B("chest");
			if ((Object)(object)chest != (Object)null && !GanyuSkinPlugin.RestRot.TryGetValue(((Object)chest).name, out chestRest))
			{
				missing.Add(((Object)chest).name);
			}
			if ((Object)(object)gyBow != (Object)null && (!GanyuSkinPlugin.RestLocalRot.TryGetValue(((Object)gyBow).name, out bowRestLocalRot) || !GanyuSkinPlugin.RestLocalPos.TryGetValue(((Object)gyBow).name, out bowRestLocalPos)))
			{
				missing.Add(((Object)gyBow).name);
			}
			if (missing.Count == 0)
			{
				return true;
			}
			if (!brokenLogged)
			{
				brokenLogged = true;
				GanyuSkinPlugin.Log.LogError((object)("Ganyu skin turned off: the model in the asset bundle has no bone(s) " + string.Join(", ", missing) + " (bundle out of date or a game update renamed Huntress bones)"));
			}
			return false;
			Pair P(string part)
			{
				//IL_00b2: 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_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)
				Pair result = new Pair
				{
					gy = B("gy_" + part),
					hun = B(part)
				};
				if ((Object)(object)result.gy == (Object)null || (Object)(object)result.hun == (Object)null)
				{
					return result;
				}
				Quaternion value3;
				if (!GanyuSkinPlugin.RestRot.TryGetValue(((Object)result.hun).name, out var value2))
				{
					missing.Add(((Object)result.hun).name);
				}
				else if (!GanyuSkinPlugin.RestRot.TryGetValue(((Object)result.gy).name, out value3))
				{
					missing.Add(((Object)result.gy).name);
				}
				else
				{
					result.offset = Quaternion.Inverse(value2) * value3;
				}
				return result;
			}
			Pair Proxy(string gy, string hun)
			{
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//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)
				Pair result = new Pair
				{
					gy = B(gy),
					hun = B(hun)
				};
				if ((Object)(object)result.gy == (Object)null || (Object)(object)result.hun == (Object)null)
				{
					return result;
				}
				Quaternion value3;
				if (!GanyuSkinPlugin.RestRot.TryGetValue(hun, out var value2))
				{
					missing.Add(hun);
				}
				else if (!GanyuSkinPlugin.RestRot.TryGetValue(gy, out value3))
				{
					missing.Add(gy);
				}
				else
				{
					result.offset = Quaternion.Inverse(value2) * value3;
				}
				return result;
			}
		}

		private void Apply(bool on)
		{
			active = on;
			model.Show(on);
			bool flag = on && GanyuSkinPlugin.Physics.Value && !SkinPhysics.IsMirrored(((Component)this).transform);
			if (flag && !physicsBuilt)
			{
				physicsBuilt = true;
				BuildPhysics();
			}
			physics?.SetOn(flag);
		}

		private void LateUpdate()
		{
			if (broken)
			{
				return;
			}
			model.Track();
			bool flag = model.IsOn(GanyuSkinPlugin.Skin, "HuntressBody");
			if (flag != active)
			{
				Apply(flag);
			}
			if (active)
			{
				if (model.InLobby)
				{
					model.UseLobbyMaterials();
				}
				NeckAndHead();
				ArmRotation(0);
				ArmRotation(1);
				LeftArmHoldsBow();
				RightArmReach();
				Feet();
				FitBowString();
				physics?.Step(Time.deltaTime);
			}
		}

		private void FitBowString()
		{
			//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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)stringLine == (Object)null) && !((Object)(object)bowBase == (Object)null) && !((Object)(object)gyBow == (Object)null) && !((Object)(object)amosNock == (Object)null) && !((Object)(object)stringL == (Object)null) && !((Object)(object)stringMid == (Object)null) && stringLine.positionCount == 3 && !(GanyuSkinPlugin.StringHalfLength <= 0f))
			{
				Vector3 position = amosNock.position;
				Vector3 val = gyBow.TransformVector(new Vector3(0f, GanyuSkinPlugin.StringHalfLength, 0f));
				Vector3 val2 = position + val;
				Vector3 val3 = position - val;
				Vector3 val4 = val2 - stringL.position;
				float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
				val4 = val3 - stringL.position;
				if (sqrMagnitude > ((Vector3)(ref val4)).sqrMagnitude)
				{
					Vector3 val5 = val2;
					val2 = val3;
					val3 = val5;
				}
				stringLine.SetPosition(0, val2);
				stringLine.SetPosition(2, val3);
				val4 = stringMid.position - bowBase.position;
				float magnitude = ((Vector3)(ref val4)).magnitude;
				if (idleDraw < 0f || magnitude < idleDraw)
				{
					idleDraw = magnitude;
				}
				float num = Mathf.Clamp01((magnitude - idleDraw) / Mathf.Max(idleDraw * 0.5f, 0.0001f));
				stringLine.SetPosition(1, Vector3.Lerp(position, stringMid.position + rightHandShift, num));
			}
		}

		private Vector3 P(Transform t)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ms.P(t);
		}

		private Quaternion R(Transform t)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ms.R(t);
		}

		private void SetR(Transform t, Quaternion q)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			ms.SetR(t, q);
		}

		private Transform B(string n)
		{
			return model.B(n);
		}

		private void CopyDelta(in Pair p)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)p.gy == (Object)null) && !((Object)(object)p.hun == (Object)null))
			{
				SetR(p.gy, R(p.hun) * p.offset);
			}
		}

		private void NeckAndHead()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//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_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)head.gy == (Object)null) && !((Object)(object)head.hun == (Object)null))
			{
				Quaternion val = R(head.hun) * headRestInv;
				if ((Object)(object)neck.gy != (Object)null && (Object)(object)chest != (Object)null)
				{
					Quaternion val2 = R(chest) * Quaternion.Inverse(chestRest);
					Quaternion val3 = Quaternion.Inverse(val2) * val;
					Quaternion val4 = val2 * Quaternion.Slerp(Quaternion.identity, val3, 0.5f);
					SetR(neck.gy, val4 * neckRest);
				}
				CopyDelta(in head);
			}
		}

		private void ArmRotation(int i)
		{
			CopyDelta(in upperArm[i]);
			CopyDelta(in lowerArm[i]);
			CopyDelta(in hand[i]);
		}

		private void IK(Transform a, Transform b, Transform c, Vector3 target, Vector3 pole)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			ms.IK(a, b, c, target, pole);
		}

		private Vector3 Pole(Transform hu, Transform hl, Transform hh)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = P(hl);
			return val + (val - (P(hu) + P(hh)) * 0.5f);
		}

		private void LeftArmHoldsBow()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: 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_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Transform gy = upperArm[0].gy;
			Transform gy2 = lowerArm[0].gy;
			Transform gy3 = hand[0].gy;
			Transform hun = upperArm[0].hun;
			Transform hun2 = lowerArm[0].hun;
			Transform hun3 = hand[0].hun;
			if ((Object)(object)gy == (Object)null || (Object)(object)gy2 == (Object)null || (Object)(object)gy3 == (Object)null || (Object)(object)hun == (Object)null || (Object)(object)hun2 == (Object)null || (Object)(object)hun3 == (Object)null)
			{
				return;
			}
			if ((Object)(object)bowBase == (Object)null || (Object)(object)gyBow == (Object)null || !GanyuSkinPlugin.HasBowMap)
			{
				IK(gy, gy2, gy3, P(hun3), Pole(hun, hun2, hun3));
				CopyDelta(in hand[0]);
				return;
			}
			Quaternion val = bowRestLocalRot;
			if (bowSign == 0)
			{
				Quaternion val2 = R(gy3) * val;
				float num = Quaternion.Angle(val2, R(bowBase) * GanyuSkinPlugin.BowMap(1));
				float num2 = Quaternion.Angle(val2, R(bowBase) * GanyuSkinPlugin.BowMap(-1));
				bowSign = ((num <= num2) ? 1 : (-1));
			}
			Quaternion val3 = R(bowBase) * GanyuSkinPlugin.BowMap(bowSign) * Quaternion.Inverse(val);
			Vector3 val4 = val3 * (bowRestLocalPos * ms.Scale(gy3));
			IK(gy, gy2, gy3, P(bowBase) - val4, Pole(hun, hun2, hun3));
			SetR(gy3, val3);
		}

		private void RightArmReach()
		{
			//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_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			rightHandShift = Vector3.zero;
			Transform gy = upperArm[1].gy;
			Transform gy2 = lowerArm[1].gy;
			Transform gy3 = hand[1].gy;
			Transform hun = upperArm[1].hun;
			Transform hun2 = lowerArm[1].hun;
			Transform hun3 = hand[1].hun;
			if ((Object)(object)gy == (Object)null || (Object)(object)gy2 == (Object)null || (Object)(object)gy3 == (Object)null || (Object)(object)hun == (Object)null || (Object)(object)hun2 == (Object)null || (Object)(object)hun3 == (Object)null)
			{
				return;
			}
			Vector3 val = P(gy);
			Vector3 val2 = P(hun);
			Vector3 val3 = P(hun3);
			Vector3 val4 = P(gy2) - val;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			val4 = P(gy3) - P(gy2);
			float num = magnitude + ((Vector3)(ref val4)).magnitude;
			val4 = P(hun2) - val2;
			float magnitude2 = ((Vector3)(ref val4)).magnitude;
			val4 = val3 - P(hun2);
			float num2 = magnitude2 + ((Vector3)(ref val4)).magnitude;
			if (num > 1E-05f && num2 > 1E-05f)
			{
				val4 = val3 - val;
				float num3 = ((Vector3)(ref val4)).magnitude / num;
				float num4 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.85f, 1f, num3));
				if (num4 > 0f)
				{
					val3 = Vector3.Lerp(val3, val + (val3 - val2) * (num / num2), num4);
				}
			}
			IK(gy, gy2, gy3, val3, Pole(hun, hun2, hun3));
			CopyDelta(in hand[1]);
			rightHandShift = gy3.position - hun3.position;
		}

		private void Feet()
		{
			CopyDelta(in foot[0]);
			CopyDelta(in foot[1]);
		}

		private void BuildPhysics()
		{
			//IL_003f: 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_0093: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			if (!SkinPhysics.Available("Ganyu", (Action<string>)GanyuSkinPlugin.Log.LogError))
			{
				return;
			}
			List<DynamicBoneCollider> list = new List<DynamicBoneCollider>();
			List<DynamicBoneCollider> list2 = new List<DynamicBoneCollider>();
			Col(list2, "thigh.l", new Vector3(0f, 0.24f, 0f), 0.07f, 0.45f);
			Col(list2, "thigh.r", new Vector3(0f, 0.24f, 0f), 0.07f, 0.45f);
			Col(list2, "calf.l", new Vector3(0f, 0.22f, 0f), 0.05f, 0.4f);
			Col(list2, "calf.r", new Vector3(0f, 0.22f, 0f), 0.05f, 0.4f);
			Col(list, "pelvis", new Vector3(0f, 0.05f, 0f), 0.12f, 0f);
			Col(list, "chest", new Vector3(0f, 0.12f, 0f), 0.13f, 0.35f);
			List<DynamicBoneCollider> list3 = list.Concat(list2).ToList();
			physics = new SkinPhysics(((Component)this).transform, "GanyuPhysics");
			float value = GanyuSkinPlugin.BreastJiggle.Value;
			Transform value2;
			Transform value3;
			bool flag = value > 0f && model.bones.TryGetValue("dyn_Breast.L", out value2) && model.bones.TryGetValue("dyn_Breast.R", out value3) && SkinPhysics.AddBreastTips(((Component)this).transform, value2, value3, "chest", "gy_neck", GanyuSkinPlugin.RestPos, GanyuSkinPlugin.RestRot, 0.5f);
			foreach (Transform item in SkinPhysics.ChainRoots(model.bones))
			{
				if (SkinPhysics.IsBreast(item))
				{
					if (flag)
					{
						SkinPhysics.TuneBreast(physics.Add(item), value);
					}
					continue;
				}
				DynamicBone val = physics.Add(item);
				string text = ((Object)item).name.Substring(4);
				Vector3 value4;
				bool flag2 = GanyuSkinPlugin.RestPos.TryGetValue(((Object)item).name, out value4) && Mathf.Abs(value4.x) < 0.06f;
				val.m_Colliders = (flag2 ? list : list3);
				if (text.StartsWith("QB_") || text.StartsWith("HB_") || text.StartsWith("XB_"))
				{
					Set(val, 0.55f, 0.2f, 0.6f, 0.6f, 0.015f);
				}
				else if (text.StartsWith("HD_"))
				{
					Set(val, 0.45f, 0.12f, 0.35f, 0.6f, 0.015f);
				}
				else if (text.StartsWith("BLS_") || text.StartsWith("HeadOrn_") || text.StartsWith("WaistOrn_"))
				{
					Set(val, 0.5f, 0.15f, 0.5f, 0.6f, 0.015f);
				}
				else
				{
					Set(val, 0.5f, 0.25f, 0.75f, 0.7f, 0.01f);
				}
			}
			physics.Finish();
			void Col(List<DynamicBoneCollider> list4, string bone, Vector3 center, float radius, float height)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (model.bones.TryGetValue(bone, out var value5))
				{
					GameObject val2 = new GameObject("GanyuCollider");
					val2.transform.SetParent(value5, false);
					DynamicBoneCollider val3 = val2.AddComponent<DynamicBoneCollider>();
					val3.m_Center = center;
					val3.m_Radius = radius;
					val3.m_Height = height;
					val3.m_Direction = (Direction)1;
					val3.m_Bound = (Bound)0;
					list4.Add(val3);
				}
			}
		}

		private static void Set(DynamicBone d, float damping, float elasticity, float stiffness, float inert, float radius)
		{
			SkinPhysics.Tune(d, damping, elasticity, stiffness, inert, radius);
		}
	}
}