// Warning: Some assembly references could not be resolved automatically. This might lead to incorrect decompilation of some parts, // for ex. property getter/setter access. To get optimal decompilation results, please manually add the missing references to the list of loaded assemblies. // EdenAutoMorpherScript, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // Eden.AutoMorpher.profile.ProfileLoader using System; using System.Collections.Generic; using System.IO; using System.Text; using UnityEngine; public class ProfileLoader { private ProfileData loadedProfileData; private const int HEX32_W = 8; public List GetProfileList() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ProfileUtils val = new ProfileUtils(); string text = Path.Combine(Application.dataPath, val.GetProfileBasePath()); List list = new List(); if (!Directory.Exists(text)) { Debug.LogWarning((object)("[ProfileUtils] Profile base path does not exist: " + text)); return list; } string[] directories = Directory.GetDirectories(text); foreach (string text2 in directories) { string fileName = Path.GetFileName(text2); if (!string.IsNullOrEmpty(fileName)) { string path = Path.Combine(text2, fileName + ".json"); string path2 = Path.Combine(text2, fileName + ".eb"); if (File.Exists(path) && File.Exists(path2)) { list.Add(fileName); } } } return list; } public ProfileData LoadProfileData(string profileName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ProfileUtils val = new ProfileUtils(); string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); path = Path.Combine(path, profileName); path = Path.Combine(path, profileName + ".json"); if (string.IsNullOrWhiteSpace(path)) { throw new AutoMorpherException("Profile File Path is Invalid", "[ProfileLoader] LoadProfileData\n - Profile Path is null, empty, or whitespace"); } if (!File.Exists(path)) { throw new AutoMorpherException("Profile File Does Not Exist", "[ProfileLoader] LoadProfileData\n - profile file does not exist\n - path : " + path); } string text = File.ReadAllText(path); this.loadedProfileData = JsonUtility.FromJson(text); if (this.loadedProfileData == null) { throw new AutoMorpherException("Failed to Load Profile Data", "[ProfileLoader] LoadProfileData\n - Can't Load Profile Data\n - Please place a valid profile data file at " + path); } return this.loadedProfileData; } public BvhTriangleMesh LoadBvhWithRootTransform(Transform rootTransform, string profileName) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00a0: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_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_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_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_014e: 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_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_015e: 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_017c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_018e: 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_0197: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_0244: 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_0252: Unknown result type (might be due to invalid IL or missing references) ProfileUtils val = new ProfileUtils(); string path = Path.Combine(Application.dataPath, val.GetProfileBasePath()); path = Path.Combine(path, profileName); path = Path.Combine(path, profileName + ".eb"); if (rootTransform == null) { throw new AutoMorpherException("Root Transform is Null", "[ProfileLoader] LoadBvhWithRootTransform\n - rootTransform is null"); } if (string.IsNullOrEmpty(path)) { throw new AutoMorpherException("Profile BVH Path is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profileBvhPath is null or empty"); } int version; ProfileBVH val2 = this.LoadProfileBVHData(path, out version); if (val2 == null || val2.vertices == null || val2.datas == null || val2.nodes == null || val2.dataIndices == null) { throw new AutoMorpherException("Profile BVH Data is Invalid", "[ProfileLoader] LoadBvhWithRootTransform\n - profile or one of its internal data fields is null"); } Matrix4x4 localToWorldMatrix = rootTransform.localToWorldMatrix; int num = val2.datas.Length; BvhTriangleMesh bvhTriangleMesh = new BvhTriangleMesh { triangles = new BvhTriangle[num], triIndices = new int[val2.dataIndices.Length], nodes = new BvhNode[val2.nodes.Length] }; for (int i = 0; i < num; i++) { profileBVHData val3 = val2.datas[i]; Vector3 val4 = val2.vertices[val3.verA]; Vector3 val5 = val2.vertices[val3.verB]; Vector3 val6 = val2.vertices[val3.verC]; Vector3 a = localToWorldMatrix.MultiplyPoint3x4(val4); Vector3 b = localToWorldMatrix.MultiplyPoint3x4(val5); Vector3 c = localToWorldMatrix.MultiplyPoint3x4(val6); Vector3 normal = this.ComputeTriangleNormal(a, b, c); bvhTriangleMesh.triangles[i] = new BvhTriangle { a = a, b = b, c = c, normal = normal, mainHumanBone = (HumanBodyBones)55 }; } Array.Copy(val2.dataIndices, bvhTriangleMesh.triIndices, val2.dataIndices.Length); for (int j = 0; j < val2.nodes.Length; j++) { profileBVHNode val7 = val2.nodes[j]; bvhTriangleMesh.nodes[j] = new BvhNode { isLeaf = val7.isLeaf, leftChild = val7.leftChild, rightChild = val7.rightChild, start = val7.start, count = val7.count, bounds = this.TransformBoundsToWorldAABB(localToWorldMatrix, val7.bounds) }; } return bvhTriangleMesh; } private ProfileBVH LoadProfileBVHData(string path, out int version) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0179: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Expected O, but got Unknown //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Expected O, but got Unknown version = 0; int num = 0; if (!File.Exists(path)) { throw new AutoMorpherException("Profile BVH File Not Found", "[ProfileLoader] LoadProfileBVHData\n - file not found\n - path : " + path); } string text = File.ReadAllText(path, Encoding.UTF8); int num2 = 0; ProfileUtils val = new ProfileUtils(); string profileMagic = val.GetProfileMagic(); if (text.Length < profileMagic.Length || text.Substring(0, profileMagic.Length) != profileMagic) { throw new AutoMorpherException("Profile BVH Magic Mismatch", "[ProfileLoader] LoadProfileBVHData\n - magic string mismatch\n - invalid or corrupted BVH file"); } num2 += profileMagic.Length; version = this.ReadHexIntSafe(text, ref num2); num = this.ReadHexIntSafe(text, ref num2); int num3 = this.ReadHexIntSafe(text, ref num2); int num4 = this.ReadHexIntSafe(text, ref num2); int num5 = this.ReadHexIntSafe(text, ref num2); int num6 = this.ReadHexIntSafe(text, ref num2); if (num3 < 0 || num4 < 0 || num5 < 0 || num6 < 0) { throw new AutoMorpherException("Profile BVH Count Data is Invalid", "[ProfileLoader] LoadProfileBVHData\n - one or more count values are negative"); } Vector3[] array = (Vector3[])(object)new Vector3[num3]; for (int i = 0; i < num3; i++) { array[i] = this.ReadHexVec3Safe(text, ref num2); } int num7 = default(int); int num8 = default(int); BaseKey3[] array2 = new ProfileUtils_VertexUtil().LoadTable(val.GetBaseDataPath(), out num7, out num8); if (array2 == null || array2.Length == 0) { throw new AutoMorpherException("Profile BVH Base Vertex Table is Invalid", "[ProfileLoader] LoadProfileBVHData\n - base vertex table is null or empty"); } ProfileUtil_IndexUtil val2 = new ProfileUtil_IndexUtil(9783); val2.Build(num); Vector3[] array3 = (Vector3[])(object)new Vector3[num3]; val2.DecodeInto(array, array3); Vector3[] array4 = (Vector3[])(object)new Vector3[num3]; for (int j = 0; j < num3; j++) { array4[j] = this.TransformVec3(array3[j], array2[j % array2.Length]); } ProfileBVH val3 = new ProfileBVH { vertices = new List(num3), datas = (profileBVHData[])(object)new profileBVHData[num4], nodes = (profileBVHNode[])(object)new profileBVHNode[num5], dataIndices = new int[num6] }; val3.vertices.AddRange(array4); for (int k = 0; k < num4; k++) { val3.datas[k] = new profileBVHData { verA = this.ReadHexIntSafe(text, ref num2), verB = this.ReadHexIntSafe(text, ref num2), verC = this.ReadHexIntSafe(text, ref num2) }; } for (int l = 0; l < num5; l++) { Vector3 val4 = this.ReadHexVec3Safe(text, ref num2); Vector3 val5 = this.ReadHexVec3Safe(text, ref num2); val3.nodes[l] = new profileBVHNode { bounds = new Bounds(val4, val5 * 2f), leftChild = this.ReadHexIntSafe(text, ref num2), rightChild = this.ReadHexIntSafe(text, ref num2), start = this.ReadHexIntSafe(text, ref num2), count = this.ReadHexIntSafe(text, ref num2), isLeaf = (num2 < text.Length && text[num2++] == '1') }; } for (int m = 0; m < num6; m++) { val3.dataIndices[m] = this.ReadHexIntSafe(text, ref num2); } return val3; } private int ReadHexIntSafe(string s, ref int p) { if (p + 8 > s.Length) { p = s.Length; throw new AutoMorpherException("Profile BVH ReadHexInt Out of Range", "[ProfileBVH] ReadHexIntSafe\n - read position exceeds string length"); } uint result = Convert.ToUInt32(s.Substring(p, 8), 16); p += 8; return (int)result; } private Vector3 ReadHexVec3Safe(string s, ref int p) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Vector3(this.ReadHexFloatSafe(s, ref p), this.ReadHexFloatSafe(s, ref p), this.ReadHexFloatSafe(s, ref p)); } private float ReadHexFloatSafe(string s, ref int p) { if (p + 8 > s.Length) { p = s.Length; throw new AutoMorpherException("Profile BVH ReadHexFloat Out of Range", "[ProfileBVH] ReadHexFloat\n - read position exceeds string length"); } uint value = Convert.ToUInt32(s.Substring(p, 8), 16); p += 8; return BitConverter.Int32BitsToSingle((int)value); } private Vector3 TransformVec3(Vector3 v, BaseKey3 k) { //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_0013: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) return new Vector3(this.TransformFloatBits(v.x, k.x), this.TransformFloatBits(v.y, k.y), this.TransformFloatBits(v.z, k.z)); } private float TransformFloatBits(float a, uint keyBits) { return BitConverter.Int32BitsToSingle(BitConverter.SingleToInt32Bits(a) ^ (int)keyBits); } private Vector3 ComputeTriangleNormal(Vector3 a, Vector3 b, Vector3 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(b - a, c - a); float magnitude = val.magnitude; if (magnitude > 1E-08f) { return val / magnitude; } return Vector3.up; } private Bounds TransformBoundsToWorldAABB(Matrix4x4 l2w, Bounds localBounds) { //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_0013: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_00fe: 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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_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_0124: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: 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_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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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) //IL_0174: 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_018c: 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_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) Vector3 center = localBounds.center; Vector3 extents = localBounds.extents; Vector3 val = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z)); Vector3 p = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, 0f - extents.y, extents.z)); Vector3 p2 = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, 0f - extents.z)); Vector3 p3 = l2w.MultiplyPoint3x4(center + new Vector3(0f - extents.x, extents.y, extents.z)); Vector3 p4 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z)); Vector3 p5 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, 0f - extents.y, extents.z)); Vector3 p6 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, 0f - extents.z)); Vector3 p7 = l2w.MultiplyPoint3x4(center + new Vector3(extents.x, extents.y, extents.z)); Vector3 min = val; Vector3 max = val; this.Encapsulate(ref min, ref max, p); this.Encapsulate(ref min, ref max, p2); this.Encapsulate(ref min, ref max, p3); this.Encapsulate(ref min, ref max, p4); this.Encapsulate(ref min, ref max, p5); this.Encapsulate(ref min, ref max, p6); this.Encapsulate(ref min, ref max, p7); return new Bounds((min + max) * 0.5f, max - min); } private void Encapsulate(ref Vector3 min, ref Vector3 max, Vector3 p) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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) min = Vector3.Min(min, p); max = Vector3.Max(max, p); } }