Ejemplo n.º 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));
                }
            }

            // parse preferred location
            location = Lib.ConfigValue(node, "location", 0u);
        }
Ejemplo n.º 2
0
        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);
            hyspos_signal   = Lib.ConfigValue(node, "hyspos_signal", 0.0);
            hysneg_signal   = Lib.ConfigValue(node, "hysneg_signal", 0.0);
            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));
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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));
            }
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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");
            is_private = Lib.ConfigValue(node, "is_private", false);

            // 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);

            fileSendFlags = new Dictionary <string, bool>();
            var fileNames = Lib.ConfigValue(node, "sendFileNames", string.Empty);

            foreach (var fileName in Lib.Tokenize(fileNames, ','))
            {
                Send(fileName, true);
            }
        }
Ejemplo n.º 7
0
        public static void Load(ConfigNode node)
        {
            // RnD subjects don't exists in sandbox
            if (!Science.GameHasRnD)
            {
                // load sandbox science subjects
                sandboxSubjects.Clear();
                if (node.HasNode("sandboxScienceSubjects"))
                {
                    foreach (var subjectNode in node.GetNode("sandboxScienceSubjects").GetNodes())
                    {
                        ScienceSubject subject = new ScienceSubject(subjectNode);
                        sandboxSubjects.Add(subject.id, subject);
                    }
                }
            }
            else
            {
                // Load API subjects (require RnD)
                subjectsReceivedBuffer.Clear();
                subjectsReceivedValueBuffer.Clear();
                ConfigNode APISubjects = new ConfigNode();
                if (node.TryGetNode("APISubjects", ref APISubjects))
                {
                    foreach (ConfigNode subjectNode in APISubjects.GetNodes("Subject"))
                    {
                        string         subjectId = Lib.ConfigValue(subjectNode, "subjectId", string.Empty);
                        ScienceSubject subject   = ResearchAndDevelopment.GetSubjectByID(subjectId);
                        if (subject == null)
                        {
                            Lib.Log($"Warning : API subject '{subjectId}' not found in ResearchAndDevelopment");
                            continue;
                        }
                        subjectsReceivedBuffer.Add(subject);
                        subjectsReceivedValueBuffer.Add(Lib.ConfigValue(subjectNode, "science", 0.0));
                    }
                }
            }

            // load uncredited science (transmission buffer)
            uncreditedScience = Lib.ConfigValue(node, "uncreditedScience", 0.0);

            // Rebuild the list of persisted subjects
            persistedSubjects.Clear();
            foreach (ExperimentInfo expInfo in experiments.Values)
            {
                foreach (SubjectData subjectData in subjectByExpThenSituationId[expInfo].Values)
                {
                    subjectData.CheckRnD();
                    subjectData.ClearDataCollectedInFlight();
                }
            }

            // load science subjects persisted data
            if (node.HasNode("subjectData"))
            {
                foreach (var subjectNode in node.GetNode("subjectData").GetNodes())
                {
                    string      integerSubjectId = DB.From_safe_key(subjectNode.name);
                    SubjectData subjectData      = GetSubjectData(integerSubjectId);
                    if (subjectData != null)
                    {
                        subjectData.Load(subjectNode);
                    }
                }
            }

            //if (ResearchAndDevelopment.Instance == null)
            //	Lib.Log("ERROR : ResearchAndDevelopment.Instance is null on subjects load !");

            // remove unknown subjects from the database
            foreach (SubjectData subjectData in unknownSubjectDatas.Values)
            {
                int bodyIndex;
                int scienceSituation;
                int biomeIndex;

                Situation.IdToFields(subjectData.Situation.Id, out bodyIndex, out scienceSituation, out biomeIndex);

                expBodiesSituationsBiomesSubject.RemoveSubject(subjectData.ExpInfo, bodyIndex, (ScienceSituation)scienceSituation, biomeIndex, subjectData);
            }

            // clear the list
            unknownSubjectDatas.Clear();


            // find them again
            IEnumerable <ScienceSubject> stockSubjects;

            if (Science.GameHasRnD)
            {
                stockSubjects = ResearchAndDevelopment.GetSubjects();
            }
            else
            {
                stockSubjects = sandboxSubjects.Values;
            }

            foreach (ScienceSubject stockSubject in stockSubjects)
            {
                if (!knownStockSubjectsId.Contains(stockSubject.id))
                {
                    GetSubjectDataFromStockId(stockSubject.id, stockSubject);
                }
            }
        }
Ejemplo n.º 8
0
        public static void Load(ConfigNode node)
        {
            // RnD subjects don't exists in sandbox
            if (!Science.GameHasRnD)
            {
                return;
            }

            // load uncredited science (transmission buffer)
            uncreditedScience = Lib.ConfigValue(node, "uncreditedScience", 0.0);

            // Rebuild the list of persisted subjects
            persistedSubjects.Clear();
            foreach (ExperimentInfo expInfo in experiments.Values)
            {
                foreach (SubjectData subjectData in subjectByExpThenSituationId[expInfo].Values)
                {
                    subjectData.CheckRnD();
                    subjectData.ClearDataCollectedInFlight();
                }
            }

            // load science subjects persisted data
            if (node.HasNode("subjectData"))
            {
                foreach (var subjectNode in node.GetNode("subjectData").GetNodes())
                {
                    string      integerSubjectId = DB.From_safe_key(subjectNode.name);
                    SubjectData subjectData      = GetSubjectData(integerSubjectId);
                    if (subjectData != null)
                    {
                        subjectData.Load(subjectNode);
                    }
                }
            }

            if (ResearchAndDevelopment.Instance == null)
            {
                Lib.Log("ERROR : ResearchAndDevelopment.Instance is null on subjects load !");
            }

            // remove unknown subjects from the database
            foreach (SubjectData subjectData in unknownSubjectDatas.Values)
            {
                int bodyIndex;
                int scienceSituation;
                int biomeIndex;

                Situation.IdToFields(subjectData.Situation.Id, out bodyIndex, out scienceSituation, out biomeIndex);

                expBodiesSituationsBiomesSubject.RemoveSubject(subjectData.ExpInfo, bodyIndex, (ScienceSituation)scienceSituation, biomeIndex, subjectData);
                bodiesSituationsBiomesSubjects.RemoveSubject(bodyIndex, (ScienceSituation)scienceSituation, biomeIndex, subjectData);
            }

            // clear the list
            unknownSubjectDatas.Clear();


            // find them again
            foreach (ScienceSubject stockSubject in ResearchAndDevelopment.GetSubjects())
            {
                if (!knownStockSubjectsId.Contains(stockSubject.id))
                {
                    GetSubjectDataFromStockId(stockSubject.id, stockSubject);
                }
            }
        }
Ejemplo n.º 9
0
        public Drive(ConfigNode node)
        {
            // parse science  files
            files = new Dictionary <SubjectData, File>();
            if (node.HasNode("files"))
            {
                foreach (var file_node in node.GetNode("files").GetNodes())
                {
                    string subject_id = DB.From_safe_key(file_node.name);
                    File   file       = File.Load(subject_id, file_node);
                    if (file != null)
                    {
                        if (files.ContainsKey(file.subjectData))
                        {
                            Lib.Log("discarding duplicate subject " + file.subjectData, Lib.LogLevel.Warning);
                        }
                        else
                        {
                            files.Add(file.subjectData, file);
                            file.subjectData.AddDataCollectedInFlight(file.size);
                        }
                    }
                    else
                    {
                        file = File.LoadOldFormat(subject_id, file_node);
                        if (file != null)
                        {
                            Lib.Log("Drive file load : converted '" + subject_id + "' to new format");
                            if (files.ContainsKey(file.subjectData))
                            {
                                Lib.Log("discarding duplicate converted subject " + file.subjectData, Lib.LogLevel.Warning);
                            }
                            else
                            {
                                files.Add(file.subjectData, file);
                                file.subjectData.AddDataCollectedInFlight(file.size);
                            }
                        }
                    }
                }
            }

            // parse science samples
            samples = new Dictionary <SubjectData, Sample>();
            if (node.HasNode("samples"))
            {
                foreach (var sample_node in node.GetNode("samples").GetNodes())
                {
                    string subject_id = DB.From_safe_key(sample_node.name);
                    Sample sample     = Sample.Load(subject_id, sample_node);
                    if (sample != null)
                    {
                        samples.Add(sample.subjectData, sample);
                        sample.subjectData.AddDataCollectedInFlight(sample.size);
                    }
                    else
                    {
                        sample = Sample.LoadOldFormat(subject_id, sample_node);
                        if (sample != null)
                        {
                            Lib.Log("Drive sample load : converted '" + subject_id + "' to new format");
                            samples.Add(sample.subjectData, sample);
                            sample.subjectData.AddDataCollectedInFlight(sample.size);
                        }
                    }
                }
            }

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

            // 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);

            fileSendFlags = new Dictionary <string, bool>();
            string fileNames = Lib.ConfigValue(node, "sendFileNames", string.Empty);

            foreach (string fileName in Lib.Tokenize(fileNames, ','))
            {
                Send(fileName, true);
            }
        }