public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            if (configNode.HasValue("passengerName"))
            {
                LoggingUtil.LogWarning(this, "The passengerName and gender attributes are obsolete since Contract Configurator 1.9.0, use kerbal instead.");
                valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "passengerName", x => passengerName = x, this, new List<string>());
                valid &= ConfigNodeUtil.ParseValue<ProtoCrewMember.Gender>(configNode, "gender", x => gender = x, this, Kerbal.RandomGender());
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "experienceTrait", x => experienceTrait = x, this, Kerbal.RandomExperienceTrait());

                legacy = true;
            }
            else
            {
                valid &= ConfigNodeUtil.ParseValue<List<Kerbal>>(configNode, "kerbal", x => kerbals = x, this, new List<Kerbal>());
                legacy = false;
            }

            valid &= ConfigNodeUtil.ParseValue<int>(configNode, "count", x => count = x, this, 1, x => Validation.GE(x, 1));
            valid &= ConfigNodeUtil.ParseValue<ProtoCrewMember.KerbalType>(configNode, "kerbalType", x => kerbalType = x, this, ProtoCrewMember.KerbalType.Tourist);

            return valid;
        }
        public MappedVariable(ConfigNode node, RasterPropMonitorComputer rpmComp)
        {
            if (!node.HasValue("mappedVariable") || !node.HasValue("mappedRange") || !node.HasValue("sourceVariable") || !node.HasValue("sourceRange"))
            {
                throw new ArgumentException("MappedVariable missing required values");
            }

            string sourceVariableStr = node.GetValue("sourceVariable");
            string sourceRange = node.GetValue("sourceRange");
            string[] sources = sourceRange.Split(',');
            if (sources.Length != 2)
            {
                throw new ArgumentException("MappedVariable sourceRange does not have exactly two values");
            }

            sourceVariable = new VariableOrNumberRange(rpmComp, sourceVariableStr, sources[0], sources[1]);

            mappedVariable = node.GetValue("mappedVariable");
            string[] destinations = node.GetValue("mappedRange").Split(',');
            if (destinations.Length != 2)
            {
                throw new ArgumentException("MappedVariable mappedRange does not have exactly two values");
            }
            mappedExtent1 = rpmComp.InstantiateVariableOrNumber(destinations[0]);
            mappedExtent2 = rpmComp.InstantiateVariableOrNumber(destinations[1]);
        }
Пример #3
0
        public ScriptV1()
        {
            exception_raised = false;

             tool = new ExternalApp();
             files_to_glue = new List<FileName>();
             replace_list = new Dictionary<string, string>();
             tools_blocks = new Dictionary<string, ConfigNode>();
             practices_block = null;

             tool_fillmatrix_info = null;
             tool_interpolate_info = null;
             tool_glue_info = null;
             tool_jointimeseries_info = null;

             meteo_block = null;
             meteo_sources_blocks = null;
             meteo_file_name = null;
             meteo_backup_files = false;
             meteo_store_path = null;
             meteo_backup_interpolated_files = false;
             meteo_store_int_path = null;
             meteo_interpolation_path = null;
             meteo_max_contiguous_skips = 8;
             meteo_task = false;
             tool_glue = new HDFGlue();

             standard_names = true;
        }
Пример #4
0
        public override void OnRedecorateModule(ConfigNode templateNode, bool payForRedecoration)
        {
            Log("OnRedecorateModule called");

            //Load the modules
            loadModulesFromTemplate(templateNode);
        }
Пример #5
0
 /// <summary>
 /// Save settings to the underlying storage
 /// </summary>
 public void Save()
 {
     ConfigNode node = AsConfigNode;
     var clsNode = new ConfigNode (GetType ().Name);
     clsNode.AddNode (node);
     clsNode.Save (filePath);
 }
Пример #6
0
 /// <summary>
 /// Creates a new ChuteTemplate from the given ProceduralChute
 /// </summary>
 /// <param name="pChute">Module to create the object from</param>
 /// <param name="node">ConfigNode to load the data from</param>
 /// <param name="id">Index of the ChuteTemplate</param>
 public ChuteTemplate(ProceduralChute pChute, ConfigNode node, int id)
 {
     this.pChute = pChute;
     this.id = id;
     this.templateGUI = new TemplateGUI(this);
     if (node != null) { Load(node); }
 }
        public void Load(ConfigNode node)
        {
            unlocked = false;

            node.TryGetValue("name", ref name);

            double cost = 0d;
            node.TryGetValue("cost", ref cost);

            node.TryGetValue("entryCost", ref entryCost);
            if(double.IsNaN(entryCost))
                entryCost = Math.Max(0d, cost * RFSettings.Instance.configEntryCostMultiplier);

            node.TryGetValue("sciEntryCost", ref sciEntryCost);
            if(double.IsNaN(sciEntryCost))
                sciEntryCost = Math.Max(0d, cost * RFSettings.Instance.configScienceCostMultiplier);

            node.TryGetValue("unlocked", ref unlocked);

            node.TryGetValue("techRequired", ref techRequired);

            if (node.HasNode("entryCostMultipliers"))
                LoadMultipliers(node.GetNode("entryCostMultipliers"));

            if (node.HasNode("entryCostSubtractors"))
                LoadSubtractors(node.GetNode("entryCostSubtractors"));

            node.TryGetValue("maxSubtraction", ref maxSubtraction);
        }
Пример #8
0
 public static string GetValueDefault(ConfigNode node, string name, string vale)
 {
     if (node.HasValue(name))
         vale = (node.GetValue(name));
     //else Debug.Log("*MCEPC key not found: " + name);
     return vale;
 }
Пример #9
0
 protected override void OnParameterLoad(ConfigNode node)
 {
     duration = Convert.ToDouble(node.GetValue("duration"));
     endTime = Convert.ToDouble(node.GetValue("endTime"));
     timerType = ConfigNodeUtil.ParseValue<TimerType>(node, "timerType", TimerType.CONTRACT_ACCEPTANCE);
     parameter = ConfigNodeUtil.ParseValue<string>(node, "parameter", "");
 }
 protected sealed override void OnSave(ConfigNode node)
 {
     try
     {
         if (Root != null)
         {
             node.AddValue("ContractIdentifier", Root.ToString());
         }
         node.AddValue("title", title ?? "");
         node.AddValue("notes", notes ?? "");
         node.AddValue("completedMessage", completedMessage ?? "");
         if (completeInSequence)
         {
             node.AddValue("completeInSequence", completeInSequence);
         }
         if (hidden)
         {
             node.AddValue("hidden", hidden);
         }
         if (hideChildren)
         {
             node.AddValue("hideChildren", hideChildren);
         }
         if (fakeFailures)
         {
             node.AddValue("fakeFailures", fakeFailures);
         }
         OnParameterSave(node);
     }
     catch (Exception e)
     {
         LoggingUtil.LogException(e);
         ExceptionLogWindow.DisplayFatalException(ExceptionLogWindow.ExceptionSituation.PARAMETER_SAVE, e, Root.ToString(), ID);
     }
 }
Пример #11
0
 public static int GetValueDefault(ConfigNode node, string name, int val)
 {
     if (node.HasValue(name))
         val = atoi(node.GetValue(name));
     //else Debug.Log("*MCEPC key not found: " + name);
     return val;
 }
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<List<VesselIdentifier>>(configNode, "vessel", x => vessels = x, this, new List<VesselIdentifier>());
            valid &= ConfigNodeUtil.ParseValue<VesselIdentifier>(configNode, "defineDockedVessel", x => defineDockedVessel = x, this, (VesselIdentifier)null);

            // Validate using the config node instead of the list as it may undergo deferred loading
            if (parent is VesselParameterGroupFactory)
            {
                if (configNode.GetValues("vessel").Count() > 1)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": When used under a VesselParameterGroup, no more than one vessel may be specified for the Docking parameter.");
                    valid = false;
                }
            }
            else
            {
                if (configNode.GetValues("vessel").Count() == 0)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": Need at least one vessel specified for the Docking parameter.");
                    valid = false;
                }
                if (configNode.GetValues("vessel").Count() > 2)
                {
                    LoggingUtil.LogError(this, ErrorPrefix() + ": Cannot specify more than two vessels for the Docking parameter.");
                    valid = false;
                }
            }

            return valid;
        }
Пример #13
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad(node);
            ConfigNode[] efficiencyNodes = node.GetNodes(kEfficiencyData);
            ConfigNode[] toolTipsShown = node.GetNodes(kToolTip);
            string value = node.GetValue("reputationIndex");

            if (string.IsNullOrEmpty(value) == false)
                reputationIndex = int.Parse(value);

            foreach (ConfigNode efficiencyNode in efficiencyNodes)
            {
                EfficiencyData efficiencyData = new EfficiencyData();
                efficiencyData.Load(efficiencyNode);
                efficiencyDataMap.Add(efficiencyData.Key, efficiencyData);
            }

            foreach (ConfigNode toolTipNode in toolTipsShown)
            {
                if (toolTipNode.HasValue("name") == false)
                    continue;
                value = toolTipNode.GetValue("name");

                if (toolTips.ContainsKey(value))
                    toolTips[value] = toolTipNode;
                else
                    toolTips.Add(value, toolTipNode);
            }
        }
Пример #14
0
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);
            node.AddValue("selectedObject", selectedObject.ToString());

            node.AddValue("showGui", showGui.ToString());
        }
        protected override void OnLoadFromConfig(ConfigNode node)
        {
            base.OnLoadFromConfig(node);

            rewardFunds = ConfigNodeUtil.ParseValue<double>(node, "rewardFunds");
            explorationType = ConfigNodeUtil.ParseValue<ExplorationType>(node, "explorationType");
        }
Пример #16
0
        public static ConfigNode ToConfigNode(this HarddiskFile file, string nodeName)
        {
            var node = new ConfigNode(nodeName);
            node.AddValue(FilenameValueString, file.Name);

            FileContent content = file.ReadAll();

            if (content.Category == FileCategory.KSM)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else if (content.Category == FileCategory.BINARY)
            {
                node.AddValue("binary", PersistenceUtilities.EncodeBase64(content.Bytes));
            }
            else
            {
                if (SafeHouse.Config.UseCompressedPersistence)
                {
                    node.AddValue("binary", EncodeBase64(content.String));
                }
                else
                {
                    node.AddValue("ascii", PersistenceUtilities.EncodeLine(content.String));
                }
            }
            return node;
        }
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<Vessel.Situations>(configNode, "situation", x => situation = x, this, Vessel.Situations.ORBITING, ValidateSituations);
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minAltitude", x => minAltitude = x, this, 0.0, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxAltitude", x => maxAltitude = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minApA", x => minApoapsis = x, this, 0.0, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxApA", x => maxApoapsis = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minPeA", x => minPeriapsis = x, this, 0.0, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxPeA", x => maxPeriapsis = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minEccentricity", x => minEccentricity = x, this, 0.0, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxEccentricity", x => maxEccentricity = x, this, double.MaxValue, x => Validation.GE(x, 0.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "minInclination", x => minInclination = x, this, 0.0, x => Validation.Between(x, 0.0, 180.0));
            valid &= ConfigNodeUtil.ParseValue<double>(configNode, "maxInclination", x => maxInclination = x, this, 180.0, x => Validation.Between(x, 0.0, 180.0));
            valid &= ConfigNodeUtil.ParseValue<Duration>(configNode, "minPeriod", x => minPeriod = x, this, new Duration(0.0));
            valid &= ConfigNodeUtil.ParseValue<Duration>(configNode, "maxPeriod", x => maxPeriod = x, this, new Duration(double.MaxValue));

            // Validate target body
            valid &= ValidateTargetBody(configNode);

            // Validation minimum and groupings
            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "minAltitude", "maxAltitude", "minApA", "maxApA", "minPeA", "maxPeA",
                "minEccentricity", "maxEccentricity", "minInclination", "maxInclination", "minPeriod", "maxPeriod" }, this);
            valid &= ConfigNodeUtil.MutuallyExclusive(configNode, new string[] { "minAltitude", "maxAltitude" },
                new string[] { "minApA", "maxApA", "minPeA", "maxPeA" }, this);

            return valid;
        }
Пример #18
0
 internal static AlarmInfo Load(ConfigNode node)
 {
     Guid vesselID = Utilities.GetNodeValue(node, "vesselID");
     string Name = Utilities.GetNodeValue(node, "Name", string.Empty);
     AlarmInfo info = new AlarmInfo(Name, vesselID);
     info.AlarmType = Utilities.GetNodeValue(node, "AlarmType", KACWrapper.KACAPI.AlarmTypeEnum.Raw);
     info.Notes = Utilities.GetNodeValue(node, "Notes", string.Empty);
     info.AlarmTime = Utilities.GetNodeValue(node, "AlarmTime", 0d);
     info.AlarmMargin = Utilities.GetNodeValue(node, "AlarmMargin", 0d);
     info.AlarmExecute = Utilities.GetNodeValue(node, "AlarmExecute", false);
     string frzkbllst = Utilities.GetNodeValue(node, "FrzKerbals", string.Empty);
     string thwkbllst = Utilities.GetNodeValue(node, "ThwKerbals", string.Empty);
     string[] frzStrings = frzkbllst.Split(',');
     if (frzStrings.Length > 0)
     {
         for (int i = 0; i < frzStrings.Length; i++)
         {
             info.FrzKerbals.Add(frzStrings[i]);
         }
     }
     string[] thwStrings = thwkbllst.Split(',');
     if (thwStrings.Length > 0)
     {
         for (int i = 0; i < thwStrings.Length; i++)
         {
             if (thwStrings[i].Length > 0)
                 info.ThwKerbals.Add(thwStrings[i]);
         }
     }
     return info;
 }
Пример #19
0
        public CustomVariable(ConfigNode node)
        {
            name = node.GetValue("name");

            foreach (ConfigNode sourceVarNode in node.GetNodes("SOURCE_VARIABLE")) {
                SourceVariable sourceVar = new SourceVariable(sourceVarNode);

                sourceVariables.Add(sourceVar);
            }

            if(sourceVariables.Count == 0) {
                throw new ArgumentException("Did not find any SOURCE_VARIABLE nodes in RPM_CUSTOM_VARIABLE", name);
            }

            string oper = node.GetValue("operator");
            if (oper == Operator.NONE.ToString()) {
                op = Operator.NONE;
            } else if (oper == Operator.AND.ToString()) {
                op = Operator.AND;
            } else if (oper == Operator.OR.ToString()) {
                op = Operator.OR;
            } else if (oper == Operator.XOR.ToString()) {
                op = Operator.XOR;
            } else {
                throw new ArgumentException("Found an invalid operator type in RPM_CUSTOM_VARIABLE", oper);
            }
        }
            public BodyDeposits(GeneratorConfiguration resource, ConfigNode node)
            {
                if (node == null) { node = new ConfigNode(); }

                this.deposits = new List<Deposit>();
                this.seed = Misc.Parse(node.GetValue("Seed"), seedGenerator.Next());

                var random = new System.Random(seed);

                for (int i = 0; i < resource.DepositCount; i++)
                {
                    float R = random.Range(resource.MinRadius, resource.MaxRadius);
                    for (int j = 0; j < resource.NumberOfTries; j++)
                    {
                        Vector2 Pos = new Vector2(random.Range(R, 360 - R), random.Range(R, 180 - R));
                        var deposit = Deposit.Generate(Pos, R, random, resource);
                        if (!deposits.Any(d => d.Shape.Vertices.Any(v => deposit.Shape.PointInPolygon(new Vector2(v.x, v.y)))) && !deposit.Shape.Vertices.Any(v => deposits.Any(d => d.Shape.PointInPolygon(new Vector2(v.x, v.y)))))
                        {
                            deposits.Add(deposit);
                            break;
                        }
                    }
                }

                var depositValues = node.GetValues("Deposit");
                for (int i = 0; i < Math.Min(deposits.Count, depositValues.Length); i++)
                {
                    deposits[i].Quantity = Misc.Parse(depositValues[i], deposits[i].InitialQuantity);
                }

                MaxQuantity = resource.MaxQuantity;
            }
Пример #21
0
 /// <summary>
 /// Load the saved TargetCommand. Open a new ITargetable object by
 /// the objects id.
 /// </summary>
 /// <param name="n">Node with the command infos</param>
 /// <param name="fc">Current flightcomputer</param>
 /// <returns>true - loaded successfull</returns>
 public override bool Load(ConfigNode n, FlightComputer fc)
 {
     if(base.Load(n, fc))
     {
         switch (TargetType)
         {
             case "Vessel":
                 {
                     Guid Vesselid = new Guid(TargetId);
                     Target = RTUtil.GetVesselById(Vesselid);
                     break;
                 }
             case "CelestialBody":
                 {
                     Target = FlightGlobals.Bodies.ElementAt(int.Parse(TargetId));
                     break;
                 }
             default:
                 {
                     Target = null;
                     break;
                 }
         }
         return true;
     }
     return false;
 }
Пример #22
0
 public void CreateNode(int size, ConfigNodeSubType subType, ConfigNodeType nType, int terminal, [MarshalAs(UnmanagedType.LPWStr)] string text, int textLength, int prefixLength)
 {
     if (nType == ConfigNodeType.Element)
     {
         this.lastProcessed = "<" + text + ">";
         if ((this.parsing || (this.bNoSearchPath && (string.Compare(text, this.treeRootPath[0], StringComparison.OrdinalIgnoreCase) == 0))) || (((this.depth == this.searchDepth) && (this.searchDepth == this.pathDepth)) && (string.Compare(text, this.treeRootPath[this.pathDepth], StringComparison.OrdinalIgnoreCase) == 0)))
         {
             this.parsing = true;
             ConfigNode currentNode = this.currentNode;
             this.currentNode = new ConfigNode(text, currentNode);
             if (this.rootNode == null)
             {
                 this.rootNode = this.currentNode;
             }
             else
             {
                 currentNode.AddChild(this.currentNode);
             }
         }
         else
         {
             this.depth++;
         }
     }
     else if ((nType == ConfigNodeType.PCData) && (this.currentNode != null))
     {
         this.currentNode.Value = text;
     }
 }
Пример #23
0
        public override void OnSave(ConfigNode node)
        {
            base.OnSave(node);
            ConfigNode saveNode;

            if (addedPartModules == null)
            {
                Log("addedPartModules is null");
                return;
            }

            foreach (PartModule addedModule in addedPartModules)
            {
                //Create a node for the module
                saveNode = ConfigNode.CreateConfigFromObject(addedModule);
                if (saveNode == null)
                {
                    Log("save node is null");
                    continue;
                }

                //Tell the module to save its data
                saveNode.name = "WBIMODULE";
                addedModule.Save(saveNode);

                //Add it to our node
                node.AddNode(saveNode);
            }
        }
Пример #24
0
         /***************************************************************************************************************
          * new persistence model
          ***************************************************************************************************************/

         public static void SaveHallOfFame(List<LogbookEntry> logbook, ConfigNode node)
         {
            Log.Info("saving hall of fame (" + logbook.Count + " logbook entries)");

            List<LogbookEntry> logbookCopy = new List<LogbookEntry>(logbook);

            Stopwatch sw = new Stopwatch();
            sw.Start();

            try
            {
               foreach (LogbookEntry entry in logbookCopy)
               {
                  ConfigNode entryNode = new ConfigNode(PERSISTENCE_NODE_ENTRY_NAME);
                  if (Log.IsLogable(Log.LEVEL.DETAIL)) Log.Detail("saving logbook entry " + entry);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_TIME, entry.UniversalTime.ToString());
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_NAME, entry.Name);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_CODE, entry.Code);
                  entryNode.AddValue(Constants.CONFIGNODE_KEY_DATA, entry.Data);
                  node.AddNode(entryNode);
               }
            }
            catch
            {
               Log.Error("exception while saving hall of fame detected; hall of fame may be corrupt");
            }
            finally
            {
               sw.Stop();
               Log.Info("hall of fame saved in " + sw.ElapsedMilliseconds + "ms");
            }
         }
Пример #25
0
        public static bool ReceiveDataExec(ConfigNode data)
        {
            RTLog.Verbose("Received Data via Api.ReceiveDataExec", RTLogLevel.API);
            RTLog.Notify("Data: {0}", data);

            return bool.Parse(data.GetValue("AbortCommand"));
        }
Пример #26
0
        public BitmapFont(ConfigNode node, string nodeUrl)
        {
            id = node.GetValue("id");
            name = node.GetValue("name");
            displayName = node.GetValue("displayName");
            size = int.Parse(node.GetValue("size"));

            UnityEngine.Texture2D texture = Utils.LoadTexture("GameData/" + nodeUrl + ".pngmap", false);

            characterMap = new Dictionary<char, BitmapChar>();
            float h = 0;
            foreach(ConfigNode n in node.GetNodes("ASP_BITMAP_CHAR"))
            {
                BitmapChar cMap = new BitmapChar(n, texture);

                characterMap[cMap.character] = cMap;

                // vh is -ve
                if (cMap.vh < height) h = cMap.vh;
            }

            height = (int) Math.Abs(h);

            UnityEngine.Object.Destroy(texture);
        }
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            valid &= ConfigNodeUtil.ParseValue<string>(configNode, "basename", x => basename = x, this);

            int index = 0;
            foreach (ConfigNode child in ConfigNodeUtil.GetChildNodes(configNode, "CONDITION"))
            {
                DataNode childDataNode = new DataNode("CONDITION_" + index++, dataNode, this);
                try
                {
                    ConfigNodeUtil.SetCurrentDataNode(childDataNode);
                    OpenBase.ConditionDetail cd = new OpenBase.ConditionDetail();
                    valid &= ConfigNodeUtil.ParseValue<OpenBase.ConditionDetail.Condition>(child, "condition", x => cd.condition = x, this);
                    valid &= ConfigNodeUtil.ParseValue<string>(child, "parameter", x => cd.parameter = x, this, "", x => ValidateMandatoryParameter(x, cd.condition));
                    conditions.Add(cd);
                }
                finally
                {
                    ConfigNodeUtil.SetCurrentDataNode(dataNode);
                }
            }
            valid &= ConfigNodeUtil.ValidateMandatoryChild(configNode, "CONDITION", this);

            return valid;
        }
        public override bool Load(ConfigNode configNode)
        {
            // Load base class
            bool valid = base.Load(configNode);

            // Check on active contracts too
            checkOnActiveContract = configNode.HasValue("checkOnActiveContract") ? checkOnActiveContract : true;

            valid &= ConfigNodeUtil.ParseValue<List<string>>(configNode, "tech", x => techs = x, this, new List<string>());

            if (configNode.HasValue("part"))
            {
                List<AvailablePart> parts = new List<AvailablePart>();
                valid &= ConfigNodeUtil.ParseValue<List<AvailablePart>>(configNode, "part", x => parts = x, this);

                foreach (AvailablePart part in parts)
                {
                    techs.AddUnique(part.TechRequired);
                }
            }

            valid &= ConfigNodeUtil.AtLeastOne(configNode, new string[] { "tech", "part" }, this);

            return valid;
        }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     //get settings node and kerbal node
     try
     {
         ConfigNode DataNode = node.GetNode("TerminusData");
         if (DataNode != null)
         {
             ConfigNode TLS_Kerbals = DataNode.GetNode("TLS_Kerbals");
             if (TLS_Kerbals != null)
             {
                 Terminus_Life_Support.TrackedKerbals.Clear();
                 foreach (ConfigNode kiNode in TLS_Kerbals.GetNodes("KerbalInfo"))
                 {
                     KerbalInfo ki = new KerbalInfo();
                     ki.FromConfigNode(kiNode);
                     if (ki.Name != "")
                         Terminus_Life_Support.TrackedKerbals.Add(ki);
                 }
                 Terminus_Life_Support.UpdateKerbalList(true);
             }
         }
     }
     catch (Exception e)
     {
         UnityEngine.Debug.LogException(e);
     }
 }
Пример #30
0
        public ProtoAntenna(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot ppms)
        {
            ConfigNode n = new ConfigNode();
            ppms.Save(n);
            Name = p.partInfo.title;
            try {
                mTarget = new Guid(n.GetValue("RTAntennaTarget"));
                DishRange = Single.Parse(n.GetValue("RTDishRange"));
                DishFactor = Double.Parse(n.GetValue("RTDishFactor"));
                OmniRange = Single.Parse(n.GetValue("RTOmniRange"));
            }
            catch (ArgumentException) {
                mTarget = Guid.Empty;
                DishRange = 0.0f;
                DishFactor = 1.0f;
                OmniRange = 0.0f;
                RTUtil.Log("ProtoAntenna parsing error. Default values assumed.");
            }

            mProtoPart = p;
            mProtoModule = ppms;
            Vessel = v;
            RTUtil.Log("ProtoAntenna: DishRange: {0}, OmniRange: {1}, Name: {2}, DishTarget: {3})",
                DishRange, OmniRange, Vessel.vesselName, DishTarget);
        }