Esempio n. 1
0
 void DrawMapRegion(DebugDrawMode mode, IServerPlayer player, IntMap map, string prefix, bool lerp, int regionX, int regionZ, int scale)
 {
     if (lerp)
     {
         int[] lerped = GameMath.BiLerpColorMap(map, scale);
         NoiseBase.DebugDrawBitmap(mode, lerped, map.InnerSize * scale, prefix + "-" + regionX + "-" + regionZ + "-l");
         player.SendMessage(groupId, "Lerped " + prefix + " map generated.", EnumChatType.CommandSuccess);
     }
     else
     {
         NoiseBase.DebugDrawBitmap(mode, map.Data, map.Size, prefix + "-" + regionX + "-" + regionZ);
         player.SendMessage(groupId, "Original " + prefix + " map generated.", EnumChatType.CommandSuccess);
     }
 }
Esempio n. 2
0
        void TestMap(IServerPlayer player, CmdArgs arguments)
        {
            if (arguments.Length < 2)
            {
                player.SendMessage(groupId, "/wgen testmap [climate|forest|wind|gprov|landform|ore]", EnumChatType.CommandError);
                return;
            }

            Random rnd  = new Random();
            long   seed = rnd.Next();

            switch (arguments[1])
            {
            case "climate":
            {
                NoiseBase.Debug = true;
                NoiseClimatePatchy noiseClimate = new NoiseClimatePatchy(seed);
                MapLayerBase       climate      = GenMaps.GetClimateMapGen(seed, noiseClimate);
                player.SendMessage(groupId, "Patchy climate map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "climater":
            {
                NoiseBase.Debug = false;
                NoiseClimateRealistic noiseClimate = new NoiseClimateRealistic(seed, api.World.BlockAccessor.MapSizeZ / TerraGenConfig.climateMapScale / TerraGenConfig.climateMapSubScale);
                MapLayerBase          climate      = GenMaps.GetClimateMapGen(seed, noiseClimate);

                NoiseBase.DebugDrawBitmap(DebugDrawMode.RGB, climate.GenLayer(0, 0, 128, 2048), 128, 2048, "realisticlimate");

                player.SendMessage(groupId, "Realistic climate map generated", EnumChatType.CommandSuccess);
            }
            break;


            case "forest":
            {
                NoiseBase.Debug = false;
                NoiseClimatePatchy noiseClimate = new NoiseClimatePatchy(seed);
                MapLayerBase       climate      = GenMaps.GetClimateMapGen(seed, noiseClimate);
                MapLayerBase       forest       = GenMaps.GetForestMapGen(seed + 1, TerraGenConfig.forestMapScale);

                IntMap climateMap = new IntMap()
                {
                    Data = climate.GenLayer(0, 0, 512, 512), Size = 512
                };

                forest.SetInputMap(climateMap, new IntMap()
                    {
                        Size = 512
                    });

                NoiseBase.Debug = true;
                forest.DebugDrawBitmap(DebugDrawMode.FirstByteGrayscale, 0, 0, "Forest 1 - Forest");
                player.SendMessage(groupId, "Forest map generated", EnumChatType.CommandSuccess);
            }
            break;


            case "ore":
            {
                NoiseBase.Debug = false;
                NoiseOre     noiseOre = new NoiseOre(seed);
                MapLayerBase climate  = GenMaps.GetOreMap(seed, noiseOre);
                NoiseBase.Debug = true;
                climate.DebugDrawBitmap(DebugDrawMode.RGB, 0, 0, 1024, "Ore 1 - Ore");
                player.SendMessage(groupId, "ore map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "oretopdistort":
                NoiseBase.Debug = true;
                NoiseBase topdistort = GenMaps.GetDepositVerticalDistort(seed);
                player.SendMessage(groupId, "Ore top distort map generated", EnumChatType.CommandSuccess);
                break;

            case "wind":
                NoiseBase.Debug = true;
                NoiseBase wind = GenMaps.GetDebugWindMap(seed);
                player.SendMessage(groupId, "Wind map generated", EnumChatType.CommandSuccess);
                break;

            case "gprov":
                NoiseBase.Debug = true;
                MapLayerBase provinces = GenMaps.GetGeologicProvinceMapGen(seed, api);

                player.SendMessage(groupId, "Province map generated", EnumChatType.CommandSuccess);
                break;


            case "landform":
            {
                NoiseBase.Debug = true;
                NoiseClimatePatchy noiseClimate = new NoiseClimatePatchy(seed);
                MapLayerBase       landforms    = GenMaps.GetLandformMapGen(seed + 1, noiseClimate, api);

                player.SendMessage(groupId, "Landforms map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "rockstrata":
            {
                NoiseBase.Debug = true;
                GenRockStrataNew mod = api.ModLoader.GetModSystem <GenRockStrataNew>();
                for (int i = 0; i < mod.strataNoises.Length; i++)
                {
                    mod.strataNoises[i].DebugDrawBitmap(DebugDrawMode.FirstByteGrayscale, 0, 0, "Rockstrata-" + mod.strata.Variants[i].BlockCode);
                }

                player.SendMessage(groupId, "Rockstrata maps generated", EnumChatType.CommandSuccess);
            }
            break;

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

            NoiseBase.Debug = false;
        }
Esempio n. 3
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;
        }
Esempio n. 4
0
        void TestMap(IServerPlayer player, CmdArgs arguments)
        {
            if (arguments.Length < 2)
            {
                player.SendMessage(groupId, "/wgen testmap [climate|forest|wind|gprov|landform|ore]", EnumChatType.CommandError);
                return;
            }

            Random rnd  = new Random();
            long   seed = rnd.Next();

            switch (arguments[1])
            {
            case "climate":
            {
                NoiseBase.Debug = true;
                NoiseClimate noiseClimate = new NoiseClimate(seed);
                MapLayerBase climate      = GenMaps.GetClimateMap(seed, noiseClimate);
                player.SendMessage(groupId, "Climate map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "forest":
            {
                NoiseBase.Debug = false;
                NoiseClimate noiseClimate = new NoiseClimate(seed);
                MapLayerBase climate      = GenMaps.GetClimateMap(seed, noiseClimate);
                MapLayerBase forest       = GenMaps.GetForestMap(seed + 1, TerraGenConfig.forestMapScale);

                IntMap climateMap = new IntMap()
                {
                    Data = climate.GenLayer(0, 0, 512, 512), Size = 512
                };

                forest.SetInputMap(climateMap, new IntMap()
                    {
                        Size = 512
                    });

                NoiseBase.Debug = true;
                forest.DebugDrawBitmap(1, 0, 0, "Forest 1 - Forest");
                player.SendMessage(groupId, "Forest map generated", EnumChatType.CommandSuccess);
            }
            break;


            case "ore":
            {
                NoiseBase.Debug = false;
                NoiseOre     noiseOre = new NoiseOre(seed);
                MapLayerBase climate  = GenMaps.GetOreMap(seed, noiseOre);
                NoiseBase.Debug = true;
                climate.DebugDrawBitmap(0, 0, 0, 1024, "Ore 1 - Ore");
                player.SendMessage(groupId, "ore map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "wind":
                NoiseBase.Debug = true;
                NoiseBase wind = GenMaps.GetDebugWindMap(seed);
                player.SendMessage(groupId, "Wind map generated", EnumChatType.CommandSuccess);
                break;

            case "gprov":
                NoiseBase.Debug = true;
                MapLayerBase provinces = GenMaps.GetGeologicProvinceMap(seed, api);

                player.SendMessage(groupId, "Province map generated", EnumChatType.CommandSuccess);
                break;

            case "landform":
            {
                NoiseBase.Debug = true;
                NoiseClimate noiseClimate = new NoiseClimate(seed);
                MapLayerBase landforms    = GenMaps.GetLandformMap(seed + 1, noiseClimate, api);

                player.SendMessage(groupId, "Landforms map generated", EnumChatType.CommandSuccess);
            }
            break;


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

            NoiseBase.Debug = false;
        }