Decompiled source of Shark v1.0.0
Mods/Shark.dll
Decompiled 12 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BoneLib; using BoneLib.BoneMenu; using BoneLib.Notifications; using FluidLab; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.Warehouse; using LabFusion.Entities; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.Player; using LabFusion.SDK.Modules; using MelonLoader; using MelonLoader.Utils; using SharkMod; using ThirdEyeBonelabMod; using ThirdEyeBonelabMod.Sharks; using ThirdEyeBonelabMod.Tools; using ThirdEyeBonelabMod.Zombies; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Mod), "Shark", "1.0.0", "RUDYHILL", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("Shark")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Shark")] [assembly: AssemblyTitle("Shark")] [assembly: AssemblyVersion("1.0.0.0")] namespace SharkMod { public class Mod : MelonMod { public override void OnInitializeMelon() { AssetFiles.Root = "Shark"; SpawnPreview.Apply(((MelonBase)this).HarmonyInstance); SpawnGuard.Apply(((MelonBase)this).HarmonyInstance); Hooking.OnLevelUnloaded += PropShell.ForgetLevel; Hooking.OnLevelUnloaded += GameGrips.ForgetLevel; Hooking.OnLevelUnloaded += Handles.ForgetLevel; Hooking.OnLevelUnloaded += Spawnables.Clear; Hooking.OnWarehouseReady += Spawnables.Register; SharkManager.Initialize(Page.Root); MelonLogger.Msg("Shark ready (BoneMenu > Shark)"); } public override void OnUpdate() { Spawnables.Update(); SharkManager.Update(); SpawnPreview.Update(); GameGrips.Update(); } public override void OnFixedUpdate() { JointFirm.FixedUpdate(); SharkManager.FixedUpdate(); } public override void OnLateUpdate() { SharkManager.LateUpdate(); } } } namespace ThirdEyeBonelabMod { public static class AssetFiles { public static string Root = "Mod"; private const string Packed = "packed:"; private static Dictionary<string, string> packed; public static string Folder(string name) { return "packed:" + name; } public static string SaveFolder(string name) { return Path.Combine(MelonEnvironment.UserDataDirectory, Root, name); } private static string Resource(string path) { if (path == null || !path.StartsWith("packed:", StringComparison.Ordinal)) { return null; } if (packed == null) { packed = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); string[] manifestResourceNames = typeof(AssetFiles).Assembly.GetManifestResourceNames(); foreach (string text in manifestResourceNames) { packed[text.Replace('\\', '/')] = text; } } string key = path.Substring("packed:".Length).Replace('\\', '/').TrimStart('/'); if (!packed.TryGetValue(key, out var value)) { return ""; } return value; } public static bool Exists(string path) { string text = Resource(path); if (text == null) { return File.Exists(path); } return text.Length > 0; } public static Stream OpenRead(string path) { string text = Resource(path); if (text == null) { if (!File.Exists(path)) { return null; } return File.OpenRead(path); } if (text.Length <= 0) { return null; } return typeof(AssetFiles).Assembly.GetManifestResourceStream(text); } public static byte[] ReadAllBytes(string path) { using Stream stream = OpenRead(path); if (stream == null) { throw new FileNotFoundException("Not in the mod: " + path); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); return memoryStream.ToArray(); } public static string ReadAllText(string path) { return Encoding.UTF8.GetString(ReadAllBytes(path)).TrimStart('\ufeff'); } public static string[] ReadAllLines(string path) { string text = ReadAllText(path).Replace("\r\n", "\n"); if (text.EndsWith("\n", StringComparison.Ordinal)) { text = text.Substring(0, text.Length - 1); } if (text.Length != 0) { return text.Split('\n'); } return new string[0]; } public static Mesh ReadMesh(string path, string name) { //IL_0055: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown if (!Exists(path)) { return null; } using BinaryReader binaryReader = new BinaryReader(OpenRead(path)); int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); Vector3[] array = (Vector3[])(object)new Vector3[num]; Vector3[] array2 = (Vector3[])(object)new Vector3[num]; Vector2[] array3 = (Vector2[])(object)new Vector2[num]; for (int i = 0; i < num; i++) { array[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[i] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); } int[] array4 = new int[num2]; for (int j = 0; j < num2; j++) { array4[j] = binaryReader.ReadInt32(); } Mesh val = new Mesh { name = name, hideFlags = (HideFlags)32, vertices = Il2CppStructArray<Vector3>.op_Implicit(array), normals = Il2CppStructArray<Vector3>.op_Implicit(array2), uv = Il2CppStructArray<Vector2>.op_Implicit(array3), triangles = Il2CppStructArray<int>.op_Implicit(array4) }; val.RecalculateBounds(); return val; } public static Texture2D ReadTexture(string path, bool data = false) { //IL_001b: 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_0020: 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_0039: Expected O, but got Unknown //IL_003b: Expected O, but got Unknown if (!Exists(path)) { return null; } Texture2D val = (data ? new Texture2D(2, 2, (TextureFormat)4, true, true) : new Texture2D(2, 2)); ((Object)val).hideFlags = (HideFlags)32; ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(ReadAllBytes(path))); return val; } public static AudioClip ReadWav(string path, string name) { if (!Exists(path)) { return null; } byte[] array = ReadAllBytes(path); int num = 0; int num2 = 0; int num3 = 0; int num4 = -1; int num5 = 0; int num6; for (int i = 12; i + 8 <= array.Length; i += 8 + num6 + (num6 & 1)) { string text = Encoding.ASCII.GetString(array, i, 4); num6 = BitConverter.ToInt32(array, i + 4); if (text == "fmt ") { num = BitConverter.ToInt16(array, i + 10); num2 = BitConverter.ToInt32(array, i + 12); num3 = BitConverter.ToInt16(array, i + 22); } else if (text == "data") { num4 = i + 8; num5 = Math.Min(num6, array.Length - num4); break; } } if (num4 < 0 || num <= 0 || num3 != 16) { return null; } int num7 = num5 / 2; float[] array2 = new float[num7]; for (int j = 0; j < num7; j++) { array2[j] = (float)BitConverter.ToInt16(array, num4 + j * 2) / 32768f; } AudioClip obj = AudioClip.Create(name, num7 / num, num, num2, false); obj.SetData(Il2CppStructArray<float>.op_Implicit(array2), 0); ((Object)obj).hideFlags = (HideFlags)32; return obj; } } public static class GameGrips { private class Pass { public IntPtr held; public Rigidbody body; public float endAt = -1f; public readonly List<Collider> hand = new List<Collider>(); public readonly List<Collider> solids = new List<Collider>(); } private const int GripLayer = 15; private static readonly Dictionary<IntPtr, List<Grip>> made = new Dictionary<IntPtr, List<Grip>>(); private static readonly Pass[] passes = new Pass[2] { new Pass(), new Pass() }; private const float PassLingers = 0.25f; public static bool IsOurs(GameObject held) { if ((Object)(object)held != (Object)null) { return ((Object)held).name == "ThirdEyeBoxGrip"; } return false; } public static void Add(Rigidbody body, Transform parts) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null || (Object)(object)parts == (Object)null) { return; } InteractableHost componentInParent = ((Component)body).GetComponentInParent<InteractableHost>(); if ((Object)(object)componentInParent == (Object)null) { return; } Clear(body); try { if (Bounds(body, parts, out var box, out var solids)) { Box(body, componentInParent, parts, ((Bounds)(ref box)).center, ((Bounds)(ref box)).size, solids); } } catch (Exception ex) { MelonLogger.Warning("Game grips: an item could not be given a grip: " + ex.Message); } } private static bool Bounds(Rigidbody body, Transform parts, out Bounds box, out List<Collider> solids) { //IL_0001: 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_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_033d: Unknown result type (might be due to invalid IL or missing references) //IL_033e: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_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_010a: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) box = default(Bounds); solids = new List<Collider>(); bool flag = false; Bounds val = default(Bounds); bool flag2 = false; foreach (MeshFilter componentsInChild in ((Component)parts).GetComponentsInChildren<MeshFilter>()) { if ((Object)(object)componentsInChild == (Object)null || (Object)(object)componentsInChild.sharedMesh == (Object)null) { continue; } Renderer component = ((Component)componentsInChild).GetComponent<Renderer>(); if ((Object)(object)component == (Object)null || !component.enabled || ((Object)componentsInChild).name.StartsWith("ThirdEyeCollider", StringComparison.Ordinal)) { continue; } Bounds bounds = componentsInChild.sharedMesh.bounds; for (int i = 0; i < 8; i++) { Vector3 val2 = ((Bounds)(ref bounds)).center + Vector3.Scale(((Bounds)(ref bounds)).extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); Vector3 val3 = parts.InverseTransformPoint(((Component)componentsInChild).transform.TransformPoint(val2)); if (!flag2) { val = new Bounds(val3, Vector3.zero); flag2 = true; } else { ((Bounds)(ref val)).Encapsulate(val3); } } } Vector3 val7 = default(Vector3); foreach (Collider componentsInChild2 in ((Component)parts).GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild2 == (Object)null || componentsInChild2.isTrigger || !componentsInChild2.enabled || (Object)(object)componentsInChild2.attachedRigidbody != (Object)(object)body) { continue; } BoxCollider val4 = ((Il2CppObjectBase)componentsInChild2).TryCast<BoxCollider>(); CapsuleCollider val5 = (((Object)(object)val4 == (Object)null) ? ((Il2CppObjectBase)componentsInChild2).TryCast<CapsuleCollider>() : null); SphereCollider val6 = (((Object)(object)val4 == (Object)null && (Object)(object)val5 == (Object)null) ? ((Il2CppObjectBase)componentsInChild2).TryCast<SphereCollider>() : null); Vector3 center; if ((Object)(object)val4 != (Object)null) { center = val4.center; val7 = val4.size * 0.5f; } else if ((Object)(object)val5 != (Object)null) { center = val5.center; float num = Mathf.Max(val5.height * 0.5f, val5.radius); ((Vector3)(ref val7))..ctor(val5.radius, val5.radius, val5.radius); ((Vector3)(ref val7))[val5.direction] = num; } else { if (!((Object)(object)val6 != (Object)null)) { continue; } center = val6.center; val7 = Vector3.one * val6.radius; } solids.Add(componentsInChild2); for (int j = 0; j < 8; j++) { Vector3 val8 = center + new Vector3(((j & 1) == 0) ? (0f - val7.x) : val7.x, ((j & 2) == 0) ? (0f - val7.y) : val7.y, ((j & 4) == 0) ? (0f - val7.z) : val7.z); Vector3 val9 = parts.InverseTransformPoint(((Component)componentsInChild2).transform.TransformPoint(val8)); if (!flag) { box = new Bounds(val9, Vector3.zero); flag = true; } else { ((Bounds)(ref box)).Encapsulate(val9); } } } if (flag2 && flag) { box = val; } return flag; } private static void Box(Rigidbody body, InteractableHost host, Transform parts, Vector3 centre, Vector3 size, List<Collider> solids) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown //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_0061: 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_0097: 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_010e: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Expected O, but got Unknown size = Vector3.Max(size, Vector3.one * 0.02f); GameObject val = new GameObject("ThirdEyeBoxGrip"); val.SetActive(false); val.layer = 15; val.transform.SetParent(parts, false); val.transform.localPosition = centre; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; BoxCollider val2 = val.AddComponent<BoxCollider>(); ((Collider)val2).isTrigger = true; val2.size = size; BoxGrip val3 = val.AddComponent<BoxGrip>(); ((Grip)val3).isThrowable = true; ((Grip)val3).ignoreGripTargetOnAttach = false; ((Grip)val3).primaryMovementAxis = Vector3.forward; ((Grip)val3).secondaryMovementAxis = Vector3.up; ((Grip)val3).gripOptions = (InteractionOptions)1; ((Grip)val3).priority = 1f; ((Grip)val3).minBreakForce = float.PositiveInfinity; ((Grip)val3).maxBreakForce = float.PositiveInfinity; ((Grip)val3).defaultGripDistance = float.PositiveInfinity; ((TargetGrip)val3).rotationLimit = 180f; ((TargetGrip)val3).rotationPriorityBuffer = 20f; ((TargetGrip)val3).targetFlipOnPrimaryAxis = true; ((TargetGrip)val3).targetFlipOnTertiaryAxis = false; val3.sandwichSize = 0.12f; float num = Mathf.Min(size.x, Mathf.Min(size.y, size.z)); val3.edgePadding = Mathf.Clamp(num * 0.25f, 0.01f, 0.03f); val3.sandwichHandPose = Handles.Pose("BoxSandwichGrip"); val3.canBeSandwichedGrabbed = false; val3.edgeHandPose = Handles.Pose("BoxEdgeGrip"); val3.edgeHandPoseRadius = 0.05f; val3.canBeEdgeGrabbed = (Object)(object)val3.edgeHandPose != (Object)null; val3.cornerHandPose = Handles.Pose("BoxCornerGrip"); val3.cornerHandPoseRadius = 0.05f; val3.canBeCornerGrabbed = (Object)(object)val3.cornerHandPose != (Object)null; val3.faceHandPose = Handles.Pose("BoxFaceGrip"); val3.faceHandPoseRadius = 1f; val3.canBeFaceGrabbed = true; val3.enabledFaces = (Faces)(-1); val3.enabledEdges = (Edges)(-1); val3.enabledCorners = (Corners)(-1); val3.forceGrabFace = (Faces)2; val3.forceGrabTop = (Faces)4; val3._boxCollider = val2; ((Grip)val3).gripColliders = new Il2CppReferenceArray<Collider>(0L); Il2CppReferenceArray<Collider> val4 = new Il2CppReferenceArray<Collider>((long)solids.Count); for (int i = 0; i < solids.Count; i++) { ((Il2CppArrayBase<Collider>)(object)val4)[i] = solids[i]; } ((Grip)val3).additionalGripColliders = val4; AnimationCurve val5 = new AnimationCurve(); val5.AddKey(-180f, 0f); val5.AddKey(0f, 0f); val5.AddKey(180f, 0f); ((Grip)val3).handleAmplifyCurve = val5; ForcePullGrip obj = val.AddComponent<ForcePullGrip>(); obj._grip = (Grip)(object)val3; obj.maxSpeed = float.PositiveInfinity; val.SetActive(true); if ((Object)(object)((Grip)val3)._marrowEntity == (Object)null) { ((Grip)val3)._marrowEntity = ((Component)body).GetComponentInParent<MarrowEntity>(); } host.DecorateHostOnChildGrips(val.transform); if (!made.TryGetValue(((Il2CppObjectBase)body).Pointer, out var value)) { value = (made[((Il2CppObjectBase)body).Pointer] = new List<Grip>()); } value.Add((Grip)(object)val3); } public static void Clear(Rigidbody body) { if ((Object)(object)body == (Object)null || !made.TryGetValue(((Il2CppObjectBase)body).Pointer, out var value)) { return; } made.Remove(((Il2CppObjectBase)body).Pointer); InteractableHost componentInParent = ((Component)body).GetComponentInParent<InteractableHost>(); foreach (Grip item in value) { if ((Object)(object)item == (Object)null) { continue; } try { if (item.attachedHands != null && item.attachedHands.Count > 0) { item.ForceDetach(); } if ((Object)(object)componentInParent != (Object)null && componentInParent._grips != null) { componentInParent._grips.Remove(item); } } catch (Exception ex) { MelonLogger.Warning("Game grips: a grip did not let go cleanly. " + ex.Message); } Object.Destroy((Object)(object)((Component)item).gameObject); } } public static void Update() { try { Track(Player.LeftHand, passes[0]); Track(Player.RightHand, passes[1]); } catch { } } private static bool Ours(Rigidbody body) { if ((Object)(object)body == (Object)null) { return false; } Transform transform = ((Component)body).transform; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((Object)(object)child != (Object)null && ((Object)child).name.StartsWith("ThirdEye", StringComparison.Ordinal)) { return true; } } return false; } private static void Track(Hand hand, Pass pass) { GameObject val = (((Object)(object)hand != (Object)null) ? hand.m_CurrentAttachedGO : null); IntPtr intPtr = (((Object)(object)val != (Object)null) ? ((Il2CppObjectBase)val).Pointer : IntPtr.Zero); if (intPtr != pass.held) { pass.held = intPtr; Rigidbody val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInParent<Rigidbody>() : null); if ((Object)(object)val2 != (Object)null && Ours(val2)) { if ((Object)(object)val2 != (Object)(object)pass.body) { End(pass); pass.body = val2; if ((Object)(object)hand.rb != (Object)null) { foreach (Collider componentsInChild in ((Component)hand.rb).GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild != (Object)null && !componentsInChild.isTrigger) { pass.hand.Add(componentsInChild); } } } foreach (Collider componentsInChild2 in ((Component)val2).GetComponentsInChildren<Collider>()) { if ((Object)(object)componentsInChild2 != (Object)null && !componentsInChild2.isTrigger && (Object)(object)componentsInChild2.attachedRigidbody == (Object)(object)val2) { pass.solids.Add(componentsInChild2); } } Set(pass, ignore: true); } pass.endAt = -1f; } else if ((Object)(object)pass.body != (Object)null) { pass.endAt = Time.time + 0.25f; } } if (pass.endAt > 0f && Time.time >= pass.endAt) { End(pass); } } private static void Set(Pass pass, bool ignore) { foreach (Collider item in pass.hand) { if ((Object)(object)item == (Object)null) { continue; } foreach (Collider solid in pass.solids) { if ((Object)(object)solid != (Object)null) { Physics.IgnoreCollision(item, solid, ignore); } } } } private static void End(Pass pass) { if ((Object)(object)pass.body != (Object)null) { Set(pass, ignore: false); } pass.body = null; pass.endAt = -1f; pass.hand.Clear(); pass.solids.Clear(); } public static void ForgetLevel() { made.Clear(); Pass[] array = passes; foreach (Pass obj in array) { obj.held = IntPtr.Zero; obj.body = null; obj.endAt = -1f; obj.hand.Clear(); obj.solids.Clear(); } } } public static class Handles { private const int GripLayer = 15; public const string HandleShape = "CylinderGripSmall"; private static readonly Dictionary<string, HandPose> poses = new Dictionary<string, HandPose>(); private static readonly HashSet<string> missing = new HashSet<string>(); private static readonly Dictionary<IntPtr, List<Grip>> made = new Dictionary<IntPtr, List<Grip>>(); public static HandPose Pose(string name) { if (poses.TryGetValue(name, out var value) && (Object)(object)value != (Object)null) { return value; } if (missing.Contains(name)) { return null; } try { foreach (HandPose item in Resources.FindObjectsOfTypeAll<HandPose>()) { if ((Object)(object)item != (Object)null && string.Equals(((Object)item).name, name, StringComparison.OrdinalIgnoreCase)) { value = item; break; } } if ((Object)(object)value == (Object)null) { value = FromFile(name); } } catch (Exception ex) { MelonLogger.Warning("Handles: the hand shape " + name + " could not be read: " + ex.Message); } if ((Object)(object)value == (Object)null) { missing.Add(name); MelonLogger.Warning("Handles: the game's hand shape " + name + " was not found; items keep their old grip"); return null; } ((Object)value).hideFlags = (HideFlags)32; poses[name] = value; MelonLogger.Msg("Handles: using the game's hand shape " + ((Object)value).name); return value; } private static HandPose FromFile(string name) { string path = Path.Combine(Application.streamingAssetsPath, "aa", "StandaloneWindows64", "deduped_assets_handpose"); if (!Directory.Exists(path)) { return null; } string[] files = Directory.GetFiles(path, name.ToLowerInvariant() + "_*.bundle"); if (files.Length == 0) { return null; } AssetBundle val = AssetBundle.LoadFromFile(files[0]); if ((Object)(object)val == (Object)null) { string text = Path.GetFileName(files[0]).ToLowerInvariant(); foreach (AssetBundle item in (Il2CppArrayBase<AssetBundle>)(object)AssetBundle.GetAllLoadedAssetBundles_Native()) { if ((Object)(object)item == (Object)null || !((Object)item).name.ToLowerInvariant().Contains(name.ToLowerInvariant())) { continue; } foreach (Object item2 in (Il2CppArrayBase<Object>)(object)item.LoadAllAssets()) { HandPose val2 = ((item2 != (Object)null) ? ((Il2CppObjectBase)item2).TryCast<HandPose>() : null); if ((Object)(object)val2 != (Object)null) { return val2; } } } MelonLogger.Warning("Handles: " + text + " could not be opened"); return null; } HandPose result = null; try { foreach (Object item3 in (Il2CppArrayBase<Object>)(object)val.LoadAllAssets()) { HandPose val3 = ((item3 != (Object)null) ? ((Il2CppObjectBase)item3).TryCast<HandPose>() : null); if ((Object)(object)val3 != (Object)null) { result = val3; break; } } } finally { val.Unload(false); } return result; } public static Grip Fixed(Rigidbody body, Transform parent, Vector3 centre, Vector3 axis, Vector3 across, float radius, float halfLength, IList<Collider> solids, bool eitherWay = true, bool forcePull = true) { //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) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Make(sliding: false, body, parent, centre, axis, across, radius, halfLength, solids, eitherWay, forcePull); } public static Grip Sliding(Rigidbody body, Transform parent, Vector3 centre, Vector3 axis, Vector3 across, float radius, float halfLength, IList<Collider> solids, bool forcePull = true) { //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) //IL_0005: Unknown result type (might be due to invalid IL or missing references) return Make(sliding: true, body, parent, centre, axis, across, radius, halfLength, solids, eitherWay: true, forcePull); } private static Grip Make(bool sliding, Rigidbody body, Transform parent, Vector3 centre, Vector3 axis, Vector3 across, float radius, float halfLength, IList<Collider> solids, bool eitherWay, bool forcePull) { //IL_0043: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_00ea: 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_0148: Expected O, but got Unknown //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_0086: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_008b: 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_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) try { InteractableHost val = (((Object)(object)body != (Object)null) ? ((Component)body).GetComponentInParent<InteractableHost>() : null); HandPose val2 = Pose("CylinderGripSmall"); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)parent == (Object)null) { return null; } axis = ((Vector3)(ref axis)).normalized; Vector3 val3 = Vector3.ProjectOnPlane(across, axis); across = ((Vector3)(ref val3)).normalized; if (((Vector3)(ref across)).sqrMagnitude < 0.5f) { val3 = Vector3.ProjectOnPlane((Mathf.Abs(axis.y) < 0.9f) ? Vector3.up : Vector3.forward, axis); across = ((Vector3)(ref val3)).normalized; } GameObject val4 = new GameObject("ThirdEyeHandle"); val4.SetActive(false); val4.layer = 15; val4.transform.SetParent(parent, false); val4.transform.localPosition = centre; val4.transform.localRotation = Quaternion.LookRotation(across, axis); val4.transform.localScale = Vector3.one; CapsuleCollider val5 = val4.AddComponent<CapsuleCollider>(); ((Collider)val5).isTrigger = true; val5.direction = 1; val5.radius = Mathf.Max(radius + 0.02f, 0.035f); val5.height = halfLength * 2f + val5.radius * 2f; GameObject val6 = new GameObject("ThirdEyeHandleTarget"); val6.transform.SetParent(val4.transform, false); val6.transform.localRotation = Quaternion.LookRotation(Vector3.up, Vector3.forward); TargetGrip val7; if (sliding) { CylinderGrip obj = val4.AddComponent<CylinderGrip>(); obj.dynamicFriction = 0.7f; obj.staticFriction = 0.9f; obj.limit = halfLength; obj.hasCapA = true; obj.hasCapB = true; obj.ignoreFlipOnZ = false; obj.rotationalFrictionMult = 1f; obj.aspectRatio = 2f; obj.variableRadius = false; obj.RadiusCurve = new AnimationCurve(); val7 = (TargetGrip)(object)obj; } else { val7 = val4.AddComponent<TargetGrip>(); } ((Grip)val7).isThrowable = true; ((Grip)val7).ignoreGripTargetOnAttach = false; ((Grip)val7).handPose = val2; ((Grip)val7).primaryMovementAxis = Vector3.forward; ((Grip)val7).secondaryMovementAxis = Vector3.up; ((Grip)val7).gripOptions = (InteractionOptions)8; ((Grip)val7).priority = 3f; ((Grip)val7).minBreakForce = float.PositiveInfinity; ((Grip)val7).maxBreakForce = float.PositiveInfinity; ((Grip)val7).defaultGripDistance = float.PositiveInfinity; ((Grip)val7).radius = radius; ((Grip)val7).targetTransform = val6.transform; val7.rotationLimit = 180f; val7.rotationPriorityBuffer = 20f; val7.targetFlipOnPrimaryAxis = eitherWay; val7.targetFlipOnTertiaryAxis = false; AnimationCurve val8 = new AnimationCurve(); val8.AddKey(-180f, -30f); val8.AddKey(-50f, -30f); val8.AddKey(0f, 0f); val8.AddKey(50f, 30f); val8.AddKey(180f, 30f); ((Grip)val7).handleAmplifyCurve = val8; List<Collider> list = new List<Collider>(); if (solids != null) { foreach (Collider solid in solids) { if ((Object)(object)solid != (Object)null && !solid.isTrigger) { list.Add(solid); } } } Il2CppReferenceArray<Collider> val9 = new Il2CppReferenceArray<Collider>((long)list.Count); for (int i = 0; i < list.Count; i++) { ((Il2CppArrayBase<Collider>)(object)val9)[i] = list[i]; } ((Grip)val7).additionalGripColliders = val9; ((Grip)val7).gripColliders = new Il2CppReferenceArray<Collider>(0L); if (forcePull) { ForcePullGrip val10 = val4.GetComponent<ForcePullGrip>(); if ((Object)(object)val10 == (Object)null) { val10 = val4.AddComponent<ForcePullGrip>(); } val10._grip = (Grip)(object)val7; val10.maxSpeed = float.PositiveInfinity; } val4.SetActive(true); if ((Object)(object)((Grip)val7)._marrowEntity == (Object)null) { ((Grip)val7)._marrowEntity = ((Component)body).GetComponentInParent<MarrowEntity>(); } val.DecorateHostOnChildGrips(val4.transform); if (!made.TryGetValue(((Il2CppObjectBase)body).Pointer, out var value)) { value = (made[((Il2CppObjectBase)body).Pointer] = new List<Grip>()); } value.Add((Grip)(object)val7); return (Grip)(object)val7; } catch (Exception ex) { MelonLogger.Warning("Handles: a handle could not be made: " + ex); return null; } } public static void Clear(Rigidbody body) { if ((Object)(object)body == (Object)null || !made.TryGetValue(((Il2CppObjectBase)body).Pointer, out var value)) { return; } made.Remove(((Il2CppObjectBase)body).Pointer); InteractableHost componentInParent = ((Component)body).GetComponentInParent<InteractableHost>(); foreach (Grip item in value) { if ((Object)(object)item == (Object)null) { continue; } try { if (item.attachedHands != null && item.attachedHands.Count > 0) { item.ForceDetach(); } if ((Object)(object)componentInParent != (Object)null && componentInParent._grips != null) { componentInParent._grips.Remove(item); } } catch (Exception ex) { MelonLogger.Warning("Handles: a handle did not let go cleanly. " + ex.Message); } Object.Destroy((Object)(object)((Component)item).gameObject); } } public static void ForgetLevel() { made.Clear(); List<string> list = new List<string>(); foreach (KeyValuePair<string, HandPose> pose in poses) { if ((Object)(object)pose.Value == (Object)null) { list.Add(pose.Key); } } foreach (string item in list) { poses.Remove(item); } } } public static class InputBlock { public static bool Blocked; public static bool TurnBlocked; public static void Apply(Harmony harmony) { Patch(harmony, typeof(RemapRig), "ApplyMovement", "MovePrefix"); Patch(harmony, typeof(OpenControllerRig), "SnapRotate", "SkipPrefix"); Patch(harmony, typeof(OpenControllerRig), "SmoothRotate", "SkipPrefix"); Patch(harmony, typeof(OpenControllerRig), "ProcessSecondaryThumbstick", "AxisPrefix"); } private static void Patch(Harmony harmony, Type type, string method, string prefix) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown try { harmony.Patch((MethodBase)AccessTools.Method(type, method, (Type[])null, (Type[])null), new HarmonyMethod(typeof(InputBlock), prefix, (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } catch (Exception ex) { MelonLogger.Warning("Stick blocking unavailable for " + method + ": " + ex.Message); } } private static void MovePrefix(ref Vector2 axis, ref bool inputPressed) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (Blocked) { axis = Vector2.zero; inputPressed = false; } } private static void AxisPrefix(ref Vector2 axis) { //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) if (Blocked || TurnBlocked) { axis = Vector2.zero; } } private static bool SkipPrefix() { if (!Blocked) { return !TurnBlocked; } return false; } } public static class Materials { private static readonly Dictionary<string, Shader> shaders = new Dictionary<string, Shader>(); public static Material Unlit(Texture texture, int queue) { if (shaders.Count == 0) { foreach (Shader item in Resources.FindObjectsOfTypeAll<Shader>()) { if ((Object)(object)item != (Object)null && !shaders.ContainsKey(((Object)item).name)) { shaders[((Object)item).name] = item; } } } string[] array = new string[4] { "Legacy Shaders/Particles/Alpha Blended", "Sprites/Default", "Universal Render Pipeline/Particles/Unlit", "Universal Render Pipeline/Unlit" }; foreach (string text in array) { if (!shaders.TryGetValue(text, out var value)) { value = Shader.Find(text); } if (!((Object)(object)value == (Object)null)) { Material obj = Transparent(value, texture); obj.renderQueue = queue; return obj; } } return null; } public static Material Transparent(Shader shader, Texture texture) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); string[] array = new string[2] { "_BaseMap", "_MainTex" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, texture); } } array = new string[2] { "_BaseColor", "_Color" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetColor(text2, Color.white); } } if (((Object)shader).name.StartsWith("Universal Render Pipeline", StringComparison.Ordinal)) { if (val.HasProperty("_Surface")) { val.SetFloat("_Surface", 1f); } if (val.HasProperty("_Blend")) { val.SetFloat("_Blend", 0f); } if (val.HasProperty("_SrcBlend")) { val.SetFloat("_SrcBlend", 5f); } if (val.HasProperty("_DstBlend")) { val.SetFloat("_DstBlend", 10f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 0f); } val.EnableKeyword("_SURFACE_TYPE_TRANSPARENT"); val.EnableKeyword("_ALPHABLEND_ON"); val.SetOverrideTag("RenderType", "Transparent"); val.renderQueue = 3000; } return val; } } public static class CrossMod { private const string PanelLayerKey = "_RudyHillCamcorderPanelLayer"; public static int CamcorderPanelLayer { get { return Mathf.RoundToInt(Shader.GetGlobalFloat("_RudyHillCamcorderPanelLayer")) - 1; } set { Shader.SetGlobalFloat("_RudyHillCamcorderPanelLayer", (float)(value + 1)); } } } public class PropShell { public readonly Rigidbody body; public readonly Transform parts; public readonly Material template; public readonly int layer; private readonly Vector3 originalScale; private readonly float originalMass; private readonly List<Renderer> hiddenRenderers = new List<Renderer>(); private readonly List<SphereCollider> shrunkColliders = new List<SphereCollider>(); private readonly List<float> shrunkRadii = new List<float>(); private readonly List<Collider> disabledColliders = new List<Collider>(); private bool gripped; public readonly bool real; public static bool OwnBodies; public bool SurfaceGrips = true; private readonly List<Collider> hiddenReach = new List<Collider>(); private static Material levelTemplate; private static Texture2D matteMap; public static bool IsReal(GameObject prop) { if ((Object)(object)prop != (Object)null) { return (Object)(object)prop.transform.Find("RudyPreview") != (Object)null; } return false; } public static void TakeOwnBody(ref GameObject prop, ref Rigidbody body) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //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) if (OwnBodies && !((Object)(object)prop == (Object)null) && !((Object)(object)body == (Object)null)) { Poolee val = prop.GetComponent<Poolee>(); if ((Object)(object)val == (Object)null) { val = ((Component)body).GetComponentInParent<Poolee>(); } if (!((Object)(object)val == (Object)null)) { GameObject val2 = new GameObject("ThirdEyeItem"); val2.layer = 1024; val2.transform.SetPositionAndRotation(body.position, body.rotation); val2.AddComponent<SphereCollider>().radius = 0.02f; Rigidbody val3 = val2.AddComponent<Rigidbody>(); val3.mass = 1f; val3.angularDrag = 0.5f; Spawnables.Forget(body); val.Despawn(); prop = val2; body = val3; } } } public static GameObject Owner(Rigidbody body) { if ((Object)(object)body == (Object)null) { return null; } Poolee componentInParent = ((Component)body).GetComponentInParent<Poolee>(); if (!((Object)(object)componentInParent != (Object)null)) { return ((Component)body).gameObject; } return ((Component)componentInParent).gameObject; } public static void Discard(GameObject owner) { if ((Object)(object)owner == (Object)null) { return; } Poolee component = owner.GetComponent<Poolee>(); if ((Object)(object)component != (Object)null) { if (owner.activeInHierarchy) { component.Despawn(); } } else { Object.Destroy((Object)(object)owner); } } public PropShell(GameObject prop, Rigidbody body, float scale, float mass, string name) { //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Expected O, but got Unknown //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Expected O, but got Unknown //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) this.body = body; Transform transform = ((Component)body).transform; real = IsReal(prop); if (real) { foreach (Renderer componentsInChild in ((Component)prop.transform.Find("RudyPreview")).GetComponentsInChildren<Renderer>()) { if (!((Object)(object)componentsInChild == (Object)null)) { if ((Object)(object)template == (Object)null && (Object)(object)componentsInChild.sharedMaterial != (Object)null) { template = componentsInChild.sharedMaterial; } if (componentsInChild.enabled) { componentsInChild.enabled = false; hiddenRenderers.Add(componentsInChild); } } } Transform val = prop.transform.Find("RudyCore"); layer = (((Object)(object)val != (Object)null) ? ((Component)val).gameObject.layer : ((Component)body).gameObject.layer); if ((Object)(object)val != (Object)null) { foreach (Collider component in ((Component)val).GetComponents<Collider>()) { if ((Object)(object)component != (Object)null && component.enabled) { component.enabled = false; disabledColliders.Add(component); } } } if ((Object)(object)template == (Object)null) { template = LevelTemplate(); } if ((Object)(object)template != (Object)null) { template = new Material(template); MakeSolid(template); } originalScale = transform.localScale; originalMass = body.mass; body.mass = mass; GameObject val2 = new GameObject(name); val2.layer = layer; val2.transform.SetParent(transform, false); parts = val2.transform; return; } foreach (Renderer componentsInChild2 in prop.GetComponentsInChildren<Renderer>()) { if (!((Object)(object)componentsInChild2 == (Object)null) && componentsInChild2.enabled) { if ((Object)(object)template == (Object)null) { template = componentsInChild2.sharedMaterial; } componentsInChild2.enabled = false; hiddenRenderers.Add(componentsInChild2); } } if ((Object)(object)template == (Object)null) { template = LevelTemplate(); } layer = ((Component)body).gameObject.layer; Collider componentInChildren = prop.GetComponentInChildren<Collider>(); if ((Object)(object)componentInChildren != (Object)null) { layer = ((Component)componentInChildren).gameObject.layer; } foreach (Collider componentsInChild3 in prop.GetComponentsInChildren<Collider>()) { if (!((Object)(object)componentsInChild3 == (Object)null) && !componentsInChild3.isTrigger && componentsInChild3.enabled) { SphereCollider val3 = ((Il2CppObjectBase)componentsInChild3).TryCast<SphereCollider>(); if ((Object)(object)val3 != (Object)null) { shrunkColliders.Add(val3); shrunkRadii.Add(val3.radius); val3.radius = 0.005f; } else { componentsInChild3.enabled = false; disabledColliders.Add(componentsInChild3); } } } originalScale = transform.localScale; originalMass = body.mass; transform.localScale = originalScale * scale; body.mass = mass; GameObject val4 = new GameObject(name); val4.layer = layer; val4.transform.SetParent(transform, false); float x = transform.lossyScale.x; val4.transform.localScale = Vector3.one / ((x > 0.0001f) ? x : 1f); parts = val4.transform; } public void RecalculateMass() { body.ResetCenterOfMass(); body.ResetInertiaTensor(); if (SurfaceGrips) { GameGrips.Add(body, parts); gripped = true; } } public void HideBallGrip() { GameObject val = Owner(body); if ((Object)(object)val == (Object)null) { return; } foreach (Grip componentsInChild in val.GetComponentsInChildren<Grip>(true)) { if ((Object)(object)componentsInChild == (Object)null || ((Object)((Component)componentsInChild).gameObject).name.StartsWith("ThirdEye", StringComparison.Ordinal)) { continue; } foreach (Collider component in ((Component)componentsInChild).GetComponents<Collider>()) { if ((Object)(object)component != (Object)null && component.isTrigger && component.enabled) { component.enabled = false; hiddenReach.Add(component); } } } } public void LetGo() { try { InteractableHost val = (((Object)(object)body != (Object)null) ? ((Component)body).GetComponentInParent<InteractableHost>() : null); if ((Object)(object)val == (Object)null) { return; } foreach (Grip componentsInChild in ((Component)val).GetComponentsInChildren<Grip>(true)) { if ((Object)(object)componentsInChild != (Object)null && componentsInChild.attachedHands != null && componentsInChild.attachedHands.Count > 0) { componentsInChild.ForceDetach(); } } } catch (Exception ex) { MelonLogger.Warning("An item could not be let go of: " + ex.Message); } } public void Restore() { //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (gripped) { GameGrips.Clear(body); } gripped = false; Handles.Clear(body); Spawnables.Forget(body); if ((Object)(object)parts != (Object)null) { Object.Destroy((Object)(object)((Component)parts).gameObject); } for (int i = 0; i < shrunkColliders.Count; i++) { if ((Object)(object)shrunkColliders[i] != (Object)null) { shrunkColliders[i].radius = shrunkRadii[i]; } } foreach (Collider disabledCollider in disabledColliders) { if ((Object)(object)disabledCollider != (Object)null) { disabledCollider.enabled = true; } } foreach (Collider item in hiddenReach) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } hiddenReach.Clear(); foreach (Renderer hiddenRenderer in hiddenRenderers) { if ((Object)(object)hiddenRenderer != (Object)null) { hiddenRenderer.enabled = true; } } if ((Object)(object)body != (Object)null) { ((Component)body).transform.localScale = originalScale; body.mass = originalMass; body.ResetCenterOfMass(); body.ResetInertiaTensor(); } } public static Material LevelTemplate() { //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown if ((Object)(object)levelTemplate != (Object)null) { return levelTemplate; } Material val = null; Material val2 = null; foreach (MeshRenderer item in Object.FindObjectsOfType<MeshRenderer>()) { Material val3 = (((Object)(object)item != (Object)null) ? ((Renderer)item).sharedMaterial : null); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val3.shader == (Object)null) && !(((Object)(object)((Component)item).transform.root != (Object)null) ? ((Object)((Component)item).transform.root).name : "").StartsWith("ThirdEye", StringComparison.Ordinal) && Solid(val3)) { string name = ((Object)val3.shader).name; if (name == "SLZ/LitMAS/LitMAS Standard") { val2 = val3; break; } string text = name.ToLowerInvariant(); if ((Object)(object)val == (Object)null && text.Contains("lit") && !text.Contains("unlit") && val3.HasProperty("_BaseMap")) { val = val3; } } } Material val4 = (((Object)(object)val2 != (Object)null) ? val2 : val); if ((Object)(object)val4 == (Object)null) { foreach (Shader item2 in Resources.FindObjectsOfTypeAll<Shader>()) { if ((Object)(object)item2 != (Object)null && ((Object)item2).name == "SLZ/LitMAS/LitMAS Standard") { val4 = new Material(item2); break; } } } if ((Object)(object)val4 == (Object)null) { return null; } levelTemplate = new Material(val4); MakeSolid(levelTemplate); return levelTemplate; } public static void ForgetLevel() { levelTemplate = null; } private static bool Solid(Material material) { if (material.renderQueue >= 2450) { return false; } if (material.HasProperty("_Surface") && material.GetFloat("_Surface") > 0.5f) { return false; } if (material.HasProperty("_ZWrite") && material.GetFloat("_ZWrite") < 0.5f) { return false; } return true; } internal static void MakeSolid(Material material) { if (material.HasProperty("_Surface")) { material.SetFloat("_Surface", 0f); } if (material.HasProperty("_ZWrite")) { material.SetFloat("_ZWrite", 1f); } if (material.HasProperty("_BlendSrc")) { material.SetFloat("_BlendSrc", 1f); } if (material.HasProperty("_BlendDst")) { material.SetFloat("_BlendDst", 0f); } if (material.HasProperty("_SrcBlend")) { material.SetFloat("_SrcBlend", 1f); } if (material.HasProperty("_DstBlend")) { material.SetFloat("_DstBlend", 0f); } if (material.HasProperty("_AlphaClip")) { material.SetFloat("_AlphaClip", 0f); } material.DisableKeyword("_SURFACE_TYPE_TRANSPARENT"); material.DisableKeyword("_ALPHATEST_ON"); material.DisableKeyword("_ALPHABLEND_ON"); material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); material.SetOverrideTag("RenderType", "Opaque"); material.renderQueue = 2000; } public static Material MakeMaterial(Material template, Color color, Texture2D albedo = null) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)template == (Object)null) { return null; } Material val = new Material(template); string[] array = new string[2] { "_BaseMap", "_MainTex" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTexture(text, (Texture)(object)albedo); } } array = new string[3] { "_BumpMap", "_MetallicGlossMap", "_DetailMap" }; foreach (string text2 in array) { if (val.HasProperty(text2)) { val.SetTexture(text2, (Texture)null); } } SetColor(val, color); return val; } public static Material MakeMatte(Material template, Color color, Texture2D albedo = null) { //IL_0001: 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_0030: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) Material val = MakeMaterial(template, color, albedo); if ((Object)(object)val == (Object)null) { return null; } if ((Object)(object)matteMap == (Object)null) { matteMap = new Texture2D(2, 2, (TextureFormat)4, false, true); ((Object)matteMap).hideFlags = (HideFlags)32; for (int i = 0; i < 4; i++) { matteMap.SetPixel(i % 2, i / 2, new Color(0f, 1f, 0.12f, 1f)); } matteMap.Apply(); } if (val.HasProperty("_MetallicGlossMap")) { val.SetTexture("_MetallicGlossMap", (Texture)(object)matteMap); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", 0f); } if (val.HasProperty("_Smoothness")) { val.SetFloat("_Smoothness", 0.12f); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.12f); } return val; } public static void SetColor(Material material, Color color) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)material == (Object)null) { return; } string[] array = new string[2] { "_BaseColor", "_Color" }; foreach (string text in array) { if (material.HasProperty(text)) { material.SetColor(text, color); } } } public static GameObject MakeBox(Transform parent, Vector3 center, Quaternion rotation, Vector3 size, Material material, int layer, bool visible) { //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_0044: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = "ThirdEyeCollider"; obj.layer = layer; obj.transform.SetParent(parent, false); obj.transform.localPosition = center; obj.transform.localRotation = rotation; obj.transform.localScale = size; Renderer component = obj.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.enabled = visible; if ((Object)(object)material != (Object)null) { component.sharedMaterial = material; } } return obj; } public static GameObject MakeCapsule(Transform parent, Vector3 center, Quaternion rotation, float radius, float height, int direction, int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown GameObject val = new GameObject("ThirdEyeCollider") { layer = layer }; val.transform.SetParent(parent, false); val.transform.localPosition = center; val.transform.localRotation = rotation; CapsuleCollider obj = val.AddComponent<CapsuleCollider>(); obj.radius = radius; obj.height = height; obj.direction = direction; return val; } public static GameObject MakeVisual(PrimitiveType type, string name, Material material, int layer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(type); ((Object)obj).name = name; obj.layer = layer; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = obj.GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null && (Object)(object)material != (Object)null) { component2.sharedMaterial = material; } return obj; } public static GameObject MakeMesh(Transform parent, Vector3 localPosition, Mesh mesh, Material material, int layer) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown GameObject val = new GameObject("ThirdEyeModel") { layer = layer }; val.transform.SetParent(parent, false); val.transform.localPosition = localPosition; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); if ((Object)(object)material != (Object)null) { ((Renderer)val2).sharedMaterial = material; } return val; } public static void PlaceLine(Transform line, Vector3 from, Vector3 to, float width) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; float magnitude = ((Vector3)(ref val)).magnitude; line.position = (from + to) * 0.5f; if (magnitude > 0.0001f) { line.rotation = Quaternion.LookRotation(val / magnitude); } line.localScale = new Vector3(width, width, Mathf.Max(magnitude, 0.0001f)); } } public static class ScriptBus { private const string Key = "RudyHill.ScriptBus.v1"; private static Dictionary<int, object[]> Shared { get { if (AppDomain.CurrentDomain.GetData("RudyHill.ScriptBus.v1") is Dictionary<int, object[]> result) { return result; } Dictionary<int, object[]> dictionary = new Dictionary<int, object[]>(); AppDomain.CurrentDomain.SetData("RudyHill.ScriptBus.v1", dictionary); return dictionary; } } public static void Offer(Rigidbody body, string[] names, bool[] writable, Func<int, float> get, Action<int, float> set) { if (!((Object)(object)body == (Object)null) && names != null && names.Length != 0) { Shared[((Object)body).GetInstanceID()] = new object[5] { body, names, writable, get, set }; } } public static void Withdraw(Rigidbody body) { if ((Object)(object)body != (Object)null) { Shared.Remove(((Object)body).GetInstanceID()); } } public static bool Find(Rigidbody body, out string[] names, out bool[] writable, out Func<int, float> get, out Action<int, float> set) { names = null; writable = null; get = null; set = null; if ((Object)(object)body == (Object)null || !Shared.TryGetValue(((Object)body).GetInstanceID(), out var value) || value.Length < 5) { return false; } object obj = value[0]; Rigidbody val = (Rigidbody)((obj is Rigidbody) ? obj : null); if (val == null || (Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)body) { return false; } names = value[1] as string[]; writable = value[2] as bool[]; get = value[3] as Func<int, float>; set = value[4] as Action<int, float>; if (names != null) { return get != null; } return false; } public static List<Rigidbody> Bodies() { List<Rigidbody> list = new List<Rigidbody>(); List<int> list2 = new List<int>(); foreach (KeyValuePair<int, object[]> item in Shared) { Rigidbody val = (Rigidbody)((item.Value.Length != 0) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val == (Object)null || !((Component)val).gameObject.activeInHierarchy) { list2.Add(item.Key); } else { list.Add(val); } } foreach (int item2 in list2) { Shared.Remove(item2); } return list; } } public static class Spawnables { private class Offer { public string title; public string description; public Action<GameObject, Rigidbody> build; public Action<string> registered; public Func<Mesh> preview; } private class PartRequest { public Action<GameObject, Rigidbody> build; public Func<bool> wanted; public Vector3 position; public float time; } private static readonly List<Offer> offers = new List<Offer>(); private static readonly Dictionary<string, Action<GameObject, Rigidbody>> builders = new Dictionary<string, Action<GameObject, Rigidbody>>(); private static readonly HashSet<int> seen = new HashSet<int>(); private static readonly List<(Poolee poolee, int frame)> waiting = new List<(Poolee, int)>(); private static readonly HashSet<int> claimedParts = new HashSet<int>(); private static readonly List<PartRequest> partRequests = new List<PartRequest>(); private static Pallet pallet; private static float nextLook; private const float LookEvery = 2f; private const float LookRadius = 30f; private static readonly HashSet<string> realItems = new HashSet<string>(); public static string PartBarcode { get; private set; } public static bool Ready { get; private set; } public static void Add(string title, string description, Action<GameObject, Rigidbody> build, Action<string> registered = null, Func<Mesh> preview = null) { offers.Add(new Offer { title = title, description = description, build = build, registered = registered, preview = preview }); } public static bool IsOurs(string barcode) { if (barcode != null) { return builders.ContainsKey(barcode); } return false; } public static bool IsReal(string barcode) { if (barcode != null) { return realItems.Contains(barcode); } return false; } public static string PalletBarcode(string title) { return "RudyHill." + Clean(AssetFiles.Root) + ".Spawnable." + Clean(title.Replace(".", "")); } private static string Clean(string id) { StringBuilder stringBuilder = new StringBuilder(); foreach (char c in id) { if (c < '\u0080' && (char.IsLetterOrDigit(c) || c == '.')) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } public static void Register() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown if (Ready) { return; } try { AssetWarehouse instance = AssetWarehouse.Instance; if (instance == null) { return; } SpawnableCrate val = default(SpawnableCrate); if (!instance.TryGetCrate<SpawnableCrate>(new Barcode("c1534c5a-837c-43ca-b4b5-33d842617365"), ref val) || (Object)(object)val == (Object)null) { MelonLogger.Warning(AssetFiles.Root + ": spawnables not registered (the game's baseball was not found)"); return; } List<SpawnableCrate> list = new List<SpawnableCrate>(); List<(Offer, SpawnableCrate)> list2 = new List<(Offer, SpawnableCrate)>(); List<(Offer, string)> list3 = new List<(Offer, string)>(); foreach (Offer offer2 in offers) { string text = PalletBarcode(offer2.title); if (instance.HasCrate(new Barcode(text))) { list3.Add((offer2, text)); continue; } if (pallet == null) { pallet = MakePallet(); } SpawnableCrate val2 = MakeCrate(val, offer2.title, offer2.description); list.Add(val2); list2.Add((offer2, val2)); } string text2 = PalletBarcode("Part"); if (instance.HasCrate(new Barcode(text2))) { PartBarcode = text2; realItems.Add(text2); } else { if (pallet == null) { pallet = MakePallet(); } SpawnableCrate val3 = MakeCrate(val, AssetFiles.Root + " Part", "Internal: the base of an extra piece."); ((Scannable)val3).Redacted = true; list.Add(val3); PartBarcode = ((Scannable)val3).Barcode.ID; } builders[PartBarcode] = BuildPart; if ((Object)(object)pallet != (Object)null) { instance.AddPallet(pallet); foreach (SpawnableCrate item3 in list) { if (!instance.HasCrate(((Scannable)item3).Barcode)) { instance.AddCrate((Crate)(object)item3); } } } foreach (var (offer, text3) in list3) { builders[text3] = offer.build; realItems.Add(text3); try { offer.registered?.Invoke(text3); } catch (Exception ex) { MelonLogger.Warning(AssetFiles.Root + ": " + offer.title + ": " + ex.Message); } } foreach (var item4 in list2) { Offer item = item4.Item1; SpawnableCrate item2 = item4.Item2; string iD = ((Scannable)item2).Barcode.ID; builders[iD] = item.build; try { item.registered?.Invoke(iD); Mesh val4 = item.preview?.Invoke(); if ((Object)(object)val4 != (Object)null) { SpawnPreview.Register(item2, val4); } else { SpawnPreview.RegisterKept(item2); } } catch (Exception ex2) { MelonLogger.Warning(AssetFiles.Root + ": " + item.title + ": " + ex2.Message); } } Ready = true; MelonLogger.Msg(AssetFiles.Root + ": " + offers.Count + " spawnables registered (" + list3.Count + " real ones from its pallet" + ((list2.Count > 0) ? (", " + list2.Count + " built on the baseball: is its pallet installed?") : "") + ")"); } catch (Exception ex3) { MelonLogger.Error(AssetFiles.Root + ": spawnables not registered: " + ex3); } } private static Pallet MakePallet() { Pallet obj = Pallet.CreatePallet(AssetFiles.Root, "RUDYHILL", true); ((Object)obj).hideFlags = (HideFlags)32; return obj; } private static SpawnableCrate MakeCrate(SpawnableCrate baseball, string title, string description) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) SpawnableCrate val = Crate.CreateCrateT<SpawnableCrate>(pallet, title, ((Crate)baseball).MainAsset, true); ((Object)val).hideFlags = (HideFlags)32; ((Scannable)val).Description = description; ((GameObjectCrate)val).MainGameObject = ((GameObjectCrate)baseball).MainGameObject; ((GameObjectCrate)val).PreviewMesh = ((GameObjectCrate)baseball).PreviewMesh; ((GameObjectCrate)val).ColliderBounds = ((GameObjectCrate)baseball).ColliderBounds; ((Crate)val).Tags = ((Crate)baseball).Tags; ((Crate)val).BoneTags = ((Crate)baseball).BoneTags; ((Scannable)val).Unlockable = false; ((Scannable)val).Redacted = false; if (!pallet.Crates.Contains((Crate)(object)val)) { pallet.Crates.Add((Crate)(object)val); } return val; } public static void Spawn(string barcode, Vector3 position, Quaternion rotation) { //IL_0004: 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_0006: Unknown result type (might be due to invalid IL or missing references) if (barcode != null) { HelperMethods.SpawnCrate(barcode, position, rotation, Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null); } } public static void Queue(Poolee poolee) { if ((Object)(object)poolee != (Object)null) { waiting.Add((poolee, Time.frameCount)); } } public static void Forget(Rigidbody body) { if ((Object)(object)body != (Object)null) { seen.Remove(((Object)body).GetInstanceID()); } } public static void Update() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if (!Ready) { return; } for (int num = waiting.Count - 1; num >= 0; num--) { (Poolee poolee, int frame) tuple = waiting[num]; var (val, _) = tuple; if (tuple.frame < Time.frameCount) { waiting.RemoveAt(num); if (!((Object)(object)val == (Object)null) && ((Component)val).gameObject.activeInHierarchy) { Rigidbody componentInChildren = ((Component)val).GetComponentInChildren<Rigidbody>(); if ((Object)(object)componentInChildren != (Object)null) { Consider(componentInChildren); } } } } if (Time.time < nextLook) { return; } nextLook = Time.time + 2f; Transform head = Player.Head; if ((Object)(object)head == (Object)null) { return; } foreach (Collider item in (Il2CppArrayBase<Collider>)(object)Physics.OverlapSphere(head.position, 30f)) { Rigidbody val2 = (((Object)(object)item != (Object)null) ? item.attachedRigidbody : null); if ((Object)(object)val2 != (Object)null) { Consider(val2); } } } private static void Consider(Rigidbody body) { if (!seen.Add(((Object)body).GetInstanceID())) { return; } Poolee componentInParent = ((Component)body).GetComponentInParent<Poolee>(); if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent.SpawnableCrate == (Object)null || ((Scannable)componentInParent.SpawnableCrate).Barcode == (Barcode)null) { return; } string iD = ((Scannable)componentInParent.SpawnableCrate).Barcode.ID; if (!builders.TryGetValue(iD, out var value)) { return; } GameObject prop = ((Component)componentInParent).gameObject; Rigidbody body2 = body; if (realItems.Contains(iD)) { Rigidbody component = prop.GetComponent<Rigidbody>(); try { value(prop, ((Object)(object)component != (Object)null) ? component : body); return; } catch (Exception ex) { MelonLogger.Error(AssetFiles.Root + ": adding to a spawned " + ((Scannable)componentInParent.SpawnableCrate).Title + " failed: " + ex); return; } } try { PropShell.TakeOwnBody(ref prop, ref body2); value(prop, body2); SpawnPreview.Built(iD, prop); } catch (Exception ex2) { MelonLogger.Error(AssetFiles.Root + ": building a spawned " + ((Scannable)componentInParent.SpawnableCrate).Title + " failed: " + ex2); } } public static bool RequestPart(Vector3 position, Action<GameObject, Rigidbody> build, Func<bool> wanted) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (PartBarcode == null) { return false; } partRequests.Add(new PartRequest { build = build, wanted = wanted, position = position, time = Time.time }); HelperMethods.SpawnCrate(PartBarcode, position, Quaternion.identity, Vector3.one, false, (Action<GameObject>)null, (Action<GameObject>)null); return true; } public static void ReleasePart(Rigidbody body) { if (!((Object)(object)body == (Object)null)) { claimedParts.Remove(((Object)body).GetInstanceID()); Forget(body); PropShell.Discard(PropShell.Owner(body)); } } private static void BuildPart(GameObject prop, Rigidbody body) { //IL_005b: 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_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) if (claimedParts.Contains(((Object)body).GetInstanceID())) { return; } partRequests.RemoveAll((PartRequest request) => Time.time - request.time > 10f || !request.wanted()); PartRequest partRequest = null; float num = 3f; foreach (PartRequest partRequest2 in partRequests) { Vector3 val = partRequest2.position - body.position; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < num) { num = magnitude; partRequest = partRequest2; } } if (partRequest == null) { Forget(body); PropShell.Discard(PropShell.Owner(body)); return; } partRequests.Remove(partRequest); claimedParts.Add(((Object)body).GetInstanceID()); try { partRequest.build(prop, body); } catch (Exception ex) { MelonLogger.Error(AssetFiles.Root + ": building on a part prop failed: " + ex); } } public static void Notify(string message) { //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_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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown MelonLogger.Msg(message); Notifier.Send(new Notification { Title = NotificationText.op_Implicit(AssetFiles.Root), Message = NotificationText.op_Implicit(message), Type = (NotificationType)0, PopupLength = 1.5f, ShowTitleOnPopup = true }); } public static void Clear() { seen.Clear(); waiting.Clear(); partRequests.Clear(); claimedParts.Clear(); } } public static class SpawnGuard { public static void Apply(Harmony harmony) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown int num = 0; string[] array = new string[2] { "OnSpawnEvent", "OnSpawn" }; foreach (string text in array) { try { MethodInfo methodInfo = AccessTools.DeclaredMethod(typeof(Poolee), text, Type.EmptyTypes, (Type[])null); if (!(methodInfo == null)) { harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(SpawnGuard), "Spawned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } } catch (Exception ex) { MelonLogger.Warning("Spawn guard: Poolee." + text + " could not be patched: " + ex.Message); } } if (num > 0) { MelonLogger.Msg("Spawn guard: the mod's spawnables are hidden as they appear"); } else { MelonLogger.Warning("Spawn guard: not in place; a baseball may show for a moment when one of the mod's things is spawned"); } } private static void Spawned(Poolee __instance) { try { if ((Object)(object)__instance == (Object)null) { return; } SpawnableCrate spawnableCrate = __instance.SpawnableCrate; if ((Object)(object)spawnableCrate == (Object)null || ((Scannable)spawnableCrate).Barcode == (Barcode)null || !Spawnables.IsOurs(((Scannable)spawnableCrate).Barcode.ID)) { return; } if (Spawnables.IsReal(((Scannable)spawnableCrate).Barcode.ID)) { Transform val = ((Component)__instance).transform.Find("RudyPreview"); if ((Object)(object)val != (Object)null) { foreach (Renderer componentsInChild in ((Component)val).GetComponentsInChildren<Renderer>(true)) { if ((Object)(object)componentsInChild != (Object)null) { componentsInChild.enabled = false; } } } } else { foreach (Renderer componentsInChild2 in ((Component)__instance).GetComponentsInChildren<Renderer>(true)) { if ((Object)(object)componentsInChild2 != (Object)null && !Ours(((Component)componentsInChild2).transform, ((Component)__instance).transform)) { componentsInChild2.forceRenderingOff = true; } } } foreach (Rigidbody componentsInChild3 in ((Component)__instance).GetComponentsInChildren<Rigidbody>(true)) { if ((Object)(object)componentsInChild3 != (Object)null && !Built(componentsInChild3)) { Spawnables.Forget(componentsInChild3); } } Spawnables.Queue(__instance); } catch (Exception ex) { MelonLogger.Warning("Spawn guard: " + ex.Message); } } private static bool Ours(Transform at, Transform root) { Transform val = at; while ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)root) { if (((Object)val).name.StartsWith("ThirdEye", StringComparison.Ordinal)) { return true; } val = val.parent; } return false; } private static bool Built(Rigidbody body) { Transform transform = ((Component)body).transform; for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); if ((Object)(object)child != (Object)null && ((Object)child).name.StartsWith("ThirdEye", StringComparison.Ordinal)) { return true; } } return false; } } } namespace ThirdEyeBonelabMod.Zombies { public class ZombieSequence { public string name; public float fps; public int frames; public bool loop; public float speed; public float[] eventCycles; public string[] eventNames; public Vector3[] positions; public Quaternion[] rotations; public float Duration => (float)Mathf.Max(frames - 1, 1) / fps; } public class NpcAttachment { public string name; public string slot; public string bone; public Vector3 position; public Quaternion rotation; public float scale; public Mesh mesh; public Texture2D texture; public Material material; } public class NpcModel { public string[] boneNames; public int[] boneParents; public Vector3[] bindPositions; public Quaternion[] bindRotations; public Mesh mesh; public readonly Dictionary<string, ZombieSequence> sequences = new Dictionary<string, ZombieSequence>(); public readonly List<NpcAttachment> attachments = new List<NpcAttachment>(); private readonly string folderName; private readonly string fileName; private readonly Color tint; private readonly (string kind, string prefix, int count)[] soundSets; private string[] materialNames; private Texture2D[] textures; private Texture2D[] shineMaps; private Texture2D[] glowMaps; private Texture2D[] detailMaps; private Material[] materials; private readonly Dictionary<string, AudioClip[]> sounds = new Dictionary<string, AudioClip[]>(); private bool loaded; private bool failed; public string FolderName => folderName; public int BoneCount { get { if (boneNames == null) { return 0; } return boneNames.Length; } } public NpcModel(string folderName, string fileName, Color tint, params (string kind, string prefix, int count)[] soundSets) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) this.folderName = folderName; this.fileName = fileName; this.tint = tint; this.soundSets = soundSets; } public bool Load() { if (loaded) { return true; } if (failed) { return false; } try { string text = AssetFiles.Folder(folderName); ReadSkin(Path.Combine(text, fileName + ".skin")); ReadAnimations(Path.Combine(text, fileName + ".anim")); textures = (Texture2D[])(object)new Texture2D[materialNames.Length]; shineMaps = (Texture2D[])(object)new Texture2D[materialNames.Length]; glowMaps = (Texture2D[])(object)new Texture2D[materialNames.Length]; detailMaps = (Texture2D[])(object)new Texture2D[materialNames.Length]; bool flag = false; for (int i = 0; i < materialNames.Length; i++) { textures[i] = AssetFiles.ReadTexture(Path.Combine(text, materialNames[i] + ".png")); shineMaps[i] = AssetFiles.ReadTexture(Path.Combine(text, materialNames[i] + "_mas.png"), data: true); glowMaps[i] = AssetFiles.ReadTexture(Path.Combine(text, materialNames[i] + "_e.png")); detailMaps[i] = AssetFiles.ReadTexture(Path.Combine(text, materialNames[i] + "_n.png"), data: true); flag |= (Object)(object)detailMaps[i] != (Object)null; } if (flag) { mesh.RecalculateTangents(); } (string, string, int)[] array = soundSets; for (int j = 0; j < array.Length; j++) { (string, string, int) tuple = array[j]; LoadSounds(text, tuple.Item1, tuple.Item2, tuple.Item3); } ReadAttachments(text); loaded = true; MelonLogger.Msg("Character loaded (" + folderName + "): " + BoneCount + " bones, " + sequences.Count + " animations"); return true; } catch (Exception ex) { failed = true; MelonLogger.Error("Character files could not be read (" + folderName + "): " + ex); return false; } } public void ForgetMaterials() { materials = null; foreach (NpcAttachment attachment in attachments) { attachment.material = null; } } public Material MaterialFor(NpcAttachment attachment) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)attachment.material == (Object)null) { attachment.material = PropShell.MakeMatte(PropShell.LevelTemplate(), Color.white, attachment.texture); } return attachment.material; } private void ReadAttachments(string folder) { //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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) string path = Path.Combine(folder, "attachments.txt"); if (!AssetFiles.Exists(path)) { return; } CultureInfo invariantCulture = CultureInfo.InvariantCulture; string[] array = AssetFiles.ReadAllLines(path); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('|'); if (array2.Length < 7) { continue; } try { Mesh val = AssetFiles.ReadMesh(Path.Combine(folder, array2[0] + ".mesh"), "ThirdEye_" + array2[0]); if (!((Object)(object)val == (Object)null)) { string[] array3 = array2[3].Split(','); string[] array4 = array2[4].Split(','); attachments.Add(new NpcAttachment { name = array2[0], slot = array2[1], bone = array2[2], position = new Vector3(float.Parse(array3[0], invariantCulture), float.Parse(array3[1], invariantCulture), float.Parse(array3[2], invariantCulture)), rotation = new Quaternion(float.Parse(array4[0], invariantCulture), float.Parse(array4[1], invariantCulture), float.Parse(array4[2], invariantCulture), float.Parse(array4[3], invariantCulture)), scale = float.Parse(array2[5], invariantCulture), mesh = val, texture = ((array2[6].Length > 0) ? AssetFiles.ReadTexture(Path.Combine(folder, array2[6])) : null) }); } } catch (Exception ex) { MelonLogger.Warning("Could not read attachment '" + array2[0] + "': " + ex.Message); } } } public Material[] Materials() { //IL_004a: 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) if (materials != null && materials.Length != 0 && (Object)(object)materials[0] != (Object)null) { return materials; } Material template = PropShell.LevelTemplate(); materials = (Material[])(object)new Material[materialNames.Length]; for (int i = 0; i < materials.Length; i++) { Material val = PropShell.MakeMatte(template, tint, textures[i]); materials[i] = val; if ((Object)(object)val == (Object)null) { continue; } if ((Object)(object)shineMaps[i] != (Object)null && val.HasProperty("_MetallicGlossMap")) { val.SetTexture("_MetallicGlossMap", (Texture)(object)shineMaps[i]); } if ((Object)(object)detailMaps[i] != (Object)null && val.HasProperty("_BumpMap")) { val.SetTexture("_BumpMap", (Texture)(object)detailMaps[i]); } if ((Object)(object)glowMaps[i] != (Object)null && val.HasProperty("_EmissionMap")) { val.SetTexture("_EmissionMap", (Texture)(object)glowMaps[i]); if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.white); } if (val.HasProperty("_Emission")) { val.SetFloat("_Emission", 1f); } val.EnableKeyword("_EMISSION"); } } return materials; } public AudioClip Sound(string kind) { if (!sounds.TryGetValue(kind, out var value) || value.Length == 0) { return null; } return value[Random.Range(0, value.Length)]; } private void LoadSounds(string folder, string kind, string prefix, int count) { List<AudioClip> list = new List<AudioClip>(); for (int i = 1; i <= count; i++) { AudioClip val = AssetFiles.ReadWav(Path.Combine(folder, prefix + i + ".wav"), prefix + i); if ((Object)(object)val != (Object)null) { list.Add(val); } } sounds[kind] = list.ToArray(); } private static string ReadName(BinaryReader reader) { int count = reader.ReadByte(); return Encoding.ASCII.GetString(reader.ReadBytes(count)); } private void ReadSkin(string path) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: 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_01e3: Expected O, but got Unknown //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(AssetFiles.OpenRead(path)); int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); int num3 = binaryReader.ReadInt32(); boneNames = new string[num]; boneParents = new int[num]; bindPositions = (Vector3[])(object)new Vector3[num]; bindRotations = (Quaternion[])(object)new Quaternion[num]; for (int i = 0; i < num; i++) { boneNames[i] = ReadName(binaryReader); boneParents[i] = binaryReader.ReadInt32(); bindPositions[i] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); bindRotations[i] = new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } Vector3[] array = (Vector3[])(object)new Vector3[num2]; Vector3[] array2 = (Vector3[])(object)new Vector3[num2]; Vector2[] array3 = (Vector2[])(object)new Vector2[num2]; BoneWeight[] array4 = (BoneWeight[])(object)new BoneWeight[num2]; for (int j = 0; j < num2; j++) { array[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); array3[j] = new Vector2(binaryReader.ReadSingle(), binaryReader.ReadSingle()); BoneWeight val = default(BoneWeight); ((BoneWeight)(ref val)).boneIndex0 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).boneIndex1 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).boneIndex2 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).boneIndex3 = binaryReader.ReadInt32(); ((BoneWeight)(ref val)).weight0 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight1 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight2 = binaryReader.ReadSingle(); ((BoneWeight)(ref val)).weight3 = binaryReader.ReadSingle(); array4[j] = val; } mesh = new Mesh(); ((Object)mesh).name = "ThirdEyeCharacter_" + folderName; ((Object)mesh).hideFlags = (HideFlags)32; mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(array); mesh.normals = Il2CppStructArray<Vector3>.op_Implicit(array2); mesh.uv = Il2CppStructArray<Vector2>.op_Implicit(array3); mesh.subMeshCount = num3; materialNames = new string[num3]; for (int k = 0; k < num3; k++) { materialNames[k] = ReadName(binaryReader); int num4 = binaryReader.ReadInt32(); int[] array5 = new int[num4]; for (int l = 0; l < num4; l++) { array5[l] = binaryReader.ReadInt32(); } mesh.SetTriangles(Il2CppStructArray<int>.op_Implicit(array5), k); } mesh.boneWeights = Il2CppStructArray<BoneWeight>.op_Implicit(array4); Matrix4x4[] array6 = (Matrix4x4[])(object)new Matrix4x4[num]; Matrix4x4[] array7 = (Matrix4x4[])(object)new Matrix4x4[num]; for (int m = 0; m < num; m++) { Matrix4x4 val2 = Matrix4x4.TRS(bindPositions[m], bindRotations[m], Vector3.one); array6[m] = ((boneParents[m] >= 0) ? (array6[boneParents[m]] * val2) : val2); array7[m] = ((Matrix4x4)(ref array6[m])).inverse; } mesh.bindposes = Il2CppStructArray<Matrix4x4>.op_Implicit(array7); mesh.RecalculateBounds(); } private void ReadAnimations(string path) { //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) using BinaryReader binaryReader = new BinaryReader(AssetFiles.OpenRead(path)); int num = binaryReader.ReadInt32(); int num2 = binaryReader.ReadInt32(); if (num != BoneCount) { throw new InvalidDataException("animations are for a different skeleton"); } for (int i = 0; i < num2; i++) { ZombieSequence zombieSequence = new ZombieSequence(); zombieSequence.name = ReadName(binaryReader); zombieSequence.fps = binaryReader.ReadSingle(); zombieSequence.frames = binaryReader.ReadInt32(); zombieSequence.loop = binaryReader.ReadInt32() != 0; zombieSequence.speed = binaryReader.ReadSingle(); int num3 = binaryReader.ReadInt32(); zombieSequence.eventCycles = new float[num3]; zombieSequence.eventNames = new string[num3]; for (int j = 0; j < num3; j++) { zombieSequence.eventCycles[j] = binaryReader.ReadSingle(); zombieSequence.eventNames[j] = ReadName(binaryReader); } int num4 = zombieSequence.frames * num; zombieSequence.positions = (Vector3[])(object)new Vector3[num4]; zombieSequence.rotations = (Quaternion[])(object)new Quaternion[num4]; for (int k = 0; k < num4; k++) { zombieSequence.positions[k] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); zombieSequence.rotations[k] = new Quaternion(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()); } sequences[zombieSequence.name] = zombieSequence; } } } } namespace