Exemplo n.º 1
0
            /// <summary>
            /// Loads the experiment from the config node and attaches it to a vessel
            /// </summary>
            void AddScienceExperiment()
            {
                // If the Node is null, abort
                if (experimentNode == null)
                {
                    return;
                }

                // Create the ScienceExperiment
                Part kerbal = FlightGlobals.ActiveVessel.evaController.part;

                experiment = kerbal.AddModule(typeof(ModuleScienceExperiment).Name) as ModuleScienceExperiment;
                if (experiment == null)
                {
                    return;
                }

                // Load the experiment
                ConfigNode.LoadObjectFromConfig(experiment, experimentNode);

                // Deactivate some things
                experiment.resettable = false;

                // Start the experiment
                experiment.OnStart(PartModule.StartState.None);
                vesselID.Add(kerbal.vessel.id);
            }
Exemplo n.º 2
0
            /// <summary>
            /// Loads the experiment from the config node and attaches it to a vessel
            /// </summary>
            void AddScienceExperiment()
            {
                // If the Node is null, abort
                if (experimentNode == null)
                    return;

                // Create the ScienceExperiment
                Part kerbal = FlightGlobals.ActiveVessel.evaController.part;
                experiment = kerbal.AddModule(typeof(ModuleScienceExperiment).Name) as ModuleScienceExperiment;

                // Load the experiment
                ConfigNode.LoadObjectFromConfig(experiment, experimentNode);

                // Deactivate some things
                experiment.resettable = false;

                // Start the experiment
                experiment.OnStart(PartModule.StartState.None);
                vesselID.Add(kerbal.vessel.id);
            }
Exemplo n.º 3
0
                public void AddScienceExperiment()
                {
                    // If the Node is null, abort
                    if (experimentNode == null)
                        return;

                    // Create the ScienceExperiment
                    Part kerbal = FlightGlobals.ActiveVessel.evaController.part;
                    experiment = kerbal.AddModule(typeof(ModuleScienceExperiment).Name) as ModuleScienceExperiment;

                    // I can't find a function that loads the module from the config node... :/ Doing it manually
                    Type type = experiment.GetType();
                    foreach (ConfigNode.Value value in experimentNode.values)
                    {
                        try
                        {
                            FieldInfo field = type.GetField(value.name);
                            if (field.FieldType == typeof(string))
                                field.SetValue(experiment, value.value);
                            else if (field.FieldType.GetMethod("Parse") != null)
                                field.SetValue(experiment, field.FieldType.GetMethod("Parse").Invoke(null, new object[] { value.value }));
                        }
                        catch { }
                    }

                    // Deactivate some things
                    experiment.resettable = false;

                    // Start the experiment
                    experiment.OnStart(PartModule.StartState.None);
                    vesselID.Add(kerbal.vessel.id);
                }