예제 #1
0
        private void ReadRegion(IServerPlayer player, CmdArgs arguments)
        {
            if (arguments.Length < 1)
            {
                player.SendMessage(groupId, "/wgen region [climate|ore|forest|wind|gprov|gprovi|landform|landformi]", EnumChatType.CommandError);
                return;
            }

            int          chunkSize   = api.WorldManager.ChunkSize;
            BlockPos     pos         = player.Entity.Pos.AsBlockPos;
            IServerChunk serverchunk = api.WorldManager.GetChunk(pos);

            if (serverchunk == null)
            {
                player.SendMessage(groupId, "Can't check here, beyond chunk boundaries!", EnumChatType.CommandError);
                return;
            }

            IMapRegion mapRegion = serverchunk.MapChunk.MapRegion;


            int regionX = pos.X / regionSize;
            int regionZ = pos.Z / regionSize;

            string arg = arguments.PopWord();

            string subarg = arguments.PopWord();
            bool   dolerp = subarg == "nolerp";

            NoiseBase.Debug = true;

            switch (arg)
            {
            case "climate":
                DrawMapRegion(0, player, mapRegion.ClimateMap, "climate", dolerp, regionX, regionZ, TerraGenConfig.climateMapScale);
                break;

            case "ore":
                string type = dolerp ? arguments.PopWord("limonite") : subarg;
                if (type == null)
                {
                    type = "limonite";
                }

                if (!mapRegion.OreMaps.ContainsKey(type))
                {
                    player.SendMessage(groupId, "Mapregion does not contain an ore map for ore " + type, EnumChatType.CommandError);
                    return;
                }

                DrawMapRegion(DebugDrawMode.RGB, player, mapRegion.OreMaps[type], "ore-" + type, dolerp, regionX, regionZ, TerraGenConfig.oreMapScale);
                break;

            case "forest":
                DrawMapRegion(DebugDrawMode.FirstByteGrayscale, player, mapRegion.ForestMap, "forest", dolerp, regionX, regionZ, TerraGenConfig.forestMapScale);
                break;


            case "oretopdistort":
                DrawMapRegion(DebugDrawMode.FirstByteGrayscale, player, mapRegion.OreMapVerticalDistortTop, "oretopdistort", dolerp, regionX, regionZ, TerraGenConfig.depositVerticalDistortScale);
                break;

            //case "depdist":
            //DrawMapRegion(0, player, mapRegion.DepositDistortionMap, "depositdistortion", dolerp, regionX, regionZ, TerraGenConfig.depositDistortionScale);
            //break;

            case "rockstrata":

                for (int i = 0; i < mapRegion.RockStrata.Length; i++)
                {
                    DrawMapRegion(DebugDrawMode.FirstByteGrayscale, player, mapRegion.RockStrata[i], "rockstrata" + i, dolerp, regionX, regionZ, TerraGenConfig.rockStrataScale);
                }
                break;

            case "wind":
            {
            }
            break;


            case "gprov":
                DrawMapRegion(DebugDrawMode.ProvinceRGB, player, mapRegion.GeologicProvinceMap, "province", dolerp, regionX, regionZ, TerraGenConfig.geoProvMapScale);
                break;


            case "gprovi":
            {
                int[] gprov            = mapRegion.GeologicProvinceMap.Data;
                int   noiseSizeGeoProv = mapRegion.GeologicProvinceMap.InnerSize;

                int outSize = (noiseSizeGeoProv + TerraGenConfig.geoProvMapPadding - 1) * TerraGenConfig.geoProvMapScale;

                GeologicProvinceVariant[] provincesByIndex = NoiseGeoProvince.provinces.Variants;

                LerpedWeightedIndex2DMap map = new LerpedWeightedIndex2DMap(gprov, noiseSizeGeoProv + 2 * TerraGenConfig.geoProvMapPadding, 2, mapRegion.GeologicProvinceMap.TopLeftPadding, mapRegion.GeologicProvinceMap.BottomRightPadding);

                int[] outColors = new int[outSize * outSize];
                for (int x = 0; x < outSize; x++)
                {
                    for (int z = 0; z < outSize; z++)
                    {
                        WeightedIndex[] indices = map[(float)x / TerraGenConfig.geoProvMapScale, (float)z / TerraGenConfig.geoProvMapScale];
                        for (int i = 0; i < indices.Length; i++)
                        {
                            indices[i].Index = provincesByIndex[indices[i].Index].ColorInt;
                        }
                        int[]   colors;
                        float[] weights;
                        map.Split(indices, out colors, out weights);
                        outColors[z * outSize + x] = ColorUtil.ColorAverage(colors, weights);
                    }
                }

                NoiseBase.DebugDrawBitmap(DebugDrawMode.ProvinceRGB, outColors, outSize, outSize, "geoprovince-lerped-" + regionX + "-" + regionZ);

                player.SendMessage(groupId, "done", EnumChatType.CommandSuccess);

                break;
            }



            case "landform":
                DrawMapRegion(DebugDrawMode.LandformRGB, player, mapRegion.LandformMap, "landform", dolerp, regionX, regionZ, TerraGenConfig.landformMapScale);
                break;



            case "landformi":
            {
                int[] data = mapRegion.LandformMap.Data;
                int   noiseSizeLandform = mapRegion.LandformMap.InnerSize;

                int outSize = (noiseSizeLandform + TerraGenConfig.landformMapPadding - 1) * TerraGenConfig.landformMapScale;

                LandformVariant[] landformsByIndex = NoiseLandforms.landforms.LandFormsByIndex;

                LerpedWeightedIndex2DMap map = new LerpedWeightedIndex2DMap(data, mapRegion.LandformMap.Size, 1, mapRegion.LandformMap.TopLeftPadding, mapRegion.LandformMap.BottomRightPadding);

                int[] outColors = new int[outSize * outSize];
                for (int x = 0; x < outSize; x++)
                {
                    for (int z = 0; z < outSize; z++)
                    {
                        WeightedIndex[] indices = map[(float)x / TerraGenConfig.landformMapScale, (float)z / TerraGenConfig.landformMapScale];
                        for (int i = 0; i < indices.Length; i++)
                        {
                            indices[i].Index = landformsByIndex[indices[i].Index].ColorInt;
                        }
                        int[]   colors;
                        float[] weights;
                        map.Split(indices, out colors, out weights);
                        outColors[z * outSize + x] = ColorUtil.ColorAverage(colors, weights);
                    }
                }

                NoiseBase.DebugDrawBitmap(DebugDrawMode.LandformRGB, outColors, outSize, outSize, "landform-lerped-" + regionX + "-" + regionZ);

                player.SendMessage(groupId, "Landform map done", EnumChatType.CommandSuccess);

                break;
            }


            default:
                player.SendMessage(groupId, "/wgen region [climate|ore|forest|wind|gprov|landform]", EnumChatType.CommandError);
                break;
            }

            NoiseBase.Debug = false;
        }