Decompiled source of Big Disrespect v1.0.1
BepInEx/plugins/Big_Disrespect/FlipOff.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Microsoft.CodeAnalysis; using Mirror; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("FlipOff")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1")] [assembly: AssemblyProduct("FlipOff")] [assembly: AssemblyTitle("FlipOff")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [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; } } } namespace FlipOff { internal static class Bird { private sealed class Rig { private readonly HandSize _size = new HandSize(); public readonly HandRig Left; public readonly HandRig Right; public PlayerCharacter Player; public Rig() { Left = new HandRig(right: false, _size); Right = new HandRig(right: true, _size); } public void Hide() { Left.Hide(); Right.Hide(); } public void Destroy() { Left.Destroy(); Right.Destroy(); } } private static readonly Dictionary<IntPtr, Rig> Rigs = new Dictionary<IntPtr, Rig>(); private static readonly List<IntPtr> Dead = new List<IntPtr>(); private static bool _armed = true; private static long _idleTicks; private static long _idleCalls; private static long _workTicks; private static long _workCalls; private static long _worst; private static long _overhead; private static bool _calibrated; public static bool Tick(PlayerCharacter pc) { if (!_armed || !Plugin.Enabled.Value || pc == null) { return false; } if (!Plugin.ShowOnOtherPlayers.Value && !IsLocal(pc)) { if (Rigs.TryGetValue(((Il2CppObjectBase)pc).Pointer, out var value)) { value.Hide(); } return false; } bool flag; bool flag2; if (Plugin.AlwaysOn.Value) { flag = (flag2 = true); } else { PlayerGestures gestures = pc.gestures; if (gestures == null) { if (Rigs.TryGetValue(((Il2CppObjectBase)pc).Pointer, out var value2)) { value2.Hide(); } return false; } flag = gestures.leftArmPointing; flag2 = gestures.rightArmPointing; } if (!flag && !flag2 && (Rigs.Count == 0 || !Rigs.ContainsKey(((Il2CppObjectBase)pc).Pointer))) { return false; } Rig rig = Get(pc); rig.Left.Tick(pc, flag); rig.Right.Tick(pc, flag2); return flag || flag2; } private static Rig Get(PlayerCharacter pc) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown if (Rigs.TryGetValue(((Il2CppObjectBase)pc).Pointer, out var value)) { return value; } value = new Rig { Player = pc }; Rigs[((Il2CppObjectBase)pc).Pointer] = value; if (Plugin.LogVerbose.Value) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("tracking a new character ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Rigs.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" in all)"); } log.LogInfo(val); } return value; } public static void HideAll() { foreach (KeyValuePair<IntPtr, Rig> rig in Rigs) { rig.Value.Hide(); } } public static void Sweep() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown if (Rigs.Count == 0) { return; } Dead.Clear(); foreach (KeyValuePair<IntPtr, Rig> rig in Rigs) { if ((Object)(object)rig.Value.Player == (Object)null) { Dead.Add(rig.Key); } } bool flag = default(bool); foreach (IntPtr item in Dead) { Rigs[item].Destroy(); Rigs.Remove(item); if (Plugin.LogVerbose.Value) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("dropped a character ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Rigs.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" left)"); } log.LogInfo(val); } } Dead.Clear(); } public static void Disarm() { if (!_armed) { return; } _armed = false; try { HideAll(); } catch (Exception) { } } public static void Rearm() { _armed = true; } public static void Prewarm() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown try { HandRig.Prewarm(); if (Plugin.LogVerbose.Value) { Plugin.Log.LogInfo((object)"meshes built ahead of the first point"); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not build the meshes ahead of time: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } public static void TickProfiled(PlayerCharacter pc) { long timestamp = Stopwatch.GetTimestamp(); bool num = Tick(pc); long num2 = Stopwatch.GetTimestamp() - timestamp; if (num) { _workTicks += num2; _workCalls++; } else { _idleTicks += num2; _idleCalls++; } if (num2 > _worst) { _worst = num2; } } private static void Calibrate() { _calibrated = true; long num = 0L; for (int i = 0; i < 4000; i++) { long timestamp = Stopwatch.GetTimestamp(); long timestamp2 = Stopwatch.GetTimestamp(); num += timestamp2 - timestamp; } _overhead = num / 4000; } public static string Profile(float seconds) { if (_idleCalls + _workCalls == 0L) { return null; } if (!_calibrated) { Calibrate(); } double num = Stopwatch.Frequency; double num2 = 1000000.0 / num; double num3 = (double)_overhead * num2; double measured = ((_idleCalls > 0) ? ((double)_idleTicks * num2 / (double)_idleCalls) : 0.0); double measured2 = ((_workCalls > 0) ? ((double)_workTicks * num2 / (double)_workCalls) : 0.0); double num4 = (double)(_idleTicks + _workTicks) * num2 - (double)(_idleCalls + _workCalls) * num3; long idleCalls = _idleCalls; long workCalls = _workCalls; double num5 = (double)_worst * num2; _idleTicks = (_idleCalls = (_workTicks = (_workCalls = (_worst = 0L)))); return $"idle {idleCalls} calls at {Net(measured, num3):0.00} us, " + $"drawing {workCalls} calls at {Net(measured2, num3):0.00} us, " + $"worst {num5:0.0} us, " + $"{num4 / ((double)seconds * 1000000.0) * 100.0:0.000}% of the clock " + $"(timing itself costs {num3:0.00} us a call and is taken off the above)"; } private static double Net(double measured, double overhead) { double num = measured - overhead; if (!(num < 0.0)) { return num; } return 0.0; } public static string Describe() { return $"aim {Plugin.Aim.Value}, finger {Plugin.FingerLength.Value}x{Plugin.FingerWidth.Value}, " + $"thumb {Plugin.ThumbLength.Value}x{Plugin.ThumbWidth.Value} at {Plugin.ThumbAngle.Value} deg, " + $"{Rigs.Count} character(s) tracked"; } private static bool IsLocal(PlayerCharacter pc) { try { if (((NetworkBehaviour)pc).isLocalPlayer) { return true; } } catch (Exception) { } PlayerCameraMinder cameraMinder = pc.cameraMinder; PlayerCameraReferences val = ((cameraMinder != null) ? cameraMinder.playerCameraReferences : null); if ((Object)(object)val != (Object)null) { return (Object)(object)val.playerCamera != (Object)null; } return false; } } internal static class CapsuleMesh { private const int MaxCached = 24; private static readonly Dictionary<int, Mesh> Cache = new Dictionary<int, Mesh>(); private static bool _broken; public static Mesh Get(float lengthInWidths, float bendDegrees, float taper) { if (_broken) { return null; } if (lengthInWidths < 0.5f) { lengthInWidths = 0.5f; } if (lengthInWidths > 40f) { lengthInWidths = 40f; } if (bendDegrees < 0f) { bendDegrees = 0f; } if (bendDegrees > 170f) { bendDegrees = 170f; } if (taper < 0.05f) { taper = 0.05f; } if (taper > 1f) { taper = 1f; } int num = ((int)(lengthInWidths * 50f + 0.5f) * 200 + (int)(bendDegrees + 0.5f)) * 101 + (int)(taper * 100f + 0.5f); if (Cache.TryGetValue(num, out var value) && (Object)(object)value != (Object)null) { return value; } if (Cache.Count >= 24) { foreach (KeyValuePair<int, Mesh> item in Cache) { if ((Object)(object)item.Value != (Object)null) { Object.Destroy((Object)(object)item.Value); } } Cache.Clear(); } Mesh val = Build((float)(num / 101 / 200) / 50f, num / 101 % 200, (float)(num % 101) / 100f); if ((Object)(object)val == (Object)null) { _broken = true; } else { Cache[num] = val; } return val; } private static Mesh Build(float lengthInWidths, float bendDegrees, float taper) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown bool flag = default(bool); try { CapsuleShape.Mesh mesh = CapsuleShape.Build(0.5f, lengthInWidths, bendDegrees, taper); Mesh val = new Mesh { name = $"FlipOffCapsule_{lengthInWidths:0.00}_{bendDegrees:0}_{taper:0.00}", hideFlags = (HideFlags)61 }; int num = mesh.Vertices.Length; Il2CppStructArray<Vector3> val2 = new Il2CppStructArray<Vector3>((long)num); Il2CppStructArray<Vector3> val3 = new Il2CppStructArray<Vector3>((long)num); Il2CppStructArray<Vector2> val4 = new Il2CppStructArray<Vector2>((long)num); Il2CppStructArray<Color> val5 = new Il2CppStructArray<Color>((long)num); for (int i = 0; i < num; i++) { ((Il2CppArrayBase<Vector3>)(object)val2)[i] = mesh.Vertices[i]; ((Il2CppArrayBase<Vector3>)(object)val3)[i] = mesh.Normals[i]; ((Il2CppArrayBase<Vector2>)(object)val4)[i] = mesh.Uvs[i]; ((Il2CppArrayBase<Color>)(object)val5)[i] = Color.white; } Il2CppStructArray<int> val6 = new Il2CppStructArray<int>((long)mesh.Triangles.Length); for (int j = 0; j < mesh.Triangles.Length; j++) { ((Il2CppArrayBase<int>)(object)val6)[j] = mesh.Triangles[j]; } val.vertices = val2; val.normals = val3; val.uv = val4; val.colors = val5; val.triangles = val6; val.RecalculateTangents(); val.RecalculateBounds(); if (Plugin.LogVerbose.Value) { ManualLogSource log = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val7 = new BepInExInfoLogInterpolatedStringHandler(67, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral("built a capsule "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<float>(lengthInWidths, "0.00"); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" widths long, bent "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<float>(bendDegrees, "0"); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" deg, taper "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<float>(taper, "0.00"); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" verts, "); ((BepInExLogInterpolatedStringHandler)val7).AppendFormatted<int>(mesh.Triangles.Length / 3); ((BepInExLogInterpolatedStringHandler)val7).AppendLiteral(" triangles"); } log.LogInfo(val7); } return val; } catch (Exception ex) { ManualLogSource log2 = Plugin.Log; BepInExErrorLogInterpolatedStringHandler val8 = new BepInExErrorLogInterpolatedStringHandler(32, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("could not build a capsule mesh: "); ((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<Exception>(ex); } log2.LogError(val8); return null; } } } internal static class CapsuleShape { public struct Mesh { public Vector3[] Vertices; public Vector3[] Normals; public Vector2[] Uvs; public int[] Triangles; public Vector3[] Centres; public float[] Radii; } private struct Station { public Vector3 Centre; public Vector3 Tangent; public Vector3 NormalFrom; public float Radius; public float Girth; } public const int Segments = 16; public const int CapRings = 5; private const float DegreesPerSpan = 7.5f; public static Mesh Build(float radius, float length, float bendDegrees = 0f, float taper = 1f) { if (radius < 0.0001f) { radius = 0.0001f; } if (taper < 0.05f) { taper = 0.05f; } if (taper > 1f) { taper = 1f; } float num = radius * taper; float num2 = length * 0.5f; float num3 = 0.5f * (radius + num); if (num2 < num3) { num2 = num3; } float num4 = 2f * num2 - radius - num; if (bendDegrees < 0f) { bendDegrees = 0f; } if (bendDegrees > 170f) { bendDegrees = 170f; } if (num4 < 1E-05f) { num4 = 0f; bendDegrees = 0f; } return Skin(Sweep(radius, taper, num2, num4, bendDegrees)); } private static List<Station> Sweep(float radius, float taper, float half, float swept, float bendDegrees) { //IL_0095: 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_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) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) List<Station> list = new List<Station>(); float num = bendDegrees * (MathF.PI / 180f); int num2 = ((bendDegrees < 0.01f) ? 1 : Math.Max(2, (int)Math.Ceiling(bendDegrees / 7.5f))); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 0f, radius - half); float num3 = radius * taper; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f, 1f); float curve = ((num > 1E-06f) ? (swept / num) : 0f); for (int i = 0; i <= 5; i++) { float x = 1.5707963f * (float)i / 5f; list.Add(new Station { Centre = Geometry.Sub(val, Geometry.Scale(val2, radius * Cos(x))), Tangent = val2, NormalFrom = val, Radius = radius * Sin(x), Girth = radius }); } for (int j = 1; j < num2; j++) { float s = swept * (float)j / (float)num2; float num4 = radius + (num3 - radius) * ((float)j / (float)num2); list.Add(new Station { Centre = Along(val, curve, s, num, swept), Tangent = TangentAt(curve, s, num, swept), NormalFrom = Along(val, curve, s, num, swept), Radius = num4, Girth = num4 }); } Vector3 val3 = Along(val, curve, swept, num, swept); Vector3 val4 = TangentAt(curve, swept, num, swept); for (int num5 = 5; num5 >= 0; num5--) { float x2 = 1.5707963f * (float)num5 / 5f; list.Add(new Station { Centre = Geometry.Add(val3, Geometry.Scale(val4, num3 * Cos(x2))), Tangent = val4, NormalFrom = val3, Radius = num3 * Sin(x2), Girth = num3 }); } return list; } private static Vector3 Along(Vector3 basePoint, float curve, float s, float bend, float swept) { //IL_0023: 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_0008: 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) if (curve <= 0f) { return Geometry.Add(basePoint, new Vector3(0f, 0f, s)); } float x = s / curve; return Geometry.Add(basePoint, new Vector3(curve * (1f - Cos(x)), 0f, curve * Sin(x))); } private static Vector3 TangentAt(float curve, float s, float bend, float swept) { //IL_0032: 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) if (curve <= 0f) { return new Vector3(0f, 0f, 1f); } float x = s / curve; return new Vector3(Sin(x), 0f, Cos(x)); } private static Mesh Skin(List<Station> stations) { //IL_005a: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) int count = stations.Count; int num = 17; int num2 = count * num; Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; Vector3[] array4 = (Vector3[])(object)new Vector3[num2]; float[] array5 = new float[num2]; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, 1f, 0f); for (int i = 0; i < count; i++) { Station station = stations[i]; Vector3 a = Geometry.Normalized(Geometry.Cross(val, station.Tangent), new Vector3(1f, 0f, 0f)); Vector3 a2 = val; for (int j = 0; j < num; j++) { float x = MathF.PI * 2f * (float)j / 16f; float num3 = Cos(x); float num4 = Sin(x); Vector3 b = Geometry.Add(Geometry.Scale(a, station.Radius * num3), Geometry.Scale(a2, station.Radius * num4)); int num5 = i * num + j; array[num5] = Geometry.Add(station.Centre, b); array4[num5] = station.NormalFrom; array5[num5] = station.Girth; array2[num5] = Geometry.Normalized(Geometry.Sub(array[num5], station.NormalFrom), station.Tangent); array3[num5] = new Vector2((float)j / 16f, (float)i / (float)(count - 1)); } } List<int> list = new List<int>(count * 16 * 6); for (int k = 0; k < count - 1; k++) { for (int l = 0; l < 16; l++) { int num6 = k * num + l; int num7 = num6 + 1; int num8 = (k + 1) * num + l; int b2 = num8 + 1; Add(list, array, num6, num7, num8); Add(list, array, num7, b2, num8); } } return new Mesh { Vertices = array, Normals = array2, Uvs = array3, Centres = array4, Radii = array5, Triangles = list.ToArray() }; } private static void Add(List<int> tris, Vector3[] verts, int a, int b, int c) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_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_0028: 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) Vector3 a2 = Geometry.Sub(verts[b], verts[a]); Vector3 b2 = Geometry.Sub(verts[c], verts[a]); if (!(Geometry.Length(Geometry.Cross(a2, b2)) < 1E-12f)) { tris.Add(a); tris.Add(b); tris.Add(c); } } private static float Sin(float x) { return (float)Math.Sin(x); } private static float Cos(float x) { return (float)Math.Cos(x); } } public enum FingerAim { WorldUp, PlayerUp, Arm } internal static class Geometry { public struct Frame { public Vector3 Finger; public Vector3 Thumb; public Vector3 Side; } public static Frame Solve(Vector3 arm, Vector3 up, FingerAim aim, float thumbAngleDeg, float thumbRollDeg, bool mirror) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: 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_003e: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //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_00d1: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Normalized(arm, new Vector3(0f, 0f, 1f)); Vector3 val2 = Normalized(up, new Vector3(0f, 1f, 0f)); Vector3 val3 = ((aim == FingerAim.Arm) ? val : val2); Vector3 v = Cross(val3, val); if (Small(v)) { v = Cross(val3, val2); } if (Small(v)) { v = Cross(val3, new Vector3(1f, 0f, 0f)); } if (Small(v)) { v = Cross(val3, new Vector3(0f, 0f, 1f)); } v = Normalized(v, new Vector3(1f, 0f, 0f)); v = Normalized(Sub(v, Scale(val3, Dot(v, val3))), v); if (mirror) { v = Scale(v, -1f); } if (thumbRollDeg != 0f) { v = RotateAbout(v, val3, mirror ? (0f - thumbRollDeg) : thumbRollDeg); } float x = thumbAngleDeg * (MathF.PI / 180f); Vector3 thumb = Normalized(Add(Scale(val3, Cos(x)), Scale(v, Sin(x))), val3); return new Frame { Finger = val3, Thumb = thumb, Side = v }; } public static Quaternion AlongZ(Vector3 dir) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008d: 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_0044: 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_00d5: 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_00e7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Normalized(dir, new Vector3(0f, 0f, 1f)); float num = 1f + val.z; if (num < 1E-06f) { return new Quaternion(0f, 1f, 0f, 0f); } Quaternion val2 = default(Quaternion); ((Quaternion)(ref val2))..ctor(0f - val.y, val.x, 0f, num); float num2 = Sqrt(val2.x * val2.x + val2.y * val2.y + val2.z * val2.z + val2.w * val2.w); if (num2 < 1E-09f) { return new Quaternion(0f, 0f, 0f, 1f); } float num3 = 1f / num2; return new Quaternion(val2.x * num3, val2.y * num3, val2.z * num3, val2.w * num3); } public static Quaternion Orient(Vector3 forward, Vector3 side) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_0095: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0061: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0103: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0233: 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_0258: 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: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: 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_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0221: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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) Vector3 val = Normalized(forward, new Vector3(0f, 0f, 1f)); Vector3 val2 = Sub(side, Scale(val, Dot(side, val))); if (Length(val2) < 1E-05f) { val2 = Sub(new Vector3(1f, 0f, 0f), Scale(val, val.x)); if (Length(val2) < 1E-05f) { val2 = Sub(new Vector3(0f, 1f, 0f), Scale(val, val.y)); } } val2 = Normalized(val2, new Vector3(1f, 0f, 0f)); Vector3 val3 = Cross(val, val2); float num = val2.x + val3.y + val.z; if (num > 0f) { float num2 = Sqrt(1f + num) * 0.5f; float num3 = 0.25f / num2; return new Quaternion((val3.z - val.y) * num3, (val.x - val2.z) * num3, (val2.y - val3.x) * num3, num2); } if (val2.x > val3.y && val2.x > val.z) { float num4 = Sqrt(1f + val2.x - val3.y - val.z) * 0.5f; float num5 = 0.25f / num4; return new Quaternion(num4, (val2.y + val3.x) * num5, (val.x + val2.z) * num5, (val3.z - val.y) * num5); } if (val3.y > val.z) { float num6 = Sqrt(1f + val3.y - val2.x - val.z) * 0.5f; float num7 = 0.25f / num6; return new Quaternion((val2.y + val3.x) * num7, num6, (val3.z + val.y) * num7, (val.x - val2.z) * num7); } float num8 = Sqrt(1f + val.z - val2.x - val3.y) * 0.5f; float num9 = 0.25f / num8; return new Quaternion((val.x + val2.z) * num9, (val3.z + val.y) * num9, num8, (val2.y - val3.x) * num9); } public static Vector3 RotateAbout(Vector3 v, Vector3 axis, float degrees) { //IL_0014: 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_0016: 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_001c: 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_002c: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0060: 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_0071: 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) float x = degrees * (MathF.PI / 180f); float num = Cos(x); float num2 = Sin(x); Vector3 val = Cross(axis, v); float num3 = Dot(axis, v) * (1f - num); return new Vector3(v.x * num + val.x * num2 + axis.x * num3, v.y * num + val.y * num2 + axis.y * num3, v.z * num + val.z * num2 + axis.z * num3); } public static Vector3 Cross(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) return new Vector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } public static float Dot(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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) return a.x * b.x + a.y * b.y + a.z * b.z; } public static Vector3 Add(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references) return new Vector3(a.x + b.x, a.y + b.y, a.z + b.z); } public static Vector3 Sub(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001a: 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_0027: Unknown result type (might be due to invalid IL or missing references) return new Vector3(a.x - b.x, a.y - b.y, a.z - b.z); } public static Vector3 Scale(Vector3 a, float k) { //IL_0000: 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_0010: 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) return new Vector3(a.x * k, a.y * k, a.z * k); } public static float Length(Vector3 a) { //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) return Sqrt(Dot(a, a)); } public static Vector3 Normalized(Vector3 v, Vector3 fallback) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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_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_0051: 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_0037: Unknown result type (might be due to invalid IL or missing references) float num = Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); if (num < 1E-06f) { return fallback; } float num2 = 1f / num; return new Vector3(v.x * num2, v.y * num2, v.z * num2); } private static bool Small(Vector3 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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_001b: 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) return v.x * v.x + v.y * v.y + v.z * v.z < 1E-08f; } private static float Sqrt(float x) { return (float)Math.Sqrt(x); } private static float Sin(float x) { return (float)Math.Sin(x); } private static float Cos(float x) { return (float)Math.Cos(x); } } internal sealed class HandSize { public float Diameter; } internal sealed class HandRig { private struct Anchor { public Transform Hand; public Transform Elbow; public Renderer Rend; public bool Valid => (Object)(object)Hand != (Object)null; } private static MaterialPropertyBlock _block; private readonly bool _right; private readonly HandSize _shared; private Anchor _local; private Anchor _remote; private bool _resolved; private float _diameter = 0.12f; private bool _measured; private GameObject _fingerGo; private GameObject _thumbGo; private Transform _fingerT; private Transform _thumbT; private Renderer _fingerR; private Renderer _thumbR; private MeshFilter _fingerMf; private MeshFilter _thumbMf; private Vector3 _fingerScale; private Vector3 _thumbScale; private float _fingerShape; private float _thumbShape; private float _fingerBend; private float _thumbBend; private bool _haveShape; private IntPtr _shapeFrom; private Vector3 _shapeCentreLocal; private float _shapeRadiusLocal; private IntPtr _dressedWith; private bool _dressedOnce; private float _nextDress; private bool _visible; private bool _preferLocal; private bool _warnedNoMaterial; private const float BoundsAreGenerous = 0.68f; private static bool _saidUnreadable; public string Name { get { if (!_right) { return "left"; } return "right"; } } public HandRig(bool right, HandSize shared) { _right = right; _shared = shared; } public void Tick(PlayerCharacter pc, bool wanted) { if (!wanted) { Show(on: false); return; } if (!_resolved) { Resolve(pc); } Anchor anchor = Pick(pc); if (!anchor.Valid) { Show(on: false); _resolved = false; return; } if ((Object)(object)_fingerGo == (Object)null) { Build(anchor); } Measure(anchor); Dress(anchor.Rend); Place(pc, anchor); Show(on: true); } public void Hide() { Show(on: false); } public void Destroy() { if ((Object)(object)_fingerGo != (Object)null) { Object.Destroy((Object)(object)_fingerGo); } if ((Object)(object)_thumbGo != (Object)null) { Object.Destroy((Object)(object)_thumbGo); } _fingerGo = (_thumbGo = null); _fingerT = (_thumbT = null); _fingerR = (_thumbR = null); _fingerMf = (_thumbMf = null); _fingerShape = (_thumbShape = 0f); _fingerBend = (_thumbBend = -1f); _haveShape = false; _shapeFrom = IntPtr.Zero; _resolved = false; _measured = false; _visible = false; _dressedWith = IntPtr.Zero; _dressedOnce = false; } private void Resolve(PlayerCharacter pc) { //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown _resolved = true; PlayerArms arms = pc.arms; PlayerRegistry registry = pc.registry; if (arms == null) { return; } _remote = new Anchor { Hand = (_right ? arms.rightHand : arms.leftHand), Elbow = ((registry == null) ? null : (_right ? registry.rightElbow : registry.leftElbow)) }; _local = new Anchor { Hand = (_right ? arms.localRightHand : arms.localLeftHand), Elbow = ((registry == null) ? null : (_right ? registry.localRightElbow : registry.localLeftElbow)) }; _remote.Rend = FindHandRenderer(_remote.Hand); _local.Rend = FindHandRenderer(_local.Hand); _measured = false; if (Plugin.DumpHierarchy.Value || Plugin.LogVerbose.Value) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" hand resolved: remote "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(_remote)); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", local "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Describe(_local)); } log.LogInfo(val); if (Plugin.DumpHierarchy.Value) { DumpRenderers("remote", _remote.Hand); DumpRenderers("local", _local.Hand); } } } private Anchor Pick(PlayerCharacter pc) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Invalid comparison between Unknown and I4 if (_preferLocal) { if (Drawn(_local.Rend)) { return _local; } if (Drawn(_remote.Rend)) { _preferLocal = false; return _remote; } } else { if (Drawn(_remote.Rend)) { return _remote; } if (Drawn(_local.Rend)) { _preferLocal = true; return _local; } } PlayerLooks looks = pc.looks; if (looks != null && (int)looks.currentLookType == 0 && _local.Valid) { return _local; } if (_remote.Valid) { return _remote; } return _local; } private static bool Drawn(Renderer r) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 if ((Object)(object)r == (Object)null) { return false; } try { return r.enabled && !r.forceRenderingOff && (int)r.shadowCastingMode != 3 && ((Component)r).gameObject.activeInHierarchy; } catch (Exception) { return false; } } private static Renderer FindHandRenderer(Transform hand) { if ((Object)(object)hand == (Object)null) { return null; } Renderer val = Search(hand); if ((Object)(object)val != (Object)null) { return val; } if (!((Object)(object)hand.parent != (Object)null)) { return null; } return Search(hand.parent); } private static Renderer Search(Transform root) { Il2CppArrayBase<Renderer> componentsInChildren; try { componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true); } catch (Exception) { return null; } if (componentsInChildren == null) { return null; } Renderer result = null; float num = float.MinValue; for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val = componentsInChildren[i]; if ((Object)(object)val == (Object)null) { continue; } string name = ((Object)((Component)val).gameObject).name; if (name.IndexOf("hand_mesh", StringComparison.OrdinalIgnoreCase) < 0) { float num2 = Score(val, name); if (!(num2 <= num)) { num = num2; result = val; } } } return result; } private static float Score(Renderer r, string name) { float num = 0f; if (name.IndexOf("BodyBall", StringComparison.OrdinalIgnoreCase) >= 0) { num += 100f; if (name.IndexOf("LOD0", StringComparison.OrdinalIgnoreCase) >= 0) { num += 10f; } } if (Extents(r, out var mn, out var mx)) { if (mn / mx > 0.7f) { num += 20f; } num += 1f / (1f + mx); } return num; } private static bool Extents(Renderer r, out float mn, out float mx) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_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_002e: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) mn = (mx = 0f); if ((Object)(object)r == (Object)null) { return false; } try { Bounds bounds = r.bounds; Vector3 size = ((Bounds)(ref bounds)).size; mn = Math.Min(size.x, Math.Min(size.y, size.z)); mx = Math.Max(size.x, Math.Max(size.y, size.z)); return mx > 0.0001f; } catch (Exception) { return false; } } private void Measure(Anchor anchor) { //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown Probe(anchor); float value = Plugin.HandSize.Value; if (value > 0f) { _diameter = value; } else { if (_measured) { return; } _measured = true; if (_shared.Diameter > 0f) { _diameter = _shared.Diameter; return; } float num = 0.12f; string text = "no hand mesh to measure"; if (_haveShape && Scaled(anchor, _shapeRadiusLocal, out var world) && Sane(world * 2f)) { num = world * 2f; text = "mesh " + ((Object)((Component)anchor.Rend).gameObject).name; } else { float num2 = 0f; int num3 = 0; StringBuilder stringBuilder = new StringBuilder(); Renderer[] array = (Renderer[])(object)new Renderer[2] { _remote.Rend, _local.Rend }; foreach (Renderer val in array) { if (FromBounds(val, out var diameter)) { num2 += diameter; num3++; if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append($"{((Object)((Component)val).gameObject).name} {diameter:0.###}"); } } if (num3 > 0) { num = num2 / (float)num3; text = ((num3 > 1) ? ($"mean of the bounding boxes of {stringBuilder} less the " + $"{0.32f:0.##} they overstate") : ($"the bounding box of {stringBuilder} less the " + $"{0.32f:0.##} it overstates")); } else { Plugin.Log.LogWarning((object)(Name + " hand: nothing here measures like a hand, so " + $"{num:0.###} m is assumed. Set HandSize in the config if " + "the fingers come out the wrong size.")); } } _diameter = num; _shared.Diameter = num; ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(53, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("this character's hands are "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<float>(_diameter, "0.###"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" m across ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("), "); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("anchored on "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(_haveShape ? "the mesh's own centre" : "the hand bone"); } log.LogInfo(val2); } } private static bool FromBounds(Renderer r, out float diameter) { diameter = 0f; if ((Object)(object)r == (Object)null || !Extents(r, out var mn, out var _)) { return false; } diameter = mn * 0.68f; return Sane(diameter); } private static bool Sane(float diameter) { if (diameter > 0.04f) { return diameter < 0.25f; } return false; } private void Probe(Anchor anchor) { //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Expected O, but got Unknown //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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_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_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Expected O, but got Unknown //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Expected O, but got Unknown Renderer rend = anchor.Rend; if ((Object)(object)rend == (Object)null || ((Il2CppObjectBase)rend).Pointer == _shapeFrom) { return; } _shapeFrom = ((Il2CppObjectBase)rend).Pointer; _haveShape = false; bool flag = default(bool); try { Mesh val = null; MeshFilter component = ((Component)rend).gameObject.GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null) { val = component.sharedMesh; } if ((Object)(object)val == (Object)null) { SkinnedMeshRenderer val2 = ((Il2CppObjectBase)rend).TryCast<SkinnedMeshRenderer>(); if ((Object)(object)val2 != (Object)null) { val = val2.sharedMesh; } } if ((Object)(object)val == (Object)null) { Unreadable(((Object)((Component)rend).gameObject).name + " has no mesh on a MeshFilter or a skinned renderer"); return; } if (!val.isReadable) { Unreadable(((Object)((Component)rend).gameObject).name + "'s mesh is not marked readable, so only its bounding box can be measured"); return; } int vertexCount = val.vertexCount; if (vertexCount < 4 || vertexCount > 60000) { Unreadable($"{((Object)((Component)rend).gameObject).name}'s mesh has {vertexCount} vertices, which is no hand ball"); return; } Il2CppStructArray<Vector3> vertices = val.vertices; if (vertices == null || ((Il2CppArrayBase<Vector3>)(object)vertices).Length == 0) { Unreadable($"{((Object)((Component)rend).gameObject).name}'s mesh has {vertexCount} vertices and is not " + "CPU-readable, so it can only be measured by its bounding box"); return; } float num = 0f; float num2 = 0f; float num3 = 0f; for (int i = 0; i < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; i++) { Vector3 val3 = ((Il2CppArrayBase<Vector3>)(object)vertices)[i]; num += val3.x; num2 += val3.y; num3 += val3.z; } Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(num / (float)((Il2CppArrayBase<Vector3>)(object)vertices).Length, num2 / (float)((Il2CppArrayBase<Vector3>)(object)vertices).Length, num3 / (float)((Il2CppArrayBase<Vector3>)(object)vertices).Length); float num4 = 0f; for (int j = 0; j < ((Il2CppArrayBase<Vector3>)(object)vertices).Length; j++) { float num5 = Geometry.Length(Geometry.Sub(((Il2CppArrayBase<Vector3>)(object)vertices)[j], val4)); if (num5 > num4) { num4 = num5; } } if (num4 <= 1E-05f) { ManualLogSource log = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" hand: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)((Component)rend).gameObject).name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("'s mesh has no size at all"); } log.LogWarning(val5); return; } _shapeCentreLocal = val4; _shapeRadiusLocal = num4; _haveShape = true; if (Plugin.LogVerbose.Value) { ManualLogSource log2 = Plugin.Log; BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(34, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" hand mesh "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(((Object)val).name); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<int>(vertexCount); ((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" verts, local radius "); ((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<float>(num4, "0.####"); } log2.LogInfo(val6); } } catch (Exception ex) { ManualLogSource log3 = Plugin.Log; BepInExWarningLogInterpolatedStringHandler val5 = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("could not read the "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" hand mesh: "); ((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex.Message); } log3.LogWarning(val5); } } private static void Unreadable(string why) { if (!_saidUnreadable) { _saidUnreadable = true; Plugin.Log.LogInfo((object)("hand sizes come from bounding boxes this run: " + why + ". That is expected here and is corrected for; HandSize overrides it.")); } } private static bool Scaled(Anchor anchor, float local, out float world) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_003f: Unknown result type (might be due to invalid IL or missing references) world = 0f; if ((Object)(object)anchor.Rend == (Object)null) { return false; } try { Vector3 lossyScale = ((Component)anchor.Rend).transform.lossyScale; float num = Math.Max(Math.Abs(lossyScale.x), Math.Max(Math.Abs(lossyScale.y), Math.Abs(lossyScale.z))); world = local * num; return world > 1E-05f; } catch (Exception) { return false; } } private void Build(Anchor anchor) { //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown int num = (((Object)(object)anchor.Rend != (Object)null) ? ((Component)anchor.Rend).gameObject.layer : ((Component)anchor.Hand).gameObject.layer); _fingerGo = Make("FlipOffFinger", num, out _fingerT, out _fingerR, out _fingerMf); _thumbGo = Make("FlipOffThumb", num, out _thumbT, out _thumbR, out _thumbMf); _visible = true; _dressedWith = IntPtr.Zero; _dressedOnce = false; _nextDress = 0f; _fingerShape = (_thumbShape = 0f); _fingerBend = (_thumbBend = -1f); if (Plugin.LogVerbose.Value) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("built the "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" fingers on layer "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num); } log.LogInfo(val); } } private static GameObject Make(string name, int layer, out Transform t, out Renderer r, out MeshFilter f) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown GameObject val = new GameObject(name) { hideFlags = (HideFlags)61, layer = layer }; f = val.AddComponent<MeshFilter>(); MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val2).receiveShadows = true; t = val.transform; r = (Renderer)(object)val2; return val; } private static float ShapeOf(float width, float length, float taper) { if (width < 0.0001f) { width = 0.0001f; } float num = length / width; float num2 = 0.5f * (1f + Clamp01(taper)); if (!(num < num2)) { return num; } return num2; } public static void Prewarm() { WarmTypes(); float num = Clamp01(Plugin.Sink.Value); float num2 = 0.5f * (1f - num); float value = Plugin.FingerTaper.Value; CapsuleMesh.Get(ShapeOf(Plugin.FingerWidth.Value, Plugin.FingerLength.Value + num2, value), Math.Abs(Plugin.FingerCurve.Value), value); CapsuleMesh.Get(ShapeOf(Plugin.ThumbWidth.Value, Plugin.ThumbLength.Value + num2, 1f), 0f, 1f); } private static void WarmTypes() { //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //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_0015: Expected O, but got Unknown //IL_006e: 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_00a0: 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_0042: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 GameObject val = null; try { val = new GameObject("FlipOffWarmup") { hideFlags = (HideFlags)61 }; MeshFilter val2 = val.AddComponent<MeshFilter>(); MeshRenderer val3 = val.AddComponent<MeshRenderer>(); ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)1; ((Renderer)val3).receiveShadows = true; if (_block == null) { _block = new MaterialPropertyBlock(); } ((Renderer)val3).GetPropertyBlock(_block); ((Renderer)val3).SetPropertyBlock(_block); Transform transform = val.transform; transform.SetPositionAndRotation(new Vector3(0f, -1000f, 0f), new Quaternion(0f, 0f, 0f, 1f)); transform.localScale = new Vector3(1f, 1f, 1f); if (((Renderer)val3).enabled && !((Renderer)val3).forceRenderingOff && (int)((Renderer)val3).shadowCastingMode == 1) { _ = ((Component)val3).gameObject.activeInHierarchy; } else _ = 0; val2.sharedMesh = null; } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(44, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("warm-up could not touch the renderer types: "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(ex.Message); } log.LogWarning(val4); } finally { if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } } } private static void Fit(MeshFilter filter, Transform t, ref float cachedShape, ref float cachedBend, ref Vector3 cachedScale, float width, float length, float bend, float taper, out float actualLength) { //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_0089: Unknown result type (might be due to invalid IL or missing references) float num = ShapeOf(width, length, taper); if (width < 0.0001f) { width = 0.0001f; } actualLength = width * num; float num2 = bend + taper * 1000f; if (!Same(cachedShape, num) || !Same(cachedBend, num2)) { Mesh val = CapsuleMesh.Get(num, bend, taper); if ((Object)(object)val != (Object)null) { filter.sharedMesh = val; cachedShape = num; cachedBend = num2; } } if (!Same(cachedScale.x, width)) { cachedScale = new Vector3(width, width, width); t.localScale = cachedScale; } } private void Dress(Renderer src) { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown if ((_dressedOnce && Time.unscaledTime < _nextDress) || (Object)(object)_fingerR == (Object)null || (Object)(object)_thumbR == (Object)null) { return; } if ((Object)(object)src == (Object)null) { if (!_warnedNoMaterial) { _warnedNoMaterial = true; Plugin.Log.LogWarning((object)("no hand renderer found for the " + Name + " hand, so the fingers have no material. Turn on DumpHierarchy and send the log.")); } return; } _dressedOnce = true; _nextDress = Time.unscaledTime + 0.5f; try { Material sharedMaterial = src.sharedMaterial; if ((Object)(object)sharedMaterial != (Object)null && ((Il2CppObjectBase)sharedMaterial).Pointer != _dressedWith) { _fingerR.sharedMaterial = sharedMaterial; _thumbR.sharedMaterial = sharedMaterial; _dressedWith = ((Il2CppObjectBase)sharedMaterial).Pointer; } if (Plugin.MatchBodyColour.Value) { if (_block == null) { _block = new MaterialPropertyBlock(); } src.GetPropertyBlock(_block); _fingerR.SetPropertyBlock(_block); _thumbR.SetPropertyBlock(_block); } else { _fingerR.SetPropertyBlock((MaterialPropertyBlock)null); _thumbR.SetPropertyBlock((MaterialPropertyBlock)null); } } catch (Exception ex) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("could not copy the hand's material: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } private void Place(PlayerCharacter pc, Anchor anchor) { //IL_0137: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0214: 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_0220: 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_0235: 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_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0064: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: 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_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_fingerT == (Object)null || (Object)(object)_thumbT == (Object)null) { return; } Vector3 position = anchor.Hand.position; Vector3 b = (((Object)(object)anchor.Elbow != (Object)null) ? anchor.Elbow.position : (((Object)(object)anchor.Hand.parent != (Object)null) ? anchor.Hand.parent.position : Geometry.Sub(position, Up(pc)))); Vector3 val = Geometry.Sub(position, b); Geometry.Frame frame = Geometry.Solve(aim: Plugin.Aim.Value, arm: val, up: Up(pc), thumbAngleDeg: Plugin.ThumbAngle.Value, thumbRollDeg: Plugin.ThumbRoll.Value, mirror: Plugin.MirrorLeftHand.Value && !_right); float diameter = _diameter; float value = Plugin.FingerCurve.Value; Vector3 val2 = Geometry.Normalized(val, frame.Finger); Vector3 a = position; float num = diameter * 0.5f; if (_haveShape && (Object)(object)anchor.Rend != (Object)null) { try { a = ((Component)anchor.Rend).transform.TransformPoint(_shapeCentreLocal); if (Scaled(anchor, _shapeRadiusLocal, out var world)) { num = world; } } catch (Exception) { a = position; num = diameter * 0.5f; } } float num2 = num * (1f - Clamp01(Plugin.Sink.Value)); Fit(_fingerMf, _fingerT, ref _fingerShape, ref _fingerBend, ref _fingerScale, diameter * Plugin.FingerWidth.Value, diameter * Plugin.FingerLength.Value + num2, Math.Abs(value), Plugin.FingerTaper.Value, out var actualLength); Fit(_thumbMf, _thumbT, ref _thumbShape, ref _thumbBend, ref _thumbScale, diameter * Plugin.ThumbWidth.Value, diameter * Plugin.ThumbLength.Value + num2, 0f, 1f, out var actualLength2); a = Geometry.Add(a, Geometry.Scale(frame.Finger, diameter * Plugin.OffsetAlong.Value)); a = Geometry.Add(a, Geometry.Scale(frame.Side, diameter * Plugin.OffsetSide.Value)); a = Geometry.Add(a, Geometry.Scale(val2, diameter * Plugin.OffsetOut.Value)); Vector3 side = ((value < 0f) ? Geometry.Scale(val2, -1f) : val2); Grow(_fingerT, a, num, frame.Finger, val2, Plugin.FingerOut.Value, actualLength, (Math.Abs(value) > 0.01f) ? Geometry.Orient(frame.Finger, side) : Geometry.AlongZ(frame.Finger)); Grow(_thumbT, a, num, frame.Thumb, val2, 0f, actualLength2, Geometry.AlongZ(frame.Thumb)); } private static void Grow(Transform t, Vector3 centre, float radius, Vector3 dir, Vector3 armDir, float around, float length, Quaternion rotation) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) Vector3 a = ((around == 0f) ? dir : Geometry.Normalized(Geometry.Add(dir, Geometry.Scale(armDir, around)), dir)); float k = radius * Clamp01(Plugin.Sink.Value); Vector3 a2 = Geometry.Add(centre, Geometry.Scale(a, k)); t.SetPositionAndRotation(Geometry.Add(a2, Geometry.Scale(dir, length * 0.5f)), rotation); } private static float Clamp01(float v) { if (!(v < 0f)) { if (!(v > 1f)) { return v; } return 1f; } return 0f; } private static bool Same(float a, float b) { if (a - b < 1E-05f) { return b - a < 1E-05f; } return false; } private Vector3 Up(PlayerCharacter pc) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (Plugin.Aim.Value == FingerAim.PlayerUp) { Transform kernal = pc.kernal; if ((Object)(object)kernal != (Object)null) { return kernal.up; } } return new Vector3(0f, 1f, 0f); } private void Show(bool on) { if (_visible != on) { _visible = on; if ((Object)(object)_fingerR != (Object)null) { _fingerR.enabled = on; } if ((Object)(object)_thumbR != (Object)null) { _thumbR.enabled = on; } } } private static string Describe(Anchor a) { if (!((Object)(object)a.Hand == (Object)null)) { return ((Object)a.Hand).name + " (elbow " + (((Object)(object)a.Elbow == (Object)null) ? "none" : ((Object)a.Elbow).name) + ", mesh " + (((Object)(object)a.Rend == (Object)null) ? "none" : ((Object)((Component)a.Rend).gameObject).name) + ")"; } return "no hand"; } private static void DumpRenderers(string label, Transform hand) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0125: 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_013f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null) { ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(label); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": no hand transform"); } log.LogInfo(val); return; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(" " + label + ": " + Path(hand)); try { Il2CppArrayBase<Renderer> componentsInChildren = ((Component)hand).GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Renderer val2 = componentsInChildren[i]; if (!((Object)(object)val2 == (Object)null)) { string[] obj = new string[6] { $"\n {((Object)((Component)val2).gameObject).name} enabled={val2.enabled} ", $"forceOff={val2.forceRenderingOff} shadows={val2.shadowCastingMode} ", null, null, null, null }; object arg = ((Component)val2).gameObject.layer; Bounds bounds = val2.bounds; obj[2] = $"layer={arg} size={((Bounds)(ref bounds)).size.x:0.###},"; bounds = val2.bounds; object arg2 = ((Bounds)(ref bounds)).size.y; bounds = val2.bounds; obj[3] = $"{arg2:0.###},{((Bounds)(ref bounds)).size.z:0.###} "; obj[4] = "mat="; obj[5] = (((Object)(object)val2.sharedMaterial == (Object)null) ? "none" : ((Object)val2.sharedMaterial).name); stringBuilder.Append(string.Concat(obj)); } } } catch (Exception ex) { stringBuilder.Append("\n (walk failed: " + ex.Message + ")"); } Plugin.Log.LogInfo((object)stringBuilder.ToString()); } private static string Path(Transform t) { StringBuilder stringBuilder = new StringBuilder(((Object)t).name); Transform parent = t.parent; int num = 0; while ((Object)(object)parent != (Object)null && num++ < 12) { stringBuilder.Insert(0, ((Object)parent).name + "/"); parent = parent.parent; } return stringBuilder.ToString(); } } [BepInPlugin("deck.bigwalk.flipoff", "Big Disrespect", "1.0.1")] public class Plugin : BasePlugin { public const string Guid = "deck.bigwalk.flipoff"; public static ManualLogSource Log; public static ConfigFile Cfg; public static ConfigEntry<bool> Enabled; public static ConfigEntry<bool> ShowOnOtherPlayers; public static ConfigEntry<bool> AlwaysOn; public static ConfigEntry<string> ToggleKeys; public static ConfigEntry<string> ReloadKeys; public static ConfigEntry<FingerAim> Aim; public static ConfigEntry<float> FingerLength; public static ConfigEntry<float> FingerWidth; public static ConfigEntry<float> ThumbLength; public static ConfigEntry<float> ThumbWidth; public static ConfigEntry<float> FingerCurve; public static ConfigEntry<float> FingerTaper; public static ConfigEntry<float> ThumbAngle; public static ConfigEntry<float> ThumbRoll; public static ConfigEntry<bool> MirrorLeftHand; public static ConfigEntry<float> HandSize; public static ConfigEntry<float> Sink; public static ConfigEntry<float> FingerOut; public static ConfigEntry<float> OffsetAlong; public static ConfigEntry<float> OffsetSide; public static ConfigEntry<float> OffsetOut; public static ConfigEntry<bool> MatchBodyColour; public static ConfigEntry<bool> LogProfile; public static ConfigEntry<bool> DumpHierarchy; public static ConfigEntry<bool> LogVerbose; public override void Load() { //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Expected O, but got Unknown //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Expected O, but got Unknown //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Expected O, but got Unknown //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: 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_04bb: Expected O, but got Unknown //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Expected O, but got Unknown Log = ((BasePlugin)this).Log; Cfg = ((BasePlugin)this).Config; Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Draw the fingers at all. The in-game toggle key flips this without a restart."); ShowOnOtherPlayers = ((BasePlugin)this).Config.Bind<bool>("General", "ShowOnOtherPlayers", true, "Also draw fingers on other players when they point. Whether it works depends on their pointing state reaching this client; if it does not, nothing is drawn and nothing breaks. Nobody else sees your fingers either way — this is a local visual and they would need the mod themselves."); AlwaysOn = ((BasePlugin)this).Config.Bind<bool>("General", "AlwaysOn", false, "Draw the fingers permanently instead of only while an arm is pointing. Meant for lining the shape up in a mirror; leave it off for normal play."); ToggleKeys = ((BasePlugin)this).Config.Bind<string>("Input", "ToggleKeys", "Minus", "Comma-separated keys that turn the mod on and off in game. Any KeyCode name works, including JoystickButton0..19 for a pad. Empty disables the binding."); ReloadKeys = ((BasePlugin)this).Config.Bind<string>("Input", "ReloadKeys", "Equals", "Comma-separated keys that re-read this config file, so the shape below can be tuned with the game running: edit the .cfg, alt-tab back, press the key."); Aim = ((BasePlugin)this).Config.Bind<FingerAim>("Shape", "Aim", FingerAim.WorldUp, "Which way the middle finger points. WorldUp is the classic gesture. PlayerUp leans with the character. Arm sends it straight down the forearm, so you flip off whatever you are aiming at and it is seen tip-on."); FingerLength = ((BasePlugin)this).Config.Bind<float>("Shape", "FingerLength", 1.6f, new ConfigDescription("How far the middle finger sticks out of the hand, in hand diameters. Measured from the hand's surface rather than its middle, so the hand cannot swallow it however big the character's hands are.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 10f), Array.Empty<object>())); FingerWidth = ((BasePlugin)this).Config.Bind<float>("Shape", "FingerWidth", 0.5f, new ConfigDescription("Middle finger thickness at the base, in hand diameters — the thick end, the tip being FingerTaper of it. A finger shorter than it is wide comes out as a ball.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 3f), Array.Empty<object>())); ThumbLength = ((BasePlugin)this).Config.Bind<float>("Shape", "ThumbLength", 0.8f, new ConfigDescription("How far the thumb sticks out of the hand, in hand diameters. About half the middle finger, the way a real one is.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 10f), Array.Empty<object>())); ThumbWidth = ((BasePlugin)this).Config.Bind<float>("Shape", "ThumbWidth", 0.55f, new ConfigDescription("Thumb thickness, in hand diameters. Half again the middle finger's, which together with its shorter length is what reads as a thumb rather than a second finger.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 3f), Array.Empty<object>())); FingerCurve = ((BasePlugin)this).Config.Bind<float>("Shape", "FingerCurve", -22f, new ConfigDescription("Degrees the middle finger curves over its length. The sign is which way it leans: negative curves it back over the arm towards you, positive away from you, 0 leaves it straight. Flip the sign if the curve goes the wrong way — it is the one thing here that cannot be told apart without looking. The curve is built into the mesh, so it stays round rather than kinking.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-170f, 170f), Array.Empty<object>())); FingerTaper = ((BasePlugin)this).Config.Bind<float>("Shape", "FingerTaper", 1f, new ConfigDescription("How thin the middle finger's tip is next to its base. 1, the default, is a plain finger of one thickness all the way up; lower it to taper the tip.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>())); ThumbAngle = ((BasePlugin)this).Config.Bind<float>("Shape", "ThumbAngle", 75f, new ConfigDescription("Degrees the thumb is swung away from the middle finger. 0 lays it alongside, 90 puts it square across the fist.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>())); ThumbRoll = ((BasePlugin)this).Config.Bind<float>("Shape", "ThumbRoll", 0f, new ConfigDescription("Degrees the thumb is rotated around the middle finger, if it ends up on the wrong face of the hand.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); MirrorLeftHand = ((BasePlugin)this).Config.Bind<bool>("Shape", "MirrorLeftHand", true, "Swing the left hand's thumb the opposite way, so the two hands mirror each other the way real ones do. Turn off if both thumbs should lean the same way."); HandSize = ((BasePlugin)this).Config.Bind<float>("Fit", "HandSize", 0f, new ConfigDescription("Hand diameter in metres, which every size above is a multiple of. 0 measures it from the hand's own mesh each time a character is found, which is what you want; set a number only if the measurement is wrong.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); Sink = ((BasePlugin)this).Config.Bind<float>("Fit", "Sink", 0f, new ConfigDescription("Where each finger is rooted, as a fraction of the hand's radius out from the hand bone: 0, the default, is right at the bone, and 1 is out at the surface. Rooting deep is deliberate — it is what keeps a finger attached even if the mod has misjudged how big the hand is. The lengths above still measure from the surface, so this does not make a finger look shorter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); FingerOut = ((BasePlugin)this).Config.Bind<float>("Fit", "FingerOut", 0.3f, new ConfigDescription("Rolls the spot the middle finger grows out of around the hand, towards the far end of the arm, so it does not rise from the very top. 0 is the top of the hand and 1 is 45 degrees round towards the fingertips. The finger still points the same way; only its root moves, and the thumb does not move at all.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-2f, 2f), Array.Empty<object>())); OffsetAlong = ((BasePlugin)this).Config.Bind<float>("Fit", "OffsetAlong", 0f, "Nudge both fingers along the middle finger's direction, in hand diameters."); OffsetSide = ((BasePlugin)this).Config.Bind<float>("Fit", "OffsetSi