Ejemplo n.º 1
0
        private void dockStage4()
        {
            RmmUtil.ToMapView();
            Part placePort = new Part();

            // int portNumber = 0;
            foreach (Part p in transactionVessel.parts)
            {
                if (p.flightID == missionFlightIDDockPart)
                {
                    placePort = p;
                }
                foreach (PartModule pm in p.Modules)
                {
                    //if (pm.GetType() == typeof(ModuleDockingNode))
                    //{
                    //    RMMModule ComOffMod = p.Modules.OfType<RMMModule>().FirstOrDefault();
                    //    if (ComOffMod.trackingPrimary == true)
                    //    {
                    //        placePort = p;
                    //        if (missionOffering.ReturnEnabled)
                    //        {
                    //            ComOffMod.commercialvehiclemode = true;
                    //            ComOffMod.commercialvehicleFolderName = missionOffering.FolderPath;
                    //            ComOffMod.commercialvehiclePartCount = (float)RmmUtil.CountVesselParts(transactionVessel);
                    //            ComOffMod.trackingPrimary = false;
                    //        }
                    //    }
                    //    portNumber = portNumber + 1;
                    //
                    //    ComOffMod.trackingActive = false;
                    //    ComOffMod.returnMission = false;
                    //    ComOffMod.trackMissionId = "";
                    //    ComOffMod.PortCode = "";
                    //}

                    // empty all science
                    if (pm.GetType() == typeof(ModuleScienceContainer))
                    {
                        ModuleScienceContainer moduleScienceContainer = (ModuleScienceContainer)pm;
                        var scienceDatas = moduleScienceContainer.GetData();
                        for (int i = 0; i < scienceDatas.Count(); i++)
                        {
                            moduleScienceContainer.RemoveData(scienceDatas[i]);
                        }
                    }
                }
            }
            transactionVessel.targetObject = null;
            handleLoadCrew(transactionVessel, _mission.CrewCount, _mission.MinimumCrew, _mission.CrewSelection);
            RmmContract.HandleContracts(transactionVessel, true, false);
            LoggerRmm.Debug("st4.5" + RmmUtil.IsDocked(_targetVessel, _targetPart) + checkDockingPortCompatibility(placePort, _targetPart));
            if (!RmmUtil.IsDocked(_targetVessel, _targetPart) && checkDockingPortCompatibility(placePort, _targetPart))
            {
                LoggerRmm.Debug("st4.6");
                placeVesselForDock(transactionVessel, placePort, _targetVessel, _targetPart, RmmUtil.GetDockingDistance(placePort));
                LoggerRmm.Debug("st4.7");
                _nextLogicTime = Planetarium.GetUniversalTime();
                _arrivalStage  = 5;
            }
            else
            {
                ScreenMessages.PostScreenMessage(_mission.VesselName + " rendezvoused", 4, ScreenMessageStyle.UPPER_CENTER);
                finishArrival();
            }
        }