コード例 #1
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        private ConfigNode SanitizeShipNode(ConfigNode node)
        {
            //PART, MODULE -> clean experiments, repack chutes, disable engines
            String filePath = KSPUtil.ApplicationRootPath + "GameData/KerbalConstructionTime/KCT_ModuleTemplates.cfg";

            if (!File.Exists(filePath))
            {
                CreateInitialTemplates();
            }
            ConfigNode ModuleTemplates = ConfigNode.Load(filePath);

            ConfigNode[] templates = ModuleTemplates.GetNodes("MODULE");

            //var nodes = node.GetNodes("PART");
            //for (int i = nodes.Count() - 1; i >= 0; i--)
            //{
            //    ConfigNode part = nodes[i];
            foreach (ConfigNode part in node.GetNodes("PART"))
            {
                //var modules = part.GetNodes("MODULE");  // error is here
                //for (int i1 = modules.Count() - 1; i1 >= 0; i1--)
                //{
                //    ConfigNode module = modules[i1];

                foreach (ConfigNode module in part.GetNodes("MODULE"))
                {
                    SanitizeNode(KCT_Utilities.PartNameFromNode(part), module, templates);
                }
            }
            return(node);
        }
コード例 #2
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public Dictionary <AvailablePart, int> GetLockedParts()
        {
            var lockedPartsOnShip = new Dictionary <AvailablePart, int>();

            if (ResearchAndDevelopment.Instance == null)
            {
                return(lockedPartsOnShip);
            }

            foreach (ConfigNode pNode in shipNode.GetNodes("PART"))
            {
                string partName = KCT_Utilities.PartNameFromNode(pNode);
                if (!KCT_Utilities.PartIsUnlocked(partName))
                {
                    AvailablePart partInfoByName = PartLoader.getPartInfoByName(partName);
                    if (!lockedPartsOnShip.ContainsKey(partInfoByName))
                    {
                        lockedPartsOnShip.Add(partInfoByName, 1);
                    }
                    else
                    {
                        ++lockedPartsOnShip[partInfoByName];
                    }
                }
            }

            return(lockedPartsOnShip);
        }
コード例 #3
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public List <string> MissingParts()
        {
            List <string> missing = new List <string>();

            foreach (ConfigNode pNode in shipNode.GetNodes("PART"))
            {
                string name = KCT_Utilities.PartNameFromNode(pNode);
                if (KCT_Utilities.GetAvailablePartByName(name) == null)
                {
                    //invalid part detected!
                    missing.Add(name);
                }
            }
            return(missing);
        }
コード例 #4
0
ファイル: KCT_BuildListVessel.cs プロジェクト: nepphhh/KCT
        public bool CheckPartsValid()
        {
            //loop through the ship's parts and check if any don't have AvailableParts that match.

            bool valid = true;

            foreach (ConfigNode pNode in shipNode.GetNodes("PART"))
            {
                if (KCT_Utilities.GetAvailablePartByName(KCT_Utilities.PartNameFromNode(pNode)) == null)
                {
                    //invalid part detected!
                    valid = false;
                    break;
                }
            }

            return(valid);
        }
コード例 #5
0
        private ConfigNode SanitizeShipNode(ConfigNode node)
        {
            //PART, MODULE -> clean experiments, repack chutes, disable engines
            String filePath = KSPUtil.ApplicationRootPath + "GameData/KerbalConstructionTime/KCT_ModuleTemplates.cfg";

            if (!File.Exists(filePath))
            {
                CreateInitialTemplates();
            }
            ConfigNode ModuleTemplates = ConfigNode.Load(filePath);

            ConfigNode[] templates = ModuleTemplates.GetNodes("MODULE");
            foreach (ConfigNode part in node.GetNodes("PART"))
            {
                foreach (ConfigNode module in part.GetNodes("MODULE"))
                {
                    SanitizeNode(KCT_Utilities.PartNameFromNode(part), module, templates);
                }
            }
            return(node);
        }
コード例 #6
0
        private ConfigNode SanitizeShipNode(ConfigNode node)
        {
            //PART, MODULE -> clean experiments, repack chutes, disable engines
            String filePath = PluginAssemblyUtilities.templatesFilePath;

            if (!File.Exists(filePath))
            {
                CreateInitialTemplates();
            }
            ConfigNode ModuleTemplates = ConfigNode.Load(filePath);

            ConfigNode[] templates = ModuleTemplates.GetNodes("MODULE");
            foreach (ConfigNode part in node.GetNodes("PART"))
            {
                foreach (ConfigNode module in part.GetNodes("MODULE"))
                {
                    SanitizeNode(KCT_Utilities.PartNameFromNode(part), module, templates);
                }
            }
            return(node);
        }
コード例 #7
0
 //NOTE: This is an approximation. This won't properly take into account for resources and tweakscale! DO NOT USE IF YOU CARE 100% ABOUT THE MASS
 public double GetTotalMass()
 {
     if (TotalMass != 0 && emptyMass != 0)
     {
         return(TotalMass);
     }
     TotalMass = 0;
     emptyMass = 0;
     foreach (ConfigNode p in this.ExtractedPartNodes)
     {
         float n1, n2;
         TotalMass += ShipConstruction.GetPartTotalMass(p, KCT_Utilities.GetAvailablePartByName(KCT_Utilities.PartNameFromNode(p)), out n1, out n2);
         emptyMass += n1;
     }
     return(TotalMass);
 }
コード例 #8
0
ファイル: KCT_GUI_BuildList.cs プロジェクト: yaus/KCT
        private static void DrawBLPlusWindow(int windowID)
        {
            //bLPlusPosition.xMax = buildListWindowPosition.xMin;
            //bLPlusPosition.width = 100;
            bLPlusPosition.yMin   = buildListWindowPosition.yMin;
            bLPlusPosition.height = 225;
            //bLPlusPosition.height = bLPlusPosition.yMax - bLPlusPosition.yMin;
            KCT_BuildListVessel b = KCT_Utilities.FindBLVesselByID(IDSelected);

            GUILayout.BeginVertical();
            if (GUILayout.Button("Scrap"))
            {
                InputLockManager.SetControlLock(ControlTypes.KSC_ALL, "KCTPopupLock");
                DialogOption[] options = new DialogOption[2];
                options[0] = new DialogOption("Yes", ScrapVessel);
                options[1] = new DialogOption("No", DummyVoid);
                MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options);
                PopupDialog.SpawnPopupDialog(diag, false, windowSkin);
                showBLPlus = false;
                ResetBLWindow();
            }
            if (GUILayout.Button("Edit"))
            {
                showBLPlus = false;
                editorWindowPosition.height = 1;
                string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp.craft";
                b.shipNode.Save(tempFile);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                KCT_GameStates.editedVessel          = b;
                KCT_GameStates.EditorShipEditingMode = true;
                KCT_GameStates.delayStart            = true;

                InputLockManager.SetControlLock(ControlTypes.EDITOR_EXIT, "KCTEditExit");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LOAD, "KCTEditLoad");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_NEW, "KCTEditNew");
                InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTEditLaunch");

                KCT_GameStates.EditedVesselParts.Clear();
                foreach (ConfigNode node in b.ExtractedPartNodes)
                {
                    string name = KCT_Utilities.PartNameFromNode(node) + KCT_Utilities.GetTweakScaleSize(node);
                    if (!KCT_GameStates.EditedVesselParts.ContainsKey(name))
                    {
                        KCT_GameStates.EditedVesselParts.Add(name, 1);
                    }
                    else
                    {
                        ++KCT_GameStates.EditedVesselParts[name];
                    }
                }

                //EditorDriver.StartAndLoadVessel(tempFile);
                EditorDriver.StartAndLoadVessel(tempFile, b.type == KCT_BuildListVessel.ListType.VAB ? EditorFacility.VAB : EditorFacility.SPH);
            }
            if (GUILayout.Button("Rename"))
            {
                centralWindowPosition.width  = 360;
                centralWindowPosition.x      = (Screen.width - 360) / 2;
                centralWindowPosition.height = 1;
                showBuildList = false;
                showBLPlus    = false;
                showRename    = true;
                newName       = b.shipName;
                //newDesc = b.getShip().shipDescription;
            }
            if (GUILayout.Button("Duplicate"))
            {
                KCT_Utilities.AddVesselToBuildList(b.NewCopy(true), b.InventoryParts.Count > 0);
            }
            if (KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()) != null && GUILayout.Button("Rollback"))
            {
                KCT_GameStates.ActiveKSC.Recon_Rollout.Find(rr => rr.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout && rr.associatedID == b.id.ToString()).SwapRolloutType();
            }
            if (!b.isFinished && GUILayout.Button("Warp To"))
            {
                KCT_GameStates.targetedItem = b;
                KCT_GameStates.canWarp      = true;
                KCT_Utilities.RampUpWarp(b);
                KCT_GameStates.warpInitiated = true;
                showBLPlus = false;
            }
            if (!b.isFinished && GUILayout.Button("Move to Top"))
            {
                if (b.type == KCT_BuildListVessel.ListType.VAB)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.VABList.Insert(0, b);
                }
                else if (b.type == KCT_BuildListVessel.ListType.SPH)
                {
                    b.RemoveFromBuildList();
                    KCT_GameStates.ActiveKSC.SPHList.Insert(0, b);
                }
            }
            if (!b.isFinished && GUILayout.Button("Rush Build 10%\n√" + Math.Round(0.2 * b.GetTotalCost())))
            {
                double cost = b.GetTotalCost();
                cost *= 0.2;
                double remainingBP = b.buildPoints - b.progress;
                if (Funding.Instance.Funds >= cost)
                {
                    b.AddProgress(remainingBP * 0.1);
                    KCT_Utilities.SpendFunds(cost, TransactionReasons.None);
                }
            }
            if (GUILayout.Button("Close"))
            {
                showBLPlus = false;
            }
            GUILayout.EndVertical();
            float width = bLPlusPosition.width;

            bLPlusPosition.x     = buildListWindowPosition.x - width;
            bLPlusPosition.width = width;
        }