示例#1
0
        public Drive(ConfigNode node)
        {
            // parse science  files
            files = new Dictionary <string, File>();
            if (node.HasNode("files"))
            {
                foreach (var file_node in node.GetNode("files").GetNodes())
                {
                    files.Add(DB.From_safe_key(file_node.name), new File(file_node));
                }
            }

            // parse science samples
            samples = new Dictionary <string, Sample>();
            if (node.HasNode("samples"))
            {
                foreach (var sample_node in node.GetNode("samples").GetNodes())
                {
                    samples.Add(DB.From_safe_key(sample_node.name), new Sample(sample_node));
                }
            }

            name = Lib.ConfigValue(node, "name", "DRIVE");

            // parse capacities. be generous with default values for backwards
            // compatibility (drives had unlimited storage before this)
            dataCapacity   = Lib.ConfigValue(node, "dataCapacity", 100000.0);
            sampleCapacity = Lib.ConfigValue(node, "sampleCapacity", 1000);
        }
示例#2
0
        public StormData(ConfigNode node)
        {
            if (node == null)
            {
                storm_generation = 0.0;
                Reset();
                return;
            }

            storm_time         = Lib.ConfigValue(node, "storm_time", 0.0);
            storm_duration     = Lib.ConfigValue(node, "storm_duration", 0.0);
            storm_generation   = Lib.ConfigValue(node, "storm_generation", 0.0);
            storm_state        = Lib.ConfigValue(node, "storm_state", 0u);
            msg_storm          = Lib.ConfigValue(node, "msg_storm", 0u);
            displayed_duration = Lib.ConfigValue(node, "displayed_duration", storm_duration);
            display_warning    = Lib.ConfigValue(node, "display_warning", true);

            if (storm_time > 0 && storm_duration <= 0)            // legacy save games did storms differently.
            {
                // storm_time used to be the point of time of the next storm, there was no storm_duration
                // as storms all had a fixed duration depending on the distance to the sun.
                // setting this to 0 will trigger a reroll of storm generation based on the new implementation.
                storm_time       = 0;
                storm_generation = 0;
            }
        }
示例#3
0
 public ConfigureModule(ConfigNode node)
 {
     type     = Lib.ConfigValue(node, "type", string.Empty);
     id_field = Lib.ConfigValue(node, "id_field", string.Empty);
     id_value = Lib.ConfigValue(node, "id_value", string.Empty);
     id_index = Lib.ConfigValue(node, "id_index", 0);
 }
示例#4
0
 public RuleData(ConfigNode node)
 {
     problem    = Lib.ConfigValue(node, "problem", 0.0);
     message    = Lib.ConfigValue(node, "message", 0u);
     time_since = Lib.ConfigValue(node, "time_since", 0.0);
     lifetime   = Lib.ConfigValue(node, "lifetime", false);
 }
示例#5
0
文件: File.cs 项目: zajc3w/Kerbalism
 public File(ConfigNode node)
 {
   content = Lib.ConfigValue(node, "content", string.Empty).Replace("$NEWLINE", "\n").Replace("$COMMENT", "//");
   send = Lib.ConfigValue(node, "send", string.Empty);
   data = Lib.ConfigValue(node, "data", 0.0);
   // note: device files are never serialized
 }
示例#6
0
        public static File Load(string integerSubjectId, ConfigNode node)
        {
            SubjectData subjectData;
            string      stockSubjectId = Lib.ConfigValue(node, "stockSubjectId", string.Empty);

            // the stock subject id is stored only if this is an asteroid sample, or a non-standard subject id
            if (stockSubjectId != string.Empty)
            {
                subjectData = ScienceDB.GetSubjectDataFromStockId(stockSubjectId);
            }
            else
            {
                subjectData = ScienceDB.GetSubjectData(integerSubjectId);
            }

            if (subjectData == null)
            {
                return(null);
            }

            double size = Lib.ConfigValue(node, "size", 0.0);

            if (double.IsNaN(size))
            {
                Lib.LogStack($"File has a NaN size on load : {subjectData.DebugStateInfo}", Lib.LogLevel.Error);
                return(null);
            }

            string resultText        = Lib.ConfigValue(node, "resultText", "");
            bool   useStockCrediting = Lib.ConfigValue(node, "useStockCrediting", false);

            return(new File(subjectData, size, useStockCrediting, resultText));
        }
示例#7
0
		public File(ConfigNode node)
		{
			size = Lib.ConfigValue(node, "size", 0.0);
			buff = Lib.ConfigValue(node, "buff", 0.0);
			send = Lib.ConfigValue(node, "send", PreferencesBasic.Instance.transmitScience);
			silentTransmission = Lib.ConfigValue(node, "silentTransmission", false);
		}
示例#8
0
        // ctor: deserialize
        public RadiationBody(ConfigNode node, Dictionary <string, RadiationModel> models, CelestialBody body)
        {
            name                 = Lib.ConfigValue(node, "name", "");
            radiation_inner      = Lib.ConfigValue(node, "radiation_inner", 0.0) / 3600.0;
            radiation_outer      = Lib.ConfigValue(node, "radiation_outer", 0.0) / 3600.0;
            radiation_pause      = Lib.ConfigValue(node, "radiation_pause", 0.0) / 3600.0;
            geomagnetic_pole_lat = Lib.ConfigValue(node, "geomagnetic_pole_lat", 90.0f);
            geomagnetic_pole_lon = Lib.ConfigValue(node, "geomagnetic_pole_lon", 0.0f);
            geomagnetic_offset   = Lib.ConfigValue(node, "geomagnetic_offset", 0.0f);
            reference            = Lib.ConfigValue(node, "reference", 0);

            // get the radiation environment
            if (!models.TryGetValue(Lib.ConfigValue(node, "radiation_model", ""), out model))
            {
                model = RadiationModel.none;
            }

            // get the body
            this.body = body;

            float lat = (float)(geomagnetic_pole_lat * Math.PI / 180.0);
            float lon = (float)(geomagnetic_pole_lon * Math.PI / 180.0);

            float x = Mathf.Cos(lat) * Mathf.Cos(lon);
            float y = Mathf.Sin(lat);
            float z = Mathf.Cos(lat) * Mathf.Sin(lon);

            geomagnetic_pole = new Vector3(x, y, z).normalized;
        }
示例#9
0
        public Drive(ConfigNode node)
        {
            // parse science  files
            files = new Dictionary <string, File>();
            if (node.HasNode("files"))
            {
                foreach (var file_node in node.GetNode("files").GetNodes())
                {
                    files.Add(DB.from_safe_key(file_node.name), new File(file_node));
                }
            }

            // parse science samples
            samples = new Dictionary <string, Sample>();
            if (node.HasNode("samples"))
            {
                foreach (var sample_node in node.GetNode("samples").GetNodes())
                {
                    samples.Add(DB.from_safe_key(sample_node.name), new Sample(sample_node));
                }
            }

            // parse preferred location
            location = Lib.ConfigValue(node, "location", 0u);
        }
示例#10
0
        // Support config file parsing
        private static void ParseSupport()
        {
            // for each profile
            foreach (ConfigNode profile_node in Lib.ParseConfigs("Profile"))
            {
                // get the name
                string name = Lib.ConfigValue(profile_node, "name", string.Empty);

                // if this is a Kerbalism Support profile
                if (name == "KerbalismSupport")
                {
                    // get the mod name and directory
                    string modname = Lib.ConfigValue(profile_node, "modname", string.Empty);
                    string moddir  = Lib.ConfigValue(profile_node, "moddir", string.Empty);

                    // if the mods directory exists
                    if (Lib.GameDirectoryExist(moddir))
                    {
                        // log profile and mod name
                        Lib.Log(Lib.BuildString("importing Kerbalism Support profile for mod: ", modname));

                        // parse nodes
                        Nodeparse(profile_node);

                        // done a Support profile now on to the next
                    }
                }
            }
        }
示例#11
0
        public Supply(ConfigNode node)
        {
            resource  = Lib.ConfigValue(node, "resource", string.Empty);
            on_pod    = Lib.ConfigValue(node, "on_pod", 0.0);
            on_eva    = Lib.ConfigValue(node, "on_eva", 0.0);
            on_rescue = Lib.ConfigValue(node, "on_rescue", Lib.ConfigValue(node, "on_resque", 0.0)); //< old typo, pre 1.1.9
            empty     = Lib.ConfigValue(node, "empty", false);

            low_threshold  = Lib.ConfigValue(node, "low_threshold", 0.15);
            low_message    = Lib.ConfigValue(node, "low_message", string.Empty);
            empty_message  = Lib.ConfigValue(node, "empty_message", string.Empty);
            refill_message = Lib.ConfigValue(node, "refill_message", string.Empty);

            // check that resource is specified
            if (resource.Length == 0)
            {
                throw new Exception("skipping resource-less supply");
            }

            // check that resource exist
            if (Lib.GetDefinition(resource) == null)
            {
                throw new Exception("resource " + resource + " doesn't exist");
            }
        }
        public VesselData(ConfigNode node)
        {
            msg_signal      = Lib.ConfigValue(node, "msg_signal", false);
            msg_belt        = Lib.ConfigValue(node, "msg_belt", false);
            cfg_ec          = Lib.ConfigValue(node, "cfg_ec", true);
            cfg_supply      = Lib.ConfigValue(node, "cfg_supply", true);
            cfg_signal      = Lib.ConfigValue(node, "cfg_signal", true);
            cfg_malfunction = Lib.ConfigValue(node, "cfg_malfunction", true);
            cfg_storm       = Lib.ConfigValue(node, "cfg_storm", true);
            cfg_script      = Lib.ConfigValue(node, "cfg_script", true);
            cfg_highlights  = Lib.ConfigValue(node, "cfg_highlights", true);
            cfg_showlink    = Lib.ConfigValue(node, "cfg_showlink", true);
            storm_time      = Lib.ConfigValue(node, "storm_time", 0.0);
            storm_age       = Lib.ConfigValue(node, "storm_age", 0.0);
            storm_state     = Lib.ConfigValue(node, "storm_state", 0u);
            group           = Lib.ConfigValue(node, "group", "NONE");
            computer        = node.HasNode("computer") ? new Computer(node.GetNode("computer")) : new Computer();
            drive           = node.HasNode("drive") ? new Drive(node.GetNode("drive")) : new Drive();

            supplies = new Dictionary <string, SupplyData>();
            foreach (var supply_node in node.GetNode("supplies").GetNodes())
            {
                supplies.Add(DB.From_Safe_Key(supply_node.name), new SupplyData(supply_node));
            }

            scansat_id = new List <uint>();
            foreach (string s in node.GetValues("scansat_id"))
            {
                scansat_id.Add(Lib.Parse.ToUInt(s));
            }
        }
示例#13
0
 public BodyData(ConfigNode node)
 {
     storm_time  = Lib.ConfigValue(node, "storm_time", 0.0);
     storm_age   = Lib.ConfigValue(node, "storm_age", 0.0);
     storm_state = Lib.ConfigValue(node, "storm_state", 0u);
     msg_storm   = Lib.ConfigValue(node, "msg_storm", 0u);
 }
示例#14
0
        // ctor: deserialize
        public RadiationModel(ConfigNode node)
        {
            name = Lib.ConfigValue(node, "name", "");

            has_inner         = Lib.ConfigValue(node, "has_inner", false);
            inner_dist        = Lib.ConfigValue(node, "inner_dist", 0.0f);
            inner_radius      = Lib.ConfigValue(node, "inner_radius", 0.0f);
            inner_compression = Lib.ConfigValue(node, "inner_compression", 1.0f);
            inner_extension   = Lib.ConfigValue(node, "inner_extension", 1.0f);
            inner_deform      = Lib.ConfigValue(node, "inner_deform", 0.0f);
            inner_quality     = Lib.ConfigValue(node, "inner_quality", 30.0f);

            has_outer          = Lib.ConfigValue(node, "has_outer", false);
            outer_dist         = Lib.ConfigValue(node, "outer_dist", 0.0f);
            outer_radius       = Lib.ConfigValue(node, "outer_radius", 0.0f);
            outer_compression  = Lib.ConfigValue(node, "outer_compression", 1.0f);
            outer_extension    = Lib.ConfigValue(node, "outer_extension", 1.0f);
            outer_border_start = Lib.ConfigValue(node, "outer_border_start", 0.1f);
            outer_border_end   = Lib.ConfigValue(node, "outer_border_end", 1.0f);
            outer_deform       = Lib.ConfigValue(node, "outer_deform", 0.0f);
            outer_quality      = Lib.ConfigValue(node, "outer_quality", 40.0f);

            has_pause          = Lib.ConfigValue(node, "has_pause", false);
            pause_radius       = Lib.ConfigValue(node, "pause_radius", 0.0f);
            pause_compression  = Lib.ConfigValue(node, "pause_compression", 1.0f);
            pause_extension    = Lib.ConfigValue(node, "pause_extension", 1.0f);
            pause_height_scale = Lib.ConfigValue(node, "pause_height_scale", 1.0f);
            pause_deform       = Lib.ConfigValue(node, "pause_deform", 0.0f);
            pause_quality      = Lib.ConfigValue(node, "pause_quality", 20.0f);
        }
示例#15
0
 public Rule(ConfigNode node)
 {
   // parse rule from config
   this.name = Lib.ConfigValue(node, "name", "");
   this.resource_name = Lib.ConfigValue(node, "resource_name", "");
   this.waste_name = Lib.ConfigValue(node, "waste_name", "");
   this.waste_ratio = Lib.ConfigValue(node, "waste_ratio", 1.0);
   this.rate = Lib.ConfigValue(node, "rate", 0.0);
   this.interval = Lib.ConfigValue(node, "interval", 0.0);
   this.degeneration = Lib.ConfigValue(node, "degeneration", 0.0);
   this.variance = Lib.ConfigValue(node, "variance", 0.0);
   this.modifier =  Lib.Tokenize(Lib.ConfigValue(node, "modifier", ""), ',');
   this.on_pod = Lib.ConfigValue(node, "on_pod", 0.0);
   this.on_eva = Lib.ConfigValue(node, "on_eva", 0.0);
   this.on_resque = Lib.ConfigValue(node, "on_resque", 999.0);
   this.waste_buffer = Lib.ConfigValue(node, "waste_buffer", 1.0);
   this.hidden_waste = Lib.ConfigValue(node, "hidden_waste", false);
   this.massless_waste = Lib.ConfigValue(node, "massless_waste", false);
   this.breakdown = Lib.ConfigValue(node, "breakdown", false);
   this.warning_threshold = Lib.ConfigValue(node, "warning_threshold", 0.33);
   this.danger_threshold = Lib.ConfigValue(node, "danger_threshold", 0.66);
   this.fatal_threshold = Lib.ConfigValue(node, "fatal_threshold", 1.0);
   this.warning_message = Lib.ConfigValue(node, "warning_message", "");
   this.danger_message = Lib.ConfigValue(node, "danger_message", "");
   this.fatal_message = Lib.ConfigValue(node, "fatal_message", "");
   this.relax_message = Lib.ConfigValue(node, "relax_message", "");
   this.low_threshold = Lib.ConfigValue(node, "low_threshold", 0.15);
   this.low_message = Lib.ConfigValue(node, "low_message", "");
   this.empty_message = Lib.ConfigValue(node, "empty_message", "");
   this.refill_message = Lib.ConfigValue(node, "refill_message", "");
 }
示例#16
0
        public static void load(ConfigNode node)
        {
            // get version (or use current one for new savegames)
            version = Lib.ConfigValue(node, "version", Lib.Version());

            // get unique id (or generate one for new savegames)
            uid = Lib.ConfigValue(node, "uid", Lib.RandomInt(int.MaxValue));

            // if this is an unsupported version, print warning
            if (string.CompareOrdinal(version, "1.1.5.0") < 0)
            {
                Lib.Log("loading save from unsupported version " + version);
            }

            // load kerbals data
            kerbals = new Dictionary <string, KerbalData>();
            if (node.HasNode("kerbals"))
            {
                foreach (var kerbal_node in node.GetNode("kerbals").GetNodes())
                {
                    kerbals.Add(from_safe_key(kerbal_node.name), new KerbalData(kerbal_node));
                }
            }

            // load vessels data
            vessels = new Dictionary <uint, VesselData>();
            if (node.HasNode("vessels"))
            {
                foreach (var vessel_node in node.GetNode("vessels").GetNodes())
                {
                    vessels.Add(Lib.Parse.ToUInt(vessel_node.name), new VesselData(vessel_node));
                }
            }

            // load bodies data
            bodies = new Dictionary <string, BodyData>();
            if (node.HasNode("bodies"))
            {
                foreach (var body_node in node.GetNode("bodies").GetNodes())
                {
                    bodies.Add(from_safe_key(body_node.name), new BodyData(body_node));
                }
            }

            // load landmark data
            if (node.HasNode("landmarks"))
            {
                landmarks = new LandmarkData(node.GetNode("landmarks"));
            }
            else
            {
                landmarks = new LandmarkData();
            }

            // if an old savegame was imported, log some debug info
            if (version != Lib.Version())
            {
                Lib.Log("savegame converted from version " + version);
            }
        }
示例#17
0
        // this is a fallback loading method for pre 3.1 / pre build 7212 files saved used the stock subject id
        public static Sample LoadOldFormat(string stockSubjectId, ConfigNode node)
        {
            SubjectData subjectData = ScienceDB.GetSubjectDataFromStockId(stockSubjectId);

            if (subjectData == null)
            {
                return(null);
            }

            double size = Lib.ConfigValue(node, "size", 0.0);

            if (double.IsNaN(size))
            {
                Lib.LogStack($"Sample has a NaN size on load : {subjectData.DebugStateInfo}", Lib.LogLevel.Error);
                return(null);
            }

            string resultText        = Lib.ConfigValue(node, "resultText", "");
            bool   useStockCrediting = Lib.ConfigValue(node, "useStockCrediting", false);

            Sample sample = new Sample(subjectData, size, useStockCrediting, resultText);

            sample.analyze = Lib.ConfigValue(node, "analyze", false);
            sample.mass    = Lib.ConfigValue(node, "mass", 0.0);

            return(sample);
        }
示例#18
0
 public SignalProcessing()
 {
   var cfg = Lib.ParseConfig("Kerbalism/Patches/Signal/SignalProcessing");
   this.techs[0] = Lib.ConfigValue(cfg, "tech0", "advElectrics");
   this.techs[1] = Lib.ConfigValue(cfg, "tech1", "largeElectrics");
   this.techs[2] = Lib.ConfigValue(cfg, "tech2", "experimentalElectrics");
 }
示例#19
0
        public static Sample Load(string integerSubjectId, ConfigNode node)
        {
            SubjectData subjectData;
            string      stockSubjectId = Lib.ConfigValue(node, "stockSubjectId", string.Empty);

            // the stock subject id is stored only if this is an asteroid sample, or a non-standard subject id
            if (stockSubjectId != string.Empty)
            {
                subjectData = ScienceDB.GetSubjectDataFromStockId(stockSubjectId);
            }
            else
            {
                subjectData = ScienceDB.GetSubjectData(integerSubjectId);
            }

            if (subjectData == null)
            {
                return(null);
            }

            double size              = Lib.ConfigValue(node, "size", 0.0);
            string resultText        = Lib.ConfigValue(node, "resultText", "");
            bool   useStockCrediting = Lib.ConfigValue(node, "useStockCrediting", false);

            Sample sample = new Sample(subjectData, size, useStockCrediting, resultText);

            sample.analyze = Lib.ConfigValue(node, "analyze", false);
            sample.mass    = Lib.ConfigValue(node, "mass", 0.0);

            return(sample);
        }
示例#20
0
 public ManufacturingQuality()
 {
   var cfg = Lib.ParseConfig("Kerbalism/Patches/System/ManufacturingQuality");
   this.techs[0] = Lib.ConfigValue(cfg, "tech0", "advConstruction");
   this.techs[1] = Lib.ConfigValue(cfg, "tech1", "specializedConstruction");
   this.techs[2] = Lib.ConfigValue(cfg, "tech2", "composites");
   this.techs[3] = Lib.ConfigValue(cfg, "tech2", "metaMaterials");
 }
示例#21
0
 public LandmarkData(ConfigNode node)
 {
     belt_crossing       = Lib.ConfigValue(node, "belt_crossing", false);
     manned_orbit        = Lib.ConfigValue(node, "manned_orbit", false);
     space_harvest       = Lib.ConfigValue(node, "space_harvest", false);
     space_analysis      = Lib.ConfigValue(node, "space_analysis", false);
     heliopause_crossing = Lib.ConfigValue(node, "heliopause_crossing", false);
 }
示例#22
0
 public ScrubberEfficiency()
 {
   var cfg = Lib.ParseConfig("Kerbalism/Patches/LifeSupport/ScrubberEfficiency");
   this.techs[0] = Lib.ConfigValue(cfg, "tech0", "miniaturization");
   this.techs[1] = Lib.ConfigValue(cfg, "tech1", "precisionEngineering");
   this.techs[2] = Lib.ConfigValue(cfg, "tech2", "scienceTech");
   this.techs[3] = Lib.ConfigValue(cfg, "tech3", "experimentalScience");
 }
示例#23
0
        // ctor: deserialize
        public RadiationBody(ConfigNode node, Dictionary <string, RadiationModel> models, CelestialBody body)
        {
            name                     = Lib.ConfigValue(node, "name", "");
            radiation_inner          = Lib.ConfigValue(node, "radiation_inner", 0.0) / 3600.0;
            radiation_inner_gradient = Lib.ConfigValue(node, "radiation_inner_gradient", 3.3);
            radiation_outer          = Lib.ConfigValue(node, "radiation_outer", 0.0) / 3600.0;
            radiation_outer_gradient = Lib.ConfigValue(node, "radiation_outer_gradient", 2.2);
            radiation_pause          = Lib.ConfigValue(node, "radiation_pause", 0.0) / 3600.0;
            radiation_surface        = Lib.ConfigValue(node, "radiation_surface", -1.0) / 3600.0;
            solar_cycle              = Lib.ConfigValue(node, "solar_cycle", -1.0);
            solar_cycle_offset       = Lib.ConfigValue(node, "solar_cycle_offset", 0.0);
            geomagnetic_pole_lat     = Lib.ConfigValue(node, "geomagnetic_pole_lat", 90.0f);
            geomagnetic_pole_lon     = Lib.ConfigValue(node, "geomagnetic_pole_lon", 0.0f);
            geomagnetic_offset       = Lib.ConfigValue(node, "geomagnetic_offset", 0.0f);
            reference                = Lib.ConfigValue(node, "reference", Lib.GetParentSun(body).flightGlobalsIndex);

            // get the radiation environment
            if (!models.TryGetValue(Lib.ConfigValue(node, "radiation_model", ""), out model))
            {
                model = RadiationModel.none;
            }

            // get the body
            this.body = body;

            float lat = (float)(geomagnetic_pole_lat * Math.PI / 180.0);
            float lon = (float)(geomagnetic_pole_lon * Math.PI / 180.0);

            float x = Mathf.Cos(lat) * Mathf.Cos(lon);
            float y = Mathf.Sin(lat);
            float z = Mathf.Cos(lat) * Mathf.Sin(lon);

            geomagnetic_pole = new Vector3(x, y, z).normalized;

            if (Lib.IsSun(body))
            {
                // suns without a solar cycle configuration default to a cycle of 6 years
                // (set to 0 if you really want none)
                if (solar_cycle < 0)
                {
                    solar_cycle = Lib.HoursInDay * 3600 * Lib.DaysInYear * 6;
                }

                // add a rather nominal surface radiation for suns that have no config
                // for comparison: the stock kerbin sun has a surface radiation of 47 rad/h, which gives 0.01 rad/h near Kerbin
                // (set to 0 if you really want none)
                if (radiation_surface < 0)
                {
                    radiation_surface = 10.0 * 3600.0;
                }
            }

            // calculate point emitter strength r0 at center of body
            if (radiation_surface > 0)
            {
                radiation_r0 = radiation_surface * 4 * Math.PI * body.Radius * body.Radius;
            }
        }
示例#24
0
        static void ProcessFissionGenerator(Vessel v, ProtoPartSnapshot p, ProtoPartModuleSnapshot m, PartModule fission_generator, resource_info ec, double elapsed_s)
        {
            // note: ignore heat

            double power     = Lib.ReflectionValue <float>(fission_generator, "PowerGeneration");
            var    reactor   = p.modules.Find(k => k.moduleName == "FissionReactor");
            double tweakable = reactor == null ? 1.0 : Lib.ConfigValue(reactor.moduleValues, "CurrentPowerPercent", 100.0) * 0.01;

            ec.Produce(power * tweakable * elapsed_s);
        }
示例#25
0
        public Rule(ConfigNode node)
        {
            name              = Lib.ConfigValue(node, "name", string.Empty);
            input             = Lib.ConfigValue(node, "input", string.Empty);
            output            = Lib.ConfigValue(node, "output", string.Empty);
            interval          = Lib.ConfigValue(node, "interval", 0.0);
            rate              = Lib.ConfigValue(node, "rate", 0.0);
            ratio             = Lib.ConfigValue(node, "ratio", 0.0);
            input_threshold   = Lib.ConfigValue(node, "input_threshold", 0.0);
            degeneration      = Lib.ConfigValue(node, "degeneration", 0.0);
            variance          = Lib.ConfigValue(node, "variance", 0.0);
            modifiers         = Lib.Tokenize(Lib.ConfigValue(node, "modifier", string.Empty), ',');
            breakdown         = Lib.ConfigValue(node, "breakdown", false);
            output_only       = Lib.ConfigValue(node, "output_only", false);
            warning_threshold = Lib.ConfigValue(node, "warning_threshold", 0.33);
            danger_threshold  = Lib.ConfigValue(node, "danger_threshold", 0.66);
            fatal_threshold   = Lib.ConfigValue(node, "fatal_threshold", 1.0);
            warning_message   = Lib.ConfigValue(node, "warning_message", string.Empty);
            danger_message    = Lib.ConfigValue(node, "danger_message", string.Empty);
            fatal_message     = Lib.ConfigValue(node, "fatal_message", string.Empty);
            relax_message     = Lib.ConfigValue(node, "relax_message", string.Empty);

            // check that name is specified
            if (name.Length == 0)
            {
                throw new Exception("skipping unnamed rule");
            }

            // check that degeneration is not zero
            if (degeneration <= double.Epsilon)
            {
                throw new Exception("skipping zero degeneration rule");
            }

            // check that resources exist
            if (input.Length > 0 && Lib.GetDefinition(input) == null)
            {
                throw new Exception("resource '" + input + "' doesn't exist");
            }
            if (output.Length > 0 && Lib.GetDefinition(output) == null)
            {
                throw new Exception("resource '" + output + "' doesn't exist");
            }

            // calculate ratio of input vs output resource
            if (input.Length > 0 && output.Length > 0 && ratio <= double.Epsilon)
            {
                var input_density  = Lib.GetDefinition(input).density;
                var output_density = Lib.GetDefinition(output).density;
                ratio = Math.Min(input_density, output_density) > double.Epsilon ? input_density / output_density : 1.0;
            }

            trigger = false;
        }
示例#26
0
        private Dictionary <uint, Drive> LoadDrives(ConfigNode node)
        {
            Dictionary <uint, Drive> result = new Dictionary <uint, Drive>();

            foreach (var n in node.GetNodes("drive"))
            {
                uint  partId = Lib.ConfigValue(n, "partId", (uint)0);
                Drive drive  = new Drive(n);
                result.Add(partId, drive);
            }
            return(result);
        }
示例#27
0
        public KerbalData(ConfigNode node)
        {
            rescue   = Lib.ConfigValue(node, "rescue", Lib.ConfigValue(node, "resque", true));           //< support pre 1.1.9 typo
            disabled = Lib.ConfigValue(node, "disabled", false);
            eva_dead = Lib.ConfigValue(node, "eva_dead", false);
            rules    = new Dictionary <string, RuleData>();

            foreach (var rule_node in node.GetNode("rules").GetNodes())
            {
                rules.Add(DB.From_safe_key(rule_node.name), new RuleData(rule_node));
            }
        }
示例#28
0
        private void Load(ConfigNode node)
        {
            msg_signal      = Lib.ConfigValue(node, "msg_signal", false);
            msg_belt        = Lib.ConfigValue(node, "msg_belt", false);
            cfg_ec          = Lib.ConfigValue(node, "cfg_ec", PreferencesMessages.Instance.ec);
            cfg_supply      = Lib.ConfigValue(node, "cfg_supply", PreferencesMessages.Instance.supply);
            cfg_signal      = Lib.ConfigValue(node, "cfg_signal", PreferencesMessages.Instance.signal);
            cfg_malfunction = Lib.ConfigValue(node, "cfg_malfunction", PreferencesMessages.Instance.malfunction);
            cfg_storm       = Lib.ConfigValue(node, "cfg_storm", PreferencesMessages.Instance.storm);
            cfg_script      = Lib.ConfigValue(node, "cfg_script", PreferencesMessages.Instance.script);
            cfg_highlights  = Lib.ConfigValue(node, "cfg_highlights", PreferencesReliability.Instance.highlights);
            cfg_showlink    = Lib.ConfigValue(node, "cfg_showlink", true);
            cfg_show        = Lib.ConfigValue(node, "cfg_show", true);

            deviceTransmit = Lib.ConfigValue(node, "deviceTransmit", true);

            solarPanelsAverageExposure = Lib.ConfigValue(node, "solarPanelsAverageExposure", -1.0);
            scienceTransmitted         = Lib.ConfigValue(node, "scienceTransmitted", 0.0);

            stormData   = new StormData(node.GetNode("StormData"));
            habitatInfo = new VesselHabitatInfo(node.GetNode("SunShielding"));
            computer    = new Computer(node.GetNode("computer"));

            supplies = new Dictionary <string, SupplyData>();
            foreach (var supply_node in node.GetNode("supplies").GetNodes())
            {
                supplies.Add(DB.From_safe_key(supply_node.name), new SupplyData(supply_node));
            }

            scansat_id = new List <uint>();
            foreach (string s in node.GetValues("scansat_id"))
            {
                scansat_id.Add(Lib.Parse.ToUInt(s));
            }

            ConfigNode partsNode = new ConfigNode();

            if (node.TryGetNode("parts", ref partsNode))
            {
                foreach (ConfigNode partDataNode in partsNode.GetNodes())
                {
                    PartData partData;
                    if (parts.TryGetValue(Lib.Parse.ToUInt(partDataNode.name), out partData))
                    {
                        partData.Load(partDataNode);
                    }
                }
            }

            filesTransmitted = new List <File>();
            vesselSituations = new VesselSituations(this);
        }
示例#29
0
 public Script(ConfigNode node)
 {
     states = new Dictionary <uint, bool>();
     foreach (string s in node.GetValues("state"))
     {
         var tokens = Lib.Tokenize(s, '@');
         if (tokens.Count < 2)
         {
             continue;
         }
         states.Add(Lib.Parse.ToUInt(tokens[0]), Lib.Parse.ToBool(tokens[1]));
     }
     prev = Lib.ConfigValue(node, "prev", string.Empty);
 }
示例#30
0
        public static void Parse()
        {
            var cfg = Lib.ParseConfig("Kerbalism/Kerbalism");

            // profile used
            Profile = Lib.ConfigValue(cfg, "Profile", string.Empty);

            // user-defined features
            Reliability  = Lib.ConfigValue(cfg, "Reliability", false);
            Deploy       = Lib.ConfigValue(cfg, "Deploy", false);
            Science      = Lib.ConfigValue(cfg, "Science", false);
            SpaceWeather = Lib.ConfigValue(cfg, "SpaceWeather", false);
            Automation   = Lib.ConfigValue(cfg, "Automation", false);

            // pressure
            PressureFactor    = Lib.ConfigValue(cfg, "PressureFactor", 10.0);
            PressureThreshold = Lib.ConfigValue(cfg, "PressureThreshold", 0.9);

            // poisoning
            PoisoningFactor    = Lib.ConfigValue(cfg, "PoisoningFactor", 0.0);
            PoisoningThreshold = Lib.ConfigValue(cfg, "PoisoningThreshold", 0.02);

            // humidity
            HumidityFactor    = Lib.ConfigValue(cfg, "HumidityFactor", 1.0);
            HumidityThreshold = Lib.ConfigValue(cfg, "HumidityThreshold", 0.95);

            // signal
            UnlinkedControl = Lib.ConfigEnum(cfg, "UnlinkedControl", UnlinkedCtrl.none);

            // science
            ScienceDialog = Lib.ConfigValue(cfg, "ScienceDialog", true);

            // reliability
            QualityScale = Lib.ConfigValue(cfg, "QualityScale", 4.0);

            // crew level
            LaboratoryCrewLevelBonus = Lib.ConfigValue(cfg, "LaboratoryCrewLevelBonus", 0.2);
            MaxLaborartoryBonus      = Lib.ConfigValue(cfg, "MaxLaborartoryBonus", 2.0);
            HarvesterCrewLevelBonus  = Lib.ConfigValue(cfg, "HarvesterCrewLevelBonus", 0.1);
            MaxHarvesterBonus        = Lib.ConfigValue(cfg, "MaxHarvesterBonus", 2.0);

            // misc
            EnforceCoherency    = Lib.ConfigValue(cfg, "EnforceCoherency", true);
            TrackingPivot       = Lib.ConfigValue(cfg, "TrackingPivot", true);
            HeadLampsCost       = Lib.ConfigValue(cfg, "HeadLampsCost", 0.002);
            LowQualityRendering = Lib.ConfigValue(cfg, "LowQualityRendering", false);
            UIScale             = Lib.ConfigValue(cfg, "UIScale", 1.0f);
            UIPanelWidthScale   = Lib.ConfigValue(cfg, "UIPanelWidthScale", 1.0f);
        }