コード例 #1
0
        private void InitQuickLaunchVessels()
        {
            quickLaunchVessels = new Dictionary <int, QuickLaunchVessel>();

            string directory = GetHangarPath();

            if (!Directory.Exists(directory))
            {
                return;
            }
            string[] launchVehicleDirectories = Directory.GetDirectories(directory);
            foreach (string launchVehiceDirectory in launchVehicleDirectories)
            {
                string launchVehicleFile = Path.Combine(launchVehiceDirectory, LAUNCHFILENAME + ".craft");
                if (!File.Exists(launchVehicleFile))
                {
                    continue;
                }
                ConfigNode         prevLaunchRootNode    = ConfigNode.Load(launchVehicleFile);
                ProtoVessel        prevlaunchProtoVessel = new ProtoVessel(prevLaunchRootNode, HighLogic.CurrentGame);
                ProtoLaunchVehicle previousLaunchVehicle = null;
                ProtoPayload       previousPayload       = null;

                string[] parts      = launchVehiceDirectory.Split(Path.DirectorySeparatorChar);
                string   vesselName = parts[parts.Length - 1];
                Debug.Log(string.Format("[BeenThereDoneThat]: Loading vessel: {0}", vesselName));

                if (!QuickLauncher.Instance.Split(prevlaunchProtoVessel, out previousLaunchVehicle, out previousPayload))
                {
                    continue;
                }
                previousLaunchVehicle.DebugVehicle();
                QuickLaunchVessel quickLaunchVessel = new QuickLaunchVessel(vesselName, prevlaunchProtoVessel, previousLaunchVehicle);
                quickLaunchVessels[quickLaunchVessel.GetHashCode()] = quickLaunchVessel;

                string missionsPath = Path.Combine(launchVehiceDirectory, "Missions");
                if (!Directory.Exists(missionsPath))
                {
                    continue;
                }
                foreach (string missionFilePath in Directory.GetFiles(missionsPath))
                {
                    ConfigNode         orbitRootNode      = ConfigNode.Load(missionFilePath);
                    ProtoVessel        orbitProtoVessel   = new ProtoVessel(orbitRootNode, HighLogic.CurrentGame);
                    ProtoLaunchVehicle orbitLaunchVehicle = null;
                    ProtoPayload       orbitPayload       = null;

                    string missionName = Path.GetFileNameWithoutExtension(missionFilePath);
                    Debug.Log(string.Format("[BeenThereDoneThat]: Loading mission: {0}", missionName));

                    if (QuickLauncher.Instance.Split(orbitProtoVessel, out orbitLaunchVehicle, out orbitPayload))
                    {
                        quickLaunchVessel.AddMission(missionFilePath, orbitProtoVessel);
                    }
                }
            }
        }
コード例 #2
0
        public bool Split(ProtoVessel protoVessel, out ProtoLaunchVehicle launchVehicle, out ProtoPayload payload)
        {
            ProtoPartSnapshot payloadSeparator = FindPayloadSeparatorPart(protoVessel.protoPartSnapshots);

            if (payloadSeparator == null)
            {
                Debug.Log("[BeenThereDoneThat]: No payloadseparator found");
                launchVehicle = null;
                payload       = null;
                return(false);
            }

            ProtoPartSnapshotTree tree = new ProtoPartSnapshotTree(protoVessel.protoPartSnapshots);

            List <ProtoPartSnapshot> payloadParts;
            List <ProtoPartSnapshot> launchVehicleParts;

            tree.Split(payloadSeparator, out launchVehicleParts, out payloadParts);
            payload       = new ProtoPayload(payloadParts);
            launchVehicle = new ProtoLaunchVehicle(payloadSeparator, launchVehicleParts);
            return(true);
        }