public void UpdateSurfaceType(BiomeSurfaceType surfaceType)
        {
            switch (surfaceType)
            {
            case BiomeSurfaceType.SurfaceMaps:
                SetAnchorVisibility("inputMaps", Visibility.Visible);
                SetAnchorVisibility("inputColor", Visibility.Gone);
                SetAnchorVisibility("inputMaterial", Visibility.Gone);
                break;

            case BiomeSurfaceType.Color:
                SetAnchorVisibility("inputMaps", Visibility.Gone);
                SetAnchorVisibility("inputColor", Visibility.Visible);
                SetAnchorVisibility("inputMaterial", Visibility.Gone);
                break;

            case BiomeSurfaceType.Material:
                SetAnchorVisibility("inputMaps", Visibility.Gone);
                SetAnchorVisibility("inputColor", Visibility.Gone);
                SetAnchorVisibility("inputMaterial", Visibility.Visible);
                break;

            default:
                break;
            }
        }
        public bool BuildGraph(List <BiomeSurfaceSwitch> surfacesSwitches)
        {
            var bSwitchCellMap = new Dictionary <BiomeSurfaceSwitch, BiomeSurfaceCell>();

            isBuilt = false;

            if (surfacesSwitches.Count == 0)
            {
                return(false);
            }

            surfaceType = surfacesSwitches.First().surface.type;

            Action <BiomeSurfaceCell, BiomeSurfaceSwitch> AddLink = (cell, s) => {
                var link = new BiomeSurfaceLink();

                link.toCell = bSwitchCellMap[s];

                if (!cell.links.Any(c => c.toCell == link.toCell))
                {
                    cell.links.Add(link);
                }
            };

            //calcul ranges
            float heightRange = surfacesSwitches.Max(s => s.maxHeight) - surfacesSwitches.Min(s => s.minHeight);
            float slopeRange  = surfacesSwitches.Max(s => s.maxSlope) - surfacesSwitches.Min(s => s.minSlope);
            float paramRange  = surfacesSwitches.Max(s => s.maxParam) - surfacesSwitches.Min(s => s.minParam);

            //Generate surface switches nodes:
            foreach (var bSwitch in surfacesSwitches)
            {
                bSwitchCellMap[bSwitch] = new BiomeSurfaceCell();
            }

            cells.Clear();
            lastCell = null;

            foreach (var bSwitch in surfacesSwitches)
            {
                BiomeSurfaceCell cell = bSwitchCellMap[bSwitch];
                cell.surface       = bSwitch.surface;
                cell.surfaceSwitch = bSwitch;
                cell.weight        = bSwitch.GetWeight(heightRange, slopeRange, paramRange);

                foreach (var biomeSwitch in surfacesSwitches)
                {
                    if (biomeSwitch.Overlaps(bSwitch))
                    {
                        AddLink(cell, biomeSwitch);
                    }
                }

                cell.links.Sort((l1, l2) => {
                    float w1 = l1.toCell.weight;
                    float w2 = l2.toCell.weight;

                    //reverse sort
                    return(w2.CompareTo(w1));
                });

                cells.Add(cell);
            }

            rootCell = cells.First();

            if (!CheckValid())
            {
                return(false);
            }

            isBuilt = true;

            return(true);
        }