public void OnMapRegionGen(IMapRegion mapRegion, int regionX, int regionZ) { IntDataMap2D map; if (OreMapLayer != null && !mapRegion.OreMaps.ContainsKey(Code)) { map = new IntDataMap2D(); map.Size = noiseSizeOre + 1; map.BottomRightPadding = 1; map.Data = OreMapLayer.GenLayer(regionX * noiseSizeOre, regionZ * noiseSizeOre, noiseSizeOre + 1, noiseSizeOre + 1); mapRegion.OreMaps[Code] = map; } if (ChildDeposits != null) { for (int k = 0; k < ChildDeposits.Length; k++) { DepositVariant childVariant = ChildDeposits[k]; if (childVariant.OreMapLayer != null && !mapRegion.OreMaps.ContainsKey(childVariant.Code)) { map = new IntDataMap2D(); map.Size = noiseSizeOre + 1; map.BottomRightPadding = 1; map.Data = childVariant.OreMapLayer.GenLayer(regionX * noiseSizeOre, regionZ * noiseSizeOre, noiseSizeOre + 1, noiseSizeOre + 1); mapRegion.OreMaps[childVariant.Code] = map; } } } }
public void OnMapRegionGen(IMapRegion mapRegion, int regionX, int regionZ) { int pad = 2; TerraGenConfig.depositVerticalDistortScale = 2; int noiseSize = api.WorldManager.RegionSize / TerraGenConfig.depositVerticalDistortScale; IntDataMap2D map = mapRegion.OreMapVerticalDistortBottom; map.Size = noiseSize + 2 * pad; map.BottomRightPadding = map.TopLeftPadding = pad; map.Data = verticalDistortBottom.GenLayer(regionX * noiseSize - pad, regionZ * noiseSize - pad, noiseSize + 2 * pad, noiseSize + 2 * pad); map = mapRegion.OreMapVerticalDistortTop; map.Size = noiseSize + 2 * pad; map.BottomRightPadding = map.TopLeftPadding = pad; map.Data = verticalDistortTop.GenLayer(regionX * noiseSize - pad, regionZ * noiseSize - pad, noiseSize + 2 * pad, noiseSize + 2 * pad); for (int i = 0; i < Deposits.Length; i++) { DepositVariant variant = Deposits[i]; variant.OnMapRegionGen(mapRegion, regionX, regionZ); } }
public override int[] GenLayer(int xCoord, int yCoord, int sizeX, int sizeY) { sizeX += zoomLevel; sizeY += zoomLevel; int[] outCache = new int[sizeX * sizeY]; int parentXCoord = xCoord / zoomLevel - 1; int parentZCoord = yCoord / zoomLevel - 1; int smallXSize = sizeX / zoomLevel; int smallZSize = sizeY / zoomLevel; int[] inInts = parent.GenLayer(parentXCoord, parentZCoord, smallXSize, smallZSize); int index, inValue; for (int i = 0; i < inInts.Length; i++) { int xpos = i % smallXSize; int zpos = i / smallXSize; inValue = inInts[i]; index = zoomLevel * xpos + zoomLevel * zpos * sizeX; for (int j = 0; j < zoomLevel * zoomLevel; j++) { outCache[index + sizeX * (j / zoomLevel) + j % zoomLevel] = inValue; } } return(CutRightAndBottom(outCache, sizeX, sizeY, zoomLevel)); }
public override int[] GenLayer(int xCoord, int zCoord, int sizeX, int sizeZ) { int[] map = parent.GenLayer(xCoord, zCoord, sizeX, sizeZ); BoxBlurHorizontal(map, range, 0, 0, sizeX, sizeZ); BoxBlurVertical(map, range, 0, 0, sizeX, sizeZ); return(map); }
private void OnMapRegionGen(IMapRegion mapRegion, int regionX, int regionZ) { int pad = TerraGenConfig.geoProvMapPadding; mapRegion.GeologicProvinceMap.Data = geologicprovinceGen.GenLayer( regionX * noiseSizeGeoProv - pad, regionZ * noiseSizeGeoProv - pad, noiseSizeGeoProv + 2 * pad, noiseSizeGeoProv + 2 * pad ); mapRegion.GeologicProvinceMap.Size = noiseSizeGeoProv + 2 * pad; mapRegion.GeologicProvinceMap.TopLeftPadding = mapRegion.GeologicProvinceMap.BottomRightPadding = pad; pad = 2; mapRegion.ClimateMap.Data = climateGen.GenLayer( regionX * noiseSizeClimate - pad, regionZ * noiseSizeClimate - pad, noiseSizeClimate + 2 * pad, noiseSizeClimate + 2 * pad ); mapRegion.ClimateMap.Size = noiseSizeClimate + 2 * pad; mapRegion.ClimateMap.TopLeftPadding = mapRegion.ClimateMap.BottomRightPadding = pad; mapRegion.ForestMap.Size = noiseSizeForest + 1; mapRegion.ForestMap.BottomRightPadding = 1; forestGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ForestMap); mapRegion.ForestMap.Data = forestGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1); mapRegion.BeachMap.Size = noiseSizeBeach + 1; mapRegion.BeachMap.BottomRightPadding = 1; mapRegion.BeachMap.Data = beachGen.GenLayer(regionX * noiseSizeBeach, regionZ * noiseSizeBeach, noiseSizeBeach + 1, noiseSizeBeach + 1); mapRegion.ShrubMap.Size = noiseSizeShrubs + 1; mapRegion.ShrubMap.BottomRightPadding = 1; bushGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ShrubMap); mapRegion.ShrubMap.Data = bushGen.GenLayer(regionX * noiseSizeShrubs, regionZ * noiseSizeShrubs, noiseSizeShrubs + 1, noiseSizeShrubs + 1); mapRegion.FlowerMap.Size = noiseSizeForest + 1; mapRegion.FlowerMap.BottomRightPadding = 1; flowerGen.SetInputMap(mapRegion.ClimateMap, mapRegion.FlowerMap); mapRegion.FlowerMap.Data = flowerGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1); pad = TerraGenConfig.landformMapPadding; mapRegion.LandformMap.Data = landformsGen.GenLayer(regionX * noiseSizeLandform - pad, regionZ * noiseSizeLandform - pad, noiseSizeLandform + 2 * pad, noiseSizeLandform + 2 * pad); mapRegion.LandformMap.Size = noiseSizeLandform + 2 * pad; mapRegion.LandformMap.TopLeftPadding = mapRegion.LandformMap.BottomRightPadding = pad; mapRegion.DirtyForSaving = true; }
private void OnMapRegionGen(IMapRegion mapRegion, int regionX, int regionZ) { /*mapRegion.DepositDistortionMap.Size = noiseSizeDepositDistortion + 1; * mapRegion.DepositDistortionMap.BottomRightPadding = 1; * mapRegion.DepositDistortionMap.Data = depositDistortionGen.GenLayer(regionX * noiseSizeDepositDistortion, regionZ * noiseSizeDepositDistortion, noiseSizeDepositDistortion + 1, noiseSizeDepositDistortion + 1);*/ int pad = TerraGenConfig.geoProvMapPadding; mapRegion.GeologicProvinceMap.Data = geologicprovinceGen.GenLayer( regionX * noiseSizeGeoProv - pad, regionZ * noiseSizeGeoProv - pad, noiseSizeGeoProv + 2 * pad, noiseSizeGeoProv + 2 * pad ); mapRegion.GeologicProvinceMap.Size = noiseSizeGeoProv + 2 * pad; mapRegion.GeologicProvinceMap.TopLeftPadding = mapRegion.GeologicProvinceMap.BottomRightPadding = pad; mapRegion.ClimateMap.Size = noiseSizeClimate + 1; mapRegion.ClimateMap.BottomRightPadding = 1; mapRegion.ClimateMap.Data = climateGen.GenLayer(regionX * noiseSizeClimate, regionZ * noiseSizeClimate, noiseSizeClimate + 1, noiseSizeClimate + 1); mapRegion.ForestMap.Size = noiseSizeForest + 1; mapRegion.ForestMap.BottomRightPadding = 1; forestGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ForestMap); mapRegion.ForestMap.Data = forestGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1); mapRegion.ShrubMap.Size = noiseSizeShrubs + 1; mapRegion.ShrubMap.BottomRightPadding = 1; bushGen.SetInputMap(mapRegion.ClimateMap, mapRegion.ShrubMap); mapRegion.ShrubMap.Data = bushGen.GenLayer(regionX * noiseSizeShrubs, regionZ * noiseSizeShrubs, noiseSizeShrubs + 1, noiseSizeShrubs + 1); mapRegion.FlowerMap.Size = noiseSizeForest + 1; mapRegion.FlowerMap.BottomRightPadding = 1; flowerGen.SetInputMap(mapRegion.ClimateMap, mapRegion.FlowerMap); mapRegion.FlowerMap.Data = flowerGen.GenLayer(regionX * noiseSizeForest, regionZ * noiseSizeForest, noiseSizeForest + 1, noiseSizeForest + 1); pad = TerraGenConfig.landformMapPadding; mapRegion.LandformMap.Data = landformsGen.GenLayer(regionX * noiseSizeLandform - pad, regionZ * noiseSizeLandform - pad, noiseSizeLandform + 2 * pad, noiseSizeLandform + 2 * pad); mapRegion.LandformMap.Size = noiseSizeLandform + 2 * pad; mapRegion.LandformMap.TopLeftPadding = mapRegion.LandformMap.BottomRightPadding = pad; //Console.WriteLine("map region {0} {1} generated", regionX, regionZ); mapRegion.DirtyForSaving = true; }
public override int[] GenLayer(int xPos, int zPos, int xSize, int zSize) { int xCoord = xPos >> 1; int zCoord = zPos >> 1; int newXSize = (xSize >> 1) + 2; int newZSize = (zSize >> 1) + 2; int[] parentInts = parent.GenLayer(xCoord, zCoord, newXSize, newZSize); int outXsize = newXSize - 1 << 1; int outZSize = newZSize - 1 << 1; int[] fuzzyZoom = new int[outXsize * outZSize]; int index; for (int z = 0; z < newZSize - 1; ++z) { index = (z << 1) * outXsize; for (int x = 0; x < newXSize - 1; ++x) { InitPositionSeed(xCoord + x, zCoord + z); int valTopLeft = parentInts[x + (z + 0) * newXSize]; int valTopRight = parentInts[x + 1 + (z + 0) * newXSize]; int valBottomLeft = parentInts[x + (z + 1) * newXSize]; int valBottomRight = parentInts[x + 1 + (z + 1) * newXSize]; fuzzyZoom[index] = valTopLeft; fuzzyZoom[index + outXsize] = selectRandom(valTopLeft, valBottomLeft); fuzzyZoom[index + 1] = selectRandom(valTopLeft, valTopRight); fuzzyZoom[index + 1 + outXsize] = selectRandom(valTopLeft, valTopRight, valBottomLeft, valBottomRight); index += 2; } } int[] outCache = new int[xSize * zSize]; for (int z = 0; z < zSize; ++z) { int srcPos = (z + (zPos & 1)) * outXsize + (xPos & 1); Array.Copy(fuzzyZoom, srcPos, outCache, z * xSize, xSize); } return(outCache); }
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; }
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; }