当前位置: 首页>>代码示例>>C#>>正文


C# ConfigNode.RemoveNode方法代码示例

本文整理汇总了C#中System.ConfigNode.RemoveNode方法的典型用法代码示例。如果您正苦于以下问题:C# ConfigNode.RemoveNode方法的具体用法?C# ConfigNode.RemoveNode怎么用?C# ConfigNode.RemoveNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ConfigNode的用法示例。


在下文中一共展示了ConfigNode.RemoveNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EditorSaveToFile

        public static void EditorSaveToFile()
        {
            //print("EditorSaveToFile called"); 
            string errLine = "1";
            try
            {
                ConfigNode AGXEditorNode = new ConfigNode("EDITOR");
                AGXEditorNode.AddValue("name", "editor");
                errLine = "2";
                if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
                {
                    errLine = "3";
                    AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //print("AGX ConfigNode Load Okay! (Saving)");
                }
               // else
                //{
                    //errLine = "4";
                    //print("AGX ConfigNode not found, creating..... (Saving)");
                    //errLine = "5";
                    //AGXEditorNode.AddValue("name", "Action Groups Extended save file");
                    //AGXEditorNode.AddNode("FLIGHT");
                    //errLine = "6";
                    //AGXEditorNode.AddNode("EDITOR");
                    //errLine = "7";
                    //AGXEditorNode.Save(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //errLine = "8";
                //}

                errLine = "9";
                //ConfigNode AGXEditorNode = AGXBaseNode.GetNode("EDITOR");
                errLine = "10";
                string hashedShipName = AGextScenario.EditorHashShipName(EditorLogic.fetch.shipNameField.Text, inVAB);
                errLine = "11";
                ConfigNode thisVsl = new ConfigNode(hashedShipName);
                errLine = "12";
                thisVsl.AddValue("name", EditorLogic.fetch.shipNameField.Text);
                errLine = "13";
                thisVsl.AddValue("currentKeyset", CurrentKeySet.ToString());
                errLine = "14";
                thisVsl.AddValue("groupNames", SaveGroupNames(""));
                errLine = "15";
                thisVsl.AddValue("groupVisibility", SaveGroupVisibility(""));
                errLine = "16";
                thisVsl.AddValue("groupVisibilityNames", SaveGroupVisibilityNames(""));
                errLine = "17";
                try
                {
                    errLine = "17c";
                    foreach (Part p in EditorLogic.SortedShipList)
                    {
                        errLine = "17d";
                        List<AGXAction> thisPartsActions = new List<AGXAction>();
                        thisPartsActions.AddRange(CurrentVesselActions.FindAll(p2 => p2.prt == p));
                        errLine = "18";
                        if (thisPartsActions.Count > 0)
                        {
                            ConfigNode partTemp = new ConfigNode("PART");
                            errLine = "19";
                            partTemp.AddValue("name", p.name);
                            partTemp.AddValue("vesselID", "0");
                            partTemp.AddValue("relLocX", (p.transform.position - EditorLogic.startPod.transform.position).x);
                            if (!inVAB)
                            {
                                partTemp.AddValue("relLocZ", ((p.transform.position - EditorLogic.startPod.transform.position).y) * -1f);
                                partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).z);
                            }
                            else
                            {
                                partTemp.AddValue("relLocY", (p.transform.position - EditorLogic.startPod.transform.position).y);
                                partTemp.AddValue("relLocZ", (p.transform.position - EditorLogic.startPod.transform.position).z);
                            }
                            errLine = "20";
                            foreach (AGXAction agxAct in thisPartsActions)
                            {
                                errLine = "21";
                                partTemp.AddNode(AGextScenario.SaveAGXActionVer2(agxAct));
                            }
                            errLine = "22";

                            thisVsl.AddNode(partTemp);
                            errLine = "23";
                        }
                       // print("part OrgPart "+ p.ConstructID+" " + p.orgPos + " " + p.orgRot);
                    }
                }
                catch
                {
                    print("AGExt No parts to save ");
                }
                errLine = "23";
                if(AGXEditorNode.HasNode(hashedShipName))
                {
                    errLine = "23";
                    AGXEditorNode.RemoveNode(hashedShipName);
                }
                errLine = "24";
                AGXEditorNode.AddNode(thisVsl);
                errLine = "25";
                //AGXBaseNode.RemoveNode("EDITOR");
//.........这里部分代码省略.........
开发者ID:erendrake,项目名称:AGExt,代码行数:101,代码来源:Editor.cs

示例2: CheckExistingShips

        public void CheckExistingShips()
        {
            List<string> existingShipsList = new List<string>();
            string fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/Ships/VAB";
            int fileLen = fileDir.Length;
            string[] fileList = Directory.GetFiles(fileDir);
            //print("sc3 " + loadShipList.Length);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7),true));
            }
                fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/Ships/SPH";
            
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), false));
            }
            fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "Ships/SPH";
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), false));
            }
            fileDir = new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "Ships/VAB";
            fileLen = fileDir.Length;
            fileList = Directory.GetFiles(fileDir);
            foreach (string file in fileList)
            {
                existingShipsList.Add(AGextScenario.EditorHashShipName(file.Substring(fileLen + 1, file.Length - fileLen - 7), true));
            }
            //ConfigNode AGXBaseNode = AGextScenario.LoadBaseNode();
            ConfigNode AGXEditorNode = new ConfigNode("EDITOR");
            AGXEditorNode.AddValue("name", "editor");
            if (File.Exists(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg"))
            {
                AGXEditorNode = ConfigNode.Load(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
            }
            foreach (ConfigNode VslNode in AGXEditorNode.nodes)
            {
                if (!existingShipsList.Contains(VslNode.name))
                {
                    AGXEditorNode.RemoveNode(VslNode.name);
                    //AGXBaseNode.RemoveNode("EDITOR");
                    //AGXBaseNode.AddNode(AGXEditorNode);
                    AGXEditorNode.Save(new DirectoryInfo(KSPUtil.ApplicationRootPath).FullName + "saves/" + HighLogic.SaveFolder + "/AGExtEditor.cfg");
                    //print("Existing ship check node save " + AGXEditorNode);
                    goto BreakOut;
                }
            }
        BreakOut:
            fileList = null;

            
        }
开发者ID:erendrake,项目名称:AGExt,代码行数:57,代码来源:Editor.cs

示例3: OnSave

        public override void OnSave(ConfigNode local, ConfigNode type, ConfigNode global)
        {
            base.OnSave(local, type, global);

            if (local == null) return;

            if (local.HasNode("Waypoints")) { local.RemoveNode("Waypoints"); }
            if (Waypoints.Count > 0) {
                ConfigNode cn = local.AddNode("Waypoints");
                cn.AddValue("Index", WaypointIndex);
                foreach (MechJebRoverWaypoint wp in Waypoints) {
                    cn.AddNode(wp.ToConfigNode());
                }
            }
        }
开发者ID:KaiSforza,项目名称:MechJeb2,代码行数:15,代码来源:MechJebModuleRoverController.cs

示例4: DoConfig

        public virtual void DoConfig(ConfigNode cfg)
        {
            configMaxThrust = configMinThrust = configHeat = -1f;
            // Get thrusts
            if (config.HasValue(thrustRating))
            {
                float thr;
                if (float.TryParse(config.GetValue(thrustRating), out thr))
                    configMaxThrust = scale * thr;
            }
            if (config.HasValue("minThrust"))
            {
                float thr;
                if (float.TryParse(config.GetValue("minThrust"), out thr))
                    configMinThrust = scale * thr;
            }

            // Get, multiply heat
            if (cfg.HasValue("heatProduction"))
            {
                float heat;
                if(float.TryParse(cfg.GetValue("heatProduction"), out heat))
                    configHeat = (float)Math.Round(heat * RFSettings.Instance.heatMultiplier, 0);
            }

            // load throttle (for later)
            configThrottle = throttle;
            if (cfg.HasValue("throttle"))
                float.TryParse(cfg.GetValue("throttle"), out configThrottle);
            else if (configMinThrust >= 0f && configMaxThrust >= 0f)
                configThrottle = configMinThrust / configMaxThrust;

            float TLMassMult = 1.0f;

            float gimbal = -1f;
            if (cfg.HasValue("gimbalRange"))
                gimbal = float.Parse(cfg.GetValue("gimbalRange"));

            float cost = 0f;
            if (cfg.HasValue("cost"))
                cost = scale * float.Parse(cfg.GetValue("cost"));

            if (techLevel != -1)
            {
                // load techlevels
                TechLevel cTL = new TechLevel();
                cTL.Load(cfg, techNodes, engineType, techLevel);
                TechLevel oTL = new TechLevel();
                oTL.Load(cfg, techNodes, engineType, origTechLevel);

                // set atmosphereCurve
                if (cfg.HasValue("IspSL") && cfg.HasValue("IspV"))
                {
                    cfg.RemoveNode("atmosphereCurve");

                    ConfigNode curve = new ConfigNode("atmosphereCurve");

                    // get the multipliers
                    float ispSL = 1f, ispV = 1f;
                    float.TryParse(cfg.GetValue("IspSL"), out ispSL);
                    float.TryParse(cfg.GetValue("IspV"), out ispV);

                    // Mod the curve by the multipliers
                    FloatCurve newAtmoCurve = new FloatCurve();
                    newAtmoCurve = Utilities.Mod(cTL.AtmosphereCurve, ispSL, ispV);
                    newAtmoCurve.Save(curve);

                    cfg.AddNode(curve);
                }

                // set heatProduction
                if (configHeat > 0)
                {
                    configHeat = MassTL(configHeat);
                }

                // set thrust and throttle
                if (configMaxThrust >= 0)
                {
                    configMaxThrust = ThrustTL(configMaxThrust);
                    if (configMinThrust >= 0)
                    {
                        configMinThrust = ThrustTL(configMinThrust);
                    }
                    else if (thrustRating.Equals("thrusterPower"))
                    {
                        configMinThrust = configMaxThrust * 0.5f;
                    }
                    else
                    {
                        configMinThrust = configMaxThrust;
                        if (configThrottle > 1.0f)
                        {
                            if (techLevel >= configThrottle)
                                configThrottle = 1.0f;
                            else
                                configThrottle = -1.0f;
                        }
                        if (configThrottle >= 0.0f)
                        {
//.........这里部分代码省略.........
开发者ID:qipa,项目名称:ModularFuelSystem,代码行数:101,代码来源:ModuleEngineConfigs.cs

示例5: ModifyEngineConfigNode

        public static void ModifyEngineConfigNode(ConfigNode engine, float ispMultiplierVac, float ispMultiplierAtm, bool extendToZeroIsp)
        {
            ConfigNode atmoCurve = engine.GetNode("atmosphereCurve");

            FloatCurve engineCurve = ModifyCurveKeys(atmoCurve, ispMultiplierVac, ispMultiplierAtm, extendToZeroIsp);
            atmoCurve = new ConfigNode("atmosphereCurve");
            engineCurve.Save(atmoCurve);
            engine.RemoveNode("atmosphereCurve");
            engine.AddNode(atmoCurve);
        }
开发者ID:stevehead,项目名称:Kerbal-Isp-Difficulty-Scaler,代码行数:10,代码来源:KerbalIspDifficultyScaler.cs

示例6: WriteNode

        public static void WriteNode(ConfigNode newNode)
        {
            var fileInfo = new FileInfo(GetSaveFilePath());
            ConfigNode persistenceNode;
            if (!fileInfo.Exists)
            {
                var cNode = new ConfigNode();
                persistenceNode = cNode.AddNode("KerbTownPersistence");
                persistenceNode.AddNode(newNode);
                cNode.Save(fileInfo.FullName);

                _ktSave = cNode;
                return;
            }

            _ktSave = ConfigNode.Load(fileInfo.FullName);
            persistenceNode = _ktSave.GetNode("KerbTownPersistence");

            var nodes = persistenceNode.GetNodes(newNode.name);
            var rootID = newNode.GetValue("ID");
            bool nodeSet = false;

            foreach (var node in from node in nodes let nodeID = node.GetValue("ID") where nodeID == rootID select node)
            {
                persistenceNode.nodes.Remove(node);
                persistenceNode.nodes.Add(newNode);
                nodeSet = true;
            }

            if (nodeSet == false)
            {
                persistenceNode.nodes.Add(newNode);
            }

            _ktSave.RemoveNode("KerbTownPersistence");
            _ktSave.AddNode(persistenceNode);

            _ktSave.Save(GetSaveFilePath());

            // Note: SetNode() isn't recursive on descendant ConfigNodes
        }
开发者ID:vosechu,项目名称:KerbTown,代码行数:41,代码来源:Extensions.cs

示例7: saveSettings

        internal void saveSettings(ConfigNode toolbarNode)
        {
            Log.info("saving toolbar settings (toolbar '{0}')", toolbarNode.name);

            toolbarNode.overwrite("x", rect.x.ToString("F0"));
            toolbarNode.overwrite("y", rect.y.ToString("F0"));
            toolbarNode.overwrite("width", savedMaxWidth.ToString("F0"));
            toolbarNode.overwrite("height", rect.height.ToString("F0"));
            toolbarNode.overwrite("autoHide", autoHide.ToString());
            toolbarNode.overwrite("drawBorder", showBorder.ToString());
            toolbarNode.overwrite("useKSPSkin", UseKSPSkin.ToString());
            toolbarNode.overwrite("buttonOrder", string.Join(",", savedButtonOrder.ToArray()));
            toolbarNode.overwrite("visibleButtons", string.Join(",", savedVisibleButtons.ToArray()));

            ConfigNode foldersNode = toolbarNode.overwriteNode("folders");
            foreach (KeyValuePair<string, FolderSettings> entry in savedFolderSettings) {
                ConfigNode folderNode = foldersNode.getOrCreateNode(entry.Key);
                folderNode.overwrite("texturePath", entry.Value.texturePath ?? "000_Toolbar/folder");
                folderNode.overwrite("toolTip", entry.Value.toolTip ?? string.Empty);
                folderNode.overwrite("buttons", string.Join(",", entry.Value.buttons.ToArray()));
            }
            if (foldersNode.CountNodes == 0) {
                toolbarNode.RemoveNode("folders");
            }
        }
开发者ID:kevin-ye,项目名称:ksp_toolbar,代码行数:25,代码来源:Toolbar.cs

示例8: Save

        /// <summary>
        /// Saves all values for the flightcomputer to the persistant
        /// </summary>
        /// <param name="n">Node to save in</param>
        public void Save(ConfigNode n)
        {
            if (n.HasNode("FlightComputer"))
                n.RemoveNode("FlightComputer");

            ConfigNode ActiveCommands = new ConfigNode("ActiveCommands");
            ConfigNode Commands = new ConfigNode("Commands");

            foreach (KeyValuePair<int, ICommand> cmd in mActiveCommands)
            {
                // Save each active command on his own node
                ConfigNode activeCommandNode = new ConfigNode(cmd.Value.GetType().Name);
                cmd.Value.Save(activeCommandNode, this);
                ActiveCommands.AddNode(activeCommandNode);
            }

            foreach (ICommand cmd in mCommandQueue)
            {
                // Save each command on his own node
                ConfigNode commandNode = new ConfigNode(cmd.GetType().Name);
                cmd.Save(commandNode, this);
                Commands.AddNode(commandNode);
            }

            ConfigNode FlightNode = new ConfigNode("FlightComputer");
            FlightNode.AddValue("TotalDelay", TotalDelay);
            FlightNode.AddNode(ActiveCommands);
            FlightNode.AddNode(Commands);

            n.AddNode(FlightNode);
        }
开发者ID:icedown,项目名称:RemoteTech,代码行数:35,代码来源:FlightComputer.cs

示例9: Save

        /// <summary>Saves all values for the flight computer to the persistent.</summary>
        /// <param name="n">Node to save in</param>
        public void Save(ConfigNode n)
        {
            if (n.HasNode("FlightComputer"))
                n.RemoveNode("FlightComputer");

            var activeCommands = new ConfigNode("ActiveCommands");
            var commands = new ConfigNode("Commands");

            // save active commands
            foreach (var cmd in _activeCommands)
            {
                // Save each active command on his own node
                var activeCommandNode = new ConfigNode(cmd.Value.GetType().Name);
                cmd.Value.Save(activeCommandNode, this);
                activeCommands.AddNode(activeCommandNode);
            }

            // save commands
            foreach (var cmd in _commandQueue)
            {
                // Save each command on his own node
                var commandNode = new ConfigNode(cmd.GetType().Name);
                cmd.Save(commandNode, this);
                commands.AddNode(commandNode);
            }

            var flightNode = new ConfigNode("FlightComputer");
            flightNode.AddValue("TotalDelay", TotalDelay);
            flightNode.AddNode(activeCommands);
            flightNode.AddNode(commands);

            n.AddNode(flightNode);
        }
开发者ID:RemoteTechnologiesGroup,项目名称:RemoteTech,代码行数:35,代码来源:FlightComputer.cs

示例10: CheckFilesChange

        private bool CheckFilesChange(UrlDir.UrlFile[] files, ConfigNode shaConfigNode)
        {
            bool noChange = true;
            StringBuilder changes = new StringBuilder();
            
            for (int i = 0; i < files.Length; i++)
            {
                ConfigNode fileNode = getFileNode(shaConfigNode, files[i].url);
                string fileSha = fileNode != null ? fileNode.GetValue("SHA") : null;

                if (fileNode == null)
                    continue;

                if (fileSha == null || filesSha[files[i].url] != fileSha)
                {
                    changes.Append("Changed : " + fileNode.GetValue("filename") + ".cfg\n");
                    noChange = false;
                }
            }
            for (int i = 0; i < files.Length; i++)
            {
                ConfigNode fileNode = getFileNode(shaConfigNode, files[i].url);

                if (fileNode == null)
                {
                    changes.Append("Added   : " + files[i].url + ".cfg\n");
                    noChange = false;
                }
                shaConfigNode.RemoveNode(fileNode);
            }
            foreach (ConfigNode fileNode in shaConfigNode.GetNodes())
            {
                changes.Append("Deleted : " + fileNode.GetValue("filename") + ".cfg\n");
                noChange = false;
            }
            if (!noChange)
                log("Changes :\n" + changes.ToString());
            return noChange;
        }
开发者ID:Kerbas-ad-astra,项目名称:ModuleManager,代码行数:39,代码来源:moduleManager.cs

示例11: DoConfig

        virtual public void DoConfig(ConfigNode cfg)
        {
            // fix propellant ratios to not be rounded
            if (cfg.HasNode("PROPELLANT"))
            {
                foreach (ConfigNode pNode in cfg.GetNodes("PROPELLANT"))
                {
                    if (pNode.HasValue("ratio"))
                    {
                        double dtmp;
                        if (double.TryParse(pNode.GetValue("ratio"), out dtmp))
                            pNode.SetValue("ratio", (dtmp * 100.0).ToString());
                    }
                }
            }
            float heat = -1;
            if (cfg.HasValue("heatProduction")) // ohai amsi: allow heat production to be changed by multiplier
            {
                heat = (float)Math.Round(float.Parse(cfg.GetValue("heatProduction")) * heatMult, 0);
                cfg.SetValue("heatProduction", heat.ToString());
            }

            // load throttle (for later)
            curThrottle = throttle;
            if (cfg.HasValue("throttle"))
                float.TryParse(cfg.GetValue("throttle"), out curThrottle);
            else if(cfg.HasValue("minThrust") && cfg.HasValue("maxThrust"))
                curThrottle = float.Parse(cfg.GetValue("minThrust")) / float.Parse(cfg.GetValue("maxThrust"));
            float TLMassMult = 1.0f;
            if (techLevel != -1)
            {
                // load techlevels
                TechLevel cTL = new TechLevel();
                //print("For engine " + part.name + ", config " + configuration + ", max TL: " + TechLevel.MaxTL(cfg, techNodes, engineType));
                cTL.Load(cfg, techNodes, engineType, techLevel);
                TechLevel oTL = new TechLevel();
                oTL.Load(cfg, techNodes, engineType, origTechLevel);


                // set atmosphereCurve
                if (cfg.HasValue("IspSL") && cfg.HasValue("IspV"))
                {
                    cfg.RemoveNode("atmosphereCurve");
                    ConfigNode curve = new ConfigNode("atmosphereCurve");
                    float ispSL, ispV;
                    float.TryParse(cfg.GetValue("IspSL"), out ispSL);
                    float.TryParse(cfg.GetValue("IspV"), out ispV);
                    FloatCurve aC = new FloatCurve();
                    aC = Mod(cTL.atmosphereCurve, ispSL, ispV);
                    aC.Save(curve);
                    cfg.AddNode(curve);
                }

                // set heatProduction and dissipation
                if (heat > 0)
                {
                    cfg.SetValue("heatProduction", MassTL(heat).ToString("0"));
                    part.heatDissipation = 0.12f / MassTL(1.0f);
                }

                // set thrust and throttle
                if (cfg.HasValue(thrustRating))
                {
                    float thr;
                    float.TryParse(cfg.GetValue(thrustRating), out thr);
                    configMaxThrust = ThrustTL(thr);
                    cfg.SetValue(thrustRating, configMaxThrust.ToString("0.0000"));
                    if (cfg.HasValue("minThrust"))
                    {
                        float.TryParse(cfg.GetValue("minThrust"), out thr);
                        configMinThrust = ThrustTL(thr);
                        cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
                    }
                    else
                    {
                        if (thrustRating.Equals("thrusterPower"))
                        {
                            configMinThrust = configMaxThrust * 0.5f;
                        }
                        else
                        {
                            configMinThrust = configMaxThrust;
                            if (curThrottle > 1.0f)
                            {
                                if (techLevel >= curThrottle)
                                    curThrottle = 1.0f;
                                else
                                    curThrottle = -1.0f;
                            }
                            if (curThrottle >= 0.0f)
                            {
                                curThrottle = (float)((double)curThrottle * cTL.Throttle());
                                configMinThrust *= curThrottle;
                            }
                            cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
                        }
                    }
                    curThrottle = configMinThrust / configMaxThrust;
                    if(origMass > 0)
                         TLMassMult =  MassTL(1.0f);
//.........这里部分代码省略.........
开发者ID:aoighost,项目名称:ModularFuelSystem,代码行数:101,代码来源:ModularEngines.cs

示例12: DoConfig

        public virtual void DoConfig(ConfigNode cfg)
        {
            // fix propellant ratios to not be rounded
            if (cfg.HasNode("PROPELLANT"))
            {
                foreach (ConfigNode pNode in cfg.GetNodes("PROPELLANT"))
                {
                    if (pNode.HasValue("ratio"))
                    {
                        double dtmp;
                        if (double.TryParse(pNode.GetValue("ratio"), out dtmp))
                            pNode.SetValue("ratio", (dtmp * 100.0).ToString());
                    }
                }
            }
            float heat = -1;
            if (cfg.HasValue("heatProduction")) // ohai amsi: allow heat production to be changed by multiplier
            {
                heat = (float)Math.Round(float.Parse(cfg.GetValue("heatProduction")) * heatMult, 0);
                cfg.SetValue("heatProduction", heat.ToString());
            }

            // load throttle (for later)
            curThrottle = throttle;
            if (cfg.HasValue("throttle"))
                float.TryParse(cfg.GetValue("throttle"), out curThrottle);
            else if(cfg.HasValue("minThrust") && cfg.HasValue("maxThrust"))
                curThrottle = float.Parse(cfg.GetValue("minThrust")) / float.Parse(cfg.GetValue("maxThrust"));
            float TLMassMult = 1.0f;

            float gimbal = -1f;
            if (cfg.HasValue("gimbalRange"))
                gimbal = float.Parse(cfg.GetValue("gimbalRange"));

            float cost = 0f;
            if(cfg.HasValue("cost"))
                cost = float.Parse(cfg.GetValue("cost"));

            if (techLevel != -1)
            {
                // load techlevels
                TechLevel cTL = new TechLevel();
                //print("For engine " + part.name + ", config " + configuration + ", max TL: " + TechLevel.MaxTL(cfg, techNodes, engineType));
                cTL.Load(cfg, techNodes, engineType, techLevel);
                TechLevel oTL = new TechLevel();
                oTL.Load(cfg, techNodes, engineType, origTechLevel);

                // set atmosphereCurve
                if (cfg.HasValue("IspSL") && cfg.HasValue("IspV"))
                {
                    cfg.RemoveNode("atmosphereCurve");
                    ConfigNode curve = new ConfigNode("atmosphereCurve");
                    float ispSL, ispV;
                    float.TryParse(cfg.GetValue("IspSL"), out ispSL);
                    float.TryParse(cfg.GetValue("IspV"), out ispV);
                    FloatCurve aC = new FloatCurve();
                    aC = Mod(cTL.AtmosphereCurve, ispSL, ispV);
                    aC.Save(curve);
                    cfg.AddNode(curve);
                }

                // set heatProduction and dissipation
                if (heat > 0)
                {
                    cfg.SetValue("heatProduction", MassTL(heat).ToString("0"));
                    part.heatDissipation = 0.12f / MassTL(1.0f);
                }

                // set thrust and throttle
                if (cfg.HasValue(thrustRating))
                {
                    float thr;
                    float.TryParse(cfg.GetValue(thrustRating), out thr);
                    configMaxThrust = ThrustTL(thr);
                    cfg.SetValue(thrustRating, configMaxThrust.ToString("0.0000"));
                    if (cfg.HasValue("minThrust"))
                    {
                        float.TryParse(cfg.GetValue("minThrust"), out thr);
                        configMinThrust = ThrustTL(thr);
                        cfg.SetValue("minThrust", configMinThrust.ToString("0.0000"));
                    }
                    else
                    {
                        if (thrustRating.Equals("thrusterPower"))
                        {
                            configMinThrust = configMaxThrust * 0.5f;
                        }
                        else
                        {
                            configMinThrust = configMaxThrust;
                            if (curThrottle > 1.0f)
                            {
                                if (techLevel >= curThrottle)
                                    curThrottle = 1.0f;
                                else
                                    curThrottle = -1.0f;
                            }
                            if (curThrottle >= 0.0f)
                            {
                                curThrottle = (float)((double)curThrottle * cTL.Throttle());
//.........这里部分代码省略.........
开发者ID:Kerbas-ad-astra,项目名称:ModularFuelSystem,代码行数:101,代码来源:ModularEngines.cs

示例13: OnSave

 public override void OnSave(ConfigNode node)
 {
     ConfigNode c1 = new ConfigNode ("color1");
     c1.AddValue ("red", color1.r);
     c1.AddValue ("green", color1.g);
     c1.AddValue ("blue", color1.b);
     node.AddNode (c1);
     ConfigNode c2 = new ConfigNode ("color2");
     c2.AddValue ("red", color2.r);
     c2.AddValue ("green", color2.g);
     c2.AddValue ("blue", color2.b);
     node.AddNode (c2);
     node.RemoveNode ("texturePattern_UIFlight");
     node.RemoveNode ("textureRepeat_UIFlight");
     node.RemoveNode ("EVENTS");
     node.RemoveNode ("ACTIONS");
     base.OnSave (node);
 }
开发者ID:Kerbas-ad-astra,项目名称:KSPModelRocketry,代码行数:18,代码来源:VariableTexture.cs

示例14: Save

        public void Save(ConfigNode node)
        {
            if (node.HasNode("Processor"))
                node.RemoveNode("Processor");

            ConfigNode Proc = new ConfigNode("Processor");

            Proc.AddValue("isHibernating", isHibernating);
            if (isHibernating)
                Proc.AddValue("hibernationLine", hibernationLine);

            if (pid != null)
                pid.Save(Proc);

            ConfigNode InstList = new ConfigNode("Instructions");
            foreach (Instruction i in instructions)
            {
                ConfigNode Inst = new ConfigNode("Instruction");
                Inst.AddValue("code", i.mText);
                Inst.AddValue("lastValue", i.lastValue);
                Inst.AddValue("skip", i.skip);
                InstList.AddNode(Inst);
            }
            Proc.AddNode(InstList);

            if (latches > 0)
            {
                ConfigNode LatchList = new ConfigNode("Latches");
                for (int i = 0; i < latches; i++)
                    LatchList.AddValue(string.Format("latch{0:D}", i), latchState[i].ToString());
                Proc.AddNode(LatchList);
            }

            if (timers > 0)
            {
                ConfigNode TimerList = new ConfigNode("Timers");
                for (int i = 0; i < timers; i++)
                    TimerList.AddValue(timerState[i].name, timerState[i].startTime);
                Proc.AddNode(TimerList);
            }

            node.AddNode(Proc);
        }
开发者ID:kjoenth,项目名称:kpu_mod,代码行数:43,代码来源:Processor.cs

示例15: LoadData

        public void LoadData()
        {
            data = ConfigNode.Load(FilePath);
            bool StationKeepingfound = false;
            bool DecayTimefound = false;

            foreach (ConfigNode vessel in data.nodes)
            {
                string id = vessel.GetValue("id");
                bool stationkeeping = bool.Parse(vessel.GetValue("stationkeeping"));
                float decaytime = float.Parse(vessel.GetValue("decaytime"));
                bool vesseldead = false;
                foreach (Vessel vess in FlightGlobals.Vessels)
                {
                    if (vess.id.ToString() == id)
                    {
                        if (vess.state == Vessel.State.DEAD)
                        {
                            data.RemoveNode(vessel);
                            StationKeeping.Remove(vess.id);
                            CanStationKeep.Remove(vess.id);
                            DecayTimes.Remove(vess.id);
                            DisplayedDecayTimes.Remove(vess);
                            vesseldead = true;
                            break;
                        }
                    }
                }
                if (vesseldead == true)
                {
                    break;
                }

                foreach (Guid ship in StationKeeping.Keys)
                {
                    if (ship.ToString() == id)
                    {
                        StationKeeping.Remove(ship);
                        StationKeeping.Add(ship, stationkeeping);
                        StationKeepingfound = true;
                        break;
                    }

                    if (StationKeepingfound == false)
                    {
                    }
                }
                foreach (Guid ship in DecayTimes.Keys)
                {
                    if (ship.ToString() == id)
                    {
                        DecayTimes.Remove(ship);
                        DecayTimes.Add(ship, decaytime);
                        DecayTimefound = true;
                        break;
                    }

                    if (DecayTimefound == false)
                    {
                    }
                }
            }
        }
开发者ID:Whitecat106,项目名称:KSP-Orbital-Decay-,代码行数:63,代码来源:VesselData.cs


注:本文中的System.ConfigNode.RemoveNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。