Decompiled source of The CH1M3R4 Model Pack v0.2.7
plugins/CH1M3R4.Body.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Newtonsoft.Json; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("ch1m3r4.body", "CH1M3R4 Full Body", "0.1.7")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class TetoBody : BaseUnityPlugin { [Serializable] private sealed class Palette { public Entry[] items; } [Serializable] private sealed class Entry { public string name; public string image; public float[] color; public float rough; public bool cutout; } private sealed class Joint { public Transform Source; public Transform Target; public Quaternion StockRest; public Quaternion TargetRest; public Quaternion TargetLocalRest; } private sealed class Body { public SkinnedMeshRenderer Stock; public SkinnedMeshRenderer[] Renderers; public Transform Model; public Transform Hips; public Transform StockHips; public Vector3 HipRest; public Vector3 StockHipRest; public Joint[] Joints; public Animator Animator; public Quaternion Basis; public SkinnedMeshRenderer ArmHost; public SkinnedMeshRenderer Heavy; public SkinnedMeshRenderer Hook; public Mesh FullMesh; public Mesh CutMesh; public WeaponVisual[] Weapons; public bool PreviousForceOff; public bool PreviousOffscreen; public bool Mannequin; public bool RestingProp; } private sealed class WeaponVisual { public Transform Root; public Vector3 BeforeRender; public bool Moved; } private static readonly FieldInfo[] WeaponFields = (from name in new string[2] { "weapons", "altweapons" } select typeof(PlayerAnimations).GetField(name, BindingFlags.Instance | BindingFlags.NonPublic) into field where field != null select field).ToArray(); private readonly List<Body> bodies = new List<Body>(); private readonly HashSet<int> attempted = new HashSet<int>(); private readonly Dictionary<string, Material> materials = new Dictionary<string, Material>(); private readonly Dictionary<Animator, AnimatorCullingMode> animatorModes = new Dictionary<Animator, AnimatorCullingMode>(); private AssetBundle bundle; private GameObject prefab; private Shader reflectionShader; private float nextSearch; private int renderDepth; private const int LeftUpperArm = 7; private const int RightUpperArm = 20; private void Awake() { //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Expected O, but got Unknown //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Expected O, but got Unknown //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Expected O, but got Unknown //IL_01c8: Unknown result type (might be due to invalid IL or missing references) if (!((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "FullBodyEnabled", true, "Replace V1's third-person body in mirrors and Clash Mode. Takes effect on restart.").Value) { return; } try { bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "ch1m3r4body")); if (!Object.op_Implicit((Object)(object)bundle)) { throw new IOException("Could not load ch1m3r4body"); } prefab = bundle.LoadAsset<GameObject>("Assets/CH1M3R4.fbx"); if (!Object.op_Implicit((Object)(object)prefab)) { throw new IOException("CH1M3R4 prefab missing"); } Palette palette = JsonConvert.DeserializeObject<Palette>(bundle.LoadAsset<TextAsset>("Assets/Materials.json").text); reflectionShader = bundle.LoadAsset<Shader>("assets/reflectionbody.shader"); if (!Object.op_Implicit((Object)(object)reflectionShader) || !reflectionShader.isSupported) { throw new InvalidOperationException("Reflection shader unavailable"); } Entry[] items = palette.items; foreach (Entry entry in items) { Material val = new Material(reflectionShader); val.color = new Color(entry.color[0], entry.color[1], entry.color[2], entry.color[3]); if (!string.IsNullOrEmpty(entry.image)) { val.mainTexture = (Texture)(object)bundle.LoadAsset<Texture2D>("assets/textures/" + entry.image.ToLowerInvariant()); if (!Object.op_Implicit((Object)(object)val.mainTexture)) { throw new IOException("Missing texture " + entry.image); } val.color = Color.white; } if (entry.cutout) { val.SetOverrideTag("RenderType", "TransparentCutout"); val.SetFloat("_Cutoff", 0.4f); val.renderQueue = 2450; } materials.Add(Key(entry.name), val); } SceneManager.sceneLoaded += OnSceneLoaded; Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCameraPostRender)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Full body bundle and materials ready"); } catch (Exception ex) { prefab = null; ((BaseUnityPlugin)this).Logger.LogError((object)ex); } } private static string Key(string name) { return new string(name.ToLowerInvariant().Where(char.IsLetterOrDigit).ToArray()); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { attempted.Clear(); nextSearch = 0f; } private void OnDestroy() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0083: Unknown result type (might be due to invalid IL or missing references) SceneManager.sceneLoaded -= OnSceneLoaded; Camera.onPreCull = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(OnCameraPreCull)); Camera.onPostRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(OnCameraPostRender)); foreach (KeyValuePair<Animator, AnimatorCullingMode> animatorMode in animatorModes) { if (Object.op_Implicit((Object)(object)animatorMode.Key)) { animatorMode.Key.cullingMode = animatorMode.Value; } } foreach (Body body in bodies) { if (Object.op_Implicit((Object)(object)body.Stock)) { ((Renderer)body.Stock).forceRenderingOff = body.PreviousForceOff; body.Stock.updateWhenOffscreen = body.PreviousOffscreen; } if (Object.op_Implicit((Object)(object)body.Model)) { Object.Destroy((Object)(object)((Component)body.Model).gameObject); } ReleaseArms(body); RestoreWeapons(body); } foreach (Material value in materials.Values) { Object.Destroy((Object)(object)value); } if (Object.op_Implicit((Object)(object)bundle)) { bundle.Unload(false); } } private void LateUpdate() { //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) if (!Object.op_Implicit((Object)(object)prefab)) { return; } if (renderDepth != 0) { RestoreWeaponMounts(); } if (Time.unscaledTime >= nextSearch) { nextSearch = Time.unscaledTime + 2f; SkinnedMeshRenderer[] array = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer stock in array) { if (((Object)stock).name != "v1_mdl") { continue; } Scene scene = ((Component)stock).gameObject.scene; if (((Scene)(ref scene)).isLoaded && IsSupportedBody(stock) && !bodies.Any((Body body) => (Object)(object)body.Stock == (Object)(object)stock) && attempted.Add(((Object)stock).GetInstanceID())) { try { bodies.Add(Attach(stock)); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Full body fit skipped for " + ((Object)stock).name + ": " + ex)); } } } } bodies.RemoveAll(delegate(Body body) { if (Object.op_Implicit((Object)(object)body.Stock) && Object.op_Implicit((Object)(object)body.Model)) { return false; } ReleaseArms(body); RestoreWeapons(body); return true; }); Animator[] array2 = animatorModes.Keys.Where((Animator a) => !Object.op_Implicit((Object)(object)a)).ToArray(); foreach (Animator key in array2) { animatorModes.Remove(key); } SyncBodies(); } private void OnCameraPreCull(Camera camera) { SyncBodies(); if (renderDepth++ != 0) { return; } foreach (Body body in bodies) { ShiftWeapons(body); } } private void OnCameraPostRender(Camera camera) { if (renderDepth > 0 && --renderDepth == 0) { RestoreWeaponMounts(); } } private void RestoreWeaponMounts() { foreach (Body body in bodies) { RestoreWeapons(body); } renderDepth = 0; } private void SyncBodies() { //IL_019e: 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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01ce: 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) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) Body body = null; foreach (Body body3 in bodies) { if (!body3.Mannequin && Object.op_Implicit((Object)(object)body3.Stock) && ((Component)body3.Stock).gameObject.activeInHierarchy && !ArmsInBindPose(body3)) { body = body3; break; } } int num = EquippedArm(); foreach (Body body4 in bodies) { if (!Object.op_Implicit((Object)(object)body4.Stock) || !Object.op_Implicit((Object)(object)body4.Model) || !((Component)body4.Stock).gameObject.activeInHierarchy) { continue; } SkinnedMeshRenderer[] renderers = body4.Renderers; foreach (SkinnedMeshRenderer val in renderers) { ((Renderer)val).enabled = ((Renderer)body4.Stock).enabled && !body4.PreviousForceOff; if (((Component)val).gameObject.layer != ((Component)body4.Stock).gameObject.layer) { ((Component)val).gameObject.layer = ((Component)body4.Stock).gameObject.layer; } } if (!((Renderer)body4.Stock).enabled) { continue; } Transform model = body4.Model; Transform transform = ((Component)body4.Stock).transform; body4.Hips.position = model.TransformPoint(body4.HipRest) + transform.TransformVector(transform.InverseTransformPoint(body4.StockHips.position) - body4.StockHipRest); Body body2 = ((!body4.Mannequin && ArmsInBindPose(body4) && body != null) ? body : body4); for (int j = 0; j < body4.Joints.Length; j++) { Joint joint = body4.Joints[j]; Transform source = body2.Joints[j].Source; if (Object.op_Implicit((Object)(object)source)) { Quaternion val2 = Quaternion.Inverse(((Component)body2.Stock).transform.rotation) * source.rotation; joint.Target.rotation = transform.rotation * val2 * Quaternion.Inverse(body2.Joints[j].StockRest) * joint.TargetRest; } } if (!body4.Mannequin) { PoseArm(body4, body2, 7, num == 2); PoseArm(body4, body2, 20, reach: true); UpdateArm(body4, num); } else if (body4.RestingProp) { PoseRestingBody(body4); } } } private static void PoseRestingBody(Body body) { //IL_001b: 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_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_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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_0132: 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_0142: 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_014c: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) Joint[] joints = body.Joints; Vector3 val = Vector3.ProjectOnPlane(joints[2].Target.position - body.Hips.position, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; if (!(normalized == Vector3.zero)) { Vector3 val2 = Vector3.Cross(Vector3.up, normalized); if (Vector3.Dot(val2, joints[20].Target.position - joints[7].Target.position) < 0f) { val2 = -val2; } Point(4, 5, normalized - 0.08f * Vector3.up); joints[5].Target.localRotation = joints[5].TargetLocalRest; int[] array = new int[2] { 7, 20 }; foreach (int num in array) { float num2 = ((num == 7) ? (-1f) : 1f); Point(num, num + 1, -normalized + num2 * 0.47f * val2 - 0.22f * Vector3.up); Point(num + 1, num + 2, -normalized + num2 * 0.13f * val2 - 0.09f * Vector3.up); joints[num + 2].Target.localRotation = joints[num + 2].TargetLocalRest; } } void Point(int joint, int child, Vector3 direction) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) Transform target = joints[joint].Target; Vector3 val3 = joints[child].Target.position - target.position; target.rotation = Quaternion.FromToRotation(val3, direction) * target.rotation; } } private WeaponVisual[] BuildWeapons(SkinnedMeshRenderer stock) { PlayerAnimations animation = ((Component)stock).GetComponentInParent<PlayerAnimations>(true); if (!Object.op_Implicit((Object)(object)animation)) { return Array.Empty<WeaponVisual>(); } IEnumerable<GameObject> source = WeaponFields.SelectMany((FieldInfo field) => (field.GetValue(animation) as GameObject[]) ?? Array.Empty<GameObject>()); WeaponVisual[] array = (from weapon in source.Where((GameObject weapon) => Object.op_Implicit((Object)(object)weapon) && weapon.transform.IsChildOf(((Component)animation).transform)).Distinct() select new WeaponVisual { Root = weapon.transform }).ToArray(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("CH1M3R4 weapon grip bound " + array.Length + " complete display weapons")); return array; } private static void ShiftWeapons(Body body) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007a: 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_0096: 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_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_0109: 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_0116: 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_0121: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)body.Stock) || !((Renderer)body.Stock).enabled || body.Mannequin || body.Weapons.Length == 0) { return; } Joint[] joints = body.Joints; Vector3 val = Palm(joints[22].Target.position, joints[27].Target.position, joints[30].Target.position); Vector3 val2 = Palm(joints[22].Source.position, joints[27].Source.position, joints[30].Source.position); WeaponVisual[] weapons = body.Weapons; foreach (WeaponVisual weaponVisual in weapons) { if (Object.op_Implicit((Object)(object)weaponVisual.Root) && ((Component)weaponVisual.Root).gameObject.activeInHierarchy) { Transform root = weaponVisual.Root; weaponVisual.BeforeRender = root.localPosition; weaponVisual.Moved = true; root.localPosition += root.parent.InverseTransformVector(val - val2); } } static Vector3 Palm(Vector3 val3, Vector3 index, Vector3 thumb) { //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_0003: 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_0017: Unknown result type (might be due to invalid IL or missing references) return Vector3.Lerp(val3, (index + thumb) * 0.5f, 0.75f); } } private static void RestoreWeapons(Body body) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) WeaponVisual[] weapons = body.Weapons; foreach (WeaponVisual weaponVisual in weapons) { if (weaponVisual.Moved) { if (Object.op_Implicit((Object)(object)weaponVisual.Root)) { weaponVisual.Root.localPosition = weaponVisual.BeforeRender; } weaponVisual.Moved = false; } } } private static bool ArmsInBindPose(Body body) { return AtRest(7) && AtRest(20); bool AtRest(int upper) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_0056: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Transform source = body.Joints[upper].Source; Transform source2 = body.Joints[upper + 1].Source; Vector3 val = ((Component)body.Stock).transform.InverseTransformVector(source2.position - source.position); Vector3 val2 = body.Basis * Vector3.up; return Mathf.Abs(Vector3.Dot(((Vector3)(ref val)).normalized, val2)) < 0.25f; } } private static void PoseArm(Body body, Body source, int index, bool reach) { //IL_000c: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00d7: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_013b: 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_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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) //IL_0242: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0253: 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_025d: 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_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: 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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: 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_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: 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_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: 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_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) Quaternion val = ((Component)body.Stock).transform.rotation * body.Basis; Transform target = body.Joints[index].Target; Transform target2 = body.Joints[index + 1].Target; Transform target3 = body.Joints[index + 2].Target; Transform source2 = source.Joints[index].Source; Transform source3 = source.Joints[index + 1].Source; Transform source4 = source.Joints[index + 2].Source; Transform sourceBody = ((Component)source.Stock).transform; Transform destination = ((Component)body.Stock).transform; Vector3 position = target.position; Vector3 val2 = IntoBody(source4); Vector3 val3 = IntoBody(source3); Vector3 val4 = IntoBody(source4) - IntoBody(source2); float num = ((index == 7) ? (-1f) : 1f); float num2 = Vector3.Distance(position, target2.position); float num3 = Vector3.Distance(target2.position, target3.position); if (num2 < 1E-05f || num3 < 1E-05f) { return; } bool flag = Mathf.Abs(Vector3.Dot(((Vector3)(ref val4)).normalized, val * Vector3.right)) > 0.85f; if (flag) { val2 = position + (num2 + num3) * (val * (reach ? new Vector3(num * 0.16f, -0.22f, 0.73f) : new Vector3(num * 0.18f, -0.73f, 0.22f))); val3 = position + val * new Vector3(num * 0.4f, -1f, -0.1f); } Vector3 val5 = val2 - position; Vector3 normalized = ((Vector3)(ref val5)).normalized; if (normalized == Vector3.zero) { return; } float num4 = Mathf.Clamp(Vector3.Distance(val2, position), Mathf.Abs(num2 - num3) + 0.0001f, num2 + num3 - 0.0001f); val5 = Vector3.ProjectOnPlane(val3 - position, normalized); Vector3 normalized2 = ((Vector3)(ref val5)).normalized; if (normalized2 == Vector3.zero) { val5 = Vector3.ProjectOnPlane(val * Vector3.down, normalized); normalized2 = ((Vector3)(ref val5)).normalized; } if (normalized2 == Vector3.zero) { val5 = Vector3.ProjectOnPlane(val * Vector3.forward, normalized); normalized2 = ((Vector3)(ref val5)).normalized; } float num5 = (num2 * num2 - num3 * num3 + num4 * num4) / (2f * num4); Vector3 val6 = position + normalized * num5 + normalized2 * Mathf.Sqrt(Mathf.Max(0f, num2 * num2 - num5 * num5)); Vector3 val7 = position + normalized * num4; target.rotation = Quaternion.FromToRotation(target2.position - position, val6 - position) * target.rotation; target2.rotation = Quaternion.FromToRotation(target3.position - target2.position, val7 - target2.position) * target2.rotation; target3.localRotation = body.Joints[index + 2].TargetLocalRest; if (!flag) { Joint joint = body.Joints[index + 7]; Joint joint2 = body.Joints[index + 10]; if (PalmFrame(target3.position, joint.Target.position, joint2.Target.position, out var frame) && PalmFrame(val2, IntoBody(source.Joints[index + 7].Source), IntoBody(source.Joints[index + 10].Source), out var frame2)) { target3.rotation = frame2 * Quaternion.Inverse(frame) * target3.rotation; } } Vector3 IntoBody(Transform val8) { //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_0017: Unknown result type (might be due to invalid IL or missing references) return destination.TransformPoint(sourceBody.InverseTransformPoint(val8.position)); } } private static bool PalmFrame(Vector3 wrist, Vector3 index, Vector3 thumb, out Quaternion frame) { //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_0003: 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_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_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_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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_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_0033: 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_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) //IL_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 val = index - wrist; Vector3 normalized = ((Vector3)(ref val)).normalized; val = thumb - wrist; Vector3 val2 = Vector3.Cross(normalized, ((Vector3)(ref val)).normalized); frame = Quaternion.identity; if (normalized == Vector3.zero || ((Vector3)(ref val2)).sqrMagnitude < 0.001f) { return false; } frame = Quaternion.LookRotation(normalized, val2); return true; } private static int EquippedArm() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Invalid comparison between Unknown and I4 HookArm instance = MonoSingleton<HookArm>.Instance; if (Object.op_Implicit((Object)(object)instance) && instance.equipped && (int)instance.state > 0) { return 2; } FistControl instance2 = MonoSingleton<FistControl>.Instance; GameObject val = (Object.op_Implicit((Object)(object)instance2) ? instance2.currentArmObject : null); Punch val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<Punch>() : null); return (Object.op_Implicit((Object)(object)val2) && (int)val2.type == 1) ? 1 : 0; } private static void UpdateArm(Body body, int arm) { if (Object.op_Implicit((Object)(object)body.ArmHost)) { bool flag = arm == 1 && Object.op_Implicit((Object)(object)body.Heavy); bool flag2 = arm == 2 && Object.op_Implicit((Object)(object)body.Hook); Mesh val = ((flag || flag2) ? body.CutMesh : body.FullMesh); if ((Object)(object)body.ArmHost.sharedMesh != (Object)(object)val) { body.ArmHost.sharedMesh = val; } if (Object.op_Implicit((Object)(object)body.Heavy)) { ((Component)body.Heavy).gameObject.layer = ((Component)body.ArmHost).gameObject.layer; ((Renderer)body.Heavy).enabled = flag && ((Renderer)body.ArmHost).enabled; } if (Object.op_Implicit((Object)(object)body.Hook)) { ((Component)body.Hook).gameObject.layer = ((Component)body.ArmHost).gameObject.layer; ((Renderer)body.Hook).enabled = flag2 && ((Renderer)body.ArmHost).enabled; } } } private void BuildArms(Body body) { try { SkinnedMeshRenderer val = body.Renderers.First((SkinnedMeshRenderer r) => ((Object)r).name == "CH1M3R4 Body and Outfit"); Mesh sharedMesh = val.sharedMesh; BoneWeight[] weights = sharedMesh.boneWeights; Transform[] bones = val.bones; HashSet<int> arm = new HashSet<int>(from i in Enumerable.Range(0, bones.Length) where Object.op_Implicit((Object)(object)bones[i]) && ((((Object)bones[i]).name.StartsWith("J_Bip_L_") && !((Object)bones[i]).name.Contains("Leg") && !((Object)bones[i]).name.EndsWith("Foot") && !((Object)bones[i]).name.EndsWith("ToeBase") && !((Object)bones[i]).name.EndsWith("Shoulder")) || (((Object)bones[i]).name.StartsWith("J_Sec_L_") && ((Object)bones[i]).name.Contains("Sleeve"))) select i); body.CutMesh = Object.Instantiate<Mesh>(sharedMesh); body.FullMesh = sharedMesh; body.ArmHost = val; int num = 0; for (int num2 = 0; num2 < sharedMesh.subMeshCount; num2++) { int[] triangles = sharedMesh.GetTriangles(num2); List<int> list = new List<int>(triangles.Length); for (int num3 = 0; num3 < triangles.Length; num3 += 3) { if (OnArm(triangles[num3]) && OnArm(triangles[num3 + 1]) && OnArm(triangles[num3 + 2])) { num++; continue; } list.Add(triangles[num3]); list.Add(triangles[num3 + 1]); list.Add(triangles[num3 + 2]); } body.CutMesh.SetTriangles(list, num2, false); } if (num == 0) { throw new InvalidOperationException("No left arm triangles identified"); } body.Heavy = G4sl33kArms.BuildWorldArm(val, true, reflectionShader); body.Hook = G4sl33kArms.BuildWorldArm(val, false, reflectionShader); SkinnedMeshRenderer heavy = body.Heavy; bool enabled = (((Renderer)body.Hook).enabled = false); ((Renderer)heavy).enabled = enabled; ((BaseUnityPlugin)this).Logger.LogInfo((object)("Mirror arm variants fitted (" + num + " default arm triangles masked)")); bool OnArm(int vertex) { //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) BoneWeight val2 = weights[vertex]; return (arm.Contains(((BoneWeight)(ref val2)).boneIndex0) ? ((BoneWeight)(ref val2)).weight0 : 0f) + (arm.Contains(((BoneWeight)(ref val2)).boneIndex1) ? ((BoneWeight)(ref val2)).weight1 : 0f) + (arm.Contains(((BoneWeight)(ref val2)).boneIndex2) ? ((BoneWeight)(ref val2)).weight2 : 0f) + (arm.Contains(((BoneWeight)(ref val2)).boneIndex3) ? ((BoneWeight)(ref val2)).weight3 : 0f) > 0.5f; } } catch (Exception ex) { if (Object.op_Implicit((Object)(object)body.Heavy)) { ((Renderer)body.Heavy).enabled = false; } if (Object.op_Implicit((Object)(object)body.Hook)) { ((Renderer)body.Hook).enabled = false; } ReleaseArms(body); body.ArmHost = null; ((BaseUnityPlugin)this).Logger.LogWarning((object)("Mirror arm variants unavailable: " + ex)); } } private void ReleaseArms(Body body) { if (Object.op_Implicit((Object)(object)body.CutMesh)) { Object.Destroy((Object)(object)body.CutMesh); } SkinnedMeshRenderer[] array = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[2] { body.Heavy, body.Hook }; foreach (SkinnedMeshRenderer val in array) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val.sharedMesh); Material[] sharedMaterials = ((Renderer)val).sharedMaterials; foreach (Material val2 in sharedMaterials) { Object.Destroy((Object)(object)val2); } Object.Destroy((Object)(object)((Component)val).gameObject); } } } private static bool IsPlayerRig(Transform t) { Transform parent = t.parent; while (Object.op_Implicit((Object)(object)parent)) { if (((Object)parent).name == "Player" || ((Object)parent).name == "Player(Clone)") { return true; } parent = parent.parent; } return false; } private static bool IsSupportedBody(SkinnedMeshRenderer stock) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)stock).transform; if (!Object.op_Implicit((Object)(object)transform.parent) || ((Object)transform.parent).name != "v1_combined") { return false; } if (!IsPlayerRig(transform)) { Scene scene = ((Component)stock).gameObject.scene; if (!(((Scene)(ref scene)).name == "45addc6c3730dae418321e00af1116c5")) { Transform parent = transform.parent.parent; while (Object.op_Implicit((Object)(object)parent)) { if (((Object)parent).name == "V1Mannequin" || ((Object)parent).name == "V1Mannequin(Clone)" || (((Object)parent).name.IndexOf("v1", StringComparison.OrdinalIgnoreCase) >= 0 && (((Object)parent).name.IndexOf("corpse", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)parent).name.IndexOf("dead", StringComparison.OrdinalIgnoreCase) >= 0))) { return true; } parent = parent.parent; } return false; } } return true; } private Body Attach(SkinnedMeshRenderer stock) { //IL_0127: 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_014c: 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_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_0172: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: 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_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_01d1: 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_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: 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_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_067c: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0697: Unknown result type (might be due to invalid IL or missing references) //IL_07ad: Unknown result type (might be due to invalid IL or missing references) Transform[] bones = stock.bones; Matrix4x4[] rest = stock.sharedMesh.bindposes; Dictionary<string, int> index = (from i in Enumerable.Range(0, bones.Length) where Object.op_Implicit((Object)(object)bones[i]) select i).ToDictionary((int i) => ((Object)bones[i]).name); Transform model = Object.Instantiate<GameObject>(prefab, ((Component)stock).transform, false).transform; try { ((Object)model).name = "CH1M3R4 Full Body"; Dictionary<string, Transform> output = (from t in ((Component)model).GetComponentsInChildren<Transform>(true) where ((Object)t).name.StartsWith("J_Bip_") select t).ToDictionary((Transform t) => ((Object)t).name); Quaternion val = Basis(Point("thigh.R") - Point("thigh.L"), Point("spine.006") - Point("spine")); Quaternion val2 = Basis(Local("R_UpperLeg") - Local("L_UpperLeg"), Local("C_Head") - Local("C_Hips")); Quaternion val3 = val * Quaternion.Inverse(val2); Vector3 val4 = (Point("foot.L") + Point("foot.R")) * 0.5f; Vector3 val5 = (Local("L_Foot") + Local("R_Foot")) * 0.5f; float num = Vector3.Distance(Point("spine.006"), val4) / Vector3.Distance(Local("C_Head"), val5); if (num <= 0f || float.IsNaN(num) || float.IsInfinity(num)) { throw new InvalidOperationException("Invalid body scale"); } model.localRotation = val3; model.localScale = Vector3.one * num; model.localPosition = val4 - val3 * (val5 * num); List<(string, string)> list = new List<(string, string)> { ("spine", "C_Hips"), ("spine.001", "C_Spine"), ("spine.002", "C_Chest"), ("spine.003", "C_UpperChest"), ("spine.005", "C_Neck"), ("spine.006", "C_Head") }; string[] array = new string[2] { "L", "R" }; foreach (string text in array) { (string, string)[] array2 = new(string, string)[8] { ("shoulder", "Shoulder"), ("upper_arm", "UpperArm"), ("forearm", "LowerArm"), ("hand", "Hand"), ("thigh", "UpperLeg"), ("shin", "LowerLeg"), ("foot", "Foot"), ("toe", "ToeBase") }; for (int num3 = 0; num3 < array2.Length; num3++) { (string, string) tuple = array2[num3]; list.Add((tuple.Item1 + "." + text, text + "_" + tuple.Item2)); } for (int num4 = 1; num4 <= 3; num4++) { list.Add(("f_index.0" + num4 + "." + text, text + "_Index" + num4)); } for (int num5 = 1; num5 <= 2; num5++) { list.Add(("thumb.0" + num5 + "." + text, text + "_Thumb" + num5)); } } SkinnedMeshRenderer[] componentsInChildren = ((Component)model).GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer[] array3 = componentsInChildren; foreach (SkinnedMeshRenderer val6 in array3) { ((Renderer)val6).sharedMaterials = ((Renderer)val6).sharedMaterials.Select((Material m) => materials[Key(((Object)m).name)]).ToArray(); ((Component)val6).gameObject.layer = ((Component)stock).gameObject.layer; val6.updateWhenOffscreen = true; ((Renderer)val6).enabled = ((Renderer)stock).enabled && !((Renderer)stock).forceRenderingOff; } Body body = new Body { Stock = stock, Model = model, Hips = Bone("C_Hips"), StockHips = bones[index["spine"]], Basis = val, HipRest = Local("C_Hips"), StockHipRest = Point("spine"), PreviousForceOff = ((Renderer)stock).forceRenderingOff, PreviousOffscreen = stock.updateWhenOffscreen, Renderers = componentsInChildren, Animator = ((Component)stock).GetComponentInParent<Animator>(true), Weapons = BuildWeapons(stock), Mannequin = !IsPlayerRig(((Component)stock).transform), RestingProp = ((Object)((Component)stock).transform.parent.parent).name.StartsWith("V1Mannequin", StringComparison.Ordinal), Joints = list.Select<(string, string), Joint>(delegate((string stock, string model) pair) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) Joint obj2 = new Joint { Source = bones[index[pair.stock]], Target = Bone(pair.model) }; Matrix4x4 val7 = Rest(pair.stock); obj2.StockRest = ((Matrix4x4)(ref val7)).rotation; obj2.TargetRest = Quaternion.Inverse(((Component)stock).transform.rotation) * Bone(pair.model).rotation; obj2.TargetLocalRest = Bone(pair.model).localRotation; return obj2; }).ToArray() }; if (Object.op_Implicit((Object)(object)body.Animator) && !animatorModes.ContainsKey(body.Animator)) { animatorModes.Add(body.Animator, body.Animator.cullingMode); body.Animator.cullingMode = (AnimatorCullingMode)0; } stock.updateWhenOffscreen = true; ((Renderer)stock).forceRenderingOff = true; if (!body.Mannequin) { BuildArms(body); } ((BaseUnityPlugin)this).Logger.LogInfo((object)("Full body fitted to " + ((Object)((Component)stock).transform.parent.parent).name + " (" + body.Joints.Length + " joints, animator " + (Object.op_Implicit((Object)(object)body.Animator) ? ((Object)body.Animator).name : "external pose source") + ")")); return body; Transform Bone(string name) { return output["J_Bip_" + name]; } Vector3 Local(string name) { //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) return model.InverseTransformPoint(Bone(name).position); } } catch { Object.Destroy((Object)(object)((Component)model).gameObject); throw; } static Quaternion Basis(Vector3 right, Vector3 up) { //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_0003: 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_000b: 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_001c: 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) Vector3 val7 = Vector3.Cross(right, up); return Quaternion.LookRotation(((Vector3)(ref val7)).normalized, ((Vector3)(ref up)).normalized); } Vector3 Point(string name) { //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) Matrix4x4 val7 = Rest(name); return ((Matrix4x4)(ref val7)).MultiplyPoint3x4(Vector3.zero); } Matrix4x4 Rest(string name) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) return ((Matrix4x4)(ref rest[index[name]])).inverse; } } }
plugins/CH1M3R4.FirstPerson.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("ch1m3r4.firstperson", "CH1M3R4 First Person", "0.1.6")] public sealed class TetoFirstPerson : BaseUnityPlugin { private sealed class Replacement { public SkinnedMeshRenderer Original; public SkinnedMeshRenderer[] Parts; } private readonly Dictionary<SkinnedMeshRenderer, Replacement> fitted = new Dictionary<SkinnedMeshRenderer, Replacement>(); private readonly HashSet<int> failed = new HashSet<int>(); private AssetBundle bundle; private GameObject template; private readonly Dictionary<string, Texture2D> armTextures = new Dictionary<string, Texture2D>(); private readonly Dictionary<(string, int), Material> litMaterials = new Dictionary<(string, int), Material>(); private readonly HashSet<string> missingMaterials = new HashSet<string>(); private Dictionary<string, Vector3> sourceJoints; private SkinnedMeshRenderer[] sourceMeshes; private float next; private string fittingStage; private void Awake() { bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "tetoarms")); if (!Object.op_Implicit((Object)(object)bundle)) { ((BaseUnityPlugin)this).Logger.LogError((object)"Cannot load tetoarms bundle"); ((Behaviour)this).enabled = false; return; } GameObject val = bundle.LoadAllAssets<GameObject>().Single(); template = val; sourceJoints = (from t in template.GetComponentsInChildren<Transform>(true) where Object.op_Implicit((Object)(object)t) && ((Object)t).name.StartsWith("J_Bip_", StringComparison.Ordinal) group t by ((Object)t).name).ToDictionary((IGrouping<string, Transform> g) => g.Key, (IGrouping<string, Transform> g) => g.First().position); sourceMeshes = template.GetComponentsInChildren<SkinnedMeshRenderer>(true); LoadArmMaterials(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location)); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TETO ARMS READY {sourceMeshes.Length} source meshes"); } private static string MaterialKey(string name) { return new string(name.Where(char.IsLetterOrDigit).Select(char.ToLowerInvariant).ToArray()); } private void LoadArmMaterials(string folder) { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown Dictionary<string, Texture2D> dictionary = new Dictionary<string, Texture2D>(); string[] source = File.ReadAllLines(Path.Combine(folder, "arm-materials.tsv")); Material[] array = (from m in sourceMeshes.SelectMany((SkinnedMeshRenderer r) => ((Renderer)r).sharedMaterials) where Object.op_Implicit((Object)(object)m) select m).Distinct().ToArray(); Material[] array2 = array; Color val2 = default(Color); foreach (Material val in array2) { string key = MaterialKey(((Object)val).name); string[] array3 = source.Select((string x) => x.Split('\t')).FirstOrDefault((string[] x) => x[0] == key); if (array3 == null) { continue; } if (array3[1].Length > 0) { if (!dictionary.TryGetValue(array3[1], out var value)) { value = new Texture2D(2, 2, (TextureFormat)4, true); string path = Path.Combine(folder, array3[1]); if (!File.Exists(path)) { path = Path.Combine(folder, "Textures", array3[1]); } if (!ImageConversion.LoadImage(value, File.ReadAllBytes(path), true)) { throw new IOException("Could not decode " + array3[1]); } ((Object)value).name = array3[1]; ((Texture)value).anisoLevel = 4; dictionary.Add(array3[1], value); } armTextures[key] = value; } else { ((Color)(ref val2))..ctor(float.Parse(array3[2], CultureInfo.InvariantCulture), float.Parse(array3[3], CultureInfo.InvariantCulture), float.Parse(array3[4], CultureInfo.InvariantCulture), 1f); Texture2D val3 = new Texture2D(1, 1, (TextureFormat)4, false); val3.SetPixel(0, 0, ((Color)(ref val2)).gamma); val3.Apply(false, true); ((Object)val3).name = ((Object)val).name + " albedo"; armTextures[key] = val3; } } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"TETO MATERIALS {armTextures.Count}/{array.Length}, {dictionary.Count} image textures"); } private Material ResolveMaterial(Material original, Material stock) { //IL_013b: 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_0142: Expected O, but got Unknown //IL_01a3: 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_0204: 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) if (!Object.op_Implicit((Object)(object)original)) { return original; } string text = MaterialKey(((Object)original).name); if (!armTextures.TryGetValue(text, out var value)) { if (missingMaterials.Add(((Object)original).name)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("TETO MATERIAL FALLBACK " + ((Object)original).name)); } return original; } (string, int) key = (text, Object.op_Implicit((Object)(object)stock) ? ((Object)stock).GetInstanceID() : 0); if (litMaterials.TryGetValue(key, out var value2)) { return value2; } bool flag = Object.op_Implicit((Object)(object)stock) && Object.op_Implicit((Object)(object)stock.shader) && stock.shader.isSupported && (stock.HasProperty("_MainTex") || stock.HasProperty("_BaseMap")); Shader val = (flag ? stock.shader : Shader.Find("Standard")); if (!Object.op_Implicit((Object)(object)val) || !val.isSupported) { throw new InvalidOperationException("No compatible arm lighting shader"); } Material val2 = (flag ? new Material(stock) : new Material(val)); ((Object)val2).name = ((Object)original).name + " (Teto Lit)"; string[] array = new string[2] { "_MainTex", "_BaseMap" }; foreach (string text2 in array) { if (val2.HasProperty(text2)) { val2.SetTexture(text2, (Texture)(object)value); val2.SetTextureOffset(text2, Vector2.zero); val2.SetTextureScale(text2, Vector2.one); } } string[] array2 = new string[2] { "_Color", "_BaseColor" }; foreach (string text3 in array2) { if (val2.HasProperty(text3)) { val2.SetColor(text3, Color.white); } } string[] array3 = new string[2] { "_EmissiveTex", "_EmissionMap" }; foreach (string text4 in array3) { if (val2.HasProperty(text4)) { val2.SetTexture(text4, (Texture)(object)Texture2D.blackTexture); } } string[] array4 = new string[2] { "_EmissionColor", "_EmissiveColor" }; foreach (string text5 in array4) { if (val2.HasProperty(text5)) { val2.SetColor(text5, Color.black); } } if (val2.HasProperty("_UseAlbedoAsEmissive")) { val2.SetInt("_UseAlbedoAsEmissive", 0); } val2.DisableKeyword("EMISSIVE"); val2.DisableKeyword("_EMISSION"); litMaterials.Add(key, val2); ((BaseUnityPlugin)this).Logger.LogInfo((object)("TETO LIGHTING " + ((Object)original).name + " uses " + ((Object)val).name)); return val2; } private static string Hierarchy(Transform t) { string text = ((Object)t).name; while (Object.op_Implicit((Object)(object)t.parent)) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private void LateUpdate() { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) KeyValuePair<SkinnedMeshRenderer, Replacement>[] array = fitted.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<SkinnedMeshRenderer, Replacement> keyValuePair = array[i]; if (!Object.op_Implicit((Object)(object)keyValuePair.Key)) { fitted.Remove(keyValuePair.Key); continue; } SkinnedMeshRenderer[] parts = keyValuePair.Value.Parts; foreach (SkinnedMeshRenderer val in parts) { if (Object.op_Implicit((Object)(object)val)) { ((Renderer)val).enabled = ((Renderer)keyValuePair.Key).enabled; } } } if (Time.unscaledTime < next) { return; } next = Time.unscaledTime + 1f; SkinnedMeshRenderer[] array2 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val2 in array2) { if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.sharedMesh)) { continue; } Scene scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || fitted.ContainsKey(val2) || failed.Contains(((Object)val2).GetInstanceID()) || (((Object)val2).name != "RightArm" && ((Object)val2).name != "Feedbacker")) { continue; } string text = Hierarchy(((Component)val2).transform); if (!text.StartsWith("Player/", StringComparison.Ordinal)) { continue; } bool flag = ((Object)val2).name == "Feedbacker" && text.Contains("/Punch/Arm Blue"); bool flag2 = ((Object)val2).name == "RightArm" && (text.Contains("/Main Camera/") || text.Contains("/StandardRevolver_NewArm/") || text.Contains("/AltRevolver_NewArm/")); if (flag || flag2) { try { fittingStage = "read target rig"; fitted.Add(val2, Fit(val2, flag)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("TETO FIT " + text)); } catch (Exception ex) { failed.Add(((Object)val2).GetInstanceID()); ((BaseUnityPlugin)this).Logger.LogWarning((object)("TETO FIT SKIPPED " + text + " at " + fittingStage + ": " + ex.ToString().Replace("\r", "").Replace("\n", " | "))); } } } } private static string SourceName(bool left, string part) { return "J_Bip_" + (left ? "L" : "R") + "_" + part; } private static Dictionary<string, string> JointNames(bool left) { Dictionary<string, string> dictionary = new Dictionary<string, string> { { "UpperArm", left ? "UpperArm" : "Upper Arm" }, { "LowerArm", "Forearm" }, { "Hand", "Hand" }, { "Shoulder", left ? "UpperArm" : "Upper Arm" } }; string[] array = new string[5] { "Thumb", "Index", "Middle", "Ring", "Little" }; foreach (string text in array) { for (int j = 1; j <= 3; j++) { string text2 = ((left && text == "Little") ? "Pinky" : text); dictionary[text + j] = (left ? (text2 + "_0" + j) : ("Finger_" + text + "_" + ((j == 1) ? "Base" : ((j == 3 || text == "Thumb") ? "Tip" : "Bridge")))); } } return dictionary; } private static Quaternion Frame(Vector3 forward, Vector3 side) { //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_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_0037: 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_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_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_0047: Unknown result type (might be due to invalid IL or missing references) if (!(((Vector3)(ref forward)).sqrMagnitude < 1E-08f)) { Vector3 val = Vector3.Cross(forward, side); if (!(((Vector3)(ref val)).sqrMagnitude < 1E-10f)) { return Quaternion.LookRotation(forward, Vector3.Cross(forward, side)); } } throw new InvalidOperationException("Degenerate palm frame"); } private Replacement Fit(SkinnedMeshRenderer target, bool left) { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_014c: 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_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_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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0184: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_05d7: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_0793: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_041e: Unknown result type (might be due to invalid IL or missing references) //IL_0604: Unknown result type (might be due to invalid IL or missing references) //IL_0609: Unknown result type (might be due to invalid IL or missing references) //IL_05f2: Unknown result type (might be due to invalid IL or missing references) //IL_0832: Unknown result type (might be due to invalid IL or missing references) //IL_084e: Unknown result type (might be due to invalid IL or missing references) //IL_060e: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0620: Unknown result type (might be due to invalid IL or missing references) //IL_0625: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) //IL_06c2: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_056e: Unknown result type (might be due to invalid IL or missing references) //IL_0573: Unknown result type (might be due to invalid IL or missing references) Transform[] bones = target.bones; Matrix4x4[] targetRest = target.sharedMesh.bindposes; if (bones.Length != targetRest.Length) { throw new InvalidOperationException("Bone and bindpose counts differ"); } Dictionary<string, string> dictionary = JointNames(left); Dictionary<string, int> index = new Dictionary<string, int>(); foreach (KeyValuePair<string, string> entry in dictionary) { int num = Array.FindIndex(bones, (Transform t) => Object.op_Implicit((Object)(object)t) && ((Object)t).name == entry.Value); if (num >= 0) { index[entry.Key] = num; } } Vector3 side = S("Little1") - S("Index1"); Vector3 side2 = T("Little1") - T("Index1"); fittingStage = "map palm joints"; Quaternion val = Frame(T("Middle1") - T("Hand"), side2) * Quaternion.Inverse(Frame(S("Middle1") - S("Hand"), side)); Vector3 val2 = T("Middle1") - T("Hand"); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = S("Middle1") - S("Hand"); float num2 = magnitude / ((Vector3)(ref val2)).magnitude; if (num2 <= 0f || float.IsNaN(num2) || float.IsInfinity(num2)) { throw new InvalidOperationException("Invalid hand scale"); } Material stockMaterial = ((IEnumerable<Material>)((Renderer)target).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m) && (m.HasProperty("_MainTex") || m.HasProperty("_BaseMap")))); List<SkinnedMeshRenderer> list = new List<SkinnedMeshRenderer>(); List<GameObject> list2 = new List<GameObject>(); try { SkinnedMeshRenderer[] array = sourceMeshes; foreach (SkinnedMeshRenderer val3 in array) { bool flag = ((Object)val3).name == "Right hand" || ((Object)val3).name.Contains("Shaped right fabric sleeve"); if (flag == left) { continue; } fittingStage = "read source mesh " + ((Object)val3).name; Mesh val4 = Object.Instantiate<Mesh>(val3.sharedMesh); Vector3[] vertices = val4.vertices; Vector3[] normals = val4.normals; BoneWeight[] boneWeights = val4.boneWeights; if (boneWeights.Length != vertices.Length) { throw new InvalidOperationException("Missing source skin weights"); } Transform[] bones2 = val3.bones; int[] array2 = new int[bones2.Length]; Vector3[] anchors = (Vector3[])(object)new Vector3[bones2.Length]; Vector3[] fittedAnchors = (Vector3[])(object)new Vector3[bones2.Length]; Quaternion[] rotations = (Quaternion[])(object)new Quaternion[bones2.Length]; float[] scales = new float[bones2.Length]; fittingStage = "map source joints " + ((Object)val3).name; for (int num4 = 0; num4 < bones2.Length; num4++) { Transform val5 = bones2[num4]; string text = SourceName(left, ""); string text2 = ((Object.op_Implicit((Object)(object)val5) && ((Object)val5).name.StartsWith(text)) ? ((Object)val5).name.Substring(text.Length) : "UpperArm"); if (!index.ContainsKey(text2)) { text2 = ((text2.IndexOf("Sleeve", StringComparison.OrdinalIgnoreCase) >= 0) ? "LowerArm" : "UpperArm"); } array2[num4] = index[text2]; anchors[num4] = S(text2); fittedAnchors[num4] = T(text2); rotations[num4] = val; scales[num4] = num2; string text3 = ((text2 == "UpperArm") ? "LowerArm" : ((text2 == "LowerArm") ? "Hand" : null)); if (text3 == null && text2.Length > 1 && (text2.EndsWith("1") || text2.EndsWith("2"))) { text3 = text2.Substring(0, text2.Length - 1) + (text2.EndsWith("1") ? "2" : "3"); } if (text3 != null && index.ContainsKey(text3) && index[text3] != index[text2]) { Vector3 val6 = S(text3) - S(text2); Vector3 val7 = T(text3) - T(text2); if (((Vector3)(ref val6)).sqrMagnitude > 1E-08f && ((Vector3)(ref val7)).sqrMagnitude > 1E-08f) { rotations[num4] = Quaternion.FromToRotation(val * val6, val7) * val; scales[num4] = ((Vector3)(ref val7)).magnitude / ((Vector3)(ref val6)).magnitude; } } } fittingStage = "remap vertices " + ((Object)val3).name; for (int num5 = 0; num5 < vertices.Length; num5++) { Vector3 sourcePoint = ((Component)val3).transform.TransformPoint(vertices[num5]); Vector3 normal = ((normals.Length == vertices.Length) ? ((Component)val3).transform.TransformDirection(normals[num5]) : Vector3.up); BoneWeight val8 = boneWeights[num5]; Vector3 sum = Vector3.zero; Vector3 norm = Vector3.zero; Apply(((BoneWeight)(ref val8)).boneIndex0, ((BoneWeight)(ref val8)).weight0); Apply(((BoneWeight)(ref val8)).boneIndex1, ((BoneWeight)(ref val8)).weight1); Apply(((BoneWeight)(ref val8)).boneIndex2, ((BoneWeight)(ref val8)).weight2); Apply(((BoneWeight)(ref val8)).boneIndex3, ((BoneWeight)(ref val8)).weight3); vertices[num5] = sum; if (normals.Length == vertices.Length) { normals[num5] = ((Vector3)(ref norm)).normalized; } ((BoneWeight)(ref val8)).boneIndex0 = array2[((BoneWeight)(ref val8)).boneIndex0]; ((BoneWeight)(ref val8)).boneIndex1 = array2[((BoneWeight)(ref val8)).boneIndex1]; ((BoneWeight)(ref val8)).boneIndex2 = array2[((BoneWeight)(ref val8)).boneIndex2]; ((BoneWeight)(ref val8)).boneIndex3 = array2[((BoneWeight)(ref val8)).boneIndex3]; boneWeights[num5] = val8; void Apply(int j, float w) { //IL_0017: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_004c: 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_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) if (!(w <= 0f)) { sum += w * (fittedAnchors[j] + rotations[j] * (sourcePoint - anchors[j]) * scales[j]); norm += w * (rotations[j] * normal); } } } fittingStage = "bind replacement " + ((Object)val3).name; val4.vertices = vertices; val4.normals = normals; val4.boneWeights = boneWeights; val4.bindposes = targetRest; val4.RecalculateBounds(); GameObject val9 = new GameObject("Teto " + ((Object)val3).name); list2.Add(val9); val9.layer = ((Component)target).gameObject.layer; val9.transform.SetParent(((Component)target).transform, false); SkinnedMeshRenderer val10 = val9.AddComponent<SkinnedMeshRenderer>(); val10.sharedMesh = val4; ((Renderer)val10).sharedMaterials = ((Renderer)val3).sharedMaterials.Select((Material m) => ResolveMaterial(m, stockMaterial)).ToArray(); val10.bones = bones; val10.rootBone = target.rootBone; ((Renderer)val10).localBounds = ((Renderer)target).localBounds; val10.updateWhenOffscreen = target.updateWhenOffscreen; ((Renderer)val10).shadowCastingMode = ((Renderer)target).shadowCastingMode; ((Renderer)val10).receiveShadows = ((Renderer)target).receiveShadows; ((Renderer)val10).enabled = ((Renderer)target).enabled; list.Add(val10); } if (list.Count == 0) { throw new InvalidOperationException("No replacement renderers"); } ((Renderer)target).forceRenderingOff = true; return new Replacement { Original = target, Parts = list.ToArray() }; } catch { foreach (GameObject item in list2) { Object.Destroy((Object)(object)item); } throw; } Vector3 S(string part) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!sourceJoints.TryGetValue(SourceName(left, part), out var value)) { throw new InvalidOperationException("Missing source joint " + SourceName(left, part)); } return value; } Vector3 T(string part) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Matrix4x4 inverse = ((Matrix4x4)(ref targetRest[index[part]])).inverse; return ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero); } } }
plugins/G4SL33K.FirstPerson.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyVersion("0.0.0.0")] [BepInPlugin("g4sl33k.firstperson", "G4SL33K First Person Arms", "0.1.5")] public sealed class G4sl33kArms : BaseUnityPlugin { private sealed class Part { public string Joint; public string Animated; public int Material; public Vector3[] Vertices; public int[] Triangles; } private sealed class Arm { public readonly Dictionary<string, Vector3> Rest = new Dictionary<string, Vector3>(); public Color[] Palette; public Part[] Parts; } private sealed class Fit { public SkinnedMeshRenderer Render; public bool PreviousForceOff; } private readonly Dictionary<SkinnedMeshRenderer, Fit> fitted = new Dictionary<SkinnedMeshRenderer, Fit>(); private readonly Dictionary<SkinnedMeshRenderer, Material[]> pickupMaterials = new Dictionary<SkinnedMeshRenderer, Material[]>(); private readonly Dictionary<Material, Material> pickupHookMaterials = new Dictionary<Material, Material>(); private readonly HashSet<int> failed = new HashSet<int>(); private readonly Dictionary<(bool, Material), Material[]> materials = new Dictionary<(bool, Material), Material[]>(); private readonly List<Texture2D> albedos = new List<Texture2D>(); private Arm red; private Arm green; private static G4sl33kArms instance; private float next; private static string Label(BinaryReader r) { return Encoding.ASCII.GetString(r.ReadBytes(r.ReadByte())); } private static Vector3 Point(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private static Arm Load(string path) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) BinaryReader r = new BinaryReader(File.OpenRead(path)); try { if (new string(r.ReadChars(4)) != "G4A1") { throw new InvalidDataException(path); } Arm arm = new Arm(); int num = r.ReadInt32(); for (int i = 0; i < num; i++) { arm.Rest.Add(Label(r), Point(r)); } arm.Palette = Enumerable.Range(0, r.ReadInt32()).Select((Func<int, Color>)delegate { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_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_001f: 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_0027: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Point(r); return new Color(val.x, val.y, val.z); }).ToArray(); arm.Parts = Enumerable.Range(0, r.ReadInt32()).Select((Func<int, Part>)delegate { Part part = new Part { Joint = Label(r), Animated = Label(r), Material = r.ReadInt32() }; int count = r.ReadInt32(); int count2 = r.ReadInt32(); part.Vertices = (from num2 in Enumerable.Range(0, count) select Point(r)).ToArray(); part.Triangles = (from num2 in Enumerable.Range(0, count2) select r.ReadInt32()).ToArray(); return part; }).ToArray(); if (r.BaseStream.Position != r.BaseStream.Length) { throw new InvalidDataException(path); } return arm; } finally { if (r != null) { ((IDisposable)r).Dispose(); } } } private void Awake() { try { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); red = Load(Path.Combine(directoryName, "knuckleblaster.mesh")); green = Load(Path.Combine(directoryName, "whiplash.mesh")); if (red.Parts.Length == 0 || green.Parts.Length == 0) { throw new InvalidDataException("Empty arm"); } instance = this; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"G4SL33K ARMS READY {red.Parts.Length} Knuckleblaster parts, {green.Parts.Length} Whiplash parts"); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex.ToString()); ((Behaviour)this).enabled = false; } } private static string PathOf(Transform t) { string text = ((Object)t).name; while (Object.op_Implicit((Object)(object)t.parent)) { t = t.parent; text = ((Object)t).name + "/" + text; } return text; } private void LateUpdate() { //IL_0231: 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_0160: 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_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Expected O, but got Unknown KeyValuePair<SkinnedMeshRenderer, Fit>[] array = fitted.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<SkinnedMeshRenderer, Fit> keyValuePair = array[i]; if (!Object.op_Implicit((Object)(object)keyValuePair.Key)) { Release(keyValuePair.Value); fitted.Remove(keyValuePair.Key); } else if (Object.op_Implicit((Object)(object)keyValuePair.Value.Render)) { ((Renderer)keyValuePair.Value.Render).enabled = ((Renderer)keyValuePair.Key).enabled; } } if (Time.unscaledTime < next) { return; } next = Time.unscaledTime + 1f; SkinnedMeshRenderer[] array2 = pickupMaterials.Keys.Where((SkinnedMeshRenderer r) => !Object.op_Implicit((Object)(object)r)).ToArray(); foreach (SkinnedMeshRenderer key in array2) { pickupMaterials.Remove(key); } SkinnedMeshRenderer[] array3 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); Material val = null; SkinnedMeshRenderer[] array4 = array3; Scene scene; foreach (SkinnedMeshRenderer val2 in array4) { if (!Object.op_Implicit((Object)(object)val2) || ((Object)val2).name != "Hook") { continue; } scene = ((Component)val2).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } string text = PathOf(((Component)val2).transform); if (text.StartsWith("Player/", StringComparison.Ordinal) && text.Contains("/Punch/Hook Arm/GreenArmFinal/")) { val = ((IEnumerable<Material>)((Renderer)val2).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.mainTexture))); if (Object.op_Implicit((Object)(object)val)) { break; } } } SkinnedMeshRenderer[] array5 = array3; foreach (SkinnedMeshRenderer val3 in array5) { if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.sharedMesh)) { continue; } scene = ((Component)val3).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || fitted.ContainsKey(val3) || failed.Contains(((Object)val3).GetInstanceID()) || (((Object)val3).name != "arm_lp" && ((Object)val3).name != "Arm" && ((Object)val3).name != "Hook")) { continue; } string text2 = PathOf(((Component)val3).transform); bool flag = text2.StartsWith("Player/", StringComparison.Ordinal); bool flag2 = text2.Replace("(Clone)", "").Contains("/V2 Target/RedArmPickup/GreenArmFinal/"); bool flag3 = flag && ((Object)val3).name == "arm_lp" && text2.Contains("/Punch/Arm Red"); bool flag4 = ((Object)val3).name == "Arm" && (flag2 || (flag && text2.Contains("/Punch/Hook Arm/GreenArmFinal/"))); if (flag2 && ((Object)val3).name == "Hook") { if (Object.op_Implicit((Object)(object)val) && !pickupMaterials.ContainsKey(val3)) { Material[] sharedMaterials = ((Renderer)val3).sharedMaterials; pickupMaterials.Add(val3, sharedMaterials); if (!pickupHookMaterials.TryGetValue(val, out var lit)) { lit = new Material(Shader.Find("Standard")) { name = "G4SL33K pickup hook", mainTexture = val.mainTexture, mainTextureScale = val.mainTextureScale, mainTextureOffset = val.mainTextureOffset }; lit.SetFloat("_Glossiness", 0.2f); pickupHookMaterials.Add(val, lit); } ((Renderer)val3).sharedMaterials = sharedMaterials.Select((Material m) => lit).ToArray(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K WHIPLASH PICKUP HOOK " + ((Object)val).name)); } } else if (flag3 || flag4) { try { fitted.Add(val3, Retarget(val3, flag3 ? red : green, flag3)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K FIT " + text2)); } catch (Exception arg) { failed.Add(((Object)val3).GetInstanceID()); ((BaseUnityPlugin)this).Logger.LogWarning((object)$"G4SL33K FIT SKIPPED {text2}: {arg}"); } } } } private static Dictionary<string, string> BoneNames(bool isRed) { Dictionary<string, string> dictionary = new Dictionary<string, string> { ["UpperArm"] = "upperarm", ["LowerArm"] = "lowerarm", ["Hand"] = "hand", ["Thumb1"] = "thumb.1", ["Thumb2"] = "thumb.2", ["Index1"] = "index.1", ["Index2"] = "index.2", ["Little1"] = (isRed ? "pinkie.1" : "pinkie.001"), ["Little2"] = (isRed ? "pinkie.2" : "pinkie.002") }; if (isRed) { dictionary["Barrel1"] = "barrel.1"; dictionary["Barrel2"] = "barrel.2"; } else { dictionary["Index3"] = "index.003"; dictionary["Middle1"] = "middle.001"; dictionary["Middle2"] = "middle-002"; dictionary["Middle3"] = "middle-003"; dictionary["Ring1"] = "ring,001"; dictionary["Ring2"] = "ring.002"; dictionary["Ring3"] = "ring.003"; dictionary["Little3"] = "pinkie.003"; } return dictionary; } private static Quaternion Frame(Vector3 wrist, Vector3 index, Vector3 little) { //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_0003: 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) //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005c: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0072: 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_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_0099: 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) Vector3 val = (index + little) * 0.5f - wrist; Vector3 val2 = little - index; if (((Vector3)(ref val)).sqrMagnitude < 1E-16f || ((Vector3)(ref val2)).sqrMagnitude < 1E-16f) { throw new InvalidOperationException("Degenerate palm frame"); } val /= ((Vector3)(ref val)).magnitude; val2 /= ((Vector3)(ref val2)).magnitude; Vector3 val3 = Vector3.Cross(val, val2); if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f) { throw new InvalidOperationException("Collinear palm joints"); } return Quaternion.LookRotation(val, val3); } private Material[] BuildMaterials(Arm arm, Material stock, bool isRed) { (bool, Material) key = (isRed, isRed ? stock : null); if (materials.TryGetValue(key, out var value)) { return value; } Shader shader = ((isRed && Object.op_Implicit((Object)(object)stock) && Object.op_Implicit((Object)(object)stock.shader) && stock.shader.isSupported && stock.HasProperty("_MainTex")) ? stock.shader : Shader.Find("Standard")); if (!Object.op_Implicit((Object)(object)shader)) { throw new InvalidOperationException("Arm lighting shader unavailable"); } Material[] array = ((IEnumerable<Color>)arm.Palette).Select((Func<Color, Material>)delegate(Color color) { //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_0026: 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_0035: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_016c: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) if (!isRed) { Material val = new Material(shader) { name = "G4SL33K claw", color = ((Color)(ref color)).gamma }; val.SetFloat("_Glossiness", 0.25f); return val; } Material val2 = ((Object.op_Implicit((Object)(object)stock) && (Object)(object)stock.shader == (Object)(object)shader) ? new Material(stock) : new Material(shader)); Texture2D val3 = new Texture2D(1, 1, (TextureFormat)4, false); ((Object)val3).name = "G4SL33K arm albedo"; val3.SetPixel(0, 0, ((Color)(ref color)).gamma); val3.Apply(false, true); albedos.Add(val3); string[] array2 = new string[2] { "_MainTex", "_BaseMap" }; foreach (string text in array2) { if (val2.HasProperty(text)) { val2.SetTexture(text, (Texture)(object)val3); val2.SetTextureOffset(text, Vector2.zero); val2.SetTextureScale(text, Vector2.one); } } string[] array3 = new string[2] { "_Color", "_BaseColor" }; foreach (string text2 in array3) { if (val2.HasProperty(text2)) { val2.SetColor(text2, Color.white); } } string[] array4 = new string[2] { "_EmissiveTex", "_EmissionMap" }; foreach (string text3 in array4) { if (val2.HasProperty(text3)) { val2.SetTexture(text3, (Texture)(object)val3); } } string[] array5 = new string[2] { "_EmissionColor", "_EmissiveColor" }; foreach (string text4 in array5) { if (val2.HasProperty(text4)) { val2.SetColor(text4, new Color(0.21f, 0.21f, 0.21f, 1f)); } } if (val2.HasProperty("_UseAlbedoAsEmissive")) { val2.SetInt("_UseAlbedoAsEmissive", 0); } val2.EnableKeyword("EMISSIVE"); val2.EnableKeyword("_EMISSION"); return val2; }).ToArray(); materials.Add(key, array); return array; } public static SkinnedMeshRenderer BuildWorldArm(SkinnedMeshRenderer body, bool heavy, Shader shader) { if (!Object.op_Implicit((Object)(object)instance)) { throw new InvalidOperationException("G4SL33K arm assets are unavailable"); } return instance.Retarget(body, heavy ? instance.red : instance.green, heavy, shader).Render; } private Fit Retarget(SkinnedMeshRenderer target, Arm arm, bool isRed, Shader worldShader = null) { //IL_01be: 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_01d4: 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_01e4: 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_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: 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_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_026d: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_065e: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0674: Expected O, but got Unknown //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06f9: Expected O, but got Unknown //IL_075c: Unknown result type (might be due to invalid IL or missing references) //IL_0778: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0598: Unknown result type (might be due to invalid IL or missing references) bool flag = Object.op_Implicit((Object)(object)worldShader); Transform[] bones = target.bones; Matrix4x4[] binds = target.sharedMesh.bindposes; if (bones.Length != binds.Length) { throw new InvalidOperationException("Bone and bindpose counts differ"); } Dictionary<string, string> source = (flag ? arm.Rest.Keys.ToDictionary((string name) => name, (string name) => "J_Bip_L_" + name) : BoneNames(isRed)); Dictionary<string, int> index = (from kv in source select (joint: kv.Key, index: Array.FindIndex(bones, (Transform b) => Object.op_Implicit((Object)(object)b) && ((Object)b).name == kv.Value)) into kv where kv.index >= 0 select kv).ToDictionary(((string joint, int index) kv) => kv.joint, ((string joint, int index) kv) => kv.index); string[] array = new string[5] { "UpperArm", "LowerArm", "Hand", "Index1", "Little1" }; foreach (string text in array) { if (!index.ContainsKey(text)) { throw new InvalidOperationException("Missing stock " + text); } } Quaternion val = Frame(T("Hand"), T("Index1"), T("Little1")) * Quaternion.Inverse(Frame(S("Hand"), S("Index1"), S("Little1"))); Vector3 val2 = (T("Index1") + T("Little1")) * 0.5f - T("Hand"); float magnitude = ((Vector3)(ref val2)).magnitude; val2 = (S("Index1") + S("Little1")) * 0.5f - S("Hand"); float num2 = magnitude / ((Vector3)(ref val2)).magnitude; if (!(num2 > 0f) || float.IsInfinity(num2)) { throw new InvalidOperationException("Invalid palm scale"); } List<Vector3> list = new List<Vector3>(); List<BoneWeight> list2 = new List<BoneWeight>(); List<int>[] array2 = arm.Palette.Select((Color _) => new List<int>()).ToArray(); Part[] parts = arm.Parts; foreach (Part part in parts) { string text2 = part.Joint; while (!index.ContainsKey(text2) && char.IsDigit(text2[text2.Length - 1]) && text2[text2.Length - 1] > '1') { text2 = text2.Substring(0, text2.Length - 1) + (char)(text2[text2.Length - 1] - 1); } if (!index.ContainsKey(text2)) { text2 = "Hand"; } string text3 = ((text2 == "UpperArm") ? "LowerArm" : ((text2 == "LowerArm") ? "Hand" : ((text2.EndsWith("1") || text2.EndsWith("2")) ? (text2.Substring(0, text2.Length - 1) + (char)(text2[text2.Length - 1] + 1)) : ""))); float num4 = num2; Quaternion val3 = val; if (index.ContainsKey(text3) && arm.Rest.ContainsKey(text3)) { Vector3 val4 = S(text3) - S(text2); Vector3 val5 = T(text3) - T(text2); if (((Vector3)(ref val4)).sqrMagnitude > 1E-09f && ((Vector3)(ref val5)).sqrMagnitude > 1E-09f) { val3 = Quaternion.FromToRotation(val * val4, val5) * val; num4 = ((Vector3)(ref val5)).magnitude / ((Vector3)(ref val4)).magnitude; } } int count = list.Count; int value; int boneIndex = ((part.Animated.StartsWith("Barrel", StringComparison.Ordinal) && index.TryGetValue(part.Animated, out value)) ? value : index[text2]); Vector3[] vertices = part.Vertices; foreach (Vector3 val6 in vertices) { list.Add(T(text2) + val3 * (val6 - S(text2)) * num4); BoneWeight item = default(BoneWeight); ((BoneWeight)(ref item)).boneIndex0 = boneIndex; ((BoneWeight)(ref item)).weight0 = 1f; list2.Add(item); } int[] triangles = part.Triangles; foreach (int num7 in triangles) { array2[part.Material].Add(count + num7); } } Material[] sharedMaterials = (flag ? ((IEnumerable<Color>)arm.Palette).Select((Func<Color, Material>)((Color color) => new Material(worldShader) { color = ((Color)(ref color)).gamma })).ToArray() : BuildMaterials(arm, ((IEnumerable<Material>)((Renderer)target).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m))), isRed)); Mesh val7 = new Mesh { name = "G4SL33K arm", indexFormat = (IndexFormat)1 }; GameObject val8 = null; try { val7.SetVertices(list); val7.subMeshCount = array2.Length; for (int num8 = 0; num8 < array2.Length; num8++) { val7.SetTriangles(array2[num8], num8); } val7.RecalculateNormals(); val7.RecalculateBounds(); val7.bindposes = binds; val7.boneWeights = list2.ToArray(); val8 = new GameObject(isRed ? "G4SL33K Knuckleblaster" : "G4SL33K Whiplash"); val8.layer = ((Component)target).gameObject.layer; val8.transform.SetParent(((Component)target).transform, false); SkinnedMeshRenderer val9 = val8.AddComponent<SkinnedMeshRenderer>(); val9.sharedMesh = val7; ((Renderer)val9).sharedMaterials = sharedMaterials; val9.bones = bones; val9.rootBone = target.rootBone; ((Renderer)val9).localBounds = ((Renderer)target).localBounds; val9.updateWhenOffscreen = target.updateWhenOffscreen; ((Renderer)val9).shadowCastingMode = ((Renderer)target).shadowCastingMode; ((Renderer)val9).receiveShadows = ((Renderer)target).receiveShadows; ((Renderer)val9).enabled = ((Renderer)target).enabled; Fit result = new Fit { Render = val9, PreviousForceOff = ((Renderer)target).forceRenderingOff }; if (!flag) { ((Renderer)target).forceRenderingOff = true; } return result; } catch { if (Object.op_Implicit((Object)(object)val8)) { Object.Destroy((Object)(object)val8); } Object.Destroy((Object)(object)val7); throw; } Vector3 S(string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) return arm.Rest[name]; } Vector3 T(string name) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) Matrix4x4 inverse = ((Matrix4x4)(ref binds[index[name]])).inverse; return ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(Vector3.zero); } } private void Release(Fit fit) { if (Object.op_Implicit((Object)(object)fit.Render)) { Object.Destroy((Object)(object)fit.Render.sharedMesh); Object.Destroy((Object)(object)((Component)fit.Render).gameObject); } } private void OnDestroy() { foreach (KeyValuePair<SkinnedMeshRenderer, Fit> item in fitted) { if (Object.op_Implicit((Object)(object)item.Key)) { ((Renderer)item.Key).forceRenderingOff = item.Value.PreviousForceOff; } Release(item.Value); } foreach (KeyValuePair<SkinnedMeshRenderer, Material[]> pickupMaterial in pickupMaterials) { if (Object.op_Implicit((Object)(object)pickupMaterial.Key)) { ((Renderer)pickupMaterial.Key).sharedMaterials = pickupMaterial.Value; } } foreach (Material value in pickupHookMaterials.Values) { Object.Destroy((Object)(object)value); } foreach (Texture2D albedo in albedos) { Object.Destroy((Object)(object)albedo); } foreach (Material[] value2 in materials.Values) { Material[] array = value2; foreach (Material val in array) { Object.Destroy((Object)(object)val); } } } }
plugins/G4SL33K.V2.dll
Decompiled an hour agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [DefaultExecutionOrder(20000)] [BepInPlugin("g4sl33k.v2", "G4SL33K V2 Encounters", "0.2.3")] public sealed class G4sl33kV2 : BaseUnityPlugin { private sealed class Model { public string[] Joints; public Vector3[] Rest; public Surface[] Surfaces; } private sealed class Surface { public string Name; public string Texture; public Color Color; public Vertex[] Vertices; public int[] Triangles; } private struct Vertex { public Vector3 Position; public Vector3 Normal; public Vector2 UV; public BoneWeight Weight; } private sealed class Fitted { public SkinnedMeshRenderer Body; public Transform Head; public bool HairRunning; public float WorldScale; public Vector3 ChestToHead; public Vector3 HeadBindPivot; public Vector3 RestUp; public JointDriver HeadDriver; public JointDriver ChestDriver; public Transform RigRoot; public JointDriver[] Drivers; public Animator[] Animators; public float SampleAt; public int Samples; public readonly List<Spring> Hair = new List<Spring>(); public Spring[][] HairChains; public readonly List<(Renderer, bool)> Hidden = new List<(Renderer, bool)>(); } private sealed class JointDriver { public Transform Source; public Transform Output; public Vector3 RestPosition; public Quaternion InverseRestRotation; public int Parent = -1; public JointDriver SegmentEnd; } private sealed class Spring { public Transform Bone; public Vector3 Rest; public Vector3 WorldPosition; public Vector3 WorldTarget; public Vector3 Goal; public Vector3 Velocity; public Vector3 PreviousStep; public float Length; public float Gain; } private readonly Dictionary<Animator, (AnimatorCullingMode Mode, int Users)> animatorClaims = new Dictionary<Animator, (AnimatorCullingMode, int)>(); private readonly Dictionary<SkinnedMeshRenderer, Fitted> fitted = new Dictionary<SkinnedMeshRenderer, Fitted>(); private readonly Dictionary<(Model Model, Mesh Stock, string Bones), Mesh> fittedMeshes = new Dictionary<(Model, Mesh, string), Mesh>(); private readonly HashSet<(Model, Mesh, string)> prewarmFailures = new HashSet<(Model, Mesh, string)>(); private readonly Dictionary<string, Texture2D> textures = new Dictionary<string, Texture2D>(); private readonly Dictionary<(Surface, Material), Material> materials = new Dictionary<(Surface, Material), Material>(); private readonly HashSet<int> failed = new HashSet<int>(); private string folder; private Model first; private Model rematch; private float next; private static string Label(BinaryReader r) { return Encoding.UTF8.GetString(r.ReadBytes(r.ReadUInt16())); } private static Vector3 Vec(BinaryReader r) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(r.ReadSingle(), r.ReadSingle(), r.ReadSingle()); } private static Model Load(string file) { //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_00b5: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(File.OpenRead(file)); if (new string(binaryReader.ReadChars(4)) != "G4V2") { throw new InvalidDataException(file); } int num = binaryReader.ReadInt32(); Model model = new Model { Joints = new string[num], Rest = (Vector3[])(object)new Vector3[num] }; for (int i = 0; i < num; i++) { model.Joints[i] = Label(binaryReader); model.Rest[i] = Vec(binaryReader); } model.Surfaces = new Surface[binaryReader.ReadInt32()]; for (int j = 0; j < model.Surfaces.Length; j++) { Surface surface = new Surface { Name = Label(binaryReader), Texture = Label(binaryReader) }; Vector3 val = Vec(binaryReader); surface.Color = new Color(val.x, val.y, val.z, 1f); surface.Vertices = new Vertex[binaryReader.ReadInt32()]; surface.Triangles = new int[binaryReader.ReadInt32()]; for (int k = 0; k < surface.Vertices.Length; k++) { Vertex vertex = new Vertex { Position = Vec(binaryReader), Normal = Vec(binaryReader), UV = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()) }; int num2 = binaryReader.ReadByte(); if (num2 < 1 || num2 > 4) { throw new InvalidDataException("Invalid skin influences"); } BoneWeight weight = default(BoneWeight); for (int l = 0; l < num2; l++) { int num3 = binaryReader.ReadByte(); float num4 = binaryReader.ReadSingle(); if (num3 >= num) { throw new InvalidDataException("Invalid bone index"); } switch (l) { case 0: ((BoneWeight)(ref weight)).boneIndex0 = num3; ((BoneWeight)(ref weight)).weight0 = num4; break; case 1: ((BoneWeight)(ref weight)).boneIndex1 = num3; ((BoneWeight)(ref weight)).weight1 = num4; break; case 2: ((BoneWeight)(ref weight)).boneIndex2 = num3; ((BoneWeight)(ref weight)).weight2 = num4; break; case 3: ((BoneWeight)(ref weight)).boneIndex3 = num3; ((BoneWeight)(ref weight)).weight3 = num4; break; } } vertex.Weight = weight; surface.Vertices[k] = vertex; } for (int m = 0; m < surface.Triangles.Length; m++) { surface.Triangles[m] = binaryReader.ReadInt32(); if (surface.Triangles[m] < 0 || surface.Triangles[m] >= surface.Vertices.Length) { throw new InvalidDataException("Invalid triangle index"); } } model.Surfaces[j] = surface; } if (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length) { throw new InvalidDataException(file); } return model; } private void Awake() { try { folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); first = Load(Path.Combine(folder, "v2-1-4.mesh")); rematch = Load(Path.Combine(folder, "v2-4-4.mesh")); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"G4SL33K V2 READY ({first.Surfaces.Length}/{rematch.Surfaces.Length} surfaces)"); SceneManager.sceneUnloaded += ResetProbe; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)ex); ((Behaviour)this).enabled = false; } } private void ResetProbe(Scene scene) { failed.Clear(); } private static string PrefabName(Transform t) { if (!((Object)t).name.EndsWith("(Clone)", StringComparison.Ordinal)) { return ((Object)t).name; } return ((Object)t).name.Substring(0, ((Object)t).name.Length - "(Clone)".Length).TrimEnd(); } private static string EncounterOf(Transform t) { bool flag = false; Transform parent = t.parent; while (Object.op_Implicit((Object)(object)parent)) { switch (PrefabName(parent)) { case "v2_GreenArm": case "V2 Green Arm": case "7 - Boss Arena 1": return "4-4"; case "V2 - Arena": case "V2 Event": case "Fake V2": flag = true; break; } parent = parent.parent; } if (!flag) { return null; } return "1-4"; } private void LateUpdate() { //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Min(Time.deltaTime, 0.025f); KeyValuePair<SkinnedMeshRenderer, Fitted>[] array = fitted.ToArray(); for (int i = 0; i < array.Length; i++) { KeyValuePair<SkinnedMeshRenderer, Fitted> keyValuePair = array[i]; if (!Object.op_Implicit((Object)(object)keyValuePair.Key) || !Object.op_Implicit((Object)(object)keyValuePair.Value.Body)) { Release(keyValuePair.Value); fitted.Remove(keyValuePair.Key); continue; } Fitted value = keyValuePair.Value; ((Renderer)value.Body).enabled = ((Renderer)keyValuePair.Key).enabled; if (((Component)keyValuePair.Key).gameObject.activeInHierarchy) { DrivePose(value); } if (num > 0f && Object.op_Implicit((Object)(object)value.Head) && ((Renderer)value.Body).enabled && ((Component)keyValuePair.Key).gameObject.activeInHierarchy) { AnimateHair(value, num); SamplePose(value); } else { value.HairRunning = false; } } if (Time.unscaledTime < next) { return; } next = Time.unscaledTime + 0.5f; bool flag = false; SkinnedMeshRenderer[] array2 = Resources.FindObjectsOfTypeAll<SkinnedMeshRenderer>(); foreach (SkinnedMeshRenderer val in array2) { if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.sharedMesh) || PrefabName(((Component)val).transform) != "v2_mdl") { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || fitted.ContainsKey(val) || failed.Contains(((Object)val).GetInstanceID())) { continue; } string text = EncounterOf(((Component)val).transform); if (text == null) { continue; } bool flag2 = text == "4-4"; Model model = (flag2 ? rematch : first); if (!((Component)val).gameObject.activeInHierarchy) { if (flag) { continue; } (Model, Mesh, string) tuple = MeshKey(model, val); if (!fittedMeshes.ContainsKey(tuple) && !prewarmFailures.Contains(tuple)) { flag = true; try { Attach(val, model, flag2, tuple, warmOnly: true); } catch (Exception ex) { prewarmFailures.Add(tuple); ((BaseUnityPlugin)this).Logger.LogWarning((object)("G4SL33K V2 could not prewarm " + text + ": " + ex.Message)); } } continue; } for (int j = 0; j < ((Component)val).transform.childCount; j++) { Transform child = ((Component)val).transform.GetChild(j); if (((Object)child).name.StartsWith("G4SL33K ", StringComparison.Ordinal)) { ((Component)child).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)child).gameObject); ((Renderer)val).forceRenderingOff = false; ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K V2 removed inherited visual " + text)); } } try { (Model, Mesh, string) key = MeshKey(model, val); bool flag3 = fittedMeshes.ContainsKey(key); Stopwatch stopwatch = Stopwatch.StartNew(); fitted.Add(val, Attach(val, model, flag2, key, warmOnly: false)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K V2 FIT " + text + " " + ((Object)((Component)val).transform.parent).name + " " + $"cached={flag3} {stopwatch.Elapsed.TotalMilliseconds:F1}ms")); } catch (Exception ex2) { failed.Add(((Object)val).GetInstanceID()); ((BaseUnityPlugin)this).Logger.LogWarning((object)("G4SL33K V2 FIT SKIPPED " + ex2)); } } } private void ClaimAnimators(Fitted f, SkinnedMeshRenderer stock) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) f.Animators = (from a in ((Component)stock).GetComponentsInParent<Animator>(true).Concat(f.Drivers.SelectMany((JointDriver d) => ((Component)d.Source).GetComponentsInParent<Animator>(true))) where Object.op_Implicit((Object)(object)a) select a).Distinct().ToArray(); Animator[] animators = f.Animators; foreach (Animator val in animators) { if (animatorClaims.TryGetValue(val, out (AnimatorCullingMode, int) value)) { animatorClaims[val] = (value.Item1, value.Item2 + 1); } else { animatorClaims.Add(val, (val.cullingMode, 1)); } val.cullingMode = (AnimatorCullingMode)0; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K V2 ANIMATORS " + string.Join(", ", f.Animators.Select((Animator a) => ((Object)a).name)))); } private void SamplePose(Fitted f) { //IL_0152: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: 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) if (f.Samples >= 8 || Time.unscaledTime < f.SampleAt || !((Renderer)f.Body).isVisible) { return; } f.SampleAt = Time.unscaledTime + 1.5f; f.Samples++; JointDriver headDriver = f.HeadDriver; JointDriver jointDriver = f.Drivers.First((JointDriver d) => ((Object)d.Source).name == "foot.L"); JointDriver jointDriver2 = f.Drivers.First((JointDriver d) => ((Object)d.Source).name == "foot.R"); float num = f.Hair.Max((Spring h) => Vector3.Distance(h.WorldPosition, h.WorldTarget)); float num2 = f.HairChains.Max((Spring[] chain) => Enumerable.Range(1, chain.Length - 1).Max((int i) => Mathf.Abs(Vector3.Distance(chain[i].WorldPosition, chain[i - 1].WorldPosition) - chain[i].Length))); IEnumerable<string> values = f.Animators.Where((Animator a) => Object.op_Implicit((Object)(object)a) && a.layerCount > 0).Select(delegate(Animator a) { //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) AnimatorStateInfo currentAnimatorStateInfo = a.GetCurrentAnimatorStateInfo(0); return $"{((Object)a).name}:{((AnimatorStateInfo)(ref currentAnimatorStateInfo)).shortNameHash}/{((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime:F2}"; }); float num3 = Vector3.Distance(f.HeadDriver.Output.localPosition, f.ChestDriver.Output.localPosition) / ((Vector3)(ref f.ChestToHead)).magnitude; ((BaseUnityPlugin)this).Logger.LogInfo((object)($"G4SL33K V2 POSE {((Object)f.Body).name} neckRatio={num3:F3} " + $"head={headDriver.Output.localPosition} feet={jointDriver.Output.localPosition}/{jointDriver2.Output.localPosition} " + string.Format("hairLag={0:F3} hairLengthError={1:F4} anim={2}", num, num2, string.Join(",", values)))); } private static Vector3 SignedScale(Matrix4x4 m) { //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) //IL_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(0)); float magnitude = ((Vector3)(ref val)).magnitude; val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(1)); float magnitude2 = ((Vector3)(ref val)).magnitude; val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(2)); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(magnitude, magnitude2, ((Vector3)(ref val)).magnitude); if (((Matrix4x4)(ref m)).determinant < 0f) { val2.x = 0f - val2.x; } return val2; } private static Quaternion RotationWithoutScale(Matrix4x4 m, Vector3 sign) { //IL_0003: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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_003b: 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) Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(2)) * Mathf.Sign(sign.z); Vector3 val2 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(1)) * Mathf.Sign(sign.y); return Quaternion.LookRotation(val, val2); } private static void DrivePose(Fitted f) { //IL_0006: 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_017f: 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_018b: 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_01a1: 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_01b1: 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_003a: 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_0049: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00af: 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_0121: 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_00e0: 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_00e7: 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_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_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_014b: 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_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0247: 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_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 worldToLocalMatrix = f.RigRoot.worldToLocalMatrix; JointDriver[] drivers = f.Drivers; foreach (JointDriver jointDriver in drivers) { if (!Object.op_Implicit((Object)(object)jointDriver.Source)) { continue; } Matrix4x4 m = worldToLocalMatrix * jointDriver.Source.localToWorldMatrix; Vector3 val = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(3)); Vector3 val4; if (jointDriver.Parent >= 0) { JointDriver jointDriver2 = f.Drivers[jointDriver.Parent]; Matrix4x4 val2 = worldToLocalMatrix * jointDriver2.Source.localToWorldMatrix; Vector3 val3 = val - Vector4.op_Implicit(((Matrix4x4)(ref val2)).GetColumn(3)); val4 = jointDriver.RestPosition - jointDriver2.RestPosition; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude > 0.0001f) { val3 = Vector3.ClampMagnitude(val3, magnitude * 1.04f); } val = jointDriver2.Output.localPosition + val3; } jointDriver.Output.localPosition = val; val4 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(2)); if (((Vector3)(ref val4)).sqrMagnitude > 1E-10f) { val4 = Vector4.op_Implicit(((Matrix4x4)(ref m)).GetColumn(1)); if (((Vector3)(ref val4)).sqrMagnitude > 1E-10f) { jointDriver.Output.localRotation = RotationWithoutScale(m, Vector3.one) * jointDriver.InverseRestRotation; } } } Transform output = f.HeadDriver.Output; Transform output2 = f.ChestDriver.Output; output.localPosition = output2.localPosition + output2.localRotation * f.ChestToHead; output.localRotation = Quaternion.RotateTowards(output2.localRotation, output.localRotation, 52f); drivers = f.Drivers; foreach (JointDriver jointDriver3 in drivers) { JointDriver segmentEnd = jointDriver3.SegmentEnd; if (segmentEnd != null) { Vector3 val5 = segmentEnd.RestPosition - jointDriver3.RestPosition; Vector3 val6 = segmentEnd.Output.localPosition - jointDriver3.Output.localPosition; if (!(((Vector3)(ref val5)).sqrMagnitude < 1E-08f) && !(((Vector3)(ref val6)).sqrMagnitude < 1E-08f)) { Quaternion localRotation = jointDriver3.Output.localRotation; jointDriver3.Output.localRotation = Quaternion.FromToRotation(localRotation * val5, val6) * localRotation; } } } } private static int Depth(Transform t) { int num = 0; while (Object.op_Implicit((Object)(object)t)) { num++; t = t.parent; } return num; } private static void CreateDrivers(Fitted f, GameObject host, List<Transform> bones, List<Matrix4x4> bind) { //IL_00a7: 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_00b0: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) f.RigRoot = host.transform; Transform[] source = bones.ToArray(); List<JointDriver> list = new List<JointDriver>(); Dictionary<Transform, int> dictionary = new Dictionary<Transform, int>(); foreach (int item in from i in Enumerable.Range(0, source.Length) where Object.op_Implicit((Object)(object)source[i]) orderby Depth(source[i]) select i) { Transform val = source[item]; Matrix4x4 val2 = bind[item]; Matrix4x4 inverse = ((Matrix4x4)(ref val2)).inverse; Vector3 sign = SignedScale(inverse); Transform transform = new GameObject(((Object)val).name + " display").transform; transform.SetParent(f.RigRoot, false); transform.localScale = Vector3.one; JointDriver jointDriver = new JointDriver { Source = val, Output = transform, RestPosition = Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(3)), InverseRestRotation = Quaternion.Inverse(RotationWithoutScale(inverse, sign)) }; if (((Object)val).name.StartsWith("spine.", StringComparison.Ordinal)) { Transform parent = val.parent; while (Object.op_Implicit((Object)(object)parent) && !dictionary.TryGetValue(parent, out jointDriver.Parent)) { jointDriver.Parent = -1; parent = parent.parent; } } dictionary[val] = list.Count; list.Add(jointDriver); bones[item] = transform; } f.Drivers = list.ToArray(); Dictionary<string, JointDriver> dictionary2 = f.Drivers.ToDictionary((JointDriver d) => ((Object)d.Source).name, (JointDriver d) => d); f.HeadDriver = dictionary2["spine.006"]; f.ChestDriver = dictionary2["spine.003"]; JointDriver[] drivers = f.Drivers; foreach (JointDriver jointDriver2 in drivers) { string text = Child(((Object)jointDriver2.Source).name); if (text.Length > 0 && ((Object)jointDriver2.Source).name.Contains(".") && !((Object)jointDriver2.Source).name.StartsWith("spine", StringComparison.Ordinal)) { dictionary2.TryGetValue(text, out jointDriver2.SegmentEnd); } } f.WorldScale = Mathf.Abs(host.transform.lossyScale.y); DrivePose(f); } private static void AnimateHair(Fitted model, float dt) { //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_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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0210: 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_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a3: 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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00ec: 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_00ff: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0184: 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_018b: 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_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_0262: 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_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //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_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0334: 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_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_036a: 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_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03aa: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_051f: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_0541: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0559: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03da: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) Transform head = model.Head; float num = Mathf.Max(0.1f, model.WorldScale); bool flag = !model.HairRunning; Transform rigRoot = model.RigRoot; Quaternion val = Quaternion.FromToRotation(rigRoot.TransformDirection(model.RestUp), Vector3.up); Spring[][] hairChains = model.HairChains; Vector3 val5; foreach (Spring[] array in hairChains) { for (int j = 0; j < array.Length; j++) { Spring spring = array[j]; if (j == 0) { spring.Goal = head.TransformPoint(spring.Rest); continue; } Spring spring2 = array[j - 1]; Vector3 val2 = spring.Rest - spring2.Rest; Vector3 val3 = head.TransformVector(val2); Vector3 val4 = Vector3.Slerp(val * rigRoot.TransformVector(val2), val3, Mathf.Lerp(0.25f, 0.07f, spring.Gain)); spring.Length = ((Vector3)(ref val3)).magnitude; spring.Goal = spring2.Goal + ((Vector3)(ref val4)).normalized * spring.Length; } bool num2 = flag; val5 = array[0].Goal - array[0].WorldTarget; flag = num2 | (((Vector3)(ref val5)).sqrMagnitude > num * num); } if (flag) { foreach (Spring item in model.Hair) { val5 = (item.WorldTarget = (item.WorldPosition = item.Goal)); item.Velocity = Vector3.zero; item.Bone.localPosition = head.InverseTransformPoint(item.Goal); item.Bone.localRotation = Quaternion.identity; } model.HairRunning = true; return; } int num3 = Mathf.Clamp(Mathf.CeilToInt(dt * 120f), 1, 4); float num4 = dt / (float)num3; Vector3 position = model.Drivers[0].Output.position; Vector3 position2 = model.ChestDriver.Output.position; float num5 = 0.14f * num; hairChains = model.HairChains; foreach (Spring[] array2 in hairChains) { for (int k = 1; k <= num3; k++) { float num6 = (float)k / (float)num3; array2[0].WorldPosition = Vector3.Lerp(array2[0].WorldTarget, array2[0].Goal, num6); for (int l = 1; l < array2.Length; l++) { Spring spring3 = array2[l]; spring3.PreviousStep = spring3.WorldPosition; Vector3 val6 = Vector3.Lerp(spring3.WorldTarget, spring3.Goal, num6); float num7 = Mathf.Lerp(160f, 34f, spring3.Gain); Vector3 val7 = (val6 - spring3.WorldPosition) * num7 + Vector3.down * (3.4f * spring3.Gain); spring3.Velocity = Vector3.ClampMagnitude((spring3.Velocity + val7 * num4) * Mathf.Exp(-6.5f * num4), 4.5f * num); spring3.WorldPosition += spring3.Velocity * num4; Vector3 val8 = position2 - position; float num8 = Vector3.Dot(spring3.WorldPosition - position, val8) / Mathf.Max(0.001f, ((Vector3)(ref val8)).sqrMagnitude); Vector3 val9 = position + val8 * Mathf.Clamp01(num8); Vector3 val10 = spring3.WorldPosition - val9; if (((Vector3)(ref val10)).sqrMagnitude > 1E-08f && ((Vector3)(ref val10)).sqrMagnitude < num5 * num5) { spring3.WorldPosition = val9 + ((Vector3)(ref val10)).normalized * num5; } } for (int m = 1; m < array2.Length; m++) { Spring spring4 = array2[m]; Spring spring5 = array2[m - 1]; Vector3 val11 = spring4.WorldPosition - spring5.WorldPosition; val5 = spring4.Goal - spring5.Goal; Vector3 normalized = ((Vector3)(ref val5)).normalized; if (((Vector3)(ref val11)).sqrMagnitude < 1E-08f) { val11 = normalized; } Vector3 val12 = Vector3.RotateTowards(normalized, ((Vector3)(ref val11)).normalized, (float)Math.PI * 4f / 15f, 0f); spring4.WorldPosition = spring5.WorldPosition + val12 * spring4.Length; spring4.Velocity = Vector3.ClampMagnitude((spring4.WorldPosition - spring4.PreviousStep) / num4, 4.5f * num); } } for (int n = 0; n < array2.Length; n++) { Spring spring6 = array2[n]; spring6.WorldTarget = spring6.Goal; spring6.Bone.localPosition = head.InverseTransformPoint(spring6.WorldPosition); if (n != 0) { Spring spring7 = array2[n - 1]; Vector3 val13 = spring6.Rest - spring7.Rest; Vector3 val14 = head.InverseTransformVector(spring6.WorldPosition - spring7.WorldPosition); spring6.Bone.localRotation = Quaternion.RotateTowards(Quaternion.identity, Quaternion.FromToRotation(val13, val14), 34f); } } } } private Material Lit(Surface surface, Material stock) { //IL_007e: 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_0085: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_0107: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) (Surface, Material) key = (surface, stock); if (materials.TryGetValue(key, out var value)) { return value; } bool flag = Object.op_Implicit((Object)(object)stock) && Object.op_Implicit((Object)(object)stock.shader) && ((Object)stock.shader).name == "ULTRAKILL/Master"; Shader val = (flag ? stock.shader : Shader.Find("Standard")); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("V2 lighting shader unavailable"); } Material val2 = (flag ? new Material(stock) : new Material(val)); ((Object)val2).name = surface.Name; bool flag2 = surface.Name.Contains("alloy") || surface.Name.Contains("shell") || surface.Name.Contains("steel"); Texture2D value2; if (!string.IsNullOrEmpty(surface.Texture)) { if (!textures.TryGetValue(surface.Texture, out value2)) { value2 = new Texture2D(2, 2, (TextureFormat)4, true) { name = surface.Texture }; if (!ImageConversion.LoadImage(value2, File.ReadAllBytes(Path.Combine(folder, surface.Texture)), true)) { throw new InvalidDataException(surface.Texture); } ((Texture)value2).filterMode = (FilterMode)0; textures.Add(surface.Texture, value2); } } else { value2 = new Texture2D(1, 1, (TextureFormat)4, false); value2.SetPixel(0, 0, ((Color)(ref surface.Color)).gamma); value2.Apply(false, true); textures["solid:" + surface.Name + ":" + textures.Count] = value2; } val2.mainTexture = (Texture)(object)value2; val2.mainTextureOffset = Vector2.zero; val2.mainTextureScale = Vector2.one; val2.color = Color.white; if (val2.HasProperty("_Glossiness")) { val2.SetFloat("_Glossiness", flag2 ? 0.32f : 0.1f); } if (val2.HasProperty("_Metallic")) { val2.SetFloat("_Metallic", flag2 ? 0.18f : 0f); } if (flag) { bool flag3 = surface.Name.Contains("cyan indicator"); val2.SetTexture("_EmissiveTex", (Texture)(object)(flag3 ? value2 : Texture2D.blackTexture)); val2.SetColor("_EmissiveColor", Color.white); val2.SetFloat("_UseAlbedoAsEmissive", 0f); val2.SetFloat("_EmissiveIntensity", flag3 ? 0.65f : 0f); if (flag3) { val2.EnableKeyword("EMISSIVE"); } else { val2.DisableKeyword("EMISSIVE"); } } if (!string.IsNullOrEmpty(surface.Texture) && !surface.Texture.StartsWith("G4Band")) { val2.SetFloat("_Cutoff", 0.42f); val2.SetOverrideTag("RenderType", "TransparentCutout"); val2.EnableKeyword("_ALPHATEST_ON"); if (!flag) { val2.SetFloat("_Mode", 1f); } val2.renderQueue = 2450; } materials.Add(key, val2); return val2; } private static string Existing(string name, Dictionary<string, int> index) { if (index.ContainsKey(name)) { return name; } if (name.StartsWith("f_") || name.StartsWith("thumb.")) { string text = name.Substring(name.Length - 2); if (name.Contains(".03") && index.ContainsKey(name.Replace(".03", ".02"))) { return name.Replace(".03", ".02"); } if (name.Contains(".02") && index.ContainsKey(name.Replace(".02", ".01"))) { return name.Replace(".02", ".01"); } return "hand" + text; } return "spine"; } private static string Child(string name) { if (name == "spine") { return "spine.003"; } if (name == "spine.003") { return "spine.005"; } if (name.Length < 3) { return ""; } string text = name.Substring(name.Length - 2); if (text != ".L" && text != ".R") { return ""; } return name.Substring(0, name.Length - 2) switch { "upper_arm" => "forearm" + text, "forearm" => "hand" + text, "thigh" => "shin" + text, "shin" => "foot" + text, "foot" => "toe" + text, _ => "", }; } private static (Model, Mesh, string) MeshKey(Model model, SkinnedMeshRenderer stock) { return (model, stock.sharedMesh, string.Join("|", stock.bones.Select((Transform b) => (!Object.op_Implicit((Object)(object)b)) ? "" : ((Object)b).name))); } private Fitted Attach(SkinnedMeshRenderer stock, Model model, bool isRematch, (Model, Mesh, string) key, bool warmOnly) { //IL_01ee: 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_0208: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_0244: 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_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0268: 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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: 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_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_046f: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Expected O, but got Unknown //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05ec: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0617: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Unknown result type (might be due to invalid IL or missing references) //IL_0671: Unknown result type (might be due to invalid IL or missing references) //IL_0689: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_07aa: Unknown result type (might be due to invalid IL or missing references) //IL_07af: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ce: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_071d: Unknown result type (might be due to invalid IL or missing references) //IL_0737: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_085e: Unknown result type (might be due to invalid IL or missing references) //IL_0863: Unknown result type (might be due to invalid IL or missing references) //IL_08ac: Unknown result type (might be due to invalid IL or missing references) //IL_08c4: Unknown result type (might be due to invalid IL or missing references) //IL_08c9: Unknown result type (might be due to invalid IL or missing references) //IL_08ce: Unknown result type (might be due to invalid IL or missing references) //IL_08e3: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_08f6: Unknown result type (might be due to invalid IL or missing references) //IL_08fb: Unknown result type (might be due to invalid IL or missing references) //IL_1012: Unknown result type (might be due to invalid IL or missing references) //IL_1017: Unknown result type (might be due to invalid IL or missing references) //IL_102c: Unknown result type (might be due to invalid IL or missing references) //IL_104d: Unknown result type (might be due to invalid IL or missing references) //IL_0d55: Unknown result type (might be due to invalid IL or missing references) //IL_0d5a: Unknown result type (might be due to invalid IL or missing references) //IL_0940: Unknown result type (might be due to invalid IL or missing references) //IL_0958: Unknown result type (might be due to invalid IL or missing references) //IL_095d: Unknown result type (might be due to invalid IL or missing references) //IL_0962: Unknown result type (might be due to invalid IL or missing references) //IL_096d: Unknown result type (might be due to invalid IL or missing references) //IL_097b: Unknown result type (might be due to invalid IL or missing references) //IL_0980: Unknown result type (might be due to invalid IL or missing references) //IL_0985: Unknown result type (might be due to invalid IL or missing references) //IL_09b1: Unknown result type (might be due to invalid IL or missing references) //IL_09d0: Unknown result type (might be due to invalid IL or missing references) //IL_09d5: Unknown result type (might be due to invalid IL or missing references) //IL_09df: Unknown result type (might be due to invalid IL or missing references) //IL_09e4: Unknown result type (might be due to invalid IL or missing references) //IL_09f2: Unknown result type (might be due to invalid IL or missing references) //IL_0a05: Unknown result type (might be due to invalid IL or missing references) //IL_0a0a: Unknown result type (might be due to invalid IL or missing references) //IL_0a0f: Unknown result type (might be due to invalid IL or missing references) //IL_0a48: Unknown result type (might be due to invalid IL or missing references) //IL_0a4d: Unknown result type (might be due to invalid IL or missing references) //IL_0a4f: Unknown result type (might be due to invalid IL or missing references) //IL_0a54: Unknown result type (might be due to invalid IL or missing references) //IL_0a56: Unknown result type (might be due to invalid IL or missing references) //IL_0a62: Unknown result type (might be due to invalid IL or missing references) //IL_0a67: Unknown result type (might be due to invalid IL or missing references) //IL_0a6c: Unknown result type (might be due to invalid IL or missing references) //IL_0a81: Unknown result type (might be due to invalid IL or missing references) //IL_0a86: Unknown result type (might be due to invalid IL or missing references) //IL_0c1b: Unknown result type (might be due to invalid IL or missing references) //IL_0c20: Unknown result type (might be due to invalid IL or missing references) //IL_0c24: Unknown result type (might be due to invalid IL or missing references) //IL_0c29: Unknown result type (might be due to invalid IL or missing references) //IL_0c30: Unknown result type (might be due to invalid IL or missing references) //IL_0c35: Unknown result type (might be due to invalid IL or missing references) //IL_0cb6: Unknown result type (might be due to invalid IL or missing references) //IL_0cc9: Unknown result type (might be due to invalid IL or missing references) //IL_0cdc: Unknown result type (might be due to invalid IL or missing references) //IL_0cef: Unknown result type (might be due to invalid IL or missing references) //IL_0cf8: Unknown result type (might be due to invalid IL or missing references) //IL_0d04: Unknown result type (might be due to invalid IL or missing references) //IL_0d79: Unknown result type (might be due to invalid IL or missing references) //IL_0d82: Expected O, but got Unknown //IL_0db4: Unknown result type (might be due to invalid IL or missing references) //IL_0e57: Unknown result type (might be due to invalid IL or missing references) //IL_0e5c: Unknown result type (might be due to invalid IL or missing references) //IL_0e61: Unknown result type (might be due to invalid IL or missing references) //IL_0e66: Unknown result type (might be due to invalid IL or missing references) List<Transform> list = stock.bones.ToList(); List<Matrix4x4> bind = stock.sharedMesh.bindposes.ToList(); if (list.Count != bind.Count) { throw new InvalidOperationException("V2 bind pose count differs from skeleton"); } Dictionary<string, int> index = new Dictionary<string, int>(); for (int i = 0; i < list.Count; i++) { if (Object.op_Implicit((Object)(object)list[i]) && !index.ContainsKey(((Object)list[i]).name)) { index.Add(((Object)list[i]).name, i); } } string[] array = new string[16] { "spine", "spine.003", "spine.005", "spine.006", "upper_arm.R", "upper_arm.L", "wing_1_1", "thigh.L", "thigh.R", "foot.L", "foot.R", "shin.L", "shin.R", "spine.001", "f_index.01.L", "f_index.01.R" }; foreach (string text in array) { if (!index.ContainsKey(text)) { throw new InvalidOperationException("Missing " + text); } } Dictionary<string, Vector3> source = model.Joints.Select((string name, int item) => (name: name, i: item)).ToDictionary(((string name, int i) x) => x.name, ((string name, int i) x) => model.Rest[x.i]); Vector3 hips = (T("thigh.L") + T("thigh.R")) * 0.5f; Vector3 val = (T("foot.L") + T("foot.R")) * 0.5f; Vector3 srcHips = (source["thigh.L"] + source["thigh.R"]) * 0.5f; Vector3 val2 = (source["foot.L"] + source["foot.R"]) * 0.5f; Vector3 val3 = T("upper_arm.R") - T("upper_arm.L"); Vector3 val4 = hips - val; Vector3 val5 = Vector3.ProjectOnPlane(val4, val3); val4 = ((Vector3)(ref val5)).normalized; val5 = Vector3.Cross(val3, val4); Vector3 normalized = ((Vector3)(ref val5)).normalized; Quaternion alignment = Quaternion.LookRotation(normalized, val4); val5 = hips - val; float magnitude = ((Vector3)(ref val5)).magnitude; val5 = srcHips - val2; float bodyScale = magnitude / ((Vector3)(ref val5)).magnitude; if (!(bodyScale > 0.2f) || !(bodyScale < 5f)) { throw new InvalidOperationException("Invalid V2 scale " + bodyScale); } Fitted fitted = new Fitted { RestUp = alignment * Vector3.up, HeadBindPivot = Neutral(source["spine.006"]), ChestToHead = Neutral(source["spine.006"]) - T("spine.003") }; int[] maps = new int[model.Joints.Length]; Vector3[] positions = (Vector3[])(object)new Vector3[maps.Length]; Quaternion[] rotations = (Quaternion[])(object)new Quaternion[maps.Length]; float[] stretch = new float[maps.Length]; Vector3[] axis = (Vector3[])(object)new Vector3[maps.Length]; int[] baseJoint = new int[maps.Length]; Mesh value = null; GameObject val6 = null; Vertex v; Vector3 p; Vector3 n; try { val6 = new GameObject("G4SL33K " + (isRematch ? "4-4" : "1-4")); val6.layer = ((Component)stock).gameObject.layer; val6.transform.SetParent(((Component)stock).transform, false); CreateDrivers(fitted, val6, list, bind); fitted.Head = list[index["spine.006"]]; Dictionary<string, int> dictionary = model.Joints.Select((string name, int item) => (name: name, i: item)).ToDictionary(((string name, int i) x) => x.name, ((string name, int i) x) => x.i); for (int num = 0; num < maps.Length; num++) { string text2 = model.Joints[num]; baseJoint[num] = num; stretch[num] = 1f; if (text2.StartsWith("Hair", StringComparison.Ordinal)) { Vector3 val7 = Neutral(model.Rest[num]); Transform transform = new GameObject(text2).transform; transform.SetParent(fitted.Head, false); transform.localPosition = val7 - fitted.HeadBindPivot; fitted.Hair.Add(new Spring { Bone = transform, Rest = transform.localPosition, Gain = (float)(text2[text2.Length - 1] - 48) / 4f }); maps[num] = list.Count; list.Add(transform); bind.Add(Matrix4x4.Translate(-val7)); positions[num] = val7; rotations[num] = alignment; continue; } if (text2.StartsWith("Wing", StringComparison.Ordinal)) { maps[num] = index["spine.003"]; positions[num] = Neutral(model.Rest[num]); rotations[num] = alignment; continue; } string text3 = Existing(text2, index); maps[num] = index[text3]; positions[num] = Neutral(model.Rest[num]); rotations[num] = alignment; if (text2.StartsWith("spine", StringComparison.Ordinal) || text2.StartsWith("shoulder")) { continue; } if (text2.StartsWith("f_") || text2.StartsWith("thumb.")) { baseJoint[num] = dictionary["hand" + text2.Substring(text2.Length - 2)]; continue; } positions[num] = T(text3); string text4 = Child(text2); Vector3 val8; Vector3 val9; if (text2.StartsWith("hand")) { string text5 = text2.Substring(text2.Length - 2); val8 = source["f_index.01" + text5] - model.Rest[num]; val9 = T("f_index.01" + text5) - T(text3); } else { if (!index.ContainsKey(text4) || !source.ContainsKey(text4)) { continue; } val8 = source[text4] - model.Rest[num]; val9 = T(text4) - T(text3); if (text2.StartsWith("upper_arm")) { positions[num] = Vector3.Lerp(positions[num], Neutral(model.Rest[num]), 0.58f); val9 = T(text4) - positions[num]; } } if (((Vector3)(ref val8)).sqrMagnitude > 1E-07f && ((Vector3)(ref val9)).sqrMagnitude > 1E-07f) { rotations[num] = Quaternion.FromToRotation(alignment * val8, val9) * alignment; axis[num] = ((Vector3)(ref val8)).normalized; if (!text2.StartsWith("hand")) { stretch[num] = ((Vector3)(ref val9)).magnitude / (((Vector3)(ref val8)).magnitude * bodyScale); } } } fitted.HairChains = (from h in fitted.Hair group h by ((Object)h.Bone).name[4] into @group select @group.OrderBy((Spring h) => ((Object)h.Bone).name).ToArray()).ToArray(); if (fitted.HairChains.Length != 2 || fitted.HairChains.Any((Spring[] chain) => chain.Length != 5)) { throw new InvalidDataException("Expected two five-joint hair chains"); } if (!fittedMeshes.TryGetValue(key, out value)) { Stopwatch stopwatch = Stopwatch.StartNew(); List<Vector3> list2 = new List<Vector3>(); List<Vector3> list3 = new List<Vector3>(); List<Vector2> list4 = new List<Vector2>(); List<BoneWeight> list5 = new List<BoneWeight>(); List<int[]> list6 = new List<int[]>(); Surface[] surfaces = model.Surfaces; foreach (Surface surface in surfaces) { int offset = list2.Count; Vertex[] vertices = surface.Vertices; for (int num2 = 0; num2 < vertices.Length; num2++) { v = vertices[num2]; BoneWeight weight = v.Weight; p = Vector3.zero; n = Vector3.zero; Add(((BoneWeight)(ref weight)).boneIndex0, ((BoneWeight)(ref weight)).weight0); Add(((BoneWeight)(ref weight)).boneIndex1, ((BoneWeight)(ref weight)).weight1); Add(((BoneWeight)(ref weight)).boneIndex2, ((BoneWeight)(ref weight)).weight2); Add(((BoneWeight)(ref weight)).boneIndex3, ((BoneWeight)(ref weight)).weight3); list2.Add(p); list3.Add(((Vector3)(ref n)).normalized); list4.Add(v.UV); list5.Add(Skin(weight, v.Position, surface.Name)); } list6.Add(surface.Triangles.Select((int num4) => num4 + offset).ToArray()); } value = new Mesh { name = "G4SL33K " + (isRematch ? "4-4" : "1-4"), indexFormat = (IndexFormat)1 }; value.SetVertices(list2); value.SetNormals(list3); value.SetUVs(0, list4); value.colors32 = Enumerable.Repeat<Color32>(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), list2.Count).ToArray(); value.subMeshCount = list6.Count; for (int num3 = 0; num3 < list6.Count; num3++) { value.SetTriangles(list6[num3], num3, false); } Matrix4x4[] array2 = bind.Select(delegate(Matrix4x4 b) { //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_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_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) Matrix4x4 inverse = ((Matrix4x4)(ref b)).inverse; return Matrix4x4.Translate(-Vector4.op_Implicit(((Matrix4x4)(ref inverse)).GetColumn(3))); }).ToArray(); array2[index["spine.006"]] = Matrix4x4.Translate(-fitted.HeadBindPivot); value.bindposes = array2; value.boneWeights = list5.ToArray(); value.RecalculateBounds(); value.UploadMeshData(false); fittedMeshes.Add(key, value); ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K V2 " + (warmOnly ? "PREWARM" : "BUILD") + " " + ((Object)value).name + " " + $"{value.vertexCount} vertices in {stopwatch.Elapsed.TotalMilliseconds:F1}ms")); } Material stockMaterial = ((IEnumerable<Material>)((Renderer)stock).sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m) && Object.op_Implicit((Object)(object)m.shader) && ((Object)m.shader).name == "ULTRAKILL/Master")); Material[] sharedMaterials = model.Surfaces.Select((Surface surface2) => Lit(surface2, stockMaterial)).ToArray(); if (warmOnly) { Object.Destroy((Object)(object)val6); return null; } fitted.Body = val6.AddComponent<SkinnedMeshRenderer>(); fitted.Body.sharedMesh = value; fitted.Body.bones = list.ToArray(); fitted.Body.rootBone = val6.transform; fitted.Body.quality = (SkinQuality)4; ((Renderer)fitted.Body).sharedMaterials = sharedMaterials; ((BaseUnityPlugin)this).Logger.LogInfo((object)("G4SL33K V2 SHADER " + ((Object)((Renderer)fitted.Body).sharedMaterials[0].shader).name)); Bounds bounds = value.bounds; ((Bounds)(ref bounds)).Expand(2f); ((Renderer)fitted.Body).localBounds = bounds; ((Renderer)fitted.Body).enabled = ((Renderer)stock).enabled; ((Renderer)fitted.Body).shadowCastingMode = ((Renderer)stock).shadowCastingMode; ((Renderer)fitted.Body).receiveShadows = ((Renderer)stock).receiveShadows; ClaimAnimators(fitted, stock); Hide(fitted, (Renderer)(object)stock); return fitted; } catch { foreach (Spring item in fitted.Hair) { if (Object.op_Implicit((Object)(object)item.Bone)) { Object.Destroy((Object)(object)((Component)item.Bone).gameObject); } } if (Object.op_Implicit((Object)(object)val6)) { Object.Destroy((Object)(object)val6); } if (Object.op_Implicit((Object)(object)value) && !fittedMeshes.ContainsKey(key)) { Object.Destroy((Object)(object)value); } throw; } void Add(int num5, float amount) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_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_0049: 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_0066: 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_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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (!(amount <= 0f)) { int num4 = baseJoint[num5]; Vector3 val10 = v.Position - model.Rest[num4]; Vector3 val11 = val10 + axis[num4] * Vector3.Dot(val10, axis[num4]) * (stretch[num4] - 1f); string text6 = model.Joints[num5]; Vector3 val12 = ((text6.StartsWith("spine") || text6.StartsWith("shoulder") || text6.StartsWith("Hair") || text6.StartsWith("Wing")) ? Neutral(v.Position) : (positions[num4] + rotations[num4] * val11 * bodyScale)); p += amount * val12; n += amount * (rotations[num4] * v.Normal); } } float BlendAt(string a, string b) { //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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0038: 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) Vector3 val10 = source[b] - source[a]; Vector3 normalized2 = ((Vector3)(ref val10)).normalized; float num4 = Vector3.Dot(P_2.p - source[b], normalized2); return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(-0.022f, 0.022f, num4)); } Vector3 Neutral(Vector3 val11) { //IL_0000: 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_000c: 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_004a: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector3 val10 = val11 - srcHips; float num4 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.12f, 1.31f, val11.y)) * (1f - Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.31f, 1.37f, val11.y))); val10.x *= 1f + 0.35f * num4; return hips + alignment * val10 * bodyScale; } static BoneWeight Pair(int a, int b, float amount) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0036: Unknown result type (might be due to invalid IL or missing references) BoneWeight result; if (amount >= 0.5f) { result = default(BoneWeight); ((BoneWeight)(ref result)).boneIndex0 = b; ((BoneWeight)(ref result)).weight0 = amount; ((BoneWeight)(ref result)).boneIndex1 = a; ((BoneWeight)(ref result)).weight1 = 1f - amount; return result; } result = default(BoneWeight); ((BoneWeight)(ref result)).boneIndex0 = a; ((BoneWeight)(ref result)).weight0 = 1f - amount; ((BoneWeight)(ref result)).boneIndex1 = b; ((BoneWeight)(ref result)).weight1 = amount; return result; } BoneWeight Skin(BoneWeight result, Vector3 val10, string text7) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: 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_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_0176: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_027e: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04a4: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_043f: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) string text6 = model.Joints[((BoneWeight)(ref result)).boneIndex0]; ((BoneWeight)(ref result)).boneIndex0 = maps[((BoneWeight)(ref result)).boneIndex0]; ((BoneWeight)(ref result)).boneIndex1 = maps[((BoneWeight)(ref result)).boneIndex1]; ((BoneWeight)(ref result)).boneIndex2 = maps[((BoneWeight)(ref result)).boneIndex2]; ((BoneWeight)(ref result)).boneIndex3 = maps[((BoneWeight)(ref result)).boneIndex3]; if (((BoneWeight)(ref result)).weight1 > ((BoneWeight)(ref result)).weight0 && ((BoneWeight)(ref result)).weight2 == 0f) { ref BoneWeight reference = ref result; float weight2 = ((BoneWeight)(ref result)).weight1; float weight3 = ((BoneWeight)(ref result)).weight0; ((BoneWeight)(ref result)).weight0 = weight2; ((BoneWeight)(ref reference)).weight1 = weight3; reference = ref result; int boneIndex = ((BoneWeight)(ref result)).boneIndex1; int boneIndex2 = ((BoneWeight)(ref result)).boneIndex0; ((BoneWeight)(ref result)).boneIndex0 = boneIndex; ((BoneWeight)(ref reference)).boneIndex1 = boneIndex2; } if (text7 == "Base" && val10.y >= 1.315f && val10.y < 1.38f && Mathf.Abs(val10.x) < 0.07f) { float amount = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.322f, 1.379f, val10.y)); return Pair(index["spine.003"], index["spine.006"], amount); } if (text6.StartsWith("Hair") || text6.StartsWith("Wing") || text6 == "spine.006") { return result; } int a = index["spine.001"]; int num4 = index["spine.003"]; if (val10.y < 0.78f && (text7.StartsWith("Matte boot", StringComparison.Ordinal) || text7 == "G4SL33K | teal trim" || text7 == "Base")) { string text8 = ((val10.x < 0f) ? ".L" : ".R"); float amount2 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.473f, 0.562f, val10.y)); float amount3 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.121f, 0.204f, val10.y)); if (!(val10.y > 0.25f)) { return Pair(index["foot" + text8], index["shin" + text8], amount3); } return Pair(index["shin" + text8], index["thigh" + text8], amount2); } if (text6.StartsWith("spine", StringComparison.Ordinal)) { float amount4 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(1.025f, 1.19f, val10.y)); return Pair(a, num4, amount4); } if (text6.StartsWith("upper_arm", StringComparison.Ordinal) || text6.StartsWith("forearm", StringComparison.Ordinal) || text6.StartsWith("hand", StringComparison.Ordinal)) { string text9 = text6.Substring(text6.Length - 2); string text10 = "upper_arm" + text9; string text11 = "forearm" + text9; string text12 = "hand" + text9; if (index.ContainsKey(text11) && index.ContainsKey(text12)) { Vector3 val11 = val10 - source[text11]; if (((Vector3)(ref val11)).sqrMagnitude < 0.0014439999f && text6 != text12) { return Pair(index[text10], index[text11], BlendAt(text10, text11)); } val11 = val10 - source[text12]; if (((Vector3)(ref val11)).sqrMagnitude < 0.000961f && text6 != text10) { return Pair(index[text11], index[text12], BlendAt(text11, text12)); } } if (text6 == text10) { float amount5 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.096f, 0.165f, Mathf.Abs(val10.x))); return Pair(num4, ((BoneWeight)(ref result)).boneIndex0, amount5); } } return result; } Vector3 T(string name) { //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_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 val10 = bind[index[name]]; val10 = ((Matrix4x4)(ref val10)).inverse; return ((Matrix4x4)(ref val10)).MultiplyPoint3x4(Vector3.zero); } } private static void Hide(Fitted f, Renderer r) { f.Hidden.Add((r, r.forceRenderingOff)); r.forceRenderingOff = true; } private void Release(Fitted f) { //IL_00dd: 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) foreach (var item in f.Hidden) { if (Object.op_Implicit((Object)(object)item.Item1)) { item.Item1.forceRenderingOff = item.Item2; } } foreach (Spring item2 in f.Hair) { if (Object.op_Implicit((Object)(object)item2.Bone)) { Object.Destroy((Object)(object)((Component)item2.Bone).gameObject); } } if (f.Animators != null) { Animator[] animators = f.Animators; foreach (Animator val in animators) { if (!animatorClaims.TryGetValue(val, out (AnimatorCullingMode, int) value)) { continue; } if (value.Item2 > 1) { animatorClaims[val] = (value.Item1, value.Item2 - 1); continue; } if (Object.op_Implicit((Object)(object)val)) { val.cullingMode = value.Item1; } animatorClaims.Remove(val); } } if (Object.op_Implicit((Object)(object)f.RigRoot)) { Object.Destroy((Object)(object)((Component)f.RigRoot).gameObject); } } private void OnDestroy() { SceneManager.sceneUnloaded -= ResetProbe; foreach (Fitted value in fitted.Values) { Release(value); } foreach (Mesh value2 in fittedMeshes.Values) { if (Object.op_Implicit((Object)(object)value2)) { Object.Destroy((Object)(object)value2); } } foreach (Material value3 in materials.Values) { Object.Destroy((Object)(object)value3); } foreach (Texture2D value4 in textures.Values) { Object.Destroy((Object)(object)value4); } } }