using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BoneLib; using BoneLib.BoneMenu; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.PuppetMasta; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using Telekinesis; using Telekinesis.Audio; using Telekinesis.Config; using Telekinesis.Force; using Telekinesis.Menu; using Telekinesis.Net; using Telekinesis.Render; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(TelekinesisMod), "Telekinesis", "2.1.1", "Yamama", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Telekinesis { public sealed class TelekinesisMod : MelonMod { private const int MaxAssetAttempts = 12; private readonly Caster _left = new Caster(left: true); private readonly Caster _right = new Caster(left: false); private Caster[] _casters; private Action _onUnloaded; private bool _wasEnabled = true; private int _assetAttempts; private float _nextAssetAttemptAt; public static TelekinesisMod Instance { get; private set; } internal Caster Left => _left; internal Caster Right => _right; public override void OnInitializeMelon() { Instance = this; _casters = new Caster[2] { _left, _right }; Step("preferences", Prefs.Load); Step("sounds", Sfx.Build); Step("fusion", Fusion.Probe); Step("level hook", delegate { _onUnloaded = OnLevelUnloaded; Hooking.OnLevelUnloaded += _onUnloaded; }); ((MelonBase)this).LoggerInstance.Msg("Telekinesis 2.1.1 ready."); } private void Step(string what, Action action) { try { action(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Startup step '" + what + "' failed: " + ex); } } public override void OnUpdate() { try { MenuPage.EnsureBuilt(); EnsureAssets(); if (!Prefs.Enabled) { if (_wasEnabled) { _wasEnabled = false; Shutdown(); } return; } _wasEnabled = true; float unscaledDeltaTime = Time.unscaledDeltaTime; _left.Tick(unscaledDeltaTime); _right.Tick(unscaledDeltaTime); Blast.Tick(); if (_left.Holding) { Haptics.Strain(left: true, _left.Strain); } if (_right.Holding) { Haptics.Strain(left: false, _right.Strain); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Update failed: " + ex); try { Shutdown(); } catch { } } } public override void OnFixedUpdate() { try { if (Prefs.Enabled) { float fixedDeltaTime = Time.fixedDeltaTime; _left.Fixed(fixedDeltaTime); _right.Fixed(fixedDeltaTime); } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Physics step failed: " + ex); } } public override void OnLateUpdate() { try { Gfx.BeginFrame(); if (Prefs.Enabled && Assets.Ready) { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { Fx.Draw(_casters, main); } } } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Error("Draw failed: " + ex); } } private void EnsureAssets() { if (!Assets.Ready && _assetAttempts < 12 && !(Time.unscaledTime < _nextAssetAttemptAt)) { _assetAttempts++; _nextAssetAttemptAt = Time.unscaledTime + 1f; Assets.Build(); if (!Assets.Ready && _assetAttempts >= 12) { ((MelonBase)this).LoggerInstance.Error($"Gave up building render assets after {12} attempts. " + "Grabbing and throwing still work; the beam and reticle will not draw."); } } } private void Shutdown() { _left.DropAll(0f); _right.DropAll(0f); Blast.ReleaseAll(); Freezer.ThawAll(); Puppets.ReleaseAll(); Claims.Clear(); } private void OnLevelUnloaded() { try { Forget(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Level reset failed: " + ex.Message); } } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { try { Forget(); } catch (Exception ex) { ((MelonBase)this).LoggerInstance.Warning("Scene reset failed: " + ex.Message); } } private void Forget() { _left.Forget(); _right.Forget(); Blast.Forget(); Freezer.Clear(); Puppets.Clear(); Claims.Clear(); } public override void OnDeinitializeMelon() { try { if (_onUnloaded != null) { Hooking.OnLevelUnloaded -= _onUnloaded; } } catch { } try { Shutdown(); } catch { } try { Sfx.Dispose(); } catch { } try { Assets.Dispose(); } catch { } try { Prefs.Save(); } catch { } } } } namespace Telekinesis.Render { internal static class Assets { private static readonly string[] Candidates = new string[6] { "GUI/Text Shader", "Sprites/Default", "UI/Default", "Unlit/Transparent", "Particles/Standard Unlit", "Hidden/Internal-Colored" }; private static Texture2D _white; private static Texture2D _glow; private static Texture2D _spark; public static FxMaterial Beam { get; private set; } public static FxMaterial Soft { get; private set; } public static FxMaterial Flat { get; private set; } public static Mesh BeamMesh { get; private set; } public static Mesh OverlayMesh { get; private set; } public static bool Ready { get; private set; } public static string ShaderName { get; private set; } = "none"; public static bool ThroughWalls { get; private set; } public static void Build() { if (Ready) { return; } try { Shader val = Resolve(); if ((Object)(object)val == (Object)null) { Melon.Logger.Warning("No usable shader yet; will retry."); return; } ShaderName = ((Object)val).name; ThroughWalls = ShaderName == "GUI/Text Shader"; _white = Solid(); _glow = Glow(); _spark = Spark(); Beam = Make(val, _glow, 4200); Soft = Make(val, _spark, 4210); Flat = Make(val, _white, 4205); BeamMesh = Dynamic("TK_Beam"); OverlayMesh = Dynamic("TK_Overlay"); Ready = true; Melon.Logger.Msg($"Render ready on '{ShaderName}' (through walls: {ThroughWalls})."); } catch (Exception ex) { Melon.Logger.Error("Building render assets failed: " + ex); } } private static Shader Resolve() { for (int i = 0; i < Candidates.Length; i++) { try { Shader val = Shader.Find(Candidates[i]); if ((Object)(object)val != (Object)null) { return val; } } catch { } } return null; } private static FxMaterial Make(Shader shader, Texture2D texture, int queue) { //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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Material material = new Material(shader) { hideFlags = (HideFlags)61, mainTexture = (Texture)(object)texture, color = Color.white, renderQueue = queue }; return new FxMaterial { Material = material, Tiling = Vector2.one }; } private static Mesh Dynamic(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_001b: Expected O, but got Unknown Mesh val = new Mesh { name = name, hideFlags = (HideFlags)61 }; val.MarkDynamic(); return val; } private static Texture2D Solid() { //IL_0004: 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_0011: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; val.SetPixel(0, 0, Color.white); val.Apply(); return val; } private static Texture2D Glow() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0022: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[4096]; float num = 32f; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Pow(1f - Mathf.Clamp01(num4), 2f); array[i * 64 + j] = new Color(1f, 1f, 1f, num5); } } val.SetPixels(Il2CppStructArray.op_Implicit(array)); val.Apply(); return val; } private static Texture2D Spark() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0022: Expected O, but got Unknown //IL_0120: 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) Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false) { hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; Color[] array = (Color[])(object)new Color[1024]; float num = 16f; for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { float num2 = ((float)j + 0.5f - num) / num; float num3 = ((float)i + 0.5f - num) / num; float num4 = Mathf.Sqrt(num2 * num2 + num3 * num3); float num5 = Mathf.Pow(1f - Mathf.Clamp01(num4 * 1.3f), 3f); float num6 = (1f - Mathf.Clamp01(Mathf.Abs(num2) * 5f)) * (1f - Mathf.Clamp01(Mathf.Abs(num3) * 1.1f)) + (1f - Mathf.Clamp01(Mathf.Abs(num3) * 5f)) * (1f - Mathf.Clamp01(Mathf.Abs(num2) * 1.1f)); array[i * 32 + j] = new Color(1f, 1f, 1f, Mathf.Clamp01(Mathf.Max(num5, num6 * 0.55f))); } } val.SetPixels(Il2CppStructArray.op_Implicit(array)); val.Apply(); return val; } public static void Dispose() { Destroy(Beam); Destroy(Soft); Destroy(Flat); Beam = null; Soft = null; Flat = null; Kill(ref _white); Kill(ref _glow); Kill(ref _spark); KillMesh(BeamMesh); KillMesh(OverlayMesh); BeamMesh = null; OverlayMesh = null; Ready = false; ShaderName = "none"; } private static void Destroy(FxMaterial fx) { try { if (fx != null && (Object)(object)fx.Material != (Object)null) { Object.Destroy((Object)(object)fx.Material); } } catch { } } private static void Kill(ref Texture2D texture) { try { if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } catch { } texture = null; } private static void KillMesh(Mesh mesh) { try { if ((Object)(object)mesh != (Object)null) { Object.Destroy((Object)(object)mesh); } } catch { } } } internal static class Fx { private static readonly MeshBuilder _beam = new MeshBuilder(512); private static readonly MeshBuilder _overlay = new MeshBuilder(512); public static Color Accent => Color.HSVToRGB(Prefs.Hue, 0.72f, 1f); public static Color Denied => new Color(1f, 0.3f, 0.22f); public static void Draw(Caster[] casters, Camera camera) { //IL_00aa: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (!Assets.Ready || (Object)(object)camera == (Object)null || casters == null) { return; } Transform transform; try { transform = ((Component)camera).transform; } catch { return; } Vector3 position = transform.position; _beam.Clear(); _overlay.Clear(); foreach (Caster caster in casters) { if (caster != null && !((Object)(object)caster.HandTransform == (Object)null)) { Vector3 position2; try { position2 = caster.HandTransform.position; } catch { continue; } if (Prefs.Beam) { Beams(caster, position2, position); } if (!caster.Holding) { Aiming(caster, position); } } } if (_beam.Commit(Assets.BeamMesh)) { Gfx.Mesh(Assets.BeamMesh, Matrix4x4.identity, Assets.Beam, Color.white); } if (_overlay.Commit(Assets.OverlayMesh)) { Gfx.Mesh(Assets.OverlayMesh, Matrix4x4.identity, Assets.Soft, Color.white); } } private static void Beams(Caster caster, Vector3 hand, Vector3 eye) { //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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Hold[] holds = caster.Holds; Color accent = Accent; float time = Time.time; foreach (Hold hold in holds) { if (hold.Alive) { Vector3 worldCenterOfMass; try { worldCenterOfMass = hold.Body.worldCenterOfMass; } catch { continue; } float num = Mathf.Clamp01(hold.Lag / 2.5f); Color color = Color.Lerp(accent, Denied, num * 0.7f); Ribbon(hand, worldCenterOfMass, eye, color, time); } } } private static void Ribbon(Vector3 from, Vector3 to, Vector3 eye, Color color, float now) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 0.05f)) { Vector3 val2 = val / magnitude; Vector3 val3 = eye - from; Vector3 val4 = Vector3.Cross(val2, val3); Vector3 normalized = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.0001f) { val4 = Vector3.Cross(val2, Vector3.up); normalized = ((Vector3)(ref val4)).normalized; } Vector3 val5 = Vector3.Cross(val2, normalized); float num = Mathf.Clamp(magnitude * 0.012f, 0.008f, 0.05f); Vector3 a = from; Color color2 = default(Color); for (int i = 1; i <= 14; i++) { float num2 = (float)i / 14f; float num3 = (float)(i - 1) / 14f; float num4 = Mathf.Sin(num2 * 9f + now * 7f) * num * 1.6f; Vector3 val6 = Vector3.Lerp(from, to, num2) + val5 * num4; float num5 = Mathf.Pow(Mathf.Max(0f, Mathf.Sin((num2 - now * 1.1f) * (float)Math.PI * 3f)), 6f); float widthA = num * Mathf.Lerp(0.55f, 1.25f, num3); float widthB = num * Mathf.Lerp(0.55f, 1.25f, num2); float num6 = Mathf.Lerp(0.85f, 0.5f, num2) + num5 * 0.5f; ((Color)(ref color2))..ctor(Mathf.Min(1f, color.r + num5 * 0.5f), Mathf.Min(1f, color.g + num5 * 0.5f), Mathf.Min(1f, color.b + num5 * 0.5f), Mathf.Clamp01(num6)); Strip(a, val6, normalized, widthA, widthB, color2); a = val6; } } } private static void Strip(Vector3 a, Vector3 b, Vector3 side, float widthA, float widthB, Color color) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) int vertexCount = _beam.VertexCount; _beam.Vertex(a - side * widthA, color, new Vector2(0f, 0f)); _beam.Vertex(a + side * widthA, color, new Vector2(1f, 0f)); _beam.Vertex(b + side * widthB, color, new Vector2(1f, 1f)); _beam.Vertex(b - side * widthB, color, new Vector2(0f, 1f)); _beam.Triangle(vertexCount, vertexCount + 1, vertexCount + 2); _beam.Triangle(vertexCount, vertexCount + 2, vertexCount + 3); } private static void Aiming(Caster caster, Vector3 eye) { //IL_001f: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_0129: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) Aim currentAim = caster.CurrentAim; if (!currentAim.Found) { return; } Color val = (currentAim.TooHeavy ? Denied : Accent); Vector3 point = currentAim.Point; Vector3 val2 = eye - point; float magnitude = ((Vector3)(ref val2)).magnitude; if (magnitude < 0.05f) { return; } Vector3 val3 = val2 / magnitude; Vector3 val4 = Vector3.Cross(Vector3.up, val3); if (((Vector3)(ref val4)).sqrMagnitude < 0.0001f) { val4 = Vector3.right; } ((Vector3)(ref val4)).Normalize(); Vector3 val5 = Vector3.Cross(val3, val4); float num = Mathf.Clamp(magnitude * 0.035f, 0.02f, 0.5f); if (Prefs.Reticle) { float num2 = Time.time * 40f * ((float)Math.PI / 180f); Vector3 val6 = val4 * Mathf.Cos(num2) + val5 * Mathf.Sin(num2); Vector3 val7 = Vector3.Cross(val3, val6); _overlay.Ring(point, val6, val7, num, num * 0.22f, new Color(val.r, val.g, val.b, 0.85f)); _overlay.Quad(point, val4, val5, num * 0.18f, num * 0.18f, new Color(val.r, val.g, val.b, 0.95f)); for (int i = 0; i < 4; i++) { float num3 = (float)i * (float)Math.PI * 0.5f + num2; Vector3 val8 = val6 * Mathf.Cos(num3) + val7 * Mathf.Sin(num3); Vector3 side = Vector3.Cross(val3, val8); _overlay.Chevron(point + val8 * (num * 1.45f), -val8, side, num * 0.5f, num * 0.24f, new Color(val.r, val.g, val.b, 0.7f)); } } if (Prefs.Highlight && (Object)(object)currentAim.Body != (Object)null) { Box(currentAim.Body, val3, val); } } private static void Box(Rigidbody body, Vector3 viewDirection, Color color) { //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_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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0155: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) Bounds bounds; try { Collider componentInChildren = ((Component)body).GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { return; } bounds = componentInChildren.bounds; } catch { return; } Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; if (((Vector3)(ref extents)).sqrMagnitude < 0.0001f) { return; } float num = Mathf.Clamp(((Vector3)(ref extents)).magnitude * 0.03f, 0.004f, 0.04f); Color color2 = default(Color); ((Color)(ref color2))..ctor(color.r, color.g, color.b, 0.55f); for (int i = 0; i < 3; i++) { for (int j = 0; j < 4; j++) { Vector3 zero = Vector3.zero; int num2 = 0; for (int k = 0; k < 3; k++) { if (k != i) { float num3 = ((((j >> num2) & 1) == 0) ? (-1f) : 1f); ((Vector3)(ref zero))[k] = ((Vector3)(ref extents))[k] * num3; num2++; } } Vector3 val = center + zero; Vector3 val2 = center + zero; ref Vector3 reference = ref val; int num4 = i; ((Vector3)(ref reference))[num4] = ((Vector3)(ref reference))[num4] - ((Vector3)(ref extents))[i]; reference = ref val2; num4 = i; ((Vector3)(ref reference))[num4] = ((Vector3)(ref reference))[num4] + ((Vector3)(ref extents))[i]; Vector3 val3 = val2 - val; Vector3 val4 = Vector3.Cross(((Vector3)(ref val3)).normalized, viewDirection); if (!(((Vector3)(ref val4)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val4)).Normalize(); int vertexCount = _overlay.VertexCount; _overlay.Vertex(val - val4 * num, color2, new Vector2(0.5f, 0.5f)); _overlay.Vertex(val + val4 * num, color2, new Vector2(0.5f, 0.5f)); _overlay.Vertex(val2 + val4 * num, color2, new Vector2(0.5f, 0.5f)); _overlay.Vertex(val2 - val4 * num, color2, new Vector2(0.5f, 0.5f)); _overlay.Triangle(vertexCount, vertexCount + 1, vertexCount + 2); _overlay.Triangle(vertexCount, vertexCount + 2, vertexCount + 3); } } } } } internal sealed class FxMaterial { public Material Material; public Vector2 Tiling = Vector2.one; } internal static class Gfx { public static readonly int ColorId = Shader.PropertyToID("_Color"); public static readonly int MainTexStId = Shader.PropertyToID("_MainTex_ST"); private const int Layer = 0; private static MaterialPropertyBlock _block; public static int Calls { get; private set; } public static void BeginFrame() { Calls = 0; } public static void Mesh(Mesh mesh, Matrix4x4 matrix, FxMaterial fx, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Mesh(mesh, matrix, fx, color, Vector2.zero); } public static void Mesh(Mesh mesh, Matrix4x4 matrix, FxMaterial fx, Color color, Vector2 scroll) { //IL_001a: 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_0073: 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_0081: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown if (!((Object)(object)mesh == (Object)null) && fx != null && !((Object)(object)fx.Material == (Object)null) && !(color.a <= 0.003f)) { if (_block == null) { _block = new MaterialPropertyBlock(); } _block.Clear(); _block.SetColor(ColorId, color); _block.SetVector(MainTexStId, new Vector4(fx.Tiling.x, fx.Tiling.y, scroll.x, scroll.y)); Graphics.DrawMesh(mesh, matrix, fx.Material, 0, (Camera)null, 0, _block); Calls++; } } } internal sealed class MeshBuilder { private readonly List _verts; private readonly List _colors; private readonly List _uvs; private readonly List _indices; public int VertexCount => _verts.Count; public bool Empty => _verts.Count == 0; public MeshBuilder(int capacity) { _verts = new List(capacity); _colors = new List(capacity); _uvs = new List(capacity); _indices = new List(capacity * 2); } public void Clear() { _verts.Clear(); _colors.Clear(); _uvs.Clear(); _indices.Clear(); } public void Vertex(Vector3 position, Color color, Vector2 uv) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) _verts.Add(position); _colors.Add(color); _uvs.Add(uv); } public void Triangle(int a, int b, int c) { _indices.Add(a); _indices.Add(b); _indices.Add(c); } public void Quad(Vector3 center, Vector3 right, Vector3 up, float halfWidth, float halfHeight, Color color) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) int count = _verts.Count; Vector3 val = right * halfWidth; Vector3 val2 = up * halfHeight; Vertex(center - val - val2, color, new Vector2(0f, 0f)); Vertex(center + val - val2, color, new Vector2(1f, 0f)); Vertex(center + val + val2, color, new Vector2(1f, 1f)); Vertex(center - val + val2, color, new Vector2(0f, 1f)); Triangle(count, count + 1, count + 2); Triangle(count, count + 2, count + 3); } public void Diamond(Vector3 center, Vector3 right, Vector3 up, float radius, Color edge, Color core) { //IL_000d: 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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) int count = _verts.Count; Vertex(center, core, new Vector2(0.5f, 0.5f)); Vertex(center + up * radius, edge, new Vector2(0.5f, 1f)); Vertex(center + right * radius, edge, new Vector2(1f, 0.5f)); Vertex(center - up * radius, edge, new Vector2(0.5f, 0f)); Vertex(center - right * radius, edge, new Vector2(0f, 0.5f)); Triangle(count, count + 1, count + 2); Triangle(count, count + 2, count + 3); Triangle(count, count + 3, count + 4); Triangle(count, count + 4, count + 1); } public void Ring(Vector3 center, Vector3 right, Vector3 up, float radius, float thickness, Color color, int segments = 14) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0080: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) int count = _verts.Count; float num = Mathf.Max(0f, radius - thickness); for (int i = 0; i <= segments; i++) { float num2 = (float)i / (float)segments * (float)Math.PI * 2f; float num3 = Mathf.Cos(num2); float num4 = Mathf.Sin(num2); Vector3 val = right * num3 + up * num4; Vertex(center + val * num, color, new Vector2(0.5f, 0.5f)); Vertex(center + val * radius, color, new Vector2(0.5f, 0.5f)); } for (int j = 0; j < segments; j++) { int num5 = count + j * 2; Triangle(num5, num5 + 1, num5 + 3); Triangle(num5, num5 + 3, num5 + 2); } } public void Chevron(Vector3 center, Vector3 direction, Vector3 side, float length, float width, Color color) { //IL_000d: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) int count = _verts.Count; Vertex(center + direction * length, color, new Vector2(0.5f, 1f)); Vertex(center - side * width, color, new Vector2(0f, 0f)); Vertex(center + side * width, color, new Vector2(1f, 0f)); Triangle(count, count + 1, count + 2); } public void Arc(Vector3 center, Vector3 right, Vector3 up, float innerRadius, float outerRadius, float startAngle, float sweepAngle, Color color, int segments = 12) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_005d: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) int count = _verts.Count; Color val2 = default(Color); for (int i = 0; i <= segments; i++) { float num = startAngle + (float)i / (float)segments * sweepAngle; float num2 = Mathf.Cos(num); float num3 = Mathf.Sin(num); Vector3 val = right * num2 + up * num3; float num4 = Mathf.Sin((float)i / (float)segments * (float)Math.PI); ((Color)(ref val2))..ctor(color.r, color.g, color.b, color.a * num4); Vertex(center + val * innerRadius, new Color(val2.r, val2.g, val2.b, 0f), new Vector2(0f, 0.5f)); Vertex(center + val * outerRadius, val2, new Vector2(1f, 0.5f)); } for (int j = 0; j < segments; j++) { int num5 = count + j * 2; Triangle(num5, num5 + 1, num5 + 3); Triangle(num5, num5 + 3, num5 + 2); } } public bool Commit(Mesh mesh) { if (_verts.Count == 0 || (Object)(object)mesh == (Object)null) { return false; } mesh.Clear(); mesh.vertices = Il2CppStructArray.op_Implicit(_verts.ToArray()); mesh.colors = Il2CppStructArray.op_Implicit(_colors.ToArray()); mesh.uv = Il2CppStructArray.op_Implicit(_uvs.ToArray()); mesh.triangles = Il2CppStructArray.op_Implicit(_indices.ToArray()); return true; } } } namespace Telekinesis.Net { internal static class Fusion { private static bool _probed; private static object _cache; private static MethodInfo _tryGet; private static MethodInfo _takeOwnership; private static PropertyInfo _hasServer; public static bool Available { get; private set; } public static string Status { get; private set; } = "not probed"; public static int Takeovers { get; private set; } public static bool InLobby { get { if (!Available || _hasServer == null) { return false; } try { return (bool)_hasServer.GetValue(null); } catch { return false; } } } [MethodImpl(MethodImplOptions.NoInlining)] public static void Probe() { if (_probed) { return; } _probed = true; try { Assembly assembly = null; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly2 in assemblies) { if (!(assembly2.GetName().Name != "LabFusion")) { assembly = assembly2; break; } } if (assembly == null) { Status = "LabFusion not installed"; Melon.Logger.Msg("Fusion not found; multiplayer features are off."); return; } _cache = (assembly.GetType("LabFusion.Entities.IMarrowEntityExtender")?.GetField("Cache", BindingFlags.Static | BindingFlags.Public))?.GetValue(null); if (_cache != null) { _tryGet = _cache.GetType().GetMethod("TryGet"); } _takeOwnership = assembly.GetType("LabFusion.Entities.NetworkEntityManager")?.GetMethod("TakeOwnership", BindingFlags.Static | BindingFlags.Public); _hasServer = assembly.GetType("LabFusion.Network.NetworkInfo")?.GetProperty("HasServer", BindingFlags.Static | BindingFlags.Public); Available = _cache != null && _tryGet != null && _takeOwnership != null; Status = (Available ? "ready" : $"partial (cache={_cache != null} tryGet={_tryGet != null} takeOwnership={_takeOwnership != null})"); Melon.Logger.Msg(Available ? "Fusion found; networked objects and player shoves are available." : ("Fusion found but its API did not match: " + Status)); } catch (Exception ex) { Status = "probe failed: " + ex.Message; Melon.Logger.Warning("Fusion probe failed: " + ex.Message); } } [MethodImpl(MethodImplOptions.NoInlining)] public static bool TakeOwnership(GameObject target) { if ((Object)(object)target == (Object)null || !Available || !InLobby) { return false; } try { MarrowEntity componentInParent = target.GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return false; } object[] array = new object[2] { componentInParent, null }; if (!(bool)_tryGet.Invoke(_cache, array) || array[1] == null) { return false; } _takeOwnership.Invoke(null, new object[1] { array[1] }); Takeovers++; return true; } catch { return false; } } public static void Reset() { Takeovers = 0; } } } namespace Telekinesis.Menu { internal static class MenuPage { private static bool _built; private static Color Accent => Fx.Accent; public static void EnsureBuilt() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (_built) { return; } Page root; try { if (Page.Root == null) { return; } root = Page.Root.CreatePage("Telekinesis", Accent, 0, true); } catch (Exception ex) { Melon.Logger.Warning("BoneMenu root page failed: " + ex.Message); return; } Section("main", delegate { Main(root); }); Section("feel", delegate { Feel(root); }); Section("powers", delegate { Powers(root); }); Section("multiplayer", delegate { Multiplayer(root); }); Section("look", delegate { Look(root); }); Section("diagnostics", delegate { Diagnostics(root); }); _built = true; Melon.Logger.Msg("BoneMenu ready."); } private static void Section(string name, Action build) { try { build(); } catch (Exception ex) { Melon.Logger.Error("BoneMenu section '" + name + "' failed: " + ex); } } private static void Main(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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) Color accent = Accent; root.CreateBool("Enabled", accent, Prefs.Enabled, (Action)delegate(bool value) { Prefs.Enabled = value; Prefs.Save(); }); root.CreateFloat("Reach", accent, Prefs.Range, 1f, 1f, 150f, (Action)delegate(float value) { Prefs.Range = value; Prefs.Save(); }); root.CreateFloat("Aim Assist", accent, Prefs.AimAssist, 0.05f, 0.02f, 2f, (Action)delegate(float value) { Prefs.AimAssist = value; Prefs.Save(); }); root.CreateFloat("Max Mass", accent, Prefs.MaxMass, 25f, 1f, 10000f, (Action)delegate(float value) { Prefs.MaxMass = value; Prefs.Save(); }); root.CreateInt("Max Held Per Hand", accent, Prefs.MaxHeld, 1, 1, 12, (Action)delegate(int value) { Prefs.MaxHeld = value; Prefs.Save(); }); root.CreateFloat("Push / Pull Speed", accent, Prefs.PullSpeed, 0.5f, 0.5f, 40f, (Action)delegate(float value) { Prefs.PullSpeed = value; Prefs.Save(); }); } private static void Feel(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) Color accent = Accent; Page obj = root.CreatePage("Feel", accent, 0, true); obj.CreateFloat("Strength", accent, Prefs.Strength, 250f, 50f, 60000f, (Action)delegate(float value) { Prefs.Strength = value; Prefs.Save(); }); obj.CreateFloat("Stiffness", accent, Prefs.Stiffness, 0.5f, 1f, 40f, (Action)delegate(float value) { Prefs.Stiffness = value; Prefs.Save(); }); obj.CreateFloat("Max Speed", accent, Prefs.MaxSpeed, 1f, 1f, 120f, (Action)delegate(float value) { Prefs.MaxSpeed = value; Prefs.Save(); }); obj.CreateBool("Match Wrist Rotation", accent, Prefs.MatchRotation, (Action)delegate(bool value) { Prefs.MatchRotation = value; Prefs.Save(); }); obj.CreateFloat("Spin Rate", accent, Prefs.Spin, 1f, 0f, 40f, (Action)delegate(float value) { Prefs.Spin = value; Prefs.Save(); }); obj.CreateFloat("Throw Boost", accent, Prefs.ThrowBoost, 0.1f, 0.1f, 8f, (Action)delegate(float value) { Prefs.ThrowBoost = value; Prefs.Save(); }); obj.CreateFloat("Charge Time", accent, Prefs.ChargeSeconds, 0.1f, 0.1f, 5f, (Action)delegate(float value) { Prefs.ChargeSeconds = value; Prefs.Save(); }); obj.CreateFloat("Charged Throw", accent, Prefs.ChargeBoost, 0.2f, 1f, 15f, (Action)delegate(float value) { Prefs.ChargeBoost = value; Prefs.Save(); }); obj.CreateFloat("Min Hold Distance", accent, Prefs.MinDistance, 0.1f, 0.2f, 5f, (Action)delegate(float value) { Prefs.MinDistance = value; Prefs.Save(); }); } private static void Powers(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_004b: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) Color accent = Accent; Page obj = root.CreatePage("Powers", accent, 0, true); obj.CreateBool("Grab NPCs", accent, Prefs.GrabNpcs, (Action)delegate(bool value) { Prefs.GrabNpcs = value; Prefs.Save(); }); obj.CreateBool("NPCs Go Limp", accent, Prefs.LimpNpcs, (Action)delegate(bool value) { Prefs.LimpNpcs = value; Prefs.Save(); if (!value) { Blast.ReleaseAll(); } }); obj.CreateBool("Force Push", accent, Prefs.Blast, (Action)delegate(bool value) { Prefs.Blast = value; Prefs.Save(); }); obj.CreateFloat("Push Force", accent, Prefs.BlastForce, 1f, 1f, 120f, (Action)delegate(float value) { Prefs.BlastForce = value; Prefs.Save(); }); obj.CreateFloat("Push Radius", accent, Prefs.BlastRadius, 0.5f, 1f, 30f, (Action)delegate(float value) { Prefs.BlastRadius = value; Prefs.Save(); }); obj.CreateFloat("Push Cooldown", accent, Prefs.BlastCooldown, 0.1f, 0f, 15f, (Action)delegate(float value) { Prefs.BlastCooldown = value; Prefs.Save(); }); obj.CreateBool("Freeze In Place", accent, Prefs.Freeze, (Action)delegate(bool value) { Prefs.Freeze = value; Prefs.Save(); }); obj.CreateFunction("Unfreeze Everything", Color.green, (Action)delegate { int value = Freezer.ThawAll(); Melon.Logger.Msg($"Thawed {value} objects."); }); } private static void Multiplayer(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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) Color accent = Accent; Page obj = root.CreatePage("Multiplayer", accent, 0, true); obj.CreateBool("Shove Players", accent, Prefs.ShovePlayers, (Action)delegate(bool value) { Prefs.ShovePlayers = value; Prefs.Save(); }); obj.CreateFloat("Shove Force", accent, Prefs.ShoveForce, 5f, 1f, 200f, (Action)delegate(float value) { Prefs.ShoveForce = value; Prefs.Save(); }); obj.CreateFloat("Shove Damage", accent, Prefs.ShoveDamage, 5f, 0f, 100f, (Action)delegate(float value) { Prefs.ShoveDamage = value; Prefs.Save(); }); obj.CreateBool("Claim Networked Objects", accent, Prefs.TakeOwnership, (Action)delegate(bool value) { Prefs.TakeOwnership = value; Prefs.Save(); }); obj.CreateFunction("Fusion Status", accent, (Action)delegate { Melon.Logger.Msg($"Fusion: available={Fusion.Available} inLobby={Fusion.InLobby} status='{Fusion.Status}' takeovers={Fusion.Takeovers} shoves={Players.Shoves}"); }); } private static void Look(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_004b: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) Color accent = Accent; Page obj = root.CreatePage("Look & Sound", accent, 0, true); obj.CreateBool("Beam", accent, Prefs.Beam, (Action)delegate(bool value) { Prefs.Beam = value; Prefs.Save(); }); obj.CreateBool("Aim Reticle", accent, Prefs.Reticle, (Action)delegate(bool value) { Prefs.Reticle = value; Prefs.Save(); }); obj.CreateBool("Target Highlight", accent, Prefs.Highlight, (Action)delegate(bool value) { Prefs.Highlight = value; Prefs.Save(); }); obj.CreateFloat("Hue", accent, Prefs.Hue, 0.02f, 0f, 1f, (Action)delegate(float value) { Prefs.Hue = value; Prefs.Save(); }); obj.CreateBool("Sound", accent, Prefs.Sound, (Action)delegate(bool value) { Prefs.Sound = value; Prefs.Save(); }); obj.CreateFloat("Volume", accent, Prefs.Volume, 0.05f, 0f, 1f, (Action)delegate(float value) { Prefs.Volume = value; Prefs.Save(); }); obj.CreateBool("Haptics", accent, Prefs.Haptics, (Action)delegate(bool value) { Prefs.Haptics = value; Prefs.Save(); }); } private static void Diagnostics(Page root) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Color accent = Accent; Page obj = root.CreatePage("Diagnostics", accent, 0, true); obj.CreateFunction("Report State", accent, (Action)Report); obj.CreateFunction("Test Sounds", accent, (Action)delegate { //IL_0019: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 at = (((Object)(object)Player.Head != (Object)null) ? Player.Head.position : Vector3.zero); Sfx.Grab(at, 5f, npc: false); Sfx.Blast(at); Sfx.Freeze(at); }); obj.CreateBool("Log Events", accent, Prefs.LogEvents, (Action)delegate(bool value) { Prefs.LogEvents = value; Prefs.Save(); }); } private static void Report() { Instance logger = Melon.Logger; TelekinesisMod instance = TelekinesisMod.Instance; logger.Msg("---- Telekinesis ----"); logger.Msg($"render: ready={Assets.Ready} shader='{Assets.ShaderName}' throughWalls={Assets.ThroughWalls} calls={Gfx.Calls}"); logger.Msg($"audio: built={Sfx.Built} ready={Sfx.Ready} volume={Prefs.Volume:0.00}"); if (instance != null) { Describe(logger, instance.Left); Describe(logger, instance.Right); } else { logger.Msg("hands: mod instance missing"); } logger.Msg($"push: fired={Blast.Pushes} staggered={Blast.Staggered}"); logger.Msg($"registries: frozen={Freezer.Count} claimed={Claims.Count} limp={Puppets.Count}"); logger.Msg($"fusion: available={Fusion.Available} inLobby={Fusion.InLobby} status='{Fusion.Status}' takeovers={Fusion.Takeovers} shoves={Players.Shoves}"); logger.Msg($"limits: reach={Prefs.Range:0}m maxMass={Prefs.MaxMass:0}kg strength={Prefs.Strength:0}N maxHeld={Prefs.MaxHeld}"); logger.Msg("---------------------"); } private static void Describe(Instance log, Caster caster) { if (caster != null) { Aim currentAim = caster.CurrentAim; string value = (currentAim.Found ? ($"{Name(currentAim.Body)} {currentAim.Mass:0.0}kg at {currentAim.Distance:0.0}m" + (currentAim.TooHeavy ? " TOO HEAVY" : string.Empty) + (currentAim.IsNpc ? " [npc]" : string.Empty)) : "nothing"); log.Msg($"{caster.Name,-5}: hand={(Object)(object)caster.HandTransform != (Object)null} held={caster.HeldCount} strain={caster.Strain:0.00} charge={caster.Charge:0.00}s aim={value}"); } } private static string Name(Rigidbody body) { try { return ((Object)(object)body == (Object)null) ? "?" : ((Object)((Component)body).gameObject).name; } catch { return "?"; } } } } namespace Telekinesis.Force { internal static class Blast { private sealed class Stagger { public PuppetMaster Puppet; public float RestoreAt; } private const float StaggerSeconds = 2.2f; private static readonly Dictionary _staggered = new Dictionary(16); private static readonly List _due = new List(16); private static readonly HashSet _seen = new HashSet(64); private static readonly HashSet _shoved = new HashSet(8); public static int Pushes { get; private set; } public static int Staggered => _staggered.Count; public static void Push(Transform hand) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_006f: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: 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_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand == (Object)null) { return; } Vector3 position; Vector3 forward; try { position = hand.position; forward = hand.forward; } catch { return; } if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { return; } ((Vector3)(ref forward)).Normalize(); float blastRadius = Prefs.BlastRadius; float blastForce = Prefs.BlastForce; Vector3 val = position + forward * (blastRadius * 0.55f); int num = 0; _seen.Clear(); _shoved.Clear(); try { Il2CppReferenceArray val2 = Physics.OverlapSphere(val, blastRadius, -1, (QueryTriggerInteraction)1); if (val2 == null) { return; } for (int i = 0; i < ((Il2CppArrayBase)(object)val2).Length; i++) { Collider val3 = ((Il2CppArrayBase)(object)val2)[i]; if ((Object)(object)val3 == (Object)null) { continue; } Rigidbody attachedRigidbody = val3.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic) { continue; } int instanceID; try { instanceID = ((Object)attachedRigidbody).GetInstanceID(); } catch { continue; } if (!_seen.Add(instanceID)) { continue; } Vector3 val4 = attachedRigidbody.position - position; float magnitude = ((Vector3)(ref val4)).magnitude; if (magnitude < 0.05f) { val4 = forward; } Vector3 normalized = ((Vector3)(ref val4)).normalized; if (Vector3.Dot(normalized, forward) < 0.35f) { continue; } RigManager val5 = Players.Owner(attachedRigidbody); if ((Object)(object)val5 != (Object)null) { if (!Players.IsLocal(val5) && Prefs.ShovePlayers) { int instanceID2; try { instanceID2 = ((Object)val5).GetInstanceID(); } catch { continue; } if (_shoved.Add(instanceID2) && Players.Shove(val5, normalized, position)) { num++; } } continue; } float num2 = 1f - Mathf.Clamp01(magnitude / Mathf.Max(0.5f, blastRadius)); num2 *= num2; PuppetMaster val6 = Targeting.Puppet(attachedRigidbody); if ((Object)(object)val6 != (Object)null) { Knock(val6); } Vector3 val7 = normalized + Vector3.up * 0.28f; Vector3 val8 = ((Vector3)(ref val7)).normalized * (blastForce * num2); try { attachedRigidbody.AddForce(val8, (ForceMode)2); } catch { continue; } num++; } } catch (Exception ex) { Melon.Logger.Warning("Push failed: " + ex.Message); return; } Pushes++; Sfx.Blast(position); Haptics.Both(0.9f, 0.09f); if (Prefs.LogEvents) { Melon.Logger.Msg($"Push moved {num} bodies."); } } private static void Knock(PuppetMaster puppet) { if (!Prefs.LimpNpcs) { return; } try { int instanceID = ((Object)puppet).GetInstanceID(); if (_staggered.TryGetValue(instanceID, out var value)) { value.RestoreAt = Time.time + 2.2f; return; } Puppets.Claim(puppet); _staggered[instanceID] = new Stagger { Puppet = puppet, RestoreAt = Time.time + 2.2f }; } catch { } } public static void Tick() { if (_staggered.Count == 0) { return; } float time = Time.time; _due.Clear(); foreach (KeyValuePair item in _staggered) { if (time >= item.Value.RestoreAt) { _due.Add(item.Key); } } for (int i = 0; i < _due.Count; i++) { Restore(_due[i]); } } private static void Restore(int id) { if (_staggered.TryGetValue(id, out var value)) { Puppets.Release(value.Puppet); _staggered.Remove(id); } } public static void ReleaseAll() { _due.Clear(); foreach (KeyValuePair item in _staggered) { _due.Add(item.Key); } for (int i = 0; i < _due.Count; i++) { Restore(_due[i]); } _staggered.Clear(); } public static void Forget() { _staggered.Clear(); _due.Clear(); _seen.Clear(); } } internal struct BodyState { public bool Gravity; public bool Kinematic; public float Drag; public float AngularDrag; public CollisionDetectionMode Collision; public bool CollisionValid; public bool Valid; public static BodyState Capture(Rigidbody body) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) BodyState result = default(BodyState); if ((Object)(object)body == (Object)null) { return result; } try { result.Gravity = body.useGravity; result.Kinematic = body.isKinematic; result.Drag = body.drag; result.AngularDrag = body.angularDrag; result.Valid = true; } catch { return default(BodyState); } try { result.Collision = body.collisionDetectionMode; result.CollisionValid = true; } catch { result.CollisionValid = false; } return result; } public void Restore(Rigidbody body) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (!Valid || (Object)(object)body == (Object)null) { return; } try { if (CollisionValid) { try { body.collisionDetectionMode = Collision; } catch { } } body.useGravity = Gravity; body.drag = Drag; body.angularDrag = AngularDrag; body.isKinematic = Kinematic; } catch { } } } internal sealed class Caster { private const float GrabThreshold = 0.6f; private const float ReleaseThreshold = 0.3f; private const float DwellSeconds = 0.35f; private readonly bool _left; private readonly Hold[] _holds = new Hold[12]; private bool _triggerDown; private float _charge; private float _nextBlastAt; private float _hum; private int _dwellId; private float _dwellSince; public string Name { get { if (!_left) { return "right"; } return "left"; } } public Aim CurrentAim { get; private set; } public Transform HandTransform { get; private set; } public int HeldCount { get; private set; } public float Charge => _charge; public float Strain { get; private set; } public Hold[] Holds => _holds; public bool Holding => HeldCount > 0; public Caster(bool left) { _left = left; for (int i = 0; i < _holds.Length; i++) { _holds[i] = new Hold(); } } public void Tick(float delta) { Hand val = Resolve(); if ((Object)(object)val == (Object)null) { DropAll(0f); HandTransform = null; CurrentAim = default(Aim); return; } Transform transform; BaseController controller; try { transform = ((Component)val).transform; controller = val.Controller; } catch { return; } HandTransform = transform; if ((Object)(object)controller == (Object)null) { return; } Prune(); float primaryAxis; bool thumbStickDown; try { primaryAxis = controller._primaryAxis; thumbStickDown = controller.GetThumbStickDown(); } catch { return; } bool triggerDown = _triggerDown; if (_triggerDown) { if (primaryAxis < 0.3f) { _triggerDown = false; } } else if (primaryAxis >= 0.6f) { _triggerDown = true; } bool pressed = _triggerDown && !triggerDown; bool released = !_triggerDown && triggerDown; bool empty = Empty(val); if (Holding) { Carrying(transform, controller, released, thumbStickDown, empty, delta); } else { Idle(transform, pressed, thumbStickDown, empty); } } private void Idle(Transform handTransform, bool pressed, bool thumbDown, bool empty) { _charge = 0f; Strain = 0f; _dwellId = 0; CurrentAim = (empty ? Targeting.Resolve(handTransform) : default(Aim)); if (Prefs.Blast && thumbDown && empty && !_triggerDown && Time.time >= _nextBlastAt) { _nextBlastAt = Time.time + Prefs.BlastCooldown; Blast.Push(handTransform); } else if (pressed && empty) { TryGrab(handTransform); } } private void Carrying(Transform handTransform, BaseController controller, bool released, bool thumbDown, bool empty, float delta) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) if (!empty) { DropAll(0f); return; } if (released) { Throw(); return; } _charge = Mathf.Min(_charge + delta, Prefs.ChargeSeconds); Vector2 val; try { val = controller._thumbstickAxis; } catch { val = Vector2.zero; } if (Mathf.Abs(val.y) > 0.15f) { float num = val.y * Prefs.PullSpeed * delta; for (int i = 0; i < _holds.Length; i++) { Hold hold = _holds[i]; if (hold.Alive) { hold.Distance = Mathf.Clamp(hold.Distance + num, Prefs.MinDistance, Prefs.Range); } } } if (Prefs.Freeze && thumbDown) { FreezeAll(); return; } Dwell(handTransform); Sfx.Hum(handTransform.position, ref _hum, HeldCount, Strain, delta); } private void Dwell(Transform handTransform) { if (HeldCount >= Prefs.MaxHeld) { CurrentAim = default(Aim); _dwellId = 0; return; } CurrentAim = Targeting.Resolve(handTransform); if (!CurrentAim.Found || CurrentAim.TooHeavy || (Object)(object)CurrentAim.Body == (Object)null) { _dwellId = 0; return; } int instanceID; try { instanceID = ((Object)CurrentAim.Body).GetInstanceID(); } catch { _dwellId = 0; return; } if (instanceID != _dwellId) { _dwellId = instanceID; _dwellSince = Time.unscaledTime; } else if (!(Time.unscaledTime - _dwellSince < 0.35f)) { _dwellId = 0; TryGrab(handTransform); } } public void Fixed(float fixedDelta) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) if ((Object)(object)HandTransform == (Object)null || !Holding) { return; } Vector3 position; Vector3 forward; Quaternion rotation; Vector3 right; Vector3 up; try { position = HandTransform.position; forward = HandTransform.forward; rotation = HandTransform.rotation; right = HandTransform.right; up = HandTransform.up; } catch { return; } int num = 0; for (int i = 0; i < _holds.Length; i++) { if (_holds[i].Alive) { num++; } } float num2 = 0f; int num3 = 0; for (int j = 0; j < _holds.Length; j++) { Hold hold = _holds[j]; if (hold.Alive) { Vector3 target = Formation(position, forward, right, up, hold.Distance, num3, num); hold.Drive(target, rotation, fixedDelta); if (hold.Lag > num2) { num2 = hold.Lag; } num3++; } } Strain = num2; } private static Vector3 Formation(Vector3 origin, Vector3 forward, Vector3 right, Vector3 up, float distance, int slot, int count) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Vector3 val = origin + forward * distance; if (count <= 1) { return val; } float num = Mathf.Clamp(distance * 0.28f, 0.4f, 2.2f); float num2 = (float)slot / (float)count * (float)Math.PI * 2f + Time.time * 0.6f; return val + (right * Mathf.Cos(num2) + up * Mathf.Sin(num2)) * num; } private void TryGrab(Transform handTransform) { //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_007a: 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_014e: Unknown result type (might be due to invalid IL or missing references) Aim currentAim = CurrentAim; if (!currentAim.Found || (Object)(object)currentAim.Body == (Object)null) { return; } if (currentAim.IsPlayer) { Vector3 direction = currentAim.Point - handTransform.position; if (Players.Shove(currentAim.PlayerRig, direction, handTransform.position)) { Sfx.Blast(currentAim.Point); Haptics.Pulse(_left, 0.85f, 0.08f); } return; } if (currentAim.TooHeavy) { Sfx.Deny(handTransform.position); Haptics.Pulse(_left, 0.35f, 0.05f); if (Prefs.LogEvents) { Melon.Logger.Msg($"Too heavy: {currentAim.Mass:0}kg > {Prefs.MaxMass:0}kg"); } return; } Hold hold = Free(); if (hold == null) { return; } float num = Mathf.Clamp(currentAim.Distance, Prefs.MinDistance, Prefs.Range); if (hold.Take(currentAim.Body, handTransform, num, currentAim.Puppet)) { HeldCount++; Sfx.Grab(currentAim.Point, currentAim.Mass, currentAim.IsNpc); Haptics.Pulse(_left, Mathf.Lerp(0.4f, 0.9f, Mathf.Clamp01(currentAim.Mass / 60f)), 0.06f); if (Prefs.LogEvents) { Melon.Logger.Msg($"Grabbed {Describe(currentAim.Body)} ({currentAim.Mass:0.0}kg) at {num:0.0}m" + (currentAim.IsNpc ? " [npc]" : string.Empty)); } } } private void Throw() { //IL_0051: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) float num = ((Prefs.ChargeSeconds <= 0.001f) ? 1f : Mathf.Clamp01(_charge / Prefs.ChargeSeconds)); float boost = Mathf.Lerp(Prefs.ThrowBoost, Prefs.ChargeBoost, num); Vector3 at = (((Object)(object)HandTransform != (Object)null) ? HandTransform.position : Vector3.zero); int heldCount = HeldCount; DropAll(boost); if (heldCount > 0) { Sfx.Throw(at, num); Haptics.Pulse(_left, Mathf.Lerp(0.45f, 1f, num), 0.08f); } } private void FreezeAll() { //IL_0051: 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) int num = 0; for (int i = 0; i < _holds.Length; i++) { Hold hold = _holds[i]; if (hold.Alive && hold.Freeze()) { num++; } } if (num != 0) { Sfx.Freeze(((Object)(object)HandTransform != (Object)null) ? HandTransform.position : Vector3.zero); Haptics.Pulse(_left, 0.5f, 0.05f); DropAll(0f); } } public void DropAll(float boost) { for (int i = 0; i < _holds.Length; i++) { _holds[i].Release(boost); } HeldCount = 0; Strain = 0f; _charge = 0f; _dwellId = 0; } public void Forget() { for (int i = 0; i < _holds.Length; i++) { _holds[i].Abandon(); } HeldCount = 0; Strain = 0f; _charge = 0f; _dwellId = 0; _triggerDown = false; } private void Prune() { int num = 0; for (int i = 0; i < _holds.Length; i++) { Hold hold = _holds[i]; if (hold.Id != 0) { if (!hold.Alive) { hold.Abandon(); } else { num++; } } } HeldCount = num; } private Hold Free() { int num = Mathf.Min(_holds.Length, Prefs.MaxHeld); for (int i = 0; i < num; i++) { if (!_holds[i].Alive) { return _holds[i]; } } return null; } private Hand Resolve() { try { if (!Player.HandsExist) { return null; } return _left ? Player.LeftHand : Player.RightHand; } catch { return null; } } private static bool Empty(Hand hand) { if ((Object)(object)hand == (Object)null) { return false; } try { return !hand.HasAttachedObject(); } catch { return false; } } private static string Describe(Rigidbody body) { try { return ((Object)((Component)body).gameObject).name; } catch { return "?"; } } } internal static class Claims { private static readonly HashSet _held = new HashSet(); public static int Count => _held.Count; public static bool IsClaimed(int id) { return _held.Contains(id); } public static bool Claim(int id) { return _held.Add(id); } public static void Release(int id) { _held.Remove(id); } public static void Clear() { _held.Clear(); } } internal static class Puppets { private sealed class Entry { public PuppetMaster Puppet; public float Weight; public int Holders; } private static readonly Dictionary _limp = new Dictionary(16); private static readonly List _scratch = new List(16); public static int Count => _limp.Count; public static void Claim(PuppetMaster puppet) { if ((Object)(object)puppet == (Object)null) { return; } try { int instanceID = ((Object)puppet).GetInstanceID(); if (_limp.TryGetValue(instanceID, out var value)) { value.Holders++; return; } _limp[instanceID] = new Entry { Puppet = puppet, Weight = puppet.muscleWeight, Holders = 1 }; puppet.muscleWeight = 0f; } catch { } } public static void Release(PuppetMaster puppet) { if (!((Object)(object)puppet == (Object)null)) { int instanceID; try { instanceID = ((Object)puppet).GetInstanceID(); } catch { return; } Release(instanceID); } } private static void Release(int id) { if (!_limp.TryGetValue(id, out var value)) { return; } value.Holders--; if (value.Holders > 0) { return; } try { if ((Object)(object)value.Puppet != (Object)null) { value.Puppet.muscleWeight = value.Weight; } } catch { } _limp.Remove(id); } public static void ReleaseAll() { _scratch.Clear(); foreach (KeyValuePair item in _limp) { _scratch.Add(item.Key); } for (int i = 0; i < _scratch.Count; i++) { if (_limp.TryGetValue(_scratch[i], out var value)) { value.Holders = 1; } Release(_scratch[i]); } _limp.Clear(); } public static void Clear() { _limp.Clear(); _scratch.Clear(); } } internal static class Freezer { private sealed class Entry { public Rigidbody Body; public BodyState State; } private static readonly Dictionary _frozen = new Dictionary(32); private static readonly List _scratch = new List(32); public static int Count { get { Prune(); return _frozen.Count; } } public static bool IsFrozen(int id) { return _frozen.ContainsKey(id); } public static void Remember(Rigidbody body, BodyState state) { if (!((Object)(object)body == (Object)null) && state.Valid) { int instanceID; try { instanceID = ((Object)body).GetInstanceID(); } catch { return; } if (!_frozen.ContainsKey(instanceID)) { _frozen[instanceID] = new Entry { Body = body, State = state }; } } } public static bool TryAdopt(Rigidbody body, out BodyState state) { state = default(BodyState); if ((Object)(object)body == (Object)null) { return false; } int instanceID; try { instanceID = ((Object)body).GetInstanceID(); } catch { return false; } if (!_frozen.TryGetValue(instanceID, out var value)) { return false; } state = value.State; _frozen.Remove(instanceID); return true; } public static int ThawAll() { int num = 0; _scratch.Clear(); foreach (KeyValuePair item in _frozen) { _scratch.Add(item.Key); } for (int i = 0; i < _scratch.Count; i++) { if (_frozen.TryGetValue(_scratch[i], out var value)) { bool flag; try { flag = (Object)(object)value.Body == (Object)null; } catch { flag = true; } if (!flag) { value.State.Restore(value.Body); num++; } } } _frozen.Clear(); _scratch.Clear(); return num; } public static void Clear() { _frozen.Clear(); _scratch.Clear(); } private static void Prune() { _scratch.Clear(); foreach (KeyValuePair item in _frozen) { bool flag; try { flag = (Object)(object)item.Value.Body == (Object)null; } catch { flag = true; } if (flag) { _scratch.Add(item.Key); } } for (int i = 0; i < _scratch.Count; i++) { _frozen.Remove(_scratch[i]); } _scratch.Clear(); } } internal sealed class Hold { private const float OwnershipInterval = 0.15f; public Rigidbody Body; public int Id; public float Distance; public PuppetMaster Puppet; private Quaternion _rotOffset = Quaternion.identity; private BodyState _state; private bool _limp; private float _ownershipAt; public bool Frozen; public float Lag { get; private set; } public float Mass { get; private set; } = 1f; public BodyState Original => _state; public bool Alive { get { try { return (Object)(object)Body != (Object)null; } catch { return false; } } } public bool Take(Rigidbody body, Transform hand, float distance, PuppetMaster puppet) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null) { return false; } int instanceID; try { instanceID = ((Object)body).GetInstanceID(); } catch { return false; } if (!Claims.Claim(instanceID)) { return false; } try { Body = body; Id = instanceID; Distance = distance; Puppet = puppet; Mass = Targeting.SafeMass(body); Frozen = false; if (!Freezer.TryAdopt(body, out _state)) { _state = BodyState.Capture(body); } if (!_state.Valid) { Claims.Release(instanceID); Body = null; return false; } body.isKinematic = false; body.useGravity = false; body.drag = 0f; body.angularDrag = 1.5f; try { if (_state.CollisionValid && (int)_state.Collision == 0) { body.collisionDetectionMode = (CollisionDetectionMode)2; } } catch { } if ((Object)(object)hand != (Object)null) { _rotOffset = Quaternion.Inverse(hand.rotation) * body.rotation; } if (Prefs.TakeOwnership) { Fusion.TakeOwnership(((Component)body).gameObject); } _ownershipAt = Time.time + 0.15f; Limp(); return true; } catch { Claims.Release(instanceID); Body = null; return false; } } private void Limp() { if (!((Object)(object)Puppet == (Object)null) && Prefs.LimpNpcs) { Puppets.Claim(Puppet); _limp = true; } } public void Drive(Vector3 target, Quaternion handRotation, float fixedDelta) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) if (!Alive || fixedDelta <= 0f) { return; } try { if (!Body.isKinematic) { if (Prefs.TakeOwnership && Time.time >= _ownershipAt) { _ownershipAt = Time.time + 0.15f; Fusion.TakeOwnership(((Component)Body).gameObject); } Vector3 val = Body.position - target; Lag = ((Vector3)(ref val)).magnitude; float stiffness = Prefs.Stiffness; Vector3 val2 = ((0f - stiffness * stiffness) * val - 2f * stiffness * Body.velocity) * Body.mass; val2 = Vector3.ClampMagnitude(val2, Prefs.Strength); if (IsFinite(val2)) { Body.AddForce(val2, (ForceMode)0); } Vector3 velocity = Body.velocity; float magnitude = ((Vector3)(ref velocity)).magnitude; float maxSpeed = Prefs.MaxSpeed; if (magnitude > maxSpeed && magnitude > 0.0001f) { Body.velocity = velocity * (maxSpeed / magnitude); } Spin(handRotation); } } catch { Abandon(); } } private void Spin(Quaternion handRotation) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_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_000e: 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_0060: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.MatchRotation) { Rigidbody body = Body; body.angularVelocity *= 0.92f; return; } Quaternion val = handRotation * _rotOffset * Quaternion.Inverse(Body.rotation); float num = default(float); Vector3 value = default(Vector3); ((Quaternion)(ref val)).ToAngleAxis(ref num, ref value); if (!float.IsNaN(num) && !float.IsInfinity(num) && IsFinite(value) && !(((Vector3)(ref value)).sqrMagnitude < 1E-06f)) { if (num > 180f) { num -= 360f; } Vector3 val2 = ((Vector3)(ref value)).normalized * (num * ((float)Math.PI / 180f) * Prefs.Spin); if (IsFinite(val2)) { Body.angularVelocity = Vector3.Lerp(Body.angularVelocity, val2, 0.35f); } } } public bool Freeze() { //IL_0011: 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) if (!Alive) { return false; } try { Body.velocity = Vector3.zero; Body.angularVelocity = Vector3.zero; Body.isKinematic = true; Freezer.Remember(Body, _state); Frozen = true; return true; } catch { return false; } } public void Release(float boost) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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) if ((Object)(object)Body == (Object)null) { Clear(); return; } try { if (Frozen) { Body.drag = _state.Drag; Body.angularDrag = _state.AngularDrag; } else { _state.Restore(Body); if (!Body.isKinematic && boost > 0f && Math.Abs(boost - 1f) > 0.001f) { Vector3 val = Body.velocity * boost; if (IsFinite(val)) { Body.velocity = val; } } } } catch { } Clear(); } public void Abandon() { Clear(); } private void Clear() { if (Id != 0) { Claims.Release(Id); } if (_limp && (Object)(object)Puppet != (Object)null) { Puppets.Release(Puppet); } _limp = false; Body = null; Puppet = null; Frozen = false; Lag = 0f; Id = 0; _state = default(BodyState); } private static bool IsFinite(Vector3 value) { //IL_0000: 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_001a: 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_0034: 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) if (!float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z)) { return !float.IsInfinity(value.z); } return false; } } internal static class Players { public static int Shoves { get; private set; } public static RigManager Owner(Rigidbody body) { try { return ((Component)body).GetComponentInParent(); } catch { return null; } } public static bool IsLocal(RigManager rig) { try { RigManager rigManager = Player.RigManager; return (Object)(object)rigManager != (Object)null && (Object)(object)rig != (Object)null && ((Object)rig).GetInstanceID() == ((Object)rigManager).GetInstanceID(); } catch { return true; } } [MethodImpl(MethodImplOptions.NoInlining)] public static bool Shove(RigManager target, Vector3 direction, Vector3 origin) { //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_00b6: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00d5: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown if ((Object)(object)target == (Object)null || !Prefs.ShovePlayers) { return false; } if (((Vector3)(ref direction)).sqrMagnitude < 0.0001f) { return false; } ((Vector3)(ref direction)).Normalize(); try { RigManager rigManager = Player.RigManager; if ((Object)(object)rigManager == (Object)null) { return false; } TriggerRefProxy componentInChildren = ((Component)rigManager).GetComponentInChildren(true); Il2CppArrayBase componentsInChildren = ((Component)target).GetComponentsInChildren(true); if (componentsInChildren == null || componentsInChildren.Length == 0) { return false; } PlayerDamageReceiver val = null; for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)null)) { val = componentsInChildren[i]; break; } } if ((Object)(object)val == (Object)null) { return false; } Attack val2 = new Attack { damage = Prefs.ShoveDamage, normal = direction, direction = direction * Prefs.ShoveForce, origin = origin, backFacing = false, attackType = (AttackType)2, proxy = componentInChildren }; val.ReceiveAttack(val2); Shoves++; if (Prefs.LogEvents) { Melon.Logger.Msg($"Shoved a player: force {Prefs.ShoveForce:0}, damage {Prefs.ShoveDamage:0}."); } return true; } catch (Exception ex) { Melon.Logger.Warning("Shove failed: " + ex.Message); return false; } } public static void Reset() { Shoves = 0; } } internal struct Aim { public bool Found; public Rigidbody Body; public Vector3 Point; public float Distance; public float Mass; public bool TooHeavy; public PuppetMaster Puppet; public RigManager PlayerRig; public bool IsNpc => (Object)(object)Puppet != (Object)null; public bool IsPlayer => (Object)(object)PlayerRig != (Object)null; } internal static class Targeting { private const int Mask = -1; public static Aim Resolve(Transform hand) { //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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) Aim result = default(Aim); if ((Object)(object)hand == (Object)null) { return result; } Vector3 position; Vector3 forward; try { position = hand.position; forward = hand.forward; } catch { return result; } if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { return result; } ((Vector3)(ref forward)).Normalize(); float range = Prefs.Range; if (Cast(position, forward, range, 0f, ref result)) { return result; } Cast(position, forward, range, Prefs.AimAssist, ref result); return result; } private static bool Cast(Vector3 origin, Vector3 direction, float range, float radius, ref Aim result) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) try { RaycastHit val = default(RaycastHit); if (!((radius <= 0.0001f) ? Physics.Raycast(origin, direction, ref val, range, -1, (QueryTriggerInteraction)1) : Physics.SphereCast(origin, radius, direction, ref val, range, -1, (QueryTriggerInteraction)1))) { return false; } Collider collider = ((RaycastHit)(ref val)).collider; if ((Object)(object)collider == (Object)null) { return false; } Rigidbody attachedRigidbody = collider.attachedRigidbody; if ((Object)(object)attachedRigidbody == (Object)null) { return false; } RigManager val2 = Players.Owner(attachedRigidbody); if ((Object)(object)val2 != (Object)null) { if (Players.IsLocal(val2) || !Prefs.ShovePlayers) { return false; } result.Found = true; result.Body = attachedRigidbody; result.Point = ((RaycastHit)(ref val)).point; result.Distance = ((RaycastHit)(ref val)).distance; result.Mass = SafeMass(attachedRigidbody); result.PlayerRig = val2; return true; } int instanceID; try { instanceID = ((Object)attachedRigidbody).GetInstanceID(); } catch { return false; } if (Claims.IsClaimed(instanceID)) { return false; } bool isKinematic; try { isKinematic = attachedRigidbody.isKinematic; } catch { return false; } if (isKinematic && !Freezer.IsFrozen(instanceID)) { return false; } PuppetMaster val3 = Puppet(attachedRigidbody); if ((Object)(object)val3 != (Object)null && !Prefs.GrabNpcs) { return false; } float num = SafeMass(attachedRigidbody); result.Found = true; result.Body = attachedRigidbody; result.Point = ((RaycastHit)(ref val)).point; result.Distance = ((RaycastHit)(ref val)).distance; result.Mass = num; result.TooHeavy = num > Prefs.MaxMass; result.Puppet = val3; return true; } catch { return false; } } public static bool IsLocalPlayer(Rigidbody body) { RigManager val = Players.Owner(body); if ((Object)(object)val != (Object)null) { return Players.IsLocal(val); } return false; } public static PuppetMaster Puppet(Rigidbody body) { try { return ((Component)body).GetComponentInParent(); } catch { return null; } } public static float SafeMass(Rigidbody body) { try { return Mathf.Max(0.01f, body.mass); } catch { return 1f; } } } } namespace Telekinesis.Config { internal static class Prefs { private static MelonPreferences_Category _category; private static MelonPreferences_Entry _enabled; private static MelonPreferences_Entry _range; private static MelonPreferences_Entry _aimAssist; private static MelonPreferences_Entry _maxMass; private static MelonPreferences_Entry _maxHeld; private static MelonPreferences_Entry _strength; private static MelonPreferences_Entry _stiffness; private static MelonPreferences_Entry _maxSpeed; private static MelonPreferences_Entry _matchRotation; private static MelonPreferences_Entry _spin; private static MelonPreferences_Entry _pullSpeed; private static MelonPreferences_Entry _minDistance; private static MelonPreferences_Entry _throwBoost; private static MelonPreferences_Entry _chargeSeconds; private static MelonPreferences_Entry _chargeBoost; private static MelonPreferences_Entry _grabNpcs; private static MelonPreferences_Entry _limpNpcs; private static MelonPreferences_Entry _blast; private static MelonPreferences_Entry _blastForce; private static MelonPreferences_Entry _blastRadius; private static MelonPreferences_Entry _blastCooldown; private static MelonPreferences_Entry _freeze; private static MelonPreferences_Entry _beam; private static MelonPreferences_Entry _reticle; private static MelonPreferences_Entry _highlight; private static MelonPreferences_Entry _hue; private static MelonPreferences_Entry _shovePlayers; private static MelonPreferences_Entry _shoveForce; private static MelonPreferences_Entry _shoveDamage; private static MelonPreferences_Entry _takeOwnership; private static MelonPreferences_Entry _sound; private static MelonPreferences_Entry _volume; private static MelonPreferences_Entry _haptics; private static MelonPreferences_Entry _logEvents; public static bool Enabled { get { return _enabled?.Value ?? true; } set { if (_enabled != null) { _enabled.Value = value; } } } public static float Range { get { return Mathf.Clamp(_range?.Value ?? 25f, 1f, 150f); } set { if (_range != null) { _range.Value = value; } } } public static float AimAssist { get { return Mathf.Clamp(_aimAssist?.Value ?? 0.25f, 0.02f, 2f); } set { if (_aimAssist != null) { _aimAssist.Value = value; } } } public static float MaxMass { get { return Mathf.Clamp(_maxMass?.Value ?? 300f, 1f, 10000f); } set { if (_maxMass != null) { _maxMass.Value = value; } } } public static int MaxHeld { get { return Mathf.Clamp(_maxHeld?.Value ?? 1, 1, 12); } set { if (_maxHeld != null) { _maxHeld.Value = value; } } } public static float Strength { get { return Mathf.Clamp(_strength?.Value ?? 4000f, 50f, 60000f); } set { if (_strength != null) { _strength.Value = value; } } } public static float Stiffness { get { return Mathf.Clamp(_stiffness?.Value ?? 9f, 1f, 40f); } set { if (_stiffness != null) { _stiffness.Value = value; } } } public static float MaxSpeed { get { return Mathf.Clamp(_maxSpeed?.Value ?? 22f, 1f, 120f); } set { if (_maxSpeed != null) { _maxSpeed.Value = value; } } } public static bool MatchRotation { get { return _matchRotation?.Value ?? true; } set { if (_matchRotation != null) { _matchRotation.Value = value; } } } public static float Spin { get { return Mathf.Clamp(_spin?.Value ?? 12f, 0f, 40f); } set { if (_spin != null) { _spin.Value = value; } } } public static float PullSpeed { get { return Mathf.Clamp(_pullSpeed?.Value ?? 8f, 0.5f, 40f); } set { if (_pullSpeed != null) { _pullSpeed.Value = value; } } } public static float MinDistance { get { return Mathf.Clamp(_minDistance?.Value ?? 0.9f, 0.2f, 5f); } set { if (_minDistance != null) { _minDistance.Value = value; } } } public static float ThrowBoost { get { return Mathf.Clamp(_throwBoost?.Value ?? 1.4f, 0.1f, 8f); } set { if (_throwBoost != null) { _throwBoost.Value = value; } } } public static float ChargeSeconds { get { return Mathf.Clamp(_chargeSeconds?.Value ?? 0.9f, 0.1f, 5f); } set { if (_chargeSeconds != null) { _chargeSeconds.Value = value; } } } public static float ChargeBoost { get { return Mathf.Clamp(_chargeBoost?.Value ?? 3.2f, 1f, 15f); } set { if (_chargeBoost != null) { _chargeBoost.Value = value; } } } public static bool GrabNpcs { get { return _grabNpcs?.Value ?? true; } set { if (_grabNpcs != null) { _grabNpcs.Value = value; } } } public static bool LimpNpcs { get { return _limpNpcs?.Value ?? true; } set { if (_limpNpcs != null) { _limpNpcs.Value = value; } } } public static bool Blast { get { return _blast?.Value ?? true; } set { if (_blast != null) { _blast.Value = value; } } } public static float BlastForce { get { return Mathf.Clamp(_blastForce?.Value ?? 18f, 1f, 120f); } set { if (_blastForce != null) { _blastForce.Value = value; } } } public static float BlastRadius { get { return Mathf.Clamp(_blastRadius?.Value ?? 6f, 1f, 30f); } set { if (_blastRadius != null) { _blastRadius.Value = value; } } } public static float BlastCooldown { get { return Mathf.Clamp(_blastCooldown?.Value ?? 1.2f, 0f, 15f); } set { if (_blastCooldown != null) { _blastCooldown.Value = value; } } } public static bool Freeze { get { return _freeze?.Value ?? true; } set { if (_freeze != null) { _freeze.Value = value; } } } public static bool Beam { get { return _beam?.Value ?? true; } set { if (_beam != null) { _beam.Value = value; } } } public static bool Reticle { get { return _reticle?.Value ?? true; } set { if (_reticle != null) { _reticle.Value = value; } } } public static bool Highlight { get { return _highlight?.Value ?? true; } set { if (_highlight != null) { _highlight.Value = value; } } } public static float Hue { get { return Mathf.Repeat(_hue?.Value ?? 0.74f, 1f); } set { if (_hue != null) { _hue.Value = value; } } } public static bool ShovePlayers { get { return _shovePlayers?.Value ?? true; } set { if (_shovePlayers != null) { _shovePlayers.Value = value; } } } public static float ShoveForce { get { return Mathf.Clamp(_shoveForce?.Value ?? 25f, 1f, 200f); } set { if (_shoveForce != null) { _shoveForce.Value = value; } } } public static float ShoveDamage { get { return Mathf.Clamp(_shoveDamage?.Value ?? 0f, 0f, 100f); } set { if (_shoveDamage != null) { _shoveDamage.Value = value; } } } public static bool TakeOwnership { get { return _takeOwnership?.Value ?? true; } set { if (_takeOwnership != null) { _takeOwnership.Value = value; } } } public static bool Sound { get { return _sound?.Value ?? true; } set { if (_sound != null) { _sound.Value = value; } } } public static float Volume { get { return Mathf.Clamp01(_volume?.Value ?? 0.7f); } set { if (_volume != null) { _volume.Value = value; } } } public static bool Haptics { get { return _haptics?.Value ?? true; } set { if (_haptics != null) { _haptics.Value = value; } } } public static bool LogEvents { get { return _logEvents?.Value ?? false; } set { if (_logEvents != null) { _logEvents.Value = value; } } } public static void Load() { _category = MelonPreferences.CreateCategory("Telekinesis"); _enabled = _category.CreateEntry("Enabled", true, "Enabled", (string)null, false, false, (ValueValidator)null, (string)null); _range = _category.CreateEntry("Range", 25f, "Reach (m)", (string)null, false, false, (ValueValidator)null, (string)null); _aimAssist = _category.CreateEntry("AimAssist", 0.25f, "Aim Assist", (string)null, false, false, (ValueValidator)null, (string)null); _maxMass = _category.CreateEntry("MaxMass", 300f, "Max Mass", (string)null, false, false, (ValueValidator)null, (string)null); _maxHeld = _category.CreateEntry("MaxHeld", 1, "Max Held Per Hand", (string)null, false, false, (ValueValidator)null, (string)null); _strength = _category.CreateEntry("Strength", 4000f, "Strength (N)", (string)null, false, false, (ValueValidator)null, (string)null); _stiffness = _category.CreateEntry("Stiffness", 9f, "Stiffness", (string)null, false, false, (ValueValidator)null, (string)null); _maxSpeed = _category.CreateEntry("MaxSpeed", 22f, "Max Speed", (string)null, false, false, (ValueValidator)null, (string)null); _matchRotation = _category.CreateEntry("MatchRotation", true, "Match Wrist Rotation", (string)null, false, false, (ValueValidator)null, (string)null); _spin = _category.CreateEntry("Spin", 12f, "Spin Rate", (string)null, false, false, (ValueValidator)null, (string)null); _pullSpeed = _category.CreateEntry("PullSpeed", 8f, "Push / Pull Speed", (string)null, false, false, (ValueValidator)null, (string)null); _minDistance = _category.CreateEntry("MinDistance", 0.9f, "Min Hold Distance", (string)null, false, false, (ValueValidator)null, (string)null); _throwBoost = _category.CreateEntry("ThrowBoost", 1.4f, "Throw Boost", (string)null, false, false, (ValueValidator)null, (string)null); _chargeSeconds = _category.CreateEntry("ChargeSeconds", 0.9f, "Charge Time (s)", (string)null, false, false, (ValueValidator)null, (string)null); _chargeBoost = _category.CreateEntry("ChargeBoost", 3.2f, "Charged Throw Boost", (string)null, false, false, (ValueValidator)null, (string)null); _grabNpcs = _category.CreateEntry("GrabNpcs", true, "Grab NPCs", (string)null, false, false, (ValueValidator)null, (string)null); _limpNpcs = _category.CreateEntry("LimpNpcs", true, "NPCs Go Limp", (string)null, false, false, (ValueValidator)null, (string)null); _blast = _category.CreateEntry("Blast", true, "Force Push", (string)null, false, false, (ValueValidator)null, (string)null); _blastForce = _category.CreateEntry("BlastForce", 18f, "Push Force", (string)null, false, false, (ValueValidator)null, (string)null); _blastRadius = _category.CreateEntry("BlastRadius", 6f, "Push Radius", (string)null, false, false, (ValueValidator)null, (string)null); _blastCooldown = _category.CreateEntry("BlastCooldown", 1.2f, "Push Cooldown (s)", (string)null, false, false, (ValueValidator)null, (string)null); _freeze = _category.CreateEntry("Freeze", true, "Freeze In Place", (string)null, false, false, (ValueValidator)null, (string)null); _beam = _category.CreateEntry("Beam", true, "Beam", (string)null, false, false, (ValueValidator)null, (string)null); _reticle = _category.CreateEntry("Reticle", true, "Aim Reticle", (string)null, false, false, (ValueValidator)null, (string)null); _highlight = _category.CreateEntry("Highlight", true, "Target Highlight", (string)null, false, false, (ValueValidator)null, (string)null); _hue = _category.CreateEntry("Hue", 0.74f, "Hue", (string)null, false, false, (ValueValidator)null, (string)null); _shovePlayers = _category.CreateEntry("ShovePlayers", true, "Shove Players", (string)null, false, false, (ValueValidator)null, (string)null); _shoveForce = _category.CreateEntry("ShoveForce", 25f, "Shove Force", (string)null, false, false, (ValueValidator)null, (string)null); _shoveDamage = _category.CreateEntry("ShoveDamage", 0f, "Shove Damage", (string)null, false, false, (ValueValidator)null, (string)null); _takeOwnership = _category.CreateEntry("TakeOwnership", true, "Claim Networked Objects", (string)null, false, false, (ValueValidator)null, (string)null); _sound = _category.CreateEntry("Sound", true, "Sound", (string)null, false, false, (ValueValidator)null, (string)null); _volume = _category.CreateEntry("Volume", 0.7f, "Volume", (string)null, false, false, (ValueValidator)null, (string)null); _haptics = _category.CreateEntry("Haptics", true, "Haptics", (string)null, false, false, (ValueValidator)null, (string)null); _logEvents = _category.CreateEntry("LogEvents", false, "Log Events", (string)null, false, false, (ValueValidator)null, (string)null); } public static void Save() { try { MelonPreferences_Category category = _category; if (category != null) { category.SaveToFile(false); } } catch { } } } } namespace Telekinesis.Audio { internal static class Haptics { public static void Pulse(bool left, float amplitude, float duration) { if (Prefs.Haptics) { Send(left, amplitude, duration); } } public static void Both(float amplitude, float duration) { if (Prefs.Haptics) { Send(left: true, amplitude, duration); Send(left: false, amplitude, duration); } } public static void Strain(bool left, float strain) { if (Prefs.Haptics) { float num = Mathf.Clamp01(strain / 2.5f); if (!(num < 0.12f)) { Send(left, num * 0.35f, 0.02f); } } } private static void Send(bool left, float amplitude, float duration) { try { if (!Player.ControllersExist) { return; } BaseController val = (left ? Player.LeftController : Player.RightController); if (!((Object)(object)val == (Object)null)) { Haptor haptor = val.haptor; if (!((Object)(object)haptor != (Object)null) || haptor.hapticsAllowed) { val.HapticAction(0f, duration, 150f, Mathf.Clamp01(amplitude)); } } } catch { } } } internal static class Sfx { private const int SampleRate = 22050; private const float HumLength = 0.5f; private const float HumRepeat = 0.44f; private static AudioClip _grab; private static AudioClip _throw; private static AudioClip _blast; private static AudioClip _freeze; private static AudioClip _deny; private static AudioClip _hum; public static bool Ready { get { if ((Object)(object)_grab != (Object)null) { return (Object)(object)_throw != (Object)null; } return false; } } public static int Built { get; private set; } public static void Build() { Built = 0; _grab = Grab(); _throw = Throw(); _blast = Blast(); _freeze = Freeze(); _deny = Deny(); _hum = Hum(); Melon.Logger.Msg($"Built {Built} sounds."); } public static void Dispose() { Kill(ref _grab); Kill(ref _throw); Kill(ref _blast); Kill(ref _freeze); Kill(ref _deny); Kill(ref _hum); Built = 0; } private static void Kill(ref AudioClip clip) { try { if ((Object)(object)clip != (Object)null) { Object.Destroy((Object)(object)clip); } } catch { } clip = null; } public static void Grab(Vector3 at, float mass, bool npc) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(1.25f, 0.62f, Mathf.Clamp01(mass / 80f)); if (npc) { num *= 0.85f; } Play(_grab, at, 1f, num); } public static void Throw(Vector3 at, float charge) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Play(_throw, at, Mathf.Lerp(0.8f, 1.25f, charge), Mathf.Lerp(1.15f, 0.8f, charge)); } public static void Blast(Vector3 at) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Play(_blast, at, 1.15f, 1f); } public static void Freeze(Vector3 at) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Play(_freeze, at, 0.9f, 1f); } public static void Deny(Vector3 at) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) Play(_deny, at, 0.7f, 1f); } public static void Hum(Vector3 at, ref float timer, int count, float strain, float delta) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) if (Prefs.Sound && !((Object)(object)_hum == (Object)null) && count > 0) { timer -= delta; if (!(timer > 0f)) { timer = 0.44f; float pitch = Mathf.Lerp(1f, 0.7f, Mathf.Clamp01(strain / 2.5f)); float volume = Mathf.Clamp01(0.35f + 0.1f * (float)(count - 1) + Mathf.Clamp01(strain / 3f) * 0.25f); Play(_hum, at, volume, pitch); } } } private static void Play(AudioClip clip, Vector3 at, float volume, float pitch) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!Prefs.Sound || (Object)(object)clip == (Object)null) { return; } try { Audio.PlayAtPoint(clip, at, Audio.SoftInteraction, Prefs.Volume * volume, pitch, 1f); } catch (Exception ex) { Melon.Logger.Warning("Playback failed: " + ex.Message); } } private static AudioClip Grab() { int num = 7717; float[] array = new float[num]; double num2 = 0.0; Random random = new Random(1201); float num3 = 0f; for (int i = 0; i < num; i++) { float num4 = (float)i / (float)num; float num5 = Mathf.Lerp(150f, 620f, Mathf.Pow(num4, 0.7f)); num2 += Math.PI * 2.0 * (double)num5 / 22050.0; float num6 = (float)(Math.Sin(num2) * 0.6 + Math.Sin(num2 * 2.0) * 0.2); float num7 = (float)(random.NextDouble() * 2.0 - 1.0); num3 = num3 * 0.72f + num7 * 0.28f; float num8 = Mathf.Sin(num4 * (float)Math.PI); array[i] = (num6 * 0.7f + num3 * 0.5f) * num8 * 0.55f; } return Make("TK_Grab", array); } private static AudioClip Throw() { int num = 6615; float[] array = new float[num]; double num2 = 0.0; Random random = new Random(3307); float num3 = 0f; float num4 = 0f; for (int i = 0; i < num; i++) { float num5 = (float)i / (float)num; float num6 = Mathf.Lerp(700f, 120f, Mathf.Pow(num5, 0.5f)); num2 += Math.PI * 2.0 * (double)num6 / 22050.0; float num7 = (float)Math.Sin(num2) * 0.55f; float num8 = (float)(random.NextDouble() * 2.0 - 1.0); float num9 = num8 - num4; num4 = num8; num3 = num3 * 0.8f + num9 * 0.2f; float num10 = Mathf.Pow(1f - num5, 1.5f); array[i] = (num7 + num3 * 1.6f) * num10 * 0.6f; } return Make("TK_Throw", array); } private static AudioClip Blast() { int num = 9922; float[] array = new float[num]; double num2 = 0.0; Random random = new Random(9091); float num3 = 0f; for (int i = 0; i < num; i++) { float num4 = (float)i / (float)num; float num5 = Mathf.Lerp(120f, 42f, Mathf.Pow(num4, 0.4f)); num2 += Math.PI * 2.0 * (double)num5 / 22050.0; float num6 = (float)Math.Sin(num2) * 0.85f; float num7 = (float)(random.NextDouble() * 2.0 - 1.0); num3 = num3 * 0.55f + num7 * 0.45f; float num8 = num3 * Mathf.Pow(1f - num4, 7f) * 0.7f; float num9 = Mathf.Pow(1f - num4, 1.2f); array[i] = (num6 * num9 + num8) * 0.7f; } return Make("TK_Blast", array); } private static AudioClip Freeze() { int num = 9261; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; for (int i = 0; i < num; i++) { float num4 = (float)i / (float)num; num2 += 0.4468042885105483; num3 += 0.5964039386814909; float num5 = Mathf.Clamp01((num4 - 0.18f) / 0.15f); float num6 = (float)(Math.Sin(num2) * 0.5 + Math.Sin(num3) * 0.4 * (double)num5); float num7 = Mathf.Pow(1f - num4, 2.2f); array[i] = num6 * num7 * 0.42f; } return Make("TK_Freeze", array); } private static AudioClip Deny() { int num = 3969; float[] array = new float[num]; double num2 = 0.0; for (int i = 0; i < num; i++) { float num3 = (float)i / (float)num; num2 += 0.026215557744241356; float num4 = ((Math.Sin(num2) >= 0.0) ? 1f : (-1f)); float num5 = Mathf.Sin(num3 * (float)Math.PI); array[i] = num4 * num5 * 0.3f; } return Make("TK_Deny", array); } private static AudioClip Hum() { int num = 11025; float[] array = new float[num]; double num2 = 0.0; double num3 = 0.0; double num4 = 0.0; for (int i = 0; i < num; i++) { float num5 = (float)i / (float)num; num4 += 0.001567234430362255; float num6 = 1f + (float)Math.Sin(num4) * 0.012f; num2 += Math.PI * 192.0 * (double)num6 / 22050.0; num3 += Math.PI * 288.0 * (double)num6 / 22050.0; float num7 = (float)(Math.Sin(num2) * 0.6 + Math.Sin(num3) * 0.25); float num8 = Mathf.Min(1f, Mathf.Min(num5, 1f - num5) / 0.08f); array[i] = num7 * num8 * 0.3f; } return Make("TK_Hum", array); } private static AudioClip Make(string name, float[] samples) { try { Il2CppStructArray val = new Il2CppStructArray((long)samples.Length); for (int i = 0; i < samples.Length; i++) { ((Il2CppArrayBase)(object)val)[i] = Mathf.Clamp(samples[i], -1f, 1f); } AudioClip obj = AudioClip.Create(name, samples.Length, 1, 22050, false); obj.SetData(val, 0); ((Object)obj).hideFlags = (HideFlags)61; Built++; return obj; } catch (Exception ex) { Melon.Logger.Warning("Building " + name + " failed: " + ex.Message); return null; } } } }