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);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected bool IsPreviouslyUsedLaunchVehicle()
        {
            List <AvailablePart>        protoPartInfos = new List <AvailablePart>();
            Dictionary <string, double> protoResources = new Dictionary <string, double>();

            previousLaunchVehicle.DebugVehicle();
            currentLaunchVehicle.DebugParts();

            if (!previousLaunchVehicle.Equals(currentLaunchVehicle))
            {
                Debug.Log("[BeenThereDoneThat]: launch vehicles not equal!");
                return(false);
            }

            Debug.Log("[BeenThereDoneThat]: launch vehicles equal!");
            return(true);
        }