public static Color GetBiomeDustColour(BodyDust body, string currentBiome)
        {
            BiomeDust biome = null;

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

            if (biome != null)
            {
                return(biome.DustColour);
            }
            if (body.DefaultBiomeColour != Color.clear)
            {
                return(body.DefaultBiomeColour);
            }

            // No colour found.
            return(Color.clear);
        }
        public static BodyDust GetBodyDust(string bodyName)
        {
            if (_bodies == null)
            {
                LoadDustColours();
            }

            BodyDust body = null;

            if (_previousBodyDust != null &&
                _previousBodyDust.Name.Equals(bodyName, StringComparison.InvariantCultureIgnoreCase))
            {
                body = _previousBodyDust;
            }
            else
            {
                _previousBiomeDust = null;
                foreach (BodyDust db in _bodies)
                {
                    if (db.Name.Equals(bodyName, StringComparison.InvariantCultureIgnoreCase))
                    {
                        body = db;
                        _previousBodyDust = db;
                        break;
                    }
                }
            }
            return(body);
        }
        public static void LoadDustColours()
        {
            //c.collider.name = "runway_lev1"


            _bodies = new List <BodyDust>();
            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("BodyDust"))
                {
                    continue;
                }

                // Load body
                BodyDust body;
                if (node.HasValue("name"))
                {
                    body = new BodyDust
                    {
                        Name       = node.GetValue("name"),
                        Biomes     = new List <BiomeDust>(),
                        Structures = new List <StructureDust>()
                    };
                }
                else
                {
                    Debug.LogWarning("[CollisionFX] Invalid BodyDust definition: \"name\" field is missing.");
                    continue;
                }

                // Load biomes
                if (node.HasNode("Biomes"))
                {
                    ConfigNode biomeNode = node.GetNode("Biomes");
                    foreach (ConfigNode.Value biomeDefinition in biomeNode.values)
                    {
                        Color c;
                        if (!TryParseDustColour(biomeDefinition, body.Name, out c))
                        {
                            continue;
                        }

                        BiomeDust biome = new BiomeDust
                        {
                            Name       = biomeDefinition.name,
                            DustColour = c
                        };
                        if (biomeDefinition.name.Equals("Default", StringComparison.InvariantCultureIgnoreCase))
                        {
                            body.DefaultBiomeColour = c;
                        }

                        body.Biomes.Add(biome);
                    }
                }

                // Load structures
                if (node.HasNode("Structures"))
                {
                    ConfigNode structureNode = node.GetNode("Structures");
                    foreach (ConfigNode.Value structureDefinition in structureNode.values)
                    {
                        Color c;
                        if (!TryParseDustColour(structureDefinition, body.Name, out c))
                        {
                            continue;
                        }

                        StructureDust structure = new StructureDust
                        {
                            Name       = structureDefinition.name,
                            DustColour = c
                        };
                        body.Structures.Add(structure);
                    }
                }

                _bodies.Add(body);
            }

            if (_bodies.Count == 0)
            {
                Debug.LogWarning("[CollisionFX] Unable to find dust definitions. Ensure " + CollisionFX.ConfigPath + " contains correct BodyDust entries.");
            }
        }