public static Color GetBiomeColour(Collider c)
        {
            if (_dustBodies == null)
                LoadDustColours();

            string currentBody = FlightGlobals.ActiveVessel.mainBody.name;
            DustBody body = null;
            if (_previousDustBody != null &&
                _previousDustBody.Name.Equals(currentBody, StringComparison.InvariantCultureIgnoreCase))
                body = _previousDustBody;
            else
            {
                _previousDustBiome = null;
                foreach (DustBody db in _dustBodies)
                {
                    if (db.Name.Equals(currentBody, StringComparison.InvariantCultureIgnoreCase))
                    {
                        body = db;
                        _previousDustBody = db;
                        break;
                    }
                }
            }

            if (body == null)
            {
                Debug.LogWarning("CollisionFX: Unable to find dust definition for body \"" + currentBody + "\"; using default.");
                return genericDustColour;
            }

            string currentBiome = IsPQS(c) ? GetCurrentBiomeName(FlightGlobals.ActiveVessel) : "Structure";
            DustBiome biome = null;
            if (_previousDustBiome != null &&
                _previousDustBiome.Name.Equals(currentBiome, StringComparison.InvariantCultureIgnoreCase))
                biome = _previousDustBiome;
            else
            {
                foreach (DustBiome b in body.Biomes)
                {
                    if (b.Name.Equals(currentBiome, StringComparison.InvariantCultureIgnoreCase))
                    {
                        biome = b;
                        _previousDustBiome = b;
                        break;
                    }
                }
            }

            if (biome == null)
            {
                Debug.LogWarning("CollisionFX: Unable to find dust definition for biome \"" + currentBiome +
                    "\" on body \"" + currentBody + "\"; using default.");
                return genericDustColour;
            }

            return biome.DustColour;
        }
        public static void LoadDustColours()
        {
            _dustBodies = new List <DustBody>();
            ConfigNode config = ConfigNode.Load(CollisionFX.ConfigPath);

            if (config == null)
            {
                Debug.LogError("CollisionFX: Configuration file not found at " + CollisionFX.ConfigPath);
                return;
            }
            foreach (ConfigNode node in config.nodes)
            {
                if (!node.name.Equals("DustBody"))
                {
                    continue;
                }

                DustBody body;
                if (node.HasValue("name"))
                {
                    body = new DustBody
                    {
                        Name   = node.GetValue("name"),
                        Biomes = new List <DustBiome>()
                    };
                    Debug.Log("#Body " + body.Name);
                }
                else
                {
                    Debug.LogWarning("CollisionFX: Invalid DustBody definition: \"name\" field is missing.");
                    continue;
                }

                if (!node.HasNode("Biomes"))
                {
                    continue;
                }
                ConfigNode biomeNode = node.GetNode("Biomes");
                foreach (ConfigNode.Value biomeDefinition in biomeNode.values)
                {
                    string   colourString = biomeDefinition.value;
                    string[] colourValues = colourString.Split(' ');
                    if (colourValues.Length > 4)
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                         body.Name + "\": Too many parameters.");
                        continue;
                    }
                    float        r, g, b, a;
                    NumberStyles flags = NumberStyles.AllowDecimalPoint;
                    if (!float.TryParse(colourValues[0], flags, CultureInfo.InvariantCulture, out r))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                         body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }
                    if (!float.TryParse(colourValues[1], flags, CultureInfo.InvariantCulture, out g))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                         body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }
                    if (!float.TryParse(colourValues[2], flags, CultureInfo.InvariantCulture, out b))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                         body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }

                    Color c;
                    if (colourValues.Length == 4)
                    {
                        if (!float.TryParse(colourValues[3], flags, CultureInfo.InvariantCulture, out a))
                        {
                            Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                             body.Name + "\": \"\" is not a valid integer.");
                            continue;
                        }
                        c = new Color(r, g, b, a);
                    }
                    else
                    {
                        c = new Color(r, g, b);
                    }

                    DustBiome biome = new DustBiome
                    {
                        Name       = biomeDefinition.name,
                        DustColour = c
                    };
                    body.Biomes.Add(biome);
                }
                _dustBodies.Add(body);
            }
        }
        public static Color GetBiomeColour(Collider c)
        {
            if (_dustBodies == null)
            {
                LoadDustColours();
            }

            string   currentBody = FlightGlobals.ActiveVessel.mainBody.name;
            DustBody body        = null;

            if (_previousDustBody != null &&
                _previousDustBody.Name.Equals(currentBody, StringComparison.InvariantCultureIgnoreCase))
            {
                body = _previousDustBody;
            }
            else
            {
                _previousDustBiome = null;
                foreach (DustBody db in _dustBodies)
                {
                    if (db.Name.Equals(currentBody, StringComparison.InvariantCultureIgnoreCase))
                    {
                        body = db;
                        _previousDustBody = db;
                        break;
                    }
                }
            }

            if (body == null)
            {
                Debug.LogWarning("CollisionFX: Unable to find dust definition for body \"" + currentBody + "\"; using default.");
                return(genericDustColour);
            }

            string    currentBiome = IsPQS(c) ? GetCurrentBiomeName(FlightGlobals.ActiveVessel) : "Structure";
            DustBiome biome        = null;

            if (_previousDustBiome != null &&
                _previousDustBiome.Name.Equals(currentBiome, StringComparison.InvariantCultureIgnoreCase))
            {
                biome = _previousDustBiome;
            }
            else
            {
                foreach (DustBiome b in body.Biomes)
                {
                    if (b.Name.Equals(currentBiome, StringComparison.InvariantCultureIgnoreCase))
                    {
                        biome = b;
                        _previousDustBiome = b;
                        break;
                    }
                }
            }

            if (biome == null)
            {
                Debug.LogWarning("CollisionFX: Unable to find dust definition for biome \"" + currentBiome +
                                 "\" on body \"" + currentBody + "\"; using default.");
                return(genericDustColour);
            }

            return(biome.DustColour);
        }
        public static void LoadDustColours()
        {
            _dustBodies = new List<DustBody>();
            ConfigNode config = ConfigNode.Load(CollisionFX.ConfigPath);
            if (config == null)
            {
                Debug.LogError("CollisionFX: Configuration file not found at " + CollisionFX.ConfigPath);
                return;
            }
            foreach (ConfigNode node in config.nodes)
            {
                if (!node.name.Equals("DustBody"))
                    continue;

                DustBody body;
                if (node.HasValue("name"))
                {
                    body = new DustBody
                    {
                        Name = node.GetValue("name"),
                        Biomes = new List<DustBiome>()
                    };
                    Debug.Log("#Body " + body.Name);
                }
                else
                {
                    Debug.LogWarning("CollisionFX: Invalid DustBody definition: \"name\" field is missing.");
                    continue;
                }

                if (!node.HasNode("Biomes"))
                    continue;
                ConfigNode biomeNode = node.GetNode("Biomes");
                foreach (ConfigNode.Value biomeDefinition in biomeNode.values)
                {
                    string colourString = biomeDefinition.value;
                    string[] colourValues = colourString.Split(' ');
                    if (colourValues.Length > 4)
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                            body.Name + "\": Too many parameters.");
                        continue;
                    }
                    float r, g, b, a;
                    NumberStyles flags = NumberStyles.AllowDecimalPoint;
                    if (!float.TryParse(colourValues[0], flags, CultureInfo.InvariantCulture, out r))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                            body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }
                    if (!float.TryParse(colourValues[1], flags, CultureInfo.InvariantCulture, out g))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                            body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }
                    if (!float.TryParse(colourValues[2], flags, CultureInfo.InvariantCulture, out b))
                    {
                        Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                            body.Name + "\": \"\" is not a valid integer.");
                        continue;
                    }

                    Color c;
                    if (colourValues.Length == 4)
                    {
                        if (!float.TryParse(colourValues[3], flags, CultureInfo.InvariantCulture, out a))
                        {
                            Debug.LogWarning("CollisionFX: Invalid Biome colour definition in body \"" +
                                body.Name + "\": \"\" is not a valid integer.");
                            continue;
                        }
                        c = new Color(r, g, b, a);
                    }
                    else
                        c = new Color(r, g, b);

                    DustBiome biome = new DustBiome
                    {
                        Name = biomeDefinition.name,
                        DustColour = c
                    };
                    body.Biomes.Add(biome);
                }
                _dustBodies.Add(body);
            }
        }