示例#1
0
        protected void Load()
        {
            foreach (string file in new string[] { DefaultBiomeDataFile, BiomeDataFile })
            {
                if (!File.Exists(file))
                {
                    continue;
                }

                ConfigNode node = ConfigNode.Load(file);
                foreach (ConfigNode bodyNode in node.GetNodes("CELESTIAL_BODY"))
                {
                    CelestialBody body;
                    try
                    {
                        body = ConfigNodeUtil.ParseValue <CelestialBody>(bodyNode, "body");
                    }
                    // Check for invalidated celestial bodies, and ignore those entries
                    catch (ArgumentException e)
                    {
                        if (e.Message.Contains("not a valid CelestialBody"))
                        {
                            continue;
                        }
                        else
                        {
                            throw;
                        }
                    }
                    Dictionary <string, BiomeData> biomeDetails = bodyInfo[body] = new Dictionary <string, BiomeData>();

                    foreach (ConfigNode biomeNode in bodyNode.GetNodes("BIOME"))
                    {
                        BiomeData biomeData = BiomeData.Load(biomeNode);
                        biomeDetails.Add(biomeData.name, biomeData);
                    }
                }
            }
        }