Decompiled source of PocketDimension v1.0.0
Mods/PocketDimension.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.Json; using System.Text.RegularExpressions; using System.Threading; using BoneLib; using BoneLib.BoneMenu; using HarmonyLib; using Il2CppCysharp.Threading.Tasks; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.Utilities; using Il2CppSLZ.Marrow.Warehouse; using Il2CppSLZ.VRMK; using Il2CppSteamworks; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using PocketDimension; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.Universal; using UnityEngine.UI; using UnityEngine.XR; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(PocketMod), "PocketDimension", "1.0.0", "MarrowByte", null)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PocketDimension { internal sealed class Backpack : IDisposable { private readonly Storage storage; private readonly Material bodyMaterial; private readonly Material portalMaterial; private readonly Material skyMaterial; private readonly Material crossingMaterial; private readonly int generation; private readonly Func<int> currentGeneration; private readonly Action<string> report; private readonly List<BoxGrip> grips = new List<BoxGrip>(); private InteractableHost? host; private GameObject? root; private PocketRoom? room; private InventoryControls? inventory; private BoxCollider? cover; private readonly ZipState zip = new ZipState(); private readonly Il2CppReferenceArray<Collider> coverHits = new Il2CppReferenceArray<Collider>(32L); private bool disposed; public bool Exists { get { if (Object.op_Implicit((Object)(object)root) && root.activeInHierarchy) { return !disposed; } return false; } } internal bool IsInside => room?.IsInside ?? false; internal bool CanRecall => room?.CanRecall ?? false; internal RoomSnapshot? Snapshot(ulong owner, byte slot, string epoch, uint sequence) { //IL_0019: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!Exists || room == null) { return null; } room.Rebase(PocketNetwork.Origin(slot)); Vector3 val = room.Origin - PocketNetwork.Origin(slot); if (((Vector3)(ref val)).sqrMagnitude > 0.01f) { return null; } return room.Snapshot(owner, slot, epoch, sequence, zip.Amount); } internal Backpack(Storage storage, Material bodyMaterial, Material portalMaterial, Material skyMaterial, Material crossingMaterial, int generation, Func<int> currentGeneration, Action<string> report) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown this.storage = storage; this.bodyMaterial = new Material(bodyMaterial); this.bodyMaterial.SetFloat("_ZipOpen", 0f); this.portalMaterial = portalMaterial; this.skyMaterial = skyMaterial; this.crossingMaterial = crossingMaterial; this.generation = generation; this.currentGeneration = currentGeneration; this.report = report; } internal void Create(Vector3 position, Quaternion rotation) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Expected O, but got Unknown //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, HandPose> dictionary = new Dictionary<string, HandPose>(); foreach (HandPose item in Resources.FindObjectsOfTypeAll<HandPose>()) { if (Object.op_Implicit((Object)(object)item) && ((Object)item).name.StartsWith("Box", StringComparison.Ordinal)) { dictionary[((Object)item).name] = item; } } string[] array = new string[4] { "BoxSandwichGrip", "BoxEdgeGrip", "BoxCornerGrip", "BoxFaceGrip" }; foreach (string key in array) { if (!dictionary.ContainsKey(key)) { throw new InvalidOperationException("Box hand poses are not loaded. Spawn the backpack after the level finishes loading."); } } int num = LayerMask.NameToLayer("Interactable"); if (num < 0) { throw new InvalidOperationException("Interactable layer is missing."); } root = new GameObject("PocketDimension"); root.SetActive(false); root.layer = num; root.transform.SetPositionAndRotation(position, rotation); Rigidbody val = root.AddComponent<Rigidbody>(); val.mass = 2f; val.interpolation = (RigidbodyInterpolation)1; val.collisionDetectionMode = (CollisionDetectionMode)2; val.solverIterations = 12; val.solverVelocityIterations = 4; MarrowEntity val2 = root.AddComponent<MarrowEntity>(); MarrowBody val3 = root.AddComponent<MarrowBody>(); val2._tags = new TagList(); val3._tags = new TagList(); host = root.AddComponent<InteractableHost>(); ((MarrowBehaviour)host).marrowEntity = val2; host._marrowBody = val3; GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)3); val4.SetActive(false); GameObject val5 = new GameObject("Bounds"); val5.transform.SetParent(root.transform, false); val5.AddComponent<MeshFilter>().sharedMesh = val4.GetComponent<MeshFilter>().sharedMesh; Object.Destroy((Object)(object)val4); MeshRenderer obj = val5.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = bodyMaterial; ((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)obj).allowOcclusionWhenDynamic = false; Box("Back", new Vector3(0f, 0f, -0.16f), new Vector3(0.4f, 0.59f, 0.03f)); Box("Bottom", new Vector3(0f, -0.29f, 0f), new Vector3(0.4f, 0.04f, 0.31f)); Box("Top", new Vector3(0f, 0.29f, 0f), new Vector3(0.4f, 0.04f, 0.31f)); Box("Left", new Vector3(-0.21f, 0f, 0f), new Vector3(0.04f, 0.55f, 0.31f)); Box("Right", new Vector3(0.21f, 0f, 0f), new Vector3(0.04f, 0.55f, 0.31f)); Box("Front lower", new Vector3(0f, -0.192f, 0.175f), new Vector3(0.38f, 0.195f, 0.06f)); Box("Front upper", new Vector3(0f, 0.242f, 0.16f), new Vector3(0.38f, 0.075f, 0.03f)); Box("Handle", new Vector3(0f, 0.378f, -0.018f), new Vector3(0.16f, 0.04f, 0.045f)); Box("Left pouch", new Vector3(-0.27f, -0.065f, 0f), new Vector3(0.13f, 0.29f, 0.2f)); Box("Right pouch", new Vector3(0.27f, -0.065f, 0f), new Vector3(0.13f, 0.29f, 0.2f)); cover = Box("Zipped cover", new Vector3(0f, 0.055f, 0.189f), new Vector3(0.32f, 0.27f, 0.024f)); foreach (BoxCollider componentsInChild in root.GetComponentsInChildren<BoxCollider>(true)) { if (Object.op_Implicit((Object)(object)componentsInChild) && ((Collider)componentsInChild).enabled && ((Object)componentsInChild).GetInstanceID() != ((Object)cover).GetInstanceID()) { AddGrip(componentsInChild, dictionary, val2); } } BoxCollider obj2 = Box("Opening", new Vector3(0f, 0.055f, 0.18f), new Vector3(0.27f, 0.22f, 0.065f)); ((Collider)obj2).isTrigger = true; ((Component)obj2).gameObject.AddComponent<OpeningTrigger>(); PreparePhysics(val2, val3, val); root.SetActive(true); host.EnableFarHover(); if (!Object.op_Implicit((Object)(object)host.Body) || !Object.op_Implicit((Object)(object)host.Rb) || host.Colliders == null || ((Il2CppArrayBase<Collider>)(object)host.Colliders).Length == 0) { throw new InvalidOperationException($"Backpack host after activation: body={Object.op_Implicit((Object)(object)host.Body)}, rigidbody={Object.op_Implicit((Object)(object)host.Rb)}, colliders={((Il2CppArrayBase<Collider>)(object)host.Colliders)?.Length ?? (-1)}."); } if (val3._colliderStates == null || ((Il2CppArrayBase<bool>)(object)val3._colliderStates).Length != ((Il2CppArrayBase<Collider>)(object)val3.Colliders).Length || val3._triggerStates == null || ((Il2CppArrayBase<bool>)(object)val3._triggerStates).Length != ((Il2CppArrayBase<Collider>)(object)val3.Triggers).Length) { throw new InvalidOperationException("Backpack collider state arrays were not initialized during activation."); } report($"Backpack physics ready: {((Il2CppArrayBase<Collider>)(object)val3.Colliders).Length} solid colliders, {((Il2CppArrayBase<Collider>)(object)val3.Triggers).Length} trigger, {((Il2CppArrayBase<Tracker>)(object)val3.Trackers).Length} trackers."); room = new PocketRoom(storage, root.transform, bodyMaterial, portalMaterial, skyMaterial, crossingMaterial, generation, currentGeneration, report); room.Create(); inventory = new InventoryControls(root.transform, room, crossingMaterial); } private void PreparePhysics(MarrowEntity entity, MarrowBody marrowBody, Rigidbody body) { //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) Il2CppArrayBase<BoxCollider> componentsInChildren = root.GetComponentsInChildren<BoxCollider>(true); Collider[] array = ((IEnumerable<BoxCollider>)componentsInChildren).Where((BoxCollider c) => Object.op_Implicit((Object)(object)c) && ((Collider)c).enabled && !((Collider)c).isTrigger).Cast<Collider>().ToArray(); Collider[] array2 = ((IEnumerable<BoxCollider>)componentsInChildren).Where((BoxCollider c) => Object.op_Implicit((Object)(object)c) && ((Collider)c).enabled && ((Collider)c).isTrigger).Cast<Collider>().ToArray(); if (array.Length != grips.Count + 1 || grips.Count == 0 || array2.Length != 1) { throw new InvalidOperationException($"Backpack geometry: solids={array.Length}, grips={grips.Count}, triggers={array2.Length}."); } marrowBody._rigidbody = body; marrowBody.HasRigidbody = true; marrowBody.SetEntity(entity); marrowBody.CopyRigidbodyInfo(body); marrowBody._colliders = Il2CppReferenceArray<Collider>.op_Implicit(array); marrowBody._triggers = Il2CppReferenceArray<Collider>.op_Implicit(array2); Bounds bounds = default(Bounds); bool flag = true; Vector3 val = default(Vector3); foreach (BoxCollider item in componentsInChildren) { if (!Object.op_Implicit((Object)(object)item) || ((Collider)item).isTrigger || !((Collider)item).enabled) { continue; } for (int num = 0; num < 8; num++) { ((Vector3)(ref val))..ctor((float)(((num & 1) != 0) ? 1 : (-1)), (float)(((num & 2) != 0) ? 1 : (-1)), (float)(((num & 4) != 0) ? 1 : (-1))); Vector3 val2 = root.transform.InverseTransformPoint(((Component)item).transform.TransformPoint(item.center + Vector3.Scale(item.size * 0.5f, val))); if (flag) { bounds = new Bounds(val2, Vector3.zero); flag = false; } else { ((Bounds)(ref bounds)).Encapsulate(val2); } } } marrowBody._bounds = bounds; entity._originalScale = root.transform.localScale; entity._bodies = Il2CppReferenceArray<MarrowBody>.op_Implicit((MarrowBody[])(object)new MarrowBody[1] { marrowBody }); entity._anchorBody = marrowBody; entity._joints = Il2CppReferenceArray<MarrowJoint>.op_Implicit(Array.Empty<MarrowJoint>()); entity.ValidatePoolee(); entity._behaviours = Il2CppReferenceArray<MarrowBehaviour>.op_Implicit(((IEnumerable<MarrowBehaviour>)root.GetComponentsInChildren<MarrowBehaviour>(true)).ToArray()); foreach (MarrowBehaviour item2 in (Il2CppArrayBase<MarrowBehaviour>)(object)entity._behaviours) { if (Object.op_Implicit((Object)(object)item2)) { item2.marrowEntity = entity; } } entity.ValidatePoseCache(); entity.InitializeInactiveState(); if (!entity._hasInactiveState || entity._inactiveStatus == null) { throw new InvalidOperationException("Backpack culling state was not initialized."); } entity.PreventDisableOnCull(true); marrowBody.GenerateTrackers(); foreach (Tracker item3 in (Il2CppArrayBase<Tracker>)(object)marrowBody.Trackers) { if (!Object.op_Implicit((Object)(object)item3)) { throw new InvalidOperationException("Backpack has a missing tracker."); } item3._body = marrowBody; item3._entity = entity; bool hasBody = (item3.hasEntity = true); item3.hasBody = hasBody; } ((MarrowBehaviour)host).marrowEntity = entity; host._marrowBody = marrowBody; Rigidbody val3 = default(Rigidbody); if (!Object.op_Implicit((Object)(object)marrowBody.Entity) || !marrowBody.HasRigidbody || !Object.op_Implicit((Object)(object)entity.AnchorBody) || !Object.op_Implicit((Object)(object)entity._poolee) || marrowBody.Colliders == null || ((Il2CppArrayBase<Collider>)(object)marrowBody.Colliders).Length != array.Length || !marrowBody.TryGetRigidbody(ref val3) || !Object.op_Implicit((Object)(object)val3) || !((Component)val3).transform.IsChildOf(root.transform)) { throw new InvalidOperationException($"Backpack physics links: entity={Object.op_Implicit((Object)(object)marrowBody.Entity)}, rigidbody={marrowBody.HasRigidbody}, anchor={Object.op_Implicit((Object)(object)entity.AnchorBody)}, pool={Object.op_Implicit((Object)(object)entity._poolee)}, colliders={((Il2CppArrayBase<Collider>)(object)marrowBody.Colliders)?.Length ?? (-1)}."); } } private void AddGrip(BoxCollider box, Dictionary<string, HandPose> poses, MarrowEntity entity) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown BoxGrip val = ((Component)box).gameObject.AddComponent<BoxGrip>(); val._boxCollider = box; ((Grip)val).gripColliders = Il2CppReferenceArray<Collider>.op_Implicit((Collider[])(object)new Collider[1] { (Collider)box }); ((Grip)val).additionalGripColliders = Il2CppReferenceArray<Collider>.op_Implicit(Array.Empty<Collider>()); ((HandReciever)val).Host = ((Il2CppObjectBase)host).Cast<IGrippable>(); ((Grip)val)._marrowEntity = entity; ((Grip)val).isThrowable = true; ((Grip)val).handleAmplifyCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(-180f, 0f), new Keyframe(180f, 0f) }); ((Grip)val).gripOptions = (InteractionOptions)1; ((Grip)val).priority = 1f; ((Grip)val).minBreakForce = float.MaxValue; ((Grip)val).maxBreakForce = float.MaxValue; ((Grip)val).defaultGripDistance = float.PositiveInfinity; ((Grip)val).gripDistanceSqr = float.PositiveInfinity; ((TargetGrip)val).rotationLimit = 180f; ((TargetGrip)val).rotationPriorityBuffer = 20f; val.sandwichSize = 0.12f; val.edgePadding = 0.015f; val.sandwichHandPose = poses["BoxSandwichGrip"]; val.edgeHandPose = poses["BoxEdgeGrip"]; val.cornerHandPose = poses["BoxCornerGrip"]; val.faceHandPose = poses["BoxFaceGrip"]; bool flag = (val.canBeFaceGrabbed = true); bool flag3 = (val.canBeCornerGrabbed = flag); bool canBeSandwichedGrabbed = (val.canBeEdgeGrabbed = flag3); val.canBeSandwichedGrabbed = canBeSandwichedGrabbed; float edgeHandPoseRadius = (val.cornerHandPoseRadius = 0.05f); val.edgeHandPoseRadius = edgeHandPoseRadius; val.faceHandPoseRadius = 1f; val.enabledCorners = (Corners)(-1); val.enabledEdges = (Edges)(-1); val.enabledFaces = (Faces)(-1); grips.Add(val); if (((Object)((Component)box).gameObject).name == "Handle") { ((Component)box).gameObject.AddComponent<ForcePullGrip>()._grip = (Grip)(object)val; } } private BoxCollider Box(string name, Vector3 position, Vector3 size) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = root.layer }; val.transform.SetParent(root.transform, false); val.transform.localPosition = position; BoxCollider obj = val.AddComponent<BoxCollider>(); obj.size = size; return obj; } private static Hand Hand(int index) { if (index != 0) { return Player.RightHand; } return Player.LeftHand; } internal void FixedTick() { if (Exists) { if (Object.op_Implicit((Object)(object)host) && !host.IsFarHoverEnabled) { host.EnableFarHover(); } if (Object.op_Implicit((Object)(object)cover)) { ((Collider)cover).enabled = !zip.IsOpen; } for (int i = 0; i < 2; i++) { LockGrip(Hand(i)); } room?.FixedTick(); } } private void LockGrip(Hand hand) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)hand)) { return; } HandReciever attachedReceiver = hand.AttachedReceiver; if (!Object.op_Implicit((Object)(object)attachedReceiver) || !((Component)attachedReceiver).transform.IsChildOf(root.transform)) { return; } ConfigurableJoint joint = hand.joint; if (Object.op_Implicit((Object)(object)joint) && Object.op_Implicit((Object)(object)((Joint)joint).connectedBody) && ((Component)((Joint)joint).connectedBody).transform.IsChildOf(root.transform)) { HandJointConfiguration handJointConfig = attachedReceiver.HandJointConfig; float breakForce; ConfigurableJointMotion val; ConfigurableJointMotion xMotion; if (handJointConfig != null) { breakForce = (handJointConfig.breakTorque = float.PositiveInfinity); handJointConfig.breakForce = breakForce; val = (ConfigurableJointMotion)0; handJointConfig.zMotion = (ConfigurableJointMotion)0; xMotion = (handJointConfig.yMotion = val); handJointConfig.xMotion = xMotion; val = (ConfigurableJointMotion)0; handJointConfig.angularZMotion = (ConfigurableJointMotion)0; xMotion = (handJointConfig.angularYMotion = val); handJointConfig.angularXMotion = xMotion; } breakForce = (((Joint)joint).breakTorque = float.PositiveInfinity); ((Joint)joint).breakForce = breakForce; val = (ConfigurableJointMotion)0; joint.zMotion = (ConfigurableJointMotion)0; xMotion = (joint.yMotion = val); joint.xMotion = xMotion; val = (ConfigurableJointMotion)0; joint.angularZMotion = (ConfigurableJointMotion)0; xMotion = (joint.angularYMotion = val); joint.angularXMotion = xMotion; joint.projectionMode = (JointProjectionMode)1; joint.projectionDistance = 0.015f; joint.projectionAngle = 5f; } } internal void Touch(Collider collider) { room?.Touch(collider); } internal bool BlocksGrab(Hand hand) { InventoryControls? inventoryControls = inventory; if (inventoryControls == null || !inventoryControls.BlocksGrab(hand)) { return room?.BlocksGrab(hand) ?? false; } return true; } internal bool BlocksCapture(Transform aim) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (!Exists || !Object.op_Implicit((Object)(object)aim)) { return false; } InventoryControls? inventoryControls = inventory; if (inventoryControls != null && inventoryControls.BlocksCapture(aim)) { return true; } PocketRoom? pocketRoom = room; if (pocketRoom != null && pocketRoom.BlocksCapture(aim)) { return true; } Transform transform = root.transform; Quaternion val = Quaternion.Inverse(transform.rotation); Ray val2 = default(Ray); ((Ray)(ref val2))..ctor(val * (aim.position - transform.position), val * aim.forward); Bounds val3 = new Bounds(Vector3.zero, new Vector3(0.7f, 0.82f, 0.6f)); float num = default(float); if (((Bounds)(ref val3)).IntersectRay(val2, ref num)) { return num <= 8f; } return false; } internal void FloatCollider(Collider collider) { room?.FloatCollider(collider); } internal void Recall(Vector3 position, Quaternion rotation) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) if (!Exists || IsInside) { return; } foreach (BoxGrip grip in grips) { if (Object.op_Implicit((Object)(object)grip) && ((Grip)grip).HasAttachedHands()) { ((Grip)grip).ForceDetach(); } } root.GetComponent<MarrowEntity>().Teleport(position, rotation, false); Rigidbody component = root.GetComponent<Rigidbody>(); Vector3 velocity = (component.angularVelocity = Vector3.zero); component.velocity = velocity; room?.ResetEntrance(); } internal void Tick() { if (Exists) { bool flag = Object.op_Implicit((Object)(object)Player.LeftController) && Player.LeftController.GetBButton(); bool flag2 = Object.op_Implicit((Object)(object)Player.RightController) && Player.RightController.GetBButton(); bool flag3 = IsHeldBy(Hand(0)); bool flag4 = IsHeldBy(Hand(1)); bool canClose = !zip.Opening || (!(flag3 && flag) && !(flag4 && flag2)) || OpeningClear(); if (zip.ReadButtons(flag3, flag, flag4, flag2, canClose)) { report(zip.Opening ? "Backpack unzipping." : "Backpack zipping."); } else if (zip.Blocked) { report("Move your hand or item clear of the opening before zipping."); } zip.Tick(Time.deltaTime); bodyMaterial.SetFloat("_ZipOpen", Mathf.SmoothStep(0f, 1f, zip.Amount)); if (Object.op_Implicit((Object)(object)cover)) { ((Collider)cover).enabled = !zip.IsOpen; } room?.SetBagOpening(zip.IsOpen, zip.Amount > 0f); room?.Tick(); inventory?.Tick(); } } private bool IsHeldBy(Hand hand) { if (!Object.op_Implicit((Object)(object)hand)) { return false; } HandReciever attachedReceiver = hand.AttachedReceiver; if (Object.op_Implicit((Object)(object)attachedReceiver)) { return ((Component)attachedReceiver).transform.IsChildOf(root.transform); } return false; } private bool OpeningClear() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (room == null || !room.CanCloseBag()) { return false; } Transform transform = root.transform; int num = Physics.OverlapBoxNonAlloc(transform.TransformPoint(new Vector3(0f, 0.055f, 0.189f)), new Vector3(0.17f, 0.145f, 0.032f), coverHits, transform.rotation, -1, (QueryTriggerInteraction)1); if (num == ((Il2CppArrayBase<Collider>)(object)coverHits).Length) { return false; } for (int i = 0; i < num; i++) { if (Object.op_Implicit((Object)(object)((Il2CppArrayBase<Collider>)(object)coverHits)[i]) && !((Component)((Il2CppArrayBase<Collider>)(object)coverHits)[i]).transform.IsChildOf(transform)) { return false; } } return true; } internal void UpdateMaterials() { room?.LateTick(); } internal void ReloadItems() { room?.RestoreItems(); } internal void ToggleDoor() { room?.ToggleDoor(); } internal void ClearInventory() { room?.ClearInventory(); } internal void GatherItems() { room?.GatherItems(); } internal void ReturnOutside() { room?.ReturnOutside(); } public void Dispose() { if (disposed) { return; } inventory?.Dispose(); inventory = null; room?.Dispose(); room = null; disposed = true; foreach (BoxGrip grip in grips) { if (Object.op_Implicit((Object)(object)grip) && ((Grip)grip).attachedHands != null && ((Grip)grip).attachedHands.Count != 0) { try { ((Grip)grip).ForceDetach(); } catch (Exception ex) { report("Backpack detach failed: " + ex.Message); } } } if (Object.op_Implicit((Object)(object)root)) { root.SetActive(false); Object.Destroy((Object)(object)root, 1f); } Object.Destroy((Object)(object)bodyMaterial); grips.Clear(); host = null; root = null; } } internal sealed class CaptureInput { private bool releaseRequired; internal bool Suppress(bool pressed, bool atPortal) { if (!pressed) { releaseRequired = false; } else if (atPortal) { releaseRequired = true; } if (!atPortal) { return releaseRequired; } return true; } } internal static class CardCrunchGuard { private static readonly CaptureInput input = new CaptureInput(); private static MethodInfo? ownedMethod; private static object? runtime; private static Func<Transform, bool>? owns; private static Action<string>? report; private static bool installed; private static bool failed; internal static void Install(Harmony harmony, Action<string> logger) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Expected O, but got Unknown if (installed || failed) { return; } report = logger; Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { Type type = assemblies[i].GetType("CardCrunch.PocketRuntime", throwOnError: false); if ((object)type != null) { MethodInfo method = type.GetMethod("Tick", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[5] { typeof(float), typeof(Transform), typeof(bool), typeof(bool), typeof(bool) }, null); ownedMethod = type.GetMethod("Owned", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Transform) }, null); if ((object)method == null || method.ReturnType != typeof(void) || (object)ownedMethod == null || ownedMethod.ReturnType != typeof(bool)) { failed = true; logger("CardCrunch compatibility unavailable: unsupported method signatures."); break; } try { harmony.Patch((MethodBase)method, new HarmonyMethod(typeof(CardCrunchGuard), "BeforeTick", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); installed = true; logger("CardCrunch portal input guard enabled."); break; } catch (Exception ex) { failed = true; logger("CardCrunch compatibility failed: " + ex.Message); break; } } } } private static void BeforeTick(object __instance, Transform __1, ref bool __2, ref bool __3) { try { if (runtime != __instance) { owns = (Func<Transform, bool>)ownedMethod.CreateDelegate(typeof(Func<Transform, bool>), __instance); runtime = __instance; } bool atPortal = PocketMod.Active?.BlocksCapture(__1) ?? false; if (input.Suppress(__2, atPortal)) { __2 = false; __3 = false; } } catch (Exception ex) { __2 = false; __3 = false; Warn(ex); } } internal static bool Owns(Transform child) { if (owns == null) { return false; } try { return owns(child); } catch (Exception ex) { Warn(ex); return true; } } private static void Warn(Exception ex) { if (!failed) { failed = true; report?.Invoke("CardCrunch interaction paused: " + ex.Message); } } } internal sealed class PocketRoom : IDisposable { private readonly record struct MotionState(Rigidbody Body, Vector3 Velocity, Vector3 AngularVelocity); private sealed class GatherMove { internal LiveItem? Saved; internal LooseItem? Loose; internal Vector3 Position; internal Quaternion Rotation; internal MotionState[] Motion = Array.Empty<MotionState>(); internal Transform Root { get { if (Saved == null) { return Loose.Root; } return ((Component)Saved.Pool).transform; } } internal void MoveTo(Vector3 position, Quaternion rotation) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Saved != null) { Move(Saved.Pool, position, rotation); return; } MoveLoose(Loose, position, rotation); Loose.Previous = Loose.Anchor.worldCenterOfMass; } internal void Float() { BodyState[] array = ((Saved != null) ? Saved.Bodies : Loose.Bodies); for (int i = 0; i < array.Length; i++) { array[i].Float(); } } } private sealed class LooseItem { internal readonly Transform Root; internal readonly MarrowEntity? Entity; internal readonly Rigidbody Anchor; internal readonly BodyState[] Bodies; internal readonly Grip[] Grips; internal readonly RenderState[] Renderers; internal bool Inside; internal Vector3 Previous; internal LooseItem(Rigidbody body, MarrowEntity? entity) { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) Entity = entity; Root = (Object.op_Implicit((Object)(object)entity) ? ((Component)entity).transform : ((Component)body).transform); Anchor = body; Bodies = ((IEnumerable<Rigidbody>)((Component)Root).GetComponentsInChildren<Rigidbody>(true)).Select((Rigidbody b) => new BodyState(b)).ToArray(); Grips = Il2CppArrayBase<Grip>.op_Implicit(((Component)Root).GetComponentsInChildren<Grip>(true)); Renderers = ((IEnumerable<Renderer>)((Component)Root).GetComponentsInChildren<Renderer>(true)).Select((Renderer r) => new RenderState(r)).ToArray(); Previous = body.worldCenterOfMass; } internal void Detach() { Grip[] grips = Grips; foreach (Grip val in grips) { if (Object.op_Implicit((Object)(object)val) && val.HasAttachedHands()) { val.ForceDetach(); } } } internal void Restore() { BodyState[] bodies = Bodies; for (int i = 0; i < bodies.Length; i++) { bodies[i].Restore(); } RenderState[] renderers = Renderers; for (int i = 0; i < renderers.Length; i++) { renderers[i].Show(visible: true); } } } private sealed record LooseCarry(LooseItem Item, Grip Grip, Hand Hand, Vector3 Position, Quaternion Rotation); private sealed class BodyState { private readonly BodyGravity gravity; private readonly MarrowBody marrow; private readonly bool cachedGravity; private readonly float cachedDrag; private readonly bool hasCachedConfig; internal Rigidbody Body => gravity.Body; internal BodyState(Rigidbody body) { gravity = new BodyGravity(body); marrow = ((Component)body).GetComponent<MarrowBody>(); if (Object.op_Implicit((Object)(object)marrow) && marrow._cachedRigidbodyInfo != null) { hasCachedConfig = true; cachedGravity = marrow._cachedRigidbodyInfo.useGravity; cachedDrag = marrow._cachedRigidbodyInfo.drag; } } internal void Float() { gravity.Float(); if (hasCachedConfig && Object.op_Implicit((Object)(object)marrow) && marrow._cachedRigidbodyInfo != null) { marrow._cachedRigidbodyInfo.useGravity = false; marrow._cachedRigidbodyInfo.drag = 0.65f; } } internal void Restore() { gravity.Restore(); if (hasCachedConfig && Object.op_Implicit((Object)(object)marrow) && marrow._cachedRigidbodyInfo != null) { marrow._cachedRigidbodyInfo.useGravity = cachedGravity; marrow._cachedRigidbodyInfo.drag = cachedDrag; } } } private sealed class LiveItem { internal StoredItem Saved; internal readonly Poolee Pool; internal readonly BodyState[] Bodies; internal readonly Grip[] Grips; internal readonly RenderState[] Renderers; internal LiveItem(StoredItem saved, Poolee pool) { Saved = saved; Pool = pool; Bodies = ((IEnumerable<Rigidbody>)((Component)pool).GetComponentsInChildren<Rigidbody>(true)).Select((Rigidbody b) => new BodyState(b)).ToArray(); Grips = Il2CppArrayBase<Grip>.op_Implicit(((Component)pool).GetComponentsInChildren<Grip>(true)); Renderers = ((IEnumerable<Renderer>)((Component)pool).GetComponentsInChildren<Renderer>(true)).Select((Renderer r) => new RenderState(r)).ToArray(); } } private sealed class RenderState { private readonly Renderer renderer; private readonly bool hidden; internal RenderState(Renderer renderer) { this.renderer = renderer; hidden = renderer.forceRenderingOff; } internal void Show(bool visible) { if (Object.op_Implicit((Object)(object)renderer)) { renderer.forceRenderingOff = hidden || !visible; } } } private sealed record Carry(Poolee Pool, Grip Grip, Hand Hand, Vector3 Position, Quaternion Rotation); private readonly Dictionary<int, CrossingVisual> crossings = new Dictionary<int, CrossingVisual>(); private readonly HashSet<int> crossingIds = new HashSet<int>(); private readonly Dictionary<int, PortalContact> touching = new Dictionary<int, PortalContact>(); private readonly Dictionary<(int, int), (Collider First, Collider Second, bool Ignored)> ignored = new Dictionary<(int, int), (Collider, Collider, bool)>(); private readonly HashSet<(int, int)> ignoreIds = new HashSet<(int, int)>(); private Collider[]? shellColliders; private bool reportedHands; private readonly Dictionary<string, string> itemNames = new Dictionary<string, string>(); private readonly HashSet<int> blockedTransfers = new HashSet<int>(); private readonly Dictionary<int, LooseItem> loose = new Dictionary<int, LooseItem>(); private Rigidbody[] bodyCache = Array.Empty<Rigidbody>(); private float nextBodyRefresh; private readonly List<(LooseCarry Carry, float Deadline)> looseAttachments = new List<(LooseCarry, float)>(); private readonly Storage storage; private readonly bool guest; private static PocketRoom? playerRoom; private static readonly HashSet<PocketRoom> activeRooms = new HashSet<PocketRoom>(); private readonly Transform bag; private readonly Material bodyMaterial; private readonly Material portalMaterial; private readonly Material skyMaterial; private readonly Material crossingMaterial; private readonly int generation; private readonly Func<int> currentGeneration; private readonly Action<string> report; private readonly Dictionary<string, LiveItem> live = new Dictionary<string, LiveItem>(); private readonly List<BodyState> playerBodies = new List<BodyState>(); private readonly Dictionary<int, BodyState> floatingBodies = new Dictionary<int, BodyState>(); private readonly Dictionary<int, (Vector3 Center, Vector3 BodyCenter, float Time)> motion = new Dictionary<int, (Vector3, Vector3, float)>(); private readonly Dictionary<int, Poolee> nearby = new Dictionary<int, Poolee>(); private Il2CppReferenceArray<Collider> roomHits = new Il2CppReferenceArray<Collider>(256L); private Il2CppReferenceArray<Collider> openingHits = new Il2CppReferenceArray<Collider>(64L); private readonly bool[] pressed = new bool[2]; private readonly List<GameObject> objects = new List<GameObject>(); private readonly List<RenderState> roomRenderers = new List<RenderState>(); private GameObject room; private Transform mouth; private Transform bagMouth; private Transform doorMouth; private GameObject door; private GameObject exit; private PortalView? view; private bool entered; private bool bagOpen; private bool bagVisible; private bool doorMode; private bool closedInside; private bool foldDoor; private Vector3 doorPosition; private readonly DoorMotion doorMotion = new DoorMotion(); private bool disposed; private bool hasPreviousHead; private Vector3 previousHead; private Vector3 returnFeet; private Vector3 returnForward; private float nextSave; private float nextTransfer; private float nextScan; private float transitionDeadline; private float nextRoomScan; private float nextBoundaryReturn; private float nextEntityScan; private bool reportScan; private bool settling; private float settleUntil; private readonly List<(Carry Carry, float Deadline)> attachments = new List<(Carry, float)>(); private readonly RestoreQueue restoreQueue = new RestoreQueue(); private Awaiter<Poolee>? restoreAwaiter; private float restoreDeadline; private bool restoreWarning; private float nextRestoreStart; private readonly Dictionary<int, RenderState> guestVisuals = new Dictionary<int, RenderState>(); internal bool IsInside => entered; internal bool CanRecall { get { if (!entered && !disposed) { return !PlayerIsInside(); } return false; } } private Transform Entrance { get { if (!doorMode) { return bagMouth; } return doorMouth; } } private bool HasOpening { get { if (!closedInside) { if (!doorMode) { return bagOpen; } return doorMotion.Ready; } return false; } } private bool OpeningVisible { get { if (!doorMode) { if (!closedInside) { return bagVisible; } return false; } return doorMotion.Visible; } } private Vector2 HalfSize { get { //IL_0022: 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) if (!doorMode) { return new Vector2(0.145f, 0.12f); } return new Vector2(0.7f, 1.2f); } } private Matrix4x4 ToRoom { get { //IL_0006: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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) Matrix4x4 val = Matrix4x4.TRS(mouth.position, mouth.rotation, Vector3.one); Matrix4x4 val2 = Matrix4x4.TRS(Entrance.position, Entrance.rotation, Vector3.one); return val * ((Matrix4x4)(ref val2)).inverse; } } private Matrix4x4 ToWorld { get { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 toRoom = ToRoom; return ((Matrix4x4)(ref toRoom)).inverse; } } internal Vector3 Origin => room.transform.position; private static bool IsPlayerPart(Transform transform) { if (!Object.op_Implicit((Object)(object)Player.RigManager) || !transform.IsChildOf(((Component)Player.RigManager).transform)) { if (Object.op_Implicit((Object)(object)Player.PhysicsRig)) { return transform.IsChildOf(((Component)Player.PhysicsRig).transform); } return false; } return true; } private static MotionState[] CaptureMotion(Transform root) { return (from body in (IEnumerable<Rigidbody>)((Component)root).GetComponentsInChildren<Rigidbody>(true) where Object.op_Implicit((Object)(object)body) && !body.isKinematic select new MotionState(body, body.velocity, body.angularVelocity)).ToArray(); } private static void ApplyMotion(MotionState[] states, Quaternion rotation) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < states.Length; i++) { MotionState motionState = states[i]; if (Object.op_Implicit((Object)(object)motionState.Body) && !motionState.Body.isKinematic) { motionState.Body.velocity = rotation * motionState.Velocity; motionState.Body.angularVelocity = rotation * motionState.AngularVelocity; } } } private Transform ItemRoot(Rigidbody body) { MarrowEntity val = EntityFor(body); Poolee val2 = (Object.op_Implicit((Object)(object)val) ? val._poolee : ((Component)body).GetComponentInParent<Poolee>()); if (!Object.op_Implicit((Object)(object)val2) || !((Component)body).transform.IsChildOf(((Component)val2).transform)) { if (!Object.op_Implicit((Object)(object)val)) { return ((Component)body).transform; } return ((Component)val).transform; } return ((Component)val2).transform; } internal void LateTick() { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02da: 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_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) if (disposed || !Object.op_Implicit((Object)(object)Player.RigManager) || !Object.op_Implicit((Object)(object)Player.Head)) { return; } KeepUpright(); if (guest) { RestoreView(); return; } if (!HasOpening || Time.unscaledTime < transitionDeadline) { ClearCrossings(); RestoreView(); return; } foreach (CrossingVisual value in crossings.Values) { value.Restore(); } crossingIds.Clear(); ignoreIds.Clear(); int[] array = (from pair in touching where Time.unscaledTime - pair.Value.LastContact > 3f select pair.Key).ToArray(); foreach (int key in array) { touching.Remove(key); } Rigidbody[] array2 = bodyCache; foreach (Rigidbody val in array2) { if (!Object.op_Implicit((Object)(object)val) || !((Component)val).gameObject.activeInHierarchy || ((Component)val).transform.IsChildOf(bag) || IsPlayerPart(((Component)val).transform) || CardCrunchGuard.Owns(((Component)val).transform)) { continue; } Vector3 val2 = val.worldCenterOfMass - room.transform.position; bool flag = ((Vector3)(ref val2)).sqrMagnitude < 44100f; Transform val3 = (flag ? mouth : Entrance); val2 = val.worldCenterOfMass - val3.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 16f)) { Transform val4 = ItemRoot(val); if (AddCrossing(val4, flag, avatar: false) && !flag && !door.activeSelf) { IgnoreShell((IEnumerable<Collider>)((Component)val4).GetComponentsInChildren<Collider>()); } } } bool flag2 = false; for (int num2 = 0; num2 < 2; num2++) { Hand val5 = Hand(num2); if (!Object.op_Implicit((Object)(object)val5)) { continue; } Vector3 val6 = Point(entered ? mouth : Entrance, ((Component)val5).transform.position); Vector3 val7 = Point(entered ? mouth : Entrance, Player.Head.position); float num3 = ((!entered) ? 1 : (-1)); if (val7.z * num3 <= 0.05f || val6.z * num3 >= -0.015f || Mathf.Abs(val6.x) > HalfSize.x + 0.02f || Mathf.Abs(val6.y) > HalfSize.y + 0.02f || Mathf.Abs(val6.z) > 1.2f) { continue; } flag2 = true; if (!entered && !door.activeSelf && val6.z < 0.18f) { IgnoreShell((IEnumerable<Collider>)((Component)val5).GetComponentsInChildren<Collider>()); } HandReciever attachedReceiver = val5.AttachedReceiver; Grip val8 = ((attachedReceiver != null) ? ((Il2CppObjectBase)attachedReceiver).TryCast<Grip>() : null); if (Object.op_Implicit((Object)(object)val8) && !((Component)val8).transform.IsChildOf(bag)) { MarrowEntity componentInParent = ((Component)val8).GetComponentInParent<MarrowEntity>(); Transform val9 = ((Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent._poolee)) ? ((Component)componentInParent._poolee).transform : (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).transform : ((Component)val8).transform)); AddCrossing(val9, entered, avatar: false); if (!entered && !door.activeSelf && val6.z < 0.18f) { IgnoreShell((IEnumerable<Collider>)((Component)val9).GetComponentsInChildren<Collider>()); } } } Avatar avatar = Player.RigManager.avatar; if (flag2 && Object.op_Implicit((Object)(object)avatar)) { AddCrossing(((Component)avatar).transform, entered, avatar: true); } array = crossings.Keys.Where((int id) => !crossingIds.Contains(id)).ToArray(); foreach (int key2 in array) { crossings[key2].Dispose(); crossings.Remove(key2); } (int, int)[] array3 = ignored.Keys.Where(((int, int) id) => !ignoreIds.Contains(id)).ToArray(); foreach ((int, int) key3 in array3) { (Collider, Collider, bool) tuple = ignored[key3]; if (Object.op_Implicit((Object)(object)tuple.Item1) && Object.op_Implicit((Object)(object)tuple.Item2)) { Physics.IgnoreCollision(tuple.Item1, tuple.Item2, tuple.Item3); } ignored.Remove(key3); } RestoreView(); } private bool AddCrossing(Transform root, bool insideRoom, bool avatar) { //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) //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_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_019e: Unknown result type (might be due to invalid IL or missing references) if (!avatar && CardCrunchGuard.Owns(root)) { return false; } int instanceID = ((Object)root).GetInstanceID(); if (crossingIds.Contains(instanceID)) { return true; } Transform val = (insideRoom ? mouth : Entrance); bool flag = avatar; if (!avatar) { Vector3 val2 = Point(val, root.position); flag = val2.z * (float)((!insideRoom) ? 1 : (-1)) < 0f && ((Vector3)(ref val2)).sqrMagnitude < 4f && ((IEnumerable<Grip>)((Component)root).GetComponentsInChildren<Grip>()).Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands()); } if (!avatar) { foreach (Renderer componentsInChild in ((Component)root).GetComponentsInChildren<Renderer>()) { if (Object.op_Implicit((Object)(object)componentsInChild) && componentsInChild.enabled && PortalGeometry.OverlapsOpening(componentsInChild.bounds, val, HalfSize)) { flag = true; break; } } } if (!flag) { return false; } if (!avatar && !CanTransfer(root, allowHeld: true)) { return false; } if (!crossings.TryGetValue(instanceID, out CrossingVisual value)) { value = (crossings[instanceID] = new CrossingVisual(root, crossingMaterial)); } if (avatar && !reportedHands) { reportedHands = true; report($"Portal hand view: {value.RendererCount} renderers."); } value.Update(val, insideRoom ? Entrance : mouth, HalfSize, insideRoom, avatar); crossingIds.Add(instanceID); return true; } private void IgnoreShell(IEnumerable<Collider> colliders) { if (shellColliders == null) { shellColliders = Il2CppArrayBase<Collider>.op_Implicit(((Component)bag).GetComponentsInChildren<Collider>()); } foreach (Collider collider in colliders) { if (!Object.op_Implicit((Object)(object)collider) || collider.isTrigger || ((Component)collider).transform.IsChildOf(bag)) { continue; } Collider[] array = shellColliders; foreach (Collider val in array) { if (Object.op_Implicit((Object)(object)val) && !val.isTrigger) { (int, int) tuple = (((Object)collider).GetInstanceID(), ((Object)val).GetInstanceID()); ignoreIds.Add(tuple); if (!ignored.ContainsKey(tuple)) { bool ignoreCollision = Physics.GetIgnoreCollision(collider, val); ignored.Add(tuple, (collider, val, ignoreCollision)); Physics.IgnoreCollision(collider, val, true); } } } } } private void ClearCrossings() { foreach (CrossingVisual value in crossings.Values) { value.Dispose(); } crossings.Clear(); foreach (var value2 in ignored.Values) { if (Object.op_Implicit((Object)(object)value2.First) && Object.op_Implicit((Object)(object)value2.Second)) { Physics.IgnoreCollision(value2.First, value2.Second, value2.Ignored); } } ignored.Clear(); touching.Clear(); } private void AddFrame(GameObject surface, bool inside) { //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_001c: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown GameObject val = new GameObject("Portal glow"); val.transform.SetParent(surface.transform, false); val.transform.localScale = new Vector3(1.15f, 1.15f, 1f); val.AddComponent<MeshFilter>().sharedMesh = surface.GetComponent<MeshFilter>().sharedMesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); Material val3 = new Material(portalMaterial); val3.SetFloat("_Frame", 1f); val3.SetFloat("_ZWrite", 0f); val3.renderQueue = 3005; ((Renderer)val2).sharedMaterial = val3; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; if (inside) { roomRenderers.Add(new RenderState((Renderer)(object)val2)); } } private void UpdateDoor(float seconds) { //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_0106: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) doorMotion.Tick(seconds); if (foldDoor && !doorMotion.Visible) { doorMode = (closedInside = (foldDoor = false)); hasPreviousHead = false; } if (doorMode) { float num = Mathf.Max(0.001f, doorMotion.Height); door.transform.localScale = new Vector3(1.4f, 2.4f * num, 1f); door.transform.rotation = doorMouth.rotation; door.transform.position = doorPosition - Vector3.up * (1.2f * (1f - num)); exit.transform.localScale = door.transform.localScale; exit.transform.position = mouth.position - Vector3.up * (1.2f * (1f - num)); } else { exit.transform.localScale = new Vector3(0.31f, 0.26f, 1f); exit.transform.position = mouth.position; } door.SetActive(doorMode && doorMotion.Visible); exit.SetActive(OpeningVisible); } internal void GatherItems() { //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: 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_02b1: Unknown result type (might be due to invalid IL or missing references) if (disposed || guest || storage.IsReadOnly) { report("Only the owner can bring items closer."); return; } if (!entered || !Object.op_Implicit((Object)(object)Player.Head) || !PlayerIsInside()) { report("Enter your pocket dimension first."); return; } if (Time.unscaledTime < transitionDeadline) { report("Wait until entry finishes."); return; } List<GatherMove> list = new List<GatherMove>(); int num = storage.Entries.Count - live.Count; foreach (LiveItem value in live.Values) { if (!Object.op_Implicit((Object)(object)value.Pool) || !((Component)value.Pool).gameObject.activeInHierarchy || value.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands()) || !CanTransfer(((Component)value.Pool).transform)) { num++; continue; } list.Add(new GatherMove { Saved = value }); } foreach (LooseItem value2 in loose.Values) { if (value2.Inside) { if (!Object.op_Implicit((Object)(object)value2.Root) || !((Component)value2.Root).gameObject.activeInHierarchy || value2.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands()) || !CanTransfer(value2.Root)) { num++; continue; } list.Add(new GatherMove { Loose = value2 }); } } List<GatherMove> list2 = new List<GatherMove>(); ClearCrossings(); try { foreach (GatherMove item in list) { Transform root = item.Root; if (!GatherPlacement.TryFind(root, Player.Head.position, Player.Head.forward, room.transform.position, mouth, HalfSize, out var position)) { num++; continue; } item.Position = root.position; item.Rotation = root.rotation; item.Motion = CaptureMotion(root); list2.Add(item); item.MoveTo(position, item.Rotation); item.Float(); Physics.SyncTransforms(); } StoredItem[] array = (from entry in list2 where entry.Saved != null select entry.Saved.Saved with { Pose = ReadPose(entry.Saved.Pool) }).ToArray(); if (!storage.TryUpdate(array)) { throw new InvalidOperationException("Position save failed: " + storage.Error); } StoredItem[] array2 = array; foreach (StoredItem storedItem in array2) { live[storedItem.Id].Saved = storedItem; } } catch (Exception ex) { foreach (GatherMove item2 in list2) { try { item2.MoveTo(item2.Position, item2.Rotation); item2.Float(); ApplyMotion(item2.Motion, Quaternion.identity); } catch (Exception ex2) { report("Item position restore failed: " + ex2.Message); } } Physics.SyncTransforms(); report("Bring items closer failed: " + ex.Message); return; } motion.Clear(); nextTransfer = Time.unscaledTime + 0.5f; report("Brought " + list2.Count + " items closer. " + Math.Max(0, num) + " left in place or not loaded."); } internal List<InventoryEntry> Inventory() { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown List<InventoryEntry> list = new List<InventoryEntry>(); SpawnableCrate val = default(SpawnableCrate); foreach (StoredItem entry in storage.Entries) { LiveItem value; bool flag = live.TryGetValue(entry.Id, out value) && Object.op_Implicit((Object)(object)value.Pool) && ((Component)value.Pool).gameObject.activeInHierarchy; if (!itemNames.TryGetValue(entry.Barcode, out string value2)) { value2 = ((!((CrateReferenceT<SpawnableCrate>)new SpawnableCrateReference(entry.Barcode)).TryGetCrate(ref val) || !Object.op_Implicit((Object)(object)val) || string.IsNullOrWhiteSpace(((Scannable)val).Title)) ? CleanName(entry.Barcode.Split('.').Last()) : (itemNames[entry.Barcode] = CleanName(((Scannable)val).Title))); } list.Add(new InventoryEntry(entry.Id, value2, flag && !storage.IsReadOnly, saved: true, "crate:" + entry.Barcode)); } foreach (KeyValuePair<int, LooseItem> item in loose) { LooseItem value3 = item.Value; if (value3.Inside && Object.op_Implicit((Object)(object)value3.Root) && ((Component)value3.Root).gameObject.activeInHierarchy) { list.Add(new InventoryEntry("loose:" + item.Key, CleanName(((Object)((Component)value3.Root).gameObject).name), ready: true, saved: false, "session:" + CleanName(((Object)((Component)value3.Root).gameObject).name))); } } return list; } private static string CleanName(string name) { return ItemNames.Clean(name); } internal void ClearInventory() { if (disposed || storage.IsReadOnly) { report("Inventory cannot be cleared while the save is read-only."); return; } if (live.Values.Any((LiveItem item) => item.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands())) || loose.Values.Any((LooseItem item) => item.Inside && item.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands()))) { report("Release stored items before clearing the backpack."); return; } if (!storage.TryRemoveMany(storage.Entries)) { report("Inventory was kept: " + storage.Error); return; } ClearCrossings(); foreach (LiveItem value in live.Values) { if (Object.op_Implicit((Object)(object)value.Pool)) { ((Component)value.Pool).gameObject.SetActive(false); try { value.Pool.Despawn(); } catch (Exception ex) { report("Item cleanup: " + ex.Message); } } } live.Clear(); KeyValuePair<int, LooseItem>[] array = loose.Where<KeyValuePair<int, LooseItem>>((KeyValuePair<int, LooseItem> pair) => pair.Value.Inside).ToArray(); for (int num = 0; num < array.Length; num++) { KeyValuePair<int, LooseItem> keyValuePair = array[num]; if (Object.op_Implicit((Object)(object)keyValuePair.Value.Root)) { ((Component)keyValuePair.Value.Root).gameObject.SetActive(false); Object.Destroy((Object)(object)((Component)keyValuePair.Value.Root).gameObject); } loose.Remove(keyValuePair.Key); } if (restoreAwaiter == null) { restoreQueue.Reset(); } report("Backpack inventory cleared."); } internal bool Eject(string id, out string message) { message = "Item is not loaded yet."; if (disposed || !Object.op_Implicit((Object)(object)Player.Head) || !Object.op_Implicit((Object)(object)Player.RigManager)) { return false; } if (entered) { message = "Return outside first."; return false; } if (live.TryGetValue(id, out LiveItem value)) { return EjectSaved(value, out message); } if (id.StartsWith("loose:", StringComparison.Ordinal) && int.TryParse(id.AsSpan(6), out var result) && loose.TryGetValue(result, out LooseItem value2)) { return EjectLoose(result, value2, out message); } return false; } private bool EjectSaved(LiveItem item, out string message) { //IL_01c1: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_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_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) message = "Item is not available."; if (storage.IsReadOnly) { message = "Save is read-only. Item kept inside."; return false; } if (!Object.op_Implicit((Object)(object)item.Pool) || !((Component)item.Pool).gameObject.activeInHierarchy || !storage.Entries.Any((StoredItem entry) => entry.Id == item.Saved.Id)) { return false; } if (item.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands())) { message = "Release this item first."; return false; } if (!CheckTransfer(((Component)item.Pool).transform)) { message = "Item is attached to another object."; return false; } Transform transform = ((Component)item.Pool).transform; if (!EjectPose(transform, out var position, out var rotation)) { message = "Make room in front of you."; return false; } Vector3 position2 = transform.position; Quaternion rotation2 = transform.rotation; ClearCrossings(); try { Move(item.Pool, position, rotation); BodyState[] bodies = item.Bodies; for (int num = 0; num < bodies.Length; num++) { bodies[num].Restore(); } RenderState[] renderers = item.Renderers; for (int num = 0; num < renderers.Length; num++) { renderers[num].Show(visible: true); } Physics.SyncTransforms(); if (!storage.TryRemove(item.Saved.Id, item.Saved.Barcode)) { throw new InvalidOperationException("Save failed. Item kept inside."); } } catch (Exception ex) { Move(item.Pool, position2, rotation2); BodyState[] bodies = item.Bodies; for (int num = 0; num < bodies.Length; num++) { bodies[num].Float(); } RenderState[] renderers = item.Renderers; for (int num = 0; num < renderers.Length; num++) { renderers[num].Show(visible: false); } message = ex.Message; report("Panel retrieval failed: " + ex.Message); return false; } live.Remove(item.Saved.Id); nextTransfer = Time.unscaledTime + 0.5f; message = "Item taken out."; report("Panel retrieved " + ((Object)((Component)item.Pool).gameObject).name + " [" + item.Saved.Barcode + "]."); return true; } private bool EjectLoose(int key, LooseItem item, out string message) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) message = "Item is not available."; if (!item.Inside || !Object.op_Implicit((Object)(object)item.Root) || !((Component)item.Root).gameObject.activeInHierarchy) { return false; } if (item.Grips.Any((Grip grip) => Object.op_Implicit((Object)(object)grip) && grip.HasAttachedHands())) { message = "Release this item first."; return false; } if (!CheckTransfer(item.Root)) { message = "Item is attached to another object."; return false; } if (!EjectPose(item.Root, out var position, out var rotation)) { message = "Make room in front of you."; return false; } Vector3 position2 = item.Root.position; Quaternion rotation2 = item.Root.rotation; ClearCrossings(); try { MoveLoose(item, position, rotation); item.Restore(); Physics.SyncTransforms(); } catch (Exception ex) { MoveLoose(item, position2, rotation2); BodyState[] bodies = item.Bodies; for (int num = 0; num < bodies.Length; num++) { bodies[num].Float(); } RenderState[] renderers = item.Renderers; for (int num = 0; num < renderers.Length; num++) { renderers[num].Show(visible: false); } message = ex.Message; return false; } loose.Remove(key); nextTransfer = Time.unscaledTime + 0.5f; message = "Item taken out."; return true; } private bool EjectPose(Transform root, out Vector3 position, out Quaternion rotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 toWorld = ToWorld; rotation = ((Matrix4x4)(ref toWorld)).rotation * root.rotation; Vector3 val = Vector3.ProjectOnPlane(Player.Head.forward, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.1f) { val = Vector3.ProjectOnPlane(Entrance.forward, Vector3.up); normalized = ((Vector3)(ref val)).normalized; } return ItemPlacement.TryFind(root, Player.Head.position, normalized, rotation, out position); } internal bool BlocksGrab(Hand hand) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (disposed || !HasOpening || !Object.op_Implicit((Object)(object)hand) || !Object.op_Implicit((Object)(object)Player.Head) || Time.unscaledTime < transitionDeadline) { return false; } if (!IsPlayerPart(((Component)hand).transform)) { return false; } Transform frame = (entered ? mouth : Entrance); return InteractionGeometry.Reaching(Point(frame, Player.Head.position), Point(frame, ((Component)hand).transform.position), HalfSize, (!entered) ? 1 : (-1)); } private static bool CanTransfer(Transform root, bool allowHeld = false) { if (PocketNetwork.Online) { Func<Transform, bool>? canControl = PocketNetwork.CanControl; if (canControl != null && !canControl(root)) { return false; } } int num; object obj; if (allowHeld) { num = (LocallyHeld(root) ? 1 : 0); if (num != 0 && Object.op_Implicit((Object)(object)Player.RigManager)) { obj = ((Component)Player.RigManager).transform; goto IL_0045; } } else { num = 0; } obj = null; goto IL_0045; IL_0045: Transform heldRig = (Transform)obj; Transform physicsRig = ((num != 0 && Object.op_Implicit((Object)(object)Player.PhysicsRig)) ? ((Component)Player.PhysicsRig).transform : null); if (!InteractionGeometry.Movable(root, heldRig, physicsRig)) { return false; } foreach (MarrowEntity componentsInChild in ((Component)root).GetComponentsInChildren<MarrowEntity>()) { if (!Object.op_Implicit((Object)(object)componentsInChild)) { continue; } if (Object.op_Implicit((Object)(object)componentsInChild._hostEntity) && !((Component)componentsInChild._hostEntity).transform.IsChildOf(root)) { return false; } if (componentsInChild._parasites != null) { Enumerator<MarrowEntity> enumerator2 = componentsInChild._parasites.GetEnumerator(); while (enumerator2.MoveNext()) { MarrowEntity current2 = enumerator2.Current; if (Object.op_Implicit((Object)(object)current2) && !((Component)current2).transform.IsChildOf(root)) { return false; } } } if (componentsInChild.Bodies == null) { continue; } foreach (MarrowBody item in (Il2CppArrayBase<MarrowBody>)(object)componentsInChild.Bodies) { if (Object.op_Implicit((Object)(object)item) && !((Component)item).transform.IsChildOf(root)) { return false; } } } return true; } private static bool LocallyHeld(Transform root) { for (int i = 0; i < 2; i++) { Hand val = Hand(i); HandReciever val2 = (Object.op_Implicit((Object)(object)val) ? val.AttachedReceiver : null); if (Object.op_Implicit((Object)(object)val2) && ((Component)val2).transform.IsChildOf(root)) { return true; } } return false; } private bool CheckTransfer(Transform root) { if (CanTransfer(root)) { return true; } if (Object.op_Implicit((Object)(object)root) && blockedTransfers.Add(((Object)root).GetInstanceID())) { report("Transfer blocked for " + ((Object)((Component)root).gameObject).name + ": fixed or connected outside this object."); } return false; } private static float GripDistance(Grip grip, Transform root, Vector3 target) { //IL_000a: 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) if (!Object.op_Implicit((Object)(object)grip) || !((Behaviour)grip).enabled || !((Component)grip).gameObject.activeInHierarchy || !((Component)grip).transform.IsChildOf(root) || grip.HasAttachedHands()) { return float.PositiveInfinity; } if (Object.op_Implicit((Object)(object)grip._marrowEntity) && !((Component)grip._marrowEntity).transform.IsChildOf(root)) { return float.PositiveInfinity; } float distance = float.PositiveInfinity; foreach (Collider component in ((Component)grip).GetComponents<Collider>()) { Measure(component); } if (grip.gripColliders != null) { foreach (Collider item in (Il2CppArrayBase<Collider>)(object)grip.gripColliders) { Measure(item); } } if (grip.additionalGripColliders != null) { foreach (Collider item2 in (Il2CppArrayBase<Collider>)(object)grip.additionalGripColliders) { Measure(item2); } } return distance; void Measure(Collider collider) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)collider) && ((Component)collider).transform.IsChildOf(root)) { Rigidbody attachedRigidbody = collider.attachedRigidbody; if (Object.op_Implicit((Object)(object)attachedRigidbody) && ((Component)attachedRigidbody).transform.IsChildOf(root)) { distance = Mathf.Min(distance, InteractionGeometry.DistanceSquared(collider, target)); } } } } private List<LooseCarry> CaptureLooseHeld(List<Carry> saved) { //IL_0141: 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) List<LooseCarry> list = new List<LooseCarry>(); for (int i = 0; i < 2; i++) { Hand val = Hand(i); if (!Object.op_Implicit((Object)(object)val)) { continue; } HandReciever attachedReceiver = val.AttachedReceiver; Grip grip = ((attachedReceiver != null) ? ((Il2CppObjectBase)attachedReceiver).TryCast<Grip>() : null); if (!Object.op_Implicit((Object)(object)grip) || ((Component)grip).transform.IsChildOf(bag) || saved.Any((Carry p) => ((Component)grip).transform.IsChildOf(((Component)p.Pool).transform))) { continue; } Rigidbody val2 = null; foreach (Collider component in ((Component)grip).GetComponents<Collider>()) { if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.attachedRigidbody)) { val2 = component.attachedRigidbody; break; } } if (!Object.op_Implicit((Object)(object)val2)) { val2 = ((Component)grip).GetComponentInParent<Rigidbody>(); } if (Object.op_Implicit((Object)(object)val2)) { LooseItem item = TrackLoose(val2, entered, allowHeld: true); if (item != null && !list.Any((LooseCarry p) => ((Object)p.Item.Root).GetInstanceID() == ((Object)item.Root).GetInstanceID())) { list.Add(new LooseCarry(item, grip, val, item.Root.position, item.Root.rotation)); } } } return list; } private void TransferLooseHeld(List<LooseCarry> carried, Matrix4x4 map, bool intoRoom) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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) foreach (LooseCarry item2 in carried) { LooseItem item = item2.Item; MoveLoose(item, ((Matrix4x4)(ref map)).MultiplyPoint3x4(item2.Position), ((Matrix4x4)(ref map)).rotation * item2.Rotation); item.Inside = intoRoom; item.Previous = item.Anchor.worldCenterOfMass; if (intoRoom) { BodyState[] bodies = item.Bodies; for (int i = 0; i < bodies.Length; i++) { bodies[i].Float(); } } else { item.Restore(); loose.Remove(((Object)item.Root).GetInstanceID()); } looseAttachments.Add((item2, Time.unscaledTime + 5f)); } } private void FinishLooseAttachments() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) for (int num = looseAttachments.Count - 1; num >= 0; num--) { (LooseCarry, float) tuple = looseAttachments[num]; var (looseCarry, _) = tuple; if (!Object.op_Implicit((Object)(object)looseCarry.Item.Root) || !Object.op_Implicit((Object)(object)looseCarry.Hand) || !Object.op_Implicit((Object)(object)looseCarry.Grip) || Time.unscaledTime > tuple.Item2 || looseCarry.Hand.HasAttachedObject()) { looseAttachments.RemoveAt(num); } else { MoveLoose(looseCarry.Item, looseCarry.Item.Root.position + ((Component)looseCarry.Hand).transform.position - ((Component)looseCarry.Grip).transform.position, looseCarry.Item.Root.rotation); PortalGrab.Attach(looseCarry.Hand, looseCarry.Grip); looseAttachments.RemoveAt(num); } } } private static MarrowEntity? EntityFor(Rigidbody body) { MarrowBody component = ((Component)body).GetComponent<MarrowBody>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.Entity) && ((Component)body).transform.IsChildOf(((Component)component.Entity).transform)) { return component.Entity; } MarrowEntity componentInParent = ((Component)body).GetComponentInParent<MarrowEntity>(); if (!Object.op_Implicit((Object)(object)componentInParent) || !((Component)body).transform.IsChildOf(((Component)componentInParent).transform)) { return null; } return componentInParent; } private LooseItem? TrackLoose(Rigidbody body, bool insideRoom, bool allowHeld = false) { if (!Object.op_Implicit((Object)(object)body) || !((Component)body).gameObject.activeInHierarchy || ((Component)body).transform.IsChildOf(bag) || IsPlayerPart(((Component)body).transform) || CardCrunchGuard.Owns(((Component)body).transform)) { return null; } MarrowEntity val = EntityFor(body); Transform root = (Object.op_Implicit((Object)(object)val) ? ((Component)val).transform : ((Component)body).transform); if (live.Values.Any((LiveItem x) => Object.op_Implicit((Object)(object)x.Pool) && root.IsChildOf(((Component)x.Pool).transform))) { return null; } int instanceID = ((Object)root).GetInstanceID(); if (!loose.TryGetValue(instanceID, out LooseItem value)) { if (!CanTransfer(root, allowHeld)) { return null; } foreach (CrossingVisual value2 in crossings.Values) { value2.Restore(); } value = (loose[instanceID] = new LooseItem(body, val)); } value.Inside = insideRoom; if (insideRoom) { BodyState[] bodies = value.Bodies; for (int num = 0; num < bodies.Length; num++) { bodies[num].Float(); } } return value; } private void ForgetLoose(Transform root) { KeyValuePair<int, LooseItem>[] array = loose.Where<KeyValuePair<int, LooseItem>>((KeyValuePair<int, LooseItem> p) => Object.op_Implicit((Object)(object)p.Value.Root) && p.Value.Root.IsChildOf(root)).ToArray(); for (int num = 0; num < array.Length; num++) { KeyValuePair<int, LooseItem> keyValuePair = array[num]; keyValuePair.Value.Restore(); loose.Remove(keyValuePair.Key); } } private void TickBodies() { //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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_03fc: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0422: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0369: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime >= nextBodyRefresh) { nextBodyRefresh = Time.unscaledTime + 0.5f; bodyCache = ((IEnumerable<Rigidbody>)Object.FindObjectsOfType<Rigidbody>()).ToArray(); } Rigidbody[] array = bodyCache; Vector3 val2; foreach (Rigidbody val in array) { if (!Object.op_Implicit((Object)(object)val) || !((Component)val).gameObject.activeInHierarchy || ((Component)val).transform.IsChildOf(bag) || IsPlayerPart(((Component)val).transform) || CardCrunchGuard.Owns(((Component)val).transform)) { continue; } Vector3 worldCenterOfMass = val.worldCenterOfMass; val2 = worldCenterOfMass - room.transform.position; if (((Vector3)(ref val2)).sqrMagnitude < 44100f) { MarrowEntity val3 = EntityFor(val); Poolee val4 = (Object.op_Implicit((Object)(object)val3) ? val3._poolee : ((Component)val).GetComponentInParent<Poolee>()); if (!Object.op_Implicit((Object)(object)val4) || !Eligible(val4) || TrackNew(val4) == null) { TrackLoose(val, insideRoom: true); } } else { if (!HasOpening || entered) { continue; } val2 = worldCenterOfMass - Entrance.position; if (!(((Vector3)(ref val2)).sqrMagnitude < 16f)) { continue; } foreach (Collider componentsInChild in ((Component)val).GetComponentsInChildren<Collider>()) { Touch(componentsInChild); } } } KeyValuePair<int, LooseItem>[] array2 = loose.ToArray(); for (int i = 0; i < array2.Length; i++) { KeyValuePair<int, LooseItem> keyValuePair = array2[i]; LooseItem value = keyValuePair.Value; if (!Object.op_Implicit((Object)(object)value.Root) || !Object.op_Implicit((Object)(object)value.Anchor) || !((Component)value.Root).gameObject.activeInHierarchy) { value.Restore(); loose.Remove(keyValuePair.Key); } else { if (!value.Inside) { continue; } BodyState[] bodies = value.Bodies; for (int j = 0; j < bodies.Length; j++) { bodies[j].Float(); } Vector3 worldCenterOfMass2 = value.Anchor.worldCenterOfMass; Vector3 val5 = Point(mouth, value.Previous); Vector3 val6 = Point(mouth, worldCenterOfMass2); if (HasOpening && Time.unscaledTime >= nextTransfer && val6.z >= 0f && val6.z < 2f && InOpening((val5.z < 0f) ? Vector3.Lerp(val5, val6, val5.z / (val5.z - val6.z)) : val6, HalfSize)) { if (!value.Grips.Any((Grip g) => Object.op_Implicit((Object)(object)g) && g.HasAttachedHands())) { MotionState[] states = CaptureMotion(value.Root); value.Detach(); Matrix4x4 toWorld = ToWorld; Vector3 position = ((Matrix4x4)(ref toWorld)).MultiplyPoint3x4(value.Root.position); toWorld = ToWorld; MoveLoose(value, position, ((Matrix4x4)(ref toWorld)).rotation * value.Root.rotation); value.Restore(); toWorld = ToWorld; ApplyMotion(states, ((Matrix4x4)(ref toWorld)).rotation); loose.Remove(keyValuePair.Key); nextTransfer = Time.unscaledTime + 0.05f; } } else { val2 = worldCenterOfMass2 - room.transform.position; if (((Vector3)(ref val2)).sqrMagnitude > 40000f && !value.Grips.Any((Grip g) => Object.op_Implicit((Object)(object)g) && g.HasAttachedHands())) { MoveLoose(value, mouth.position - mouth.forward * 2f, value.Root.rotation); } value.Previous = value.Anchor.worldCenterOfMass; } } } } private void DepositLoose(Rigidbody body) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) if (!HasOpening) { return; } LooseItem looseItem = TrackLoose(body, insideRoom: false); if (looseItem != null) { Matrix4x4 toRoom = ToRoom; Vector3 position = ((Matrix4x4)(ref toRoom)).MultiplyPoint3x4(looseItem.Root.position); MotionState[] states = CaptureMotion(looseItem.Root); looseItem.Detach(); toRoom = ToRoom; MoveLoose(looseItem, position, ((Matrix4x4)(ref toRoom)).rotation * looseItem.Root.rotation); looseItem.Inside = true; looseItem.Previous = looseItem.Anchor.worldCenterOfMass; BodyState[] bodies = looseItem.Bodies; for (int i = 0; i < bodies.Length; i++) { bodies[i].Float(); } toR
Mods/PocketDimension.Fusion.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Il2CppSLZ.Marrow.Interaction; using LabFusion.Entities; using LabFusion.Network; using LabFusion.Player; using LabFusion.SDK.Modules; using MelonLoader; using Microsoft.CodeAnalysis; using PocketDimension.Fusion; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(FusionMod), "PocketDimension Fusion", "1.0.0", "MarrowByte", null)] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: MelonAdditionalDependencies(new string[] { "PocketDimension", "LabFusion" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PocketDimension.Fusion { public sealed class FusionMod : MelonMod { private static readonly Dictionary<ulong, HashSet<int>> protectedItems = new Dictionary<ulong, HashSet<int>>(); private static readonly Dictionary<ulong, float> lastSeen = new Dictionary<ulong, float>(); private static readonly Dictionary<int, (NetworkEntity Entity, bool Locked)> locks = new Dictionary<int, (NetworkEntity, bool)>(); public override void OnInitializeMelon() { if (!ModuleMessageManager.TypeToHandlerLookup.ContainsKey(typeof(PocketStateMessage))) { ModuleMessageManager.RegisterHandler<PocketStateMessage>(); } PocketNetwork.Connected = () => NetworkInfo.HasServer && PlayerIDManager.LocalID != null; PocketNetwork.LocalSlot = () => PlayerIDManager.LocalSmallID; PocketNetwork.HasPlayer = (ulong id) => PlayerIDManager.GetPlayerID(id) != null; PocketNetwork.CanControl = CanControl; PocketNetwork.EntityId = delegate(Transform root) { NetworkEntity? obj = Find(root); return ((int?)((obj != null) ? new ushort?(obj.ID) : ((ushort?)null))) ?? (-1); }; PocketNetwork.FindEntity = FindEntity; PocketNetwork.Send = Send; ((MelonBase)this).LoggerInstance.Msg("Pocket sharing enabled. Visitors cannot manage stored items."); } private static NetworkEntity? Find(Transform root) { if (!Object.op_Implicit((Object)(object)root)) { return null; } MarrowEntity val = ((Component)root).GetComponent<MarrowEntity>(); if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)root).GetComponentInParent<MarrowEntity>(); } if (!Object.op_Implicit((Object)(object)val)) { val = ((Component)root).GetComponentInChildren<MarrowEntity>(); } NetworkEntity result = default(NetworkEntity); if (!Object.op_Implicit((Object)(object)val) || !IMarrowEntityExtender.Cache.TryGet(val, ref result)) { return null; } return result; } private static bool CanControl(Transform root) { NetworkEntity val = Find(root); if (val != null) { if (val.GetExtender<NetworkPlayer>() == null) { return val.IsOwner; } return false; } return true; } private static Transform? FindEntity(int id, ulong owner) { if (id < 0 || id > 65535) { return null; } NetworkEntity entity = NetworkEntityManager.IDManager.RegisteredEntities.GetEntity((ushort)id); if (entity != null) { PlayerID ownerID = entity.OwnerID; if (ownerID != null && ownerID.PlatformID == owner && entity.GetExtender<NetworkPlayer>() == null) { IMarrowEntityExtender extender = entity.GetExtender<IMarrowEntityExtender>(); MarrowEntity val = ((extender != null) ? extender.MarrowEntity : null); if (!Object.op_Implicit((Object)(object)val) || !((Component)val).gameObject.activeInHierarchy) { return null; } return ((Component)val).transform; } } return null; } private static void Send(RoomSnapshot state) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) Protect(state); NetMessage val = NetMessage.ModuleCreate<PocketStateMessage>(RoomWire.Encode(state), new MessageRoute((RelayType)3, (NetworkChannel)0), (byte?)PlayerIDManager.LocalSmallID); try { MessageSender.SendToServer((NetworkChannel)0, val); } finally { ((IDisposable)val)?.Dispose(); } } internal static void Protect(RoomSnapshot state) { HashSet<int> hashSet = new HashSet<int>(); if (state.Active) { RoomItem[] items = state.Items; foreach (RoomItem val in items) { if (val.Entity < 0 || val.Entity > 65535) { continue; } NetworkEntity entity = NetworkEntityManager.IDManager.RegisteredEntities.GetEntity((ushort)val.Entity); if (entity == null) { continue; } PlayerID ownerID = entity.OwnerID; if (((ownerID != null) ? new ulong?(ownerID.PlatformID) : ((ulong?)null)) != state.Owner || entity.GetExtender<NetworkPlayer>() != null) { continue; } hashSet.Add(val.Entity); if (locks.TryGetValue(val.Entity, out (NetworkEntity, bool) value) && value.Item1 != entity) { if (!value.Item2) { value.Item1.UnlockOwner(); } locks.Remove(val.Entity); } if (!locks.ContainsKey(val.Entity)) { locks[val.Entity] = (entity, entity.IsOwnerLocked); } entity.LockOwner(); } } protectedItems[state.Owner] = hashSet; lastSeen[state.Owner] = Time.unscaledTime; ReleaseUnused(); } private static void ReleaseUnused() { HashSet<int> hashSet = protectedItems.Values.SelectMany((HashSet<int> ids) => ids).ToHashSet(); KeyValuePair<int, (NetworkEntity, bool)>[] array = locks.ToArray(); for (int num = 0; num < array.Length; num++) { KeyValuePair<int, (NetworkEntity, bool)> keyValuePair = array[num]; if (!hashSet.Contains(keyValuePair.Key) || !keyValuePair.Value.Item1.IsRegistered) { if (!keyValuePair.Value.Item2) { keyValuePair.Value.Item1.UnlockOwner(); } locks.Remove(keyValuePair.Key); } } } public override void OnUpdate() { ulong[] array = protectedItems.Keys.ToArray(); foreach (ulong num in array) { if (!NetworkInfo.HasServer || PlayerIDManager.GetPlayerID(num) == null || Time.unscaledTime - lastSeen[num] > 15f) { protectedItems.Remove(num); lastSeen.Remove(num); } } ReleaseUnused(); } public override void OnDeinitializeMelon() { PocketNetwork.Connected = null; PocketNetwork.LocalSlot = null; PocketNetwork.HasPlayer = null; PocketNetwork.CanControl = null; PocketNetwork.EntityId = null; PocketNetwork.FindEntity = null; PocketNetwork.Send = null; protectedItems.Clear(); lastSeen.Clear(); ReleaseUnused(); } } public sealed class PocketStateMessage : ModuleMessageHandler { protected override void OnHandleMessage(ReceivedMessage received) { if (((ReceivedMessage)(ref received)).Sender.HasValue) { PlayerID playerID = PlayerIDManager.GetPlayerID(((ReceivedMessage)(ref received)).Sender.Value); RoomSnapshot val = default(RoomSnapshot); if (playerID != null && !playerID.IsMe && RoomWire.Decode(((ReceivedMessage)(ref received)).Bytes, playerID.PlatformID, playerID.SmallID, ref val)) { FusionMod.Protect(val); PocketNetwork.Receive?.Invoke(val); } } } } }