/// <summary> /// Call the stock ModuleDockingNode.FindNodeApproaches(), and prevent it to ignore the vessels we are putting /// on physics hold by temporary setting Vessel.packed to false. Not that there is also a check on the Part.packed /// field, but we don't need to handle it since we always unpack parts that have a ModuleDockingNode. /// </summary> private void FindNodeApproachesPatched(ModuleDockingNode dockingNode) { if (PhysicsHoldManager.Instance == null || PhysicsHoldManager.Instance.OnHoldAndPackedInstances.Count == 0) { return; } foreach (VesselPhysicsHold instance in PhysicsHoldManager.Instance.OnHoldAndPackedInstances) { instance.vessel.packed = false; } try { dockingNode.otherNode = dockingNode.FindNodeApproaches(); } catch (Exception e) { Debug.LogError($"ModuleDockingNode threw during FindNodeApproaches\n{e}"); } finally { foreach (VesselPhysicsHold instance in PhysicsHoldManager.Instance.OnHoldAndPackedInstances) { instance.vessel.packed = true; } } }