Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of KeqingMercenarySkin v1.0.0
KeqingMercenarySkin.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
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: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("KeqingMercenarySkin")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1fcfbc9aa9e837111921640ebe16a404100bfcad")] [assembly: AssemblyProduct("KeqingMercenarySkin")] [assembly: AssemblyTitle("KeqingMercenarySkin")] [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 KeqingSkin { [BepInPlugin("com.H1xl.KeqingMercenarySkin", "KeqingMercenarySkin", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class KeqingSkinPlugin : BaseUnityPlugin { public const string GUID = "com.H1xl.KeqingMercenarySkin"; public const string NAME = "KeqingMercenarySkin"; public const string VERSION = "1.0.0"; private const string TOKEN = "KEQINGSKIN_MERC_KEQING_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> SwordGlow; internal static ConfigEntry<float> GemGlow; private const float SWORD_SCALE = 0.8f; internal static readonly Color SwordLightColor = new Color(62f / 85f, 42f / 85f, 0.79607844f); internal static GameObject Template; internal static Transform TplModel; internal static readonly Dictionary<string, Quaternion> RestRot = new Dictionary<string, Quaternion>(); internal static readonly Dictionary<string, Vector3> RestPos = new Dictionary<string, Vector3>(); internal static Vector3 GripLeftPos; internal static Quaternion GripLeftRot; 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[2] { "MercMesh", "MercSwordMesh" }; private static readonly string[] RendererOrder = new string[6] { "Keqing_Sword", "Keqing_Eyes", "Keqing_Gem", "Keqing_Face", "Keqing_Hair", "Keqing_Body" }; private const float EyesPower = 1.5f; private const float SwordPower = 2f; private const float GemPower = 1.5f; internal static readonly Dictionary<string, Quaternion> Align = new Dictionary<string, Quaternion>(); internal static Vector3 Forward = Vector3.forward; internal static float ArmRatio = 1f; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; 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 Keqing's eyes."); SwordGlow = GlowSetting("Sword", "Glow of Mistsplitter Reforged's blade edge and gems, and of its light."); GemGlow = GlowSetting("Gem", "Glow of the Electro Vision gem on Keqing's collar."); try { Setup(); } catch (Exception ex) { Log.LogError((object)("Keqing skin setup failed: " + ex)); } RecommendedModsNotice.Init(Log, "MercBody", () => 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>())); } internal static float Power(ConfigEntry<float> setting, float atDefault) { return atDefault * setting.Value / 0.5f; } private void Setup() { //IL_0118: 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_0140: 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_0168: Unknown result type (might be due to invalid IL or missing references) Template = SkinAssets.LoadTemplate(((BaseUnityPlugin)this).Info.Location, "keqingskin", "mdlMerc", out TplModel); SkinAssets.ReadRestPose(TplModel, RestRot, RestPos); SetupLeftGrip(); SetupRetarget(); Shader hg = SkinAssets.LoadHGStandard(); Dictionary<string, Material> mats = new Dictionary<string, Material>(); SkinnedMeshRenderer[] componentsInChildren = Template.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { mats[((Object)val).name] = ConvertMaterial(((Renderer)val).sharedMaterial, hg, ((Object)val).name); OurRenderers.Add(((Object)val).name); LobbyMats[((Object)val).name] = SkinAssets.LobbyVariant(mats[((Object)val).name], ((Object)val).name != "Keqing_Sword" && ((Object)val).name != "Keqing_Gem"); } Sprite icon = Skins.CreateSkinIcon(new Color(0.47f, 0.36f, 0.68f), new Color(0.24f, 0.18f, 0.4f), new Color(0.93f, 0.91f, 0.97f), new Color(0.86f, 0.71f, 0.38f), new Color(0.08f, 0.07f, 0.12f)); Skin = SkinRegistration.Register("RoR2/Base/Merc/MercBody.prefab", "RoR2/Base/Merc/MercDisplay.prefab", (GameObject model) => Attach(model, mats), "skinMercKeqing", "KEQINGSKIN_MERC_KEQING_NAME", "Keqing", icon); Log.LogInfo((object)"KeqingMercenarySkin 1.0.0 ready."); } private static void SetupLeftGrip() { //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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008d: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00bd: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //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_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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_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) if (new string[5] { "kq_sword", "kq_grip.r", "kq_grip.l", "kq_hand.r", "kq_hand.l" }.Any((string n) => !RestRot.ContainsKey(n))) { throw new Exception("sword/grip bones missing in the model"); } Quaternion val = Quaternion.Inverse(RestRot["kq_sword"]); Vector3 val2 = val * (RestPos["kq_grip.r"] - RestPos["kq_sword"]); Quaternion val3 = val * RestRot["kq_grip.r"]; Vector3 val4 = val * (RestPos["kq_grip.l"] - RestPos["kq_sword"]); Vector3 normalized = ((Vector3)(ref val4)).normalized; Vector3 val5 = Vector3.ProjectOnPlane(val2, normalized); Vector3 val6 = Vector3.Cross(normalized, val5); Vector3 normalized2 = ((Vector3)(ref val6)).normalized; Matrix4x4 val7 = Matrix4x4.Scale(new Vector3(-1f, 1f, 1f)); Matrix4x4 val8 = Matrix4x4.Rotate(RestRot["kq_hand.r"]); Matrix4x4 val9 = Matrix4x4.Rotate(RestRot["kq_hand.l"]); Matrix4x4 val10 = val7 * val8 * val7; Matrix4x4 val11 = ((Matrix4x4)(ref val10)).inverse * val9; Matrix4x4 identity = Matrix4x4.identity; for (int num = 0; num < 3; num++) { for (int num2 = 0; num2 < 3; num2++) { ((Matrix4x4)(ref identity))[num, num2] = ((num == num2) ? 1f : 0f) - 2f * ((Vector3)(ref normalized2))[num] * ((Vector3)(ref normalized2))[num2]; } } Matrix4x4 val12 = identity * Matrix4x4.Rotate(val3) * val7 * val11; GripLeftRot = Quaternion.LookRotation(Vector4.op_Implicit(((Matrix4x4)(ref val12)).GetColumn(2)), Vector4.op_Implicit(((Matrix4x4)(ref val12)).GetColumn(1))); float num3 = Mathf.Abs(((Component)TplModel).GetComponentsInChildren<Transform>(true).First((Transform x) => ((Object)x).name == "kq_sword").lossyScale.x / TplModel.lossyScale.x); GripLeftPos = (val2 + val4) / num3; } private static void SetupRetarget() { //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) string[] array = new string[2] { "l", "r" }; foreach (string text in array) { (string, string, string, string)[] array2 = new(string, string, string, string)[4] { ("kq_upper_arm." + text, "kq_lower_arm." + text, "upper_arm." + text, "lower_arm." + text), ("kq_lower_arm." + text, "kq_hand." + text, "lower_arm." + text, "hand." + text), ("kq_thigh." + text, "kq_calf." + text, "thigh." + text, "calf." + text), ("kq_calf." + text, "kq_foot." + text, "calf." + text, "foot." + text) }; for (int j = 0; j < array2.Length; j++) { (string, string, string, string) tuple = array2[j]; if (new string[4] { tuple.Item1, tuple.Item2, tuple.Item3, tuple.Item4 }.All(RestPos.ContainsKey)) { Align[tuple.Item1] = Quaternion.FromToRotation(Dir(tuple.Item1, tuple.Item2), Dir(tuple.Item3, tuple.Item4)); } } if (Align.TryGetValue("kq_lower_arm." + text, out var value)) { Align["kq_hand." + text] = value; } } if (RestPos.ContainsKey("toe.l") && RestPos.ContainsKey("foot.l")) { Vector3 val = Dir("foot.l", "toe.l"); val.y = 0f; if (((Vector3)(ref val)).sqrMagnitude > 1E-06f) { Forward = ((Vector3)(ref val)).normalized; } } ArmRatio = Arm("kq_upper_arm.l", "kq_lower_arm.l", "kq_hand.l") / Arm("upper_arm.l", "lower_arm.l", "hand.l"); static float Arm(string u, string l, string h) { //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_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) Vector3 val2 = Dir(u, l); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = Dir(l, h); return magnitude + ((Vector3)(ref val2)).magnitude; } static Vector3 Dir(string a, string b) { //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) return RestPos[b] - RestPos[a]; } } private static RendererInfo[] Attach(GameObject model, Dictionary<string, Material> mats) { //IL_0053: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Dictionary<Transform, Transform> map; RendererInfo[] result = SkinAttach.Attach(model, Template, TplModel, mats, RendererOrder, null, 0.8f, out map); Transform val = ((IEnumerable<Transform>)map.Values).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "kq_grip.l")); if ((Object)(object)val != (Object)null) { val.localPosition = GripLeftPos; val.localRotation = GripLeftRot; } Transform val2 = ((IEnumerable<Transform>)map.Values).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "kq_sword")); if ((Object)(object)val2 != (Object)null) { val2.localScale *= 0.8f; } if (!Object.op_Implicit((Object)(object)model.GetComponent<KeqingState>())) { model.AddComponent<KeqingState>(); } return result; } private static Material ConvertMaterial(Material src, Shader hg, string part) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) Material val = SkinAssets.NewHG(hg, "matKeqingSkin_" + part, src); bool flag = part == "Keqing_Sword"; Texture val2 = SkinAssets.EmissionMap(src); if ((part == "Keqing_Body" || part == "Keqing_Gem" || flag) && (Object)(object)val2 != (Object)null) { SkinAssets.SetGlow(val, val2, flag ? Power(SwordGlow, 2f) : ((part == "Keqing_Gem") ? Power(GemGlow, 1.5f) : Power(EyesGlow, 1.5f))); } if (!flag) { float num = ((part == "Keqing_Hair") ? 0.88f : 0.95f); val.SetColor("_Color", new Color(num, num, num)); } SkinAssets.SetSurface(val, flag ? 0.4f : 0.05f, !flag); return val; } } [DefaultExecutionOrder(10000)] public class KeqingState : MonoBehaviour { private struct Bone { public Transform kq; public Transform merc; public Quaternion mercRestInv; public Quaternion kqRest; } private sealed class SkirtPanel { public Transform root; public Quaternion rest; public Vector3 tipOffset; public Vector3 outward; public readonly float[] near = new float[2]; public Quaternion follow = Quaternion.identity; } private sealed class Col { public DynamicBoneCollider c; public Vector3 a; public Vector3 b; public float radius; } private const float HEEL_EXTRA = 0.037f; private const float NEAR = 0.12f; private const float FAR = 0.35f; private const float FOREARM_ROLL = 0.75f; private const float SKIRT_TOP = 0.12f; private const float SKIRT_BOTTOM = -0.22f; private const float HAND_MARGIN = 0.05f; private static readonly Vector3 SkirtTop = new Vector3(0.18f, 0.2f, 0.05f); private static readonly Vector3 SkirtHem = new Vector3(0.29f, 0.3f, 0.19f); private SkinModel model; private ModelSpace ms; private CharacterModel characterModel; private SkinPhysics physics; private bool physicsBuilt; private readonly List<SkirtPanel> skirts = new List<SkirtPanel>(); private bool active; private bool broken; private static bool brokenLogged; private readonly Dictionary<Light, Color> lightColors = new Dictionary<Light, Color>(); private readonly float[] gripWeight = new float[2] { -1f, -1f }; private Transform sword; private Vector3 swordRestLocal; private Quaternion swordRestRot; private Bone neck; private Bone head; private Bone pelvis; private Bone stomach; private Bone chest; private Bone spine; private Bone spine1; private Vector3 spineAxis = Vector3.up; private readonly Bone[] thigh = new Bone[2]; private readonly Bone[] calf = new Bone[2]; private readonly Bone[] foot = new Bone[2]; private readonly Bone[] toe = new Bone[2]; private readonly Bone[] upperArm = new Bone[2]; private readonly Bone[] lowerArm = new Bone[2]; private readonly Bone[] hand = new Bone[2]; private readonly Transform[] grip = (Transform[])(object)new Transform[2]; private readonly Transform[] swordHandPlacement = (Transform[])(object)new Transform[2]; private readonly Transform[] ku = (Transform[])(object)new Transform[2]; private readonly Transform[] kl = (Transform[])(object)new Transform[2]; private readonly Transform[] kh = (Transform[])(object)new Transform[2]; private readonly Transform[] mu = (Transform[])(object)new Transform[2]; private readonly Transform[] ml = (Transform[])(object)new Transform[2]; private readonly Transform[] mh = (Transform[])(object)new Transform[2]; private readonly float[] w = new float[2]; private readonly Vector3[] extra = (Vector3[])(object)new Vector3[2]; private Quaternion skirtPd; private Vector3 skirtPp; private readonly HashSet<Light> swordLights = new HashSet<Light>(); private void Awake() { //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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) model = new SkinModel((Component)(object)this, KeqingSkinPlugin.OurRenderers, KeqingSkinPlugin.HiddenRenderers, KeqingSkinPlugin.LobbyMats); characterModel = model.characterModel; ms = new ModelSpace(((Component)this).transform); sword = B("kq_sword"); if ((Object)(object)sword != (Object)null) { swordRestLocal = sword.localPosition; swordRestRot = sword.localRotation; } BuildSkirts(); ((Component)this).gameObject.AddComponent<KeqingSkirtDriver>().state = this; broken = !CheckBones(); if (!broken) { CacheBones(); } Apply(on: false); } private void CacheBones() { //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_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_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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) neck = Make("neck"); head = Make("head"); pelvis = Make("pelvis"); stomach = Make("stomach"); chest = Make("chest"); spine = Make("spine"); spine1 = Make("spine1"); Dictionary<string, Vector3> restPos = KeqingSkinPlugin.RestPos; if (restPos.TryGetValue("pelvis", out var value) && restPos.TryGetValue("chest", out var value2)) { Vector3 val = value2 - value; if (((Vector3)(ref val)).sqrMagnitude > 1E-08f) { val = value2 - value; spineAxis = ((Vector3)(ref val)).normalized; } } for (int i = 0; i < 2; i++) { string text = ((i == 0) ? "l" : "r"); thigh[i] = Make("thigh." + text); calf[i] = Make("calf." + text); foot[i] = Make("foot." + text); toe[i] = Make("toe." + text); upperArm[i] = Make("upper_arm." + text); lowerArm[i] = Make("lower_arm." + text); hand[i] = Make("hand." + text); grip[i] = B("kq_grip." + text); swordHandPlacement[i] = B("SwordHandPlacement." + text); ku[i] = upperArm[i].kq; kl[i] = lowerArm[i].kq; kh[i] = hand[i].kq; mu[i] = upperArm[i].merc; ml[i] = lowerArm[i].merc; mh[i] = hand[i].merc; } Bone Make(string part) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0070: 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_00b3: 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_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) Bone result = new Bone { kq = B("kq_" + part), merc = B(part), mercRestInv = Quaternion.identity, kqRest = Quaternion.identity }; Dictionary<string, Quaternion> restRot = KeqingSkinPlugin.RestRot; if ((Object)(object)result.merc != (Object)null && restRot.TryGetValue(part, out var value3)) { result.mercRestInv = Quaternion.Inverse(value3); } if ((Object)(object)result.kq != (Object)null && restRot.TryGetValue("kq_" + part, out var value4)) { result.kqRest = (KeqingSkinPlugin.Align.TryGetValue("kq_" + part, out var value5) ? value5 : Quaternion.identity) * value4; } return result; } } private bool CheckBones() { if (!model.Attached) { return true; } List<string> list = new List<string>(); List<string> list2 = new List<string> { "neck", "head", "pelvis", "stomach", "chest", "spine", "spine1" }; string[] array = new string[2] { "l", "r" }; foreach (string text in array) { string[] array2 = new string[7] { "thigh.", "calf.", "foot.", "toe.", "upper_arm.", "lower_arm.", "hand." }; foreach (string text2 in array2) { list2.Add(text2 + text); } } foreach (string item in list2.Concat(list2.Select((string n) => "kq_" + n))) { if ((Object)(object)B(item) != (Object)null && !KeqingSkinPlugin.RestRot.ContainsKey(item)) { list.Add(item); } } if (list.Count == 0) { return true; } if (!brokenLogged) { brokenLogged = true; KeqingSkinPlugin.Log.LogError((object)("Keqing skin turned off: the model in the asset bundle has no bone(s) " + string.Join(", ", list) + " (bundle out of date or a game update renamed Mercenary bones)")); } return false; } private void Apply(bool on) { active = on; model.Show(on); bool flag = on && KeqingSkinPlugin.Physics.Value && !SkinPhysics.IsMirrored(((Component)this).transform); if (flag && !physicsBuilt) { physicsBuilt = true; BuildPhysics(); } physics?.SetOn(flag); if (on && model.InLobby) { model.UseLobbyMaterials(); } if (!on) { RestoreLights(); } } private void SetLights() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) LightInfo[] array = (((Object)(object)characterModel != (Object)null) ? characterModel.baseLightInfos : null); if (array == null) { return; } Color val = KeqingSkinPlugin.SwordLightColor * KeqingSkinPlugin.Power(KeqingSkinPlugin.SwordGlow, 1f); for (int i = 0; i < array.Length; i++) { Light light = array[i].light; if ((Object)(object)light == (Object)null) { continue; } if (!lightColors.ContainsKey(light)) { lightColors[light] = array[i].defaultColor; if ((Object)(object)((Component)light).transform.parent != (Object)null && ((Object)((Component)light).transform.parent).name == "SwordBase") { swordLights.Add(light); } } array[i].defaultColor = (swordLights.Contains(light) ? val : Color.black); } } private void RestoreLights() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) LightInfo[] array = (((Object)(object)characterModel != (Object)null) ? characterModel.baseLightInfos : null); if (array == null) { return; } for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i].light != (Object)null && lightColors.TryGetValue(array[i].light, out var value)) { array[i].defaultColor = value; } } } private void LateUpdate() { if (broken) { return; } model.Track(); bool flag = model.IsOn(KeqingSkinPlugin.Skin, "MercBody"); if (flag != active) { Apply(flag); } if (active) { if (model.InLobby) { model.UseLobbyMaterials(); } SetLights(); Waist(); CopyDelta(in neck); CopyDelta(in head); Leg(0); Leg(1); Arms(); physics?.Step(Time.deltaTime); } } private Transform B(string n) { return model.B(n); } 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 Quaternion Delta(in Bone b) { //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_0012: Unknown result type (might be due to invalid IL or missing references) return R(b.merc) * b.mercRestInv; } private void CopyDelta(in Bone b) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)b.kq == (Object)null) && !((Object)(object)b.merc == (Object)null)) { SetR(b.kq, Delta(in b) * b.kqRest); } } 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 static Quaternion Twist(Quaternion q, Vector3 axis) { //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_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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0056: 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_0064: 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_00ae: 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_0090: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = axis * Vector3.Dot(new Vector3(q.x, q.y, q.z), axis); Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(val.x, val.y, val.z, q.w); float num = Mathf.Sqrt(val2.x * val2.x + val2.y * val2.y + val2.z * val2.z + val2.w * val2.w); if (!(num < 1E-06f)) { return new Quaternion(val2.x / num, val2.y / num, val2.z / num, val2.w / num); } return Quaternion.identity; } private void Waist() { //IL_0067: 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_006d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0094: 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_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00cb: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)spine.kq == (Object)null) && !((Object)(object)spine1.kq == (Object)null) && !((Object)(object)pelvis.merc == (Object)null) && !((Object)(object)stomach.merc == (Object)null) && !((Object)(object)chest.merc == (Object)null)) { Quaternion val = Delta(in pelvis); Quaternion val2 = Quaternion.Inverse(val); Vector3 axis = val * spineAxis; Quaternion val3 = Delta(in stomach) * val2; Quaternion val4 = val3 * Quaternion.Inverse(Twist(val3, axis)); Quaternion val5 = Twist(Delta(in chest) * val2, axis); SetR(spine.kq, val4 * Quaternion.Slerp(Quaternion.identity, val5, 1f / 3f) * val * spine.kqRest); SetR(spine1.kq, val4 * Quaternion.Slerp(Quaternion.identity, val5, 2f / 3f) * val * spine1.kqRest); } } private void Leg(int i) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00fd: 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) //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_011f: Unknown result type (might be due to invalid IL or missing references) Transform kq = thigh[i].kq; Transform kq2 = calf[i].kq; Transform kq3 = foot[i].kq; Transform merc = thigh[i].merc; Transform merc2 = calf[i].merc; Transform merc3 = foot[i].merc; if (!((Object)(object)kq == (Object)null) && !((Object)(object)kq2 == (Object)null) && !((Object)(object)kq3 == (Object)null) && !((Object)(object)merc == (Object)null) && !((Object)(object)merc2 == (Object)null) && !((Object)(object)merc3 == (Object)null)) { CopyDelta(in thigh[i]); CopyDelta(in calf[i]); Vector3 pole = P(kq2) + Delta(in thigh[i]) * KeqingSkinPlugin.Forward * 0.5f; IK(kq, kq2, kq3, P(merc3) + Vector3.up * 0.037f, pole); CopyDelta(in foot[i]); CopyDelta(in toe[i]); } } private float HandGap(int i) { //IL_0035: 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) Transform merc = hand[i].merc; Transform val = swordHandPlacement[i]; if (!((Object)(object)merc != (Object)null) || !((Object)(object)val != (Object)null)) { return 99f; } Vector3 val2 = P(merc) - P(val); return ((Vector3)(ref val2)).magnitude; } private void Arms() { //IL_0117: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_0192: 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_0198: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_01f4: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 2; i++) { if ((Object)(object)ku[i] == (Object)null || (Object)(object)kl[i] == (Object)null || (Object)(object)kh[i] == (Object)null || (Object)(object)mu[i] == (Object)null || (Object)(object)ml[i] == (Object)null || (Object)(object)mh[i] == (Object)null) { return; } float num = Mathf.InverseLerp(0.35f, 0.12f, HandGap(i)); w[i] = ((gripWeight[i] < 0f) ? num : Mathf.MoveTowards(gripWeight[i], num, Time.deltaTime * 6f)); gripWeight[i] = w[i]; } if ((Object)(object)sword == (Object)null || (Object)(object)grip[0] == (Object)null || (Object)(object)grip[1] == (Object)null) { return; } if ((Object)(object)pelvis.merc != (Object)null) { skirtPd = Delta(in pelvis); skirtPp = P(pelvis.merc); } float num2 = 0f; if (model.InLobby) { num2 = 1f - w[1]; w[1] = 1f; w[0] *= 1f - num2; } extra[0] = (extra[1] = Vector3.zero); for (int j = 0; j < 3; j++) { SolveArms(num2); bool flag = true; for (int k = 0; k < 2; k++) { Vector3 val = ForearmOverlap(kl[k], kh[k]); if (!(((Vector3)(ref val)).sqrMagnitude < 1E-06f)) { ref Vector3 reference = ref extra[k]; reference += val; flag = false; } } if (flag) { break; } } } private void PutSwordInHand(Transform hand, Transform grip, float 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) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_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_0063: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Quaternion.Inverse(R(sword)); Quaternion val2 = val * R(grip); Vector3 val3 = val * (P(grip) - P(sword)); Quaternion val4 = R(hand) * Quaternion.Inverse(val2); Vector3 val5 = P(hand) - val4 * val3; Vector3 val6 = P(sword); SetR(sword, Quaternion.Slerp(R(sword), val4, t)); sword.position = ((Component)this).transform.TransformPoint(Vector3.Lerp(val6, val5, t)); } private Vector3 ForearmOverlap(Transform elbow, Transform wrist) { //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_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_001a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_004e: Unknown result type (might be due to invalid IL or missing references) Vector3 val = P(elbow); Vector3 val2 = P(wrist); Vector3 result = Vector3.zero; for (int i = 1; i <= 4; i++) { Vector3 val3 = Vector3.Lerp(val, val2, (float)i / 4f); Vector3 val4 = OutOfSkirt(val3) - val3; if (((Vector3)(ref val4)).sqrMagnitude > ((Vector3)(ref result)).sqrMagnitude) { result = val4; } } return result; } private void SolveArms(float hold) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_0117: 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_0129: 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_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_01d6: 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_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: 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_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: 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_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: 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_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0399: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_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_0207: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0226: 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_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 2; i++) { CopyDelta(in upperArm[i]); CopyDelta(in lowerArm[i]); CopyDelta(in hand[i]); } sword.localPosition = swordRestLocal; sword.localRotation = swordRestRot; if (hold > 0.001f) { PutSwordInHand(kh[1], grip[1], hold); } Vector3 val = Vector3.zero; float num = 0f; float num2 = Mathf.Max(w[0], w[1]); for (int j = 0; j < 2; j++) { if (!(w[j] <= 0.001f)) { Vector3 val2 = (P(mh[j]) - P(mu[j])) * KeqingSkinPlugi