private void ResetIVA() { try { if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { JSIAdvPodsUtil.Log_Debug("Need to reset IVA in part {0}({1})", part.name, part.craftID); // Now the cruical bit. // If the root part changed, we actually need to recreate the IVA forcibly even if it still exists. if (vessel.rootPart != knownRootPart) { // In this case we also need to kick the user out of IVA if they're currently in our pod, // otherwise lots of things screw up in a bizarre fashion. if (JSIAdvPodsUtil.UserIsInPod(part)) { JSIAdvPodsUtil.Log_Debug("The user is in pod {0} and I need to kick them out.", part.partName); CameraManager.Instance.SetCameraFlight(); } if (part.internalModel != null) { Destroy(part.internalModel.gameObject); part.internalModel = null; } } // But otherwise the existing one will serve. // If the internal model doesn't yet exist, this call will implicitly create it anyway. // It will also initialise it, which in this case implies moving it into the correct location in internal space // and populate it with crew, which is what we want. if (part.CrewCapacity > 0) { part.SpawnIVA(); } else { part.CreateInternalModel(); if (part.internalModel != null) { part.internalModel.Initialize(part); } } part.internalModel.SetVisible(true); setVisible = true; // And then we remember the root part and the active vessel these coordinates refer to. knownRootPart = vessel.rootPart; lastActiveVessel = FlightGlobals.ActiveVessel; ResetShadersBackup(); if (DeepFreezerModule != null && DeepFreezerMethod != null) { DeepFreezerMethod.Invoke(DeepFreezerModule, null); } else { if (DeepFreezerModule == null && part.Modules.Contains("DeepFreezer")) { DeepFreezerModule = part.Modules["DeepFreezer"]; } if (DeepFreezerModule != null) { object methodObj = JSIAdvPodsUtil.GetObjectMethod(DeepFreezerModule, "InternalModelCreated"); if (methodObj != null) { DeepFreezerMethod = methodObj as MethodInfo; if (DeepFreezerMethod != null) { DeepFreezerMethod.Invoke(DeepFreezerModule, null); } } } } } } catch (Exception ex) { JSIAdvPodsUtil.Log_Debug("Reset IVA failed: {0}", ex); } }