예제 #1
0
        public static void test()
        {
            ConfigNode testNode = new ConfigNode("TESTNODE");
            testNode.AddValue("fooName", "fooValue");

            ConfigNode innerTestNode = new ConfigNode("INNERTESTNODE");
            ConfigNode innerInnerTestNode = new ConfigNode("SUPERINNERTESTNODE");
            innerInnerTestNode.AddValue("superFooName", "superFooValue");
            innerTestNode.AddValue("innerFooName", "innerFooValue");
            innerTestNode.AddNode(innerInnerTestNode);
            testNode.AddNode(innerTestNode);

            innerTestNode = new ConfigNode("INNERTESTNODE2");
            innerTestNode.AddValue("innerFooName2", "innerFooValue2");
            innerTestNode.AddValue("innerFooName2-2", "innerFooValue2-2");
            testNode.AddNode(innerTestNode);


            String data = testNode.ToString();
            MonoBehaviour.print("raw node string: " + data);
            ConfigNode reparsedNode = SSTUNodeUtils.parseConfigNode(data);
            MonoBehaviour.print("new node: " + reparsedNode);

            ConfigNode stockReparsedNode = ConfigNode.Parse(data);
            MonoBehaviour.print("stockNewNode: " + stockReparsedNode.nodes[0]);
        }
예제 #2
0
        public void Load(ConfigNode node)
        {
            Debug.Log("FlightData Load");
            Debug.Log(node.ToString());
            if (node.HasValue("dataDeepSpace"))
                dataDeepSpace = float.Parse(node.GetValue("dataDeepSpace"));
            else
                dataDeepSpace = 0.0f;

            if (node.HasValue("flightTimeDeepSpace"))
                flightTimeDeepSpace = int.Parse(node.GetValue("flightTimeDeepSpace"));
            else
                flightTimeDeepSpace = 0;

            if (node.HasNode("bodyData"))
            {
                if (dataBodies == null)
                    dataBodies = new List<FlightDataBody>();
                else
                    dataBodies.Clear();
                foreach (ConfigNode bodyNode in node.GetNodes("bodyData"))
                {
                    FlightDataBody body = new FlightDataBody();
                    body.Load(bodyNode);
                    dataBodies.Add(body);
                }
            }
        }
예제 #3
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("RENAME") || node.HasNode("DISABLE"))
     {
         configNodeData = node.ToString();
     }
 }
예제 #4
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("TEXTURESET"))
     {
         configNodeData = node.ToString();
     }
     initialize();
 }
예제 #5
0
 public override void OnLoad(ConfigNode node)
 {
     if (configString == null) {
         configString = node.ToString ();
     } else {
         node = ConfigNode.Parse (configString).GetNode ("MODULE");
     }
     CreateSwitchInfos (node);
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { configNodeData = node.ToString(); }
     if (!loadedConfig)
     {
         loadedConfig = true;
         loadConfigData(SSTUConfigNodeUtils.parseConfigNode(configNodeData));
     }
 }
예제 #7
0
        public override void OnLoad(ConfigNode config)
        {
            if (this.configString == null)
            {
                this.configString = config.ToString();
            }
            config = Misc.Parse(configString).GetNode("MODULE");

            resources = config.GetNodes("Resource").Select(n => new Resource(n)).ToList();
        }
예제 #8
0
 public override void OnLoad(ConfigNode node)
 {
     if (configString == null) {
         configString = node.ToString ();
         CreateNodeInfos (node);
     } else {
         ConfigNode n = ConfigNode.Parse (configString).GetNode("MODULE");
         CreateNodeInfos (n);
         LoadNodeInfos (node);
     }
 }
        /// <summary>
        /// Loads the BehaviourFactory from the given ConfigNode.
        /// </summary>
        /// <param name="configNode">ConfigNode to load from</param>
        /// <returns>Whether the load was successful</returns>
        public virtual bool Load(ConfigNode configNode)
        {
            bool valid = true;
            ConfigNodeUtil.SetCurrentDataNode(dataNode);

            // Get name and type
            valid &= ConfigNodeUtil.ParseValue<string>(configNode, "type", x => type = x, this);
            valid &= ConfigNodeUtil.ParseValue<string>(configNode, "name", x => name = x, this, type);

            // Load targetBody
            valid &= ConfigNodeUtil.ParseValue<CelestialBody>(configNode, "targetBody", x => _targetBody = x, this, (CelestialBody)null);

            config = configNode.ToString();
            return valid;
        }
예제 #10
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("LOOK_CONST") || node.HasNode("POS_CONST"))
     {
         configNodeData = node.ToString();
     }
     if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
     {
         initialize();
     }
     else
     {
         initializePrefab();
     }
 }
        internal override void Awake()
        {
            String FilePath = System.IO.Path.Combine(
                System.Reflection.Assembly.GetExecutingAssembly().Location,
                "Settings.cfg").Replace("\\", "/");

            ConfigNode cnLoad = new ConfigNode();
            cnLoad = ConfigNode.Load(FilePath);
            ConfigNode.LoadObjectFromConfig(settings, cnLoad);

            settings.TestString = "Hello again";

            ConfigNode cnToPrint = new ConfigNode("settings");
            cnToPrint= ConfigNode.CreateConfigFromObject(settings);
            LogFormatted(cnToPrint.ToString());

            cnToPrint.Save(FilePath);
        }
        /// <summary>
        /// Loads the ContractRequirement from the given ConfigNode.  The base version loads the following:
        ///     - child nodes
        ///     - invertRequirement
        /// </summary>
        /// <param name="configNode">Config node to load from</param>
        /// <returns>Whether the load was successful or not.</returns>
        public virtual bool Load(ConfigNode configNode)
        {
            bool valid = true;
            ConfigNodeUtil.SetCurrentDataNode(dataNode);

            // Get name and type
            valid &= ConfigNodeUtil.ParseValue<string>(configNode, "type", x => type = x, this);
            valid &= ConfigNodeUtil.ParseValue<string>(configNode, "name", x => name = x, this, type);

            if (!configNode.HasValue("targetBody"))
            {
                configNode.AddValue("targetBody", "@/targetBody");
            }
            valid &= ConfigNodeUtil.ParseValue<CelestialBody>(configNode, "targetBody", x => _targetBody = x, this, (CelestialBody)null);

            // By default, do not check the requirement for active contracts
            valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "checkOnActiveContract", x => checkOnActiveContract = x, this, false);

            // Load invertRequirement flag
            valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "invertRequirement", x => invertRequirement = x, this, false);

            config = configNode.ToString();
            return valid;
        }
예제 #13
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (!HighLogic.LoadedSceneIsFlight && !HighLogic.LoadedSceneIsEditor)
     {
         mapLoaded = false;
     }
     if (node.HasNode("MOUNT"))
     {
         configNodeData = node.ToString();
     }
     initialize();
 }
예제 #14
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor)
     {
         initialize();
     }
     else
     {
         configNodeString = node.ToString();
         onPrefabLoad(node);//only occurs on database load (loading screen, reload on space-center screen)
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (string.IsNullOrEmpty(configNodeData)) { configNodeData = node.ToString(); }
     init(false);
 }
        /// <summary>
        /// Loads the contract type details from the given config node.
        /// </summary>
        /// <param name="configNode">The config node to load from.</param>
        /// <returns>Whether the load was successful.</returns>
        public bool Load(ConfigNode configNode)
        {
            LoggingUtil.LogLevel origLogLevel = LoggingUtil.logLevel;

            try
            {
                // Logging on
                LoggingUtil.CaptureLog = true;
                ConfigNodeUtil.SetCurrentDataNode(null);

                // Load values that are immediately required
                bool valid = true;
                valid &= ConfigNodeUtil.ParseValue<ContractGroup>(configNode, "group", x => group = x, this, (ContractGroup)null);

                // Set up the data node
                dataNode = new DataNode(configNode.GetValue("name"), group != null ? group.dataNode : null, this);
                ConfigNodeUtil.SetCurrentDataNode(dataNode);

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

                // Try to turn on trace mode
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "trace", x => trace = x, this, false);
                if (trace)
                {
                    LoggingUtil.logLevel = LoggingUtil.LogLevel.VERBOSE;
                    LoggingUtil.LogWarning(this, "Tracing enabled for contract type " + name);
                }

                // Load contract text details
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "title", x => title = x, this);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "tag", x => tag = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "description", x => description = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "topic", x => topic = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "subject", x => subject = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "motivation", x => motivation = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "notes", x => notes = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "synopsis", x => synopsis = x, this);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "completedMessage", x => completedMessage = x, this);

                // Load optional attributes
                valid &= ConfigNodeUtil.ParseValue<Agent>(configNode, "agent", x => agent = x, this, (Agent)null);
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "minExpiry", x => minExpiry = x, this, 1.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "maxExpiry", x => maxExpiry = x, this, 7.0f, x => Validation.GE(x, minExpiry));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "deadline", x => deadline = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "cancellable", x => cancellable = x, this, true);
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "declinable", x => declinable = x, this, true);
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "autoAccept", x => autoAccept = x, this, false);
                valid &= ConfigNodeUtil.ParseValue<List<Contract.ContractPrestige>>(configNode, "prestige", x => prestige = x, this, new List<Contract.ContractPrestige>());
                valid &= ConfigNodeUtil.ParseValue<CelestialBody>(configNode, "targetBody", x => targetBody = x, this, (CelestialBody)null);
            
                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxCompletions", x => maxCompletions = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxSimultaneous", x => maxSimultaneous = x, this, 0, x => Validation.GE(x, 0));

                // Load rewards
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardFunds", x => rewardFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardReputation", x => rewardReputation = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardScience", x => rewardScience = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "failureFunds", x => failureFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "failureReputation", x => failureReputation = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "advanceFunds", x => advanceFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));

                // Load other values
                valid &= ConfigNodeUtil.ParseValue<double>(configNode, "weight", x => weight = x, this, 1.0, x => Validation.GE(x, 0.0f));

                // Merge in data from the parent contract group
                for (ContractGroup currentGroup = group; currentGroup != null; currentGroup = currentGroup.parent)
                {
                    // Merge dataValues - this is a flag saying what values need to be unique at the contract level
                    foreach (KeyValuePair<string, bool> pair in currentGroup.dataValues)
                    {
                        dataValues[group.name + ":" + pair.Key] = pair.Value;
                    }

                    // Merge uniquenessChecks
                    foreach (KeyValuePair<string, DataNode.UniquenessCheck> pair in currentGroup.uniquenessChecks)
                    {
                        uniquenessChecks[group.name + ":" + pair.Key] = pair.Value;
                    }
                }

                // Load DATA nodes
                valid &= dataNode.ParseDataNodes(configNode, this, dataValues, uniquenessChecks);

                // Check for unexpected values - always do this last
                valid &= ConfigNodeUtil.ValidateUnexpectedValues(configNode, this);

                log = LoggingUtil.capturedLog;
                LoggingUtil.CaptureLog = false;

                // Load parameters
                foreach (ConfigNode contractParameter in ConfigNodeUtil.GetChildNodes(configNode, "PARAMETER"))
                {
                    ParameterFactory paramFactory = null;
                    valid &= ParameterFactory.GenerateParameterFactory(contractParameter, this, out paramFactory);
                    if (paramFactory != null)
                    {
                        paramFactories.Add(paramFactory);
                        if (paramFactory.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Load behaviours
                foreach (ConfigNode requirementNode in ConfigNodeUtil.GetChildNodes(configNode, "BEHAVIOUR"))
                {
                    BehaviourFactory behaviourFactory = null;
                    valid &= BehaviourFactory.GenerateBehaviourFactory(requirementNode, this, out behaviourFactory);
                    if (behaviourFactory != null)
                    {
                        behaviourFactories.Add(behaviourFactory);
                        if (behaviourFactory.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Load requirements
                foreach (ConfigNode requirementNode in ConfigNodeUtil.GetChildNodes(configNode, "REQUIREMENT"))
                {
                    ContractRequirement requirement = null;
                    valid &= ContractRequirement.GenerateRequirement(requirementNode, this, out requirement);
                    if (requirement != null)
                    {
                        requirements.Add(requirement);
                        if (requirement.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Logging on
                LoggingUtil.CaptureLog = true;

                // Check we have at least one valid parameter
                if (paramFactories.Count() == 0)
                {
                    LoggingUtil.LogError(this.GetType(), ErrorPrefix() + ": Need at least one parameter for a contract!");
                    valid = false;
                }

                // Do the deferred loads
                valid &= ConfigNodeUtil.ExecuteDeferredLoads();

                config = configNode.ToString();
                hash = config.GetHashCode();
                enabled = valid;
                log += LoggingUtil.capturedLog;

				if (LoggingUtil.logLevel == LoggingUtil.LogLevel.VERBOSE || LoggingUtil.logLevel == LoggingUtil.LogLevel.DEBUG)
				{
					//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
					// to write the complete config and log for contract to both the system log and
					// a seperate CC log file
					//
					string pattern = @"\[(VERBOSE|DEBUG|INFO|WARNING|ERROR)\] ContractConfigurator\.ExpressionParser.BaseParser.+\n";
					string replacement = "";
					Regex rgx = new Regex(pattern);

					// First, write to the standard log file.  the regex strips out the leading text of the line, but 
					// if you want the text there, then just remove the rgx.Replace
					LoggingUtil.LogDebug(this, config);
					// Write the log out, ignoring the BaseParser lines
					LoggingUtil.LogDebug(this, rgx.Replace(log, replacement));

					// Now write to the CC log file, in a much cleaner manner 
					string path = ccLogFile;

					// Delete the file first time through, ignore any errors
					if (deleteCCLogfile)
					{
						deleteCCLogfile = false;
						try {
							if (File.Exists(path))
								File.Delete(path);
						} catch { 
							LoggingUtil.LogError(this, "Exception while attempting to delete the file: " + path);
						}
					}
					// Create the file if it doesn't exist
					if (!File.Exists(path)) 
					{
						// Create a file to write to.
						try {
							using (StreamWriter sw = File.CreateText(path)) {}
						} catch {
							LoggingUtil.LogError(this, "Exception while attempting to create the file: " + path);
						}
					}

					// This regex also strips out the second part of the line, so that the output is very clean 

					string pattern2 = @"\[(VERBOSE|DEBUG|INFO|WARNING|ERROR)\] ContractConfigurator\.ExpressionParser\.DataNode: ";
					Regex rgx2 = new Regex(pattern2);

					// Now write the config and the cleaned up log to it
					try {
						using (StreamWriter sw = File.AppendText (path)) {
							sw.WriteLine (config);
							sw.WriteLine("++++++++++\n");
							sw.WriteLine(rgx2.Replace(rgx.Replace(log, replacement), replacement));
							sw.WriteLine("==================================================================================");
	        		    }
					} catch {
						LoggingUtil.LogError(this, "Exception while attempting to write to the file: " + path);
					}
					//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
				}
				LoggingUtil.CaptureLog = false;

				return valid;
			}
            catch
            {
                enabled = false;
                throw;
            }
            finally
            {
                LoggingUtil.logLevel = origLogLevel;
                loaded = true;
            }
        }
예제 #17
0
 private void dumpConfigNode(ConfigNode node)
 {
     print("ConfigNode: name: " + node.name.ToString() + " id: " + node.id.ToString());
     print("values: ");
     print("ToString: " + node.ToString());
 }
예제 #18
0
        void AddTank(double value)
        {
            PartResource partResource = resource;
            //Debug.LogWarning ("[MFT] Adding tank from API " + name + " amount: " + value);
            maxAmountExpression = null;

            ConfigNode node = new ConfigNode ("RESOURCE");
            node.AddValue ("name", name);
            node.AddValue ("amount", value);
            node.AddValue ("maxAmount", value);
            #if DEBUG
            print (node.ToString ());
            #endif
            partResource = part.AddResource (node);
            partResource.enabled = true;

            module.RaiseResourceListChanged ();

            // Update symmetry counterparts.
            if (HighLogic.LoadedSceneIsEditor && propagate) {
                foreach (Part sym in part.symmetryCounterparts) {
                    PartResource symResc = sym.AddResource (node);
                    symResc.enabled = true;
                    PartMessageService.Send<PartResourceListChanged> (this, sym);
                }
            }
        }
예제 #19
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("UVMAP"))
     {
         configNodeData = node.ToString();
     }
     if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
     {
         loadConfigData();
         updateEditorFields();
         prepModel();
     }
 }
예제 #20
0
        public override void OnLoad(ConfigNode config)
        {
            if (this.configString == null)
            {
                this.configString = config.ToString();
            }

            loadConfig();
        }
예제 #21
0
 public void Save(ConfigNode node)
 {
     Debug.Log("FlightData Save");
     Debug.Log(node.ToString());
     node.AddValue("dataDeepSpace", dataDeepSpace);
     node.AddValue("flightTimeDeepSpace", flightTimeDeepSpace);
     if (dataBodies != null)
     {
         foreach (FlightDataBody body in dataBodies)
         {
             ConfigNode bodyNode = node.AddNode("bodyData");
             body.Save(bodyNode);
         }
     }
     Debug.Log(node.ToString());
 }
        /// <summary>
        /// Loads the contract type details from the given config node.
        /// </summary>
        /// <param name="configNode">The config node to load from.</param>
        /// <returns>Whether the load was successful.</returns>
        public bool Load(ConfigNode configNode)
        {
            LoggingUtil.LogLevel origLogLevel = LoggingUtil.logLevel;

            try
            {
                // Logging on
                LoggingUtil.CaptureLog = true;

                dataNode = new DataNode(configNode.GetValue("name"), this);

                ConfigNodeUtil.SetCurrentDataNode(dataNode);
                bool valid = true;

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

                // Try to turn on trace mode
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "trace", x => trace = x, this, false);
                if (trace)
                {
                    LoggingUtil.logLevel = LoggingUtil.LogLevel.VERBOSE;
                    LoggingUtil.LogWarning(this, "Tracing enabled for contract type " + name);
                }

                // Load contract text details
                valid &= ConfigNodeUtil.ParseValue<ContractGroup>(configNode, "group", x => group = x, this, (ContractGroup)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "title", x => title = x, this);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "tag", x => tag = x, this, "");
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "description", x => description = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "topic", x => topic = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "subject", x => subject = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "motivation", x => motivation = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "notes", x => notes = x, this, (string)null);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "synopsis", x => synopsis = x, this);
                valid &= ConfigNodeUtil.ParseValue<string>(configNode, "completedMessage", x => completedMessage = x, this);

                // Load optional attributes
                valid &= ConfigNodeUtil.ParseValue<Agent>(configNode, "agent", x => agent = x, this, (Agent)null);
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "minExpiry", x => minExpiry = x, this, 1.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "maxExpiry", x => maxExpiry = x, this, 7.0f, x => Validation.GE(x, minExpiry));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "deadline", x => deadline = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "cancellable", x => cancellable = x, this, true);
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "declinable", x => declinable = x, this, true);
                valid &= ConfigNodeUtil.ParseValue<bool>(configNode, "autoAccept", x => autoAccept = x, this, false);
                valid &= ConfigNodeUtil.ParseValue<List<Contract.ContractPrestige>>(configNode, "prestige", x => prestige = x, this, new List<Contract.ContractPrestige>());
                valid &= ConfigNodeUtil.ParseValue<CelestialBody>(configNode, "targetBody", x => targetBody = x, this, (CelestialBody)null);

                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxCompletions", x => maxCompletions = x, this, 0, x => Validation.GE(x, 0));
                valid &= ConfigNodeUtil.ParseValue<int>(configNode, "maxSimultaneous", x => maxSimultaneous = x, this, 0, x => Validation.GE(x, 0));

                // Load rewards
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardFunds", x => rewardFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardReputation", x => rewardReputation = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "rewardScience", x => rewardScience = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "failureFunds", x => failureFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "failureReputation", x => failureReputation = x, this, 0.0f, x => Validation.GE(x, 0.0f));
                valid &= ConfigNodeUtil.ParseValue<float>(configNode, "advanceFunds", x => advanceFunds = x, this, 0.0f, x => Validation.GE(x, 0.0f));

                // Load other values
                valid &= ConfigNodeUtil.ParseValue<double>(configNode, "weight", x => weight = x, this, 1.0, x => Validation.GE(x, 0.0f));

                // Load DATA nodes
                valid &= DataNode.ParseDataNodes(configNode, this, dataValues, uniqueValues);

                // Check for unexpected values - always do this last
                valid &= ConfigNodeUtil.ValidateUnexpectedValues(configNode, this);

                log = LoggingUtil.capturedLog;
                LoggingUtil.CaptureLog = false;

                // Load parameters
                foreach (ConfigNode contractParameter in ConfigNodeUtil.GetChildNodes(configNode, "PARAMETER"))
                {
                    ParameterFactory paramFactory = null;
                    valid &= ParameterFactory.GenerateParameterFactory(contractParameter, this, out paramFactory);
                    if (paramFactory != null)
                    {
                        paramFactories.Add(paramFactory);
                        if (paramFactory.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Load behaviours
                foreach (ConfigNode requirementNode in ConfigNodeUtil.GetChildNodes(configNode, "BEHAVIOUR"))
                {
                    BehaviourFactory behaviourFactory = null;
                    valid &= BehaviourFactory.GenerateBehaviourFactory(requirementNode, this, out behaviourFactory);
                    if (behaviourFactory != null)
                    {
                        behaviourFactories.Add(behaviourFactory);
                        if (behaviourFactory.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Load requirements
                foreach (ConfigNode requirementNode in ConfigNodeUtil.GetChildNodes(configNode, "REQUIREMENT"))
                {
                    ContractRequirement requirement = null;
                    valid &= ContractRequirement.GenerateRequirement(requirementNode, this, out requirement);
                    if (requirement != null)
                    {
                        requirements.Add(requirement);
                        if (requirement.hasWarnings)
                        {
                            hasWarnings = true;
                        }
                    }
                }

                // Logging on
                LoggingUtil.CaptureLog = true;

                // Check we have at least one valid parameter
                if (paramFactories.Count() == 0)
                {
                    LoggingUtil.LogError(this.GetType(), ErrorPrefix() + ": Need at least one parameter for a contract!");
                    valid = false;
                }

                // Do the deferred loads
                valid &= ConfigNodeUtil.ExecuteDeferredLoads();

                config = configNode.ToString();
                hash = config.GetHashCode();
                enabled = valid;
                log += LoggingUtil.capturedLog;
                LoggingUtil.CaptureLog = false;

                return valid;
            }
            catch
            {
                enabled = false;
                throw;
            }
            finally
            {
                LoggingUtil.logLevel = origLogLevel;
                loaded = true;
            }
        }
예제 #23
0
 public override void OnLoad(ConfigNode node)
 {
     if(node.HasNode("CONVERTERRECIPE"))//load the recipe config for the prefab part instance;
     {
         print ("prefab init, creating prefab test instances!");
         loadRecipeFromNode(node);
         configNodeString = node.ToString();
     }
 }
예제 #24
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
     {
         configNodeData = node.ToString();
     }
 }
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (string.IsNullOrEmpty(configNodeData)) { configNodeData = node.ToString(); }
     if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
     {
         //prefab init... do not do init during OnLoad for editor or flight... trying for some consistent loading sequences this time around
         initializePrefab(node);
     }
     else
     {
         initialize();
     }
 }
예제 #26
0
 public override void OnLoad(ConfigNode node)
 {
     configString = node.ToString ();
     switch_infos = new List<SwitchInfo> ();
     CreateSwitchInfos (node);
 }
예제 #27
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("TECHLIMIT")) { configNodeData = node.ToString(); }
     updateModelScale();//for prefab part...
 }
예제 #28
0
        public override void OnLoad(ConfigNode node)
        {
            base.OnLoad (node);

            //only runs for prefab construction, e.g. loading screen or database reload while on space center screen
            if(!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)
            {
                configNodeString = node.ToString();
                loadConfigFromNode(node);
            }
            else
            {
                loadTankConfigsFromPrefab();
                if(persistentMass>0){part.mass=persistentMass;}
            }
        }
예제 #29
0
 public override void OnLoad(ConfigNode node)
 {
     base.OnLoad(node);
     if (node.HasNode("TANK"))//only prefab instance config node should contain this data...but whatever, grab it whenever it is present
     {
         configNodeData = node.ToString();
     }
     initialize();
 }
예제 #30
0
 public override void OnLoad(ConfigNode node)
 {
     CDebug.log(node.ToString());
 }