示例#1
0
 public MapLayerOre(long seed, NoiseOre map, float zoomMul, float contrastMul, float sub) : base(seed)
 {
     this.map         = map;
     this.zoomMul     = zoomMul;
     this.contrastMul = contrastMul;
     this.sub         = sub;
 }
示例#2
0
        public static MapLayerBase GetOreMap(long seed, NoiseOre oreNoise, float scaleMul, float contrast, float sub)
        {
            MapLayerBase ore = new MapLayerOre(seed + 1, oreNoise, scaleMul, contrast, sub);

            ore.DebugDrawBitmap(DebugDrawMode.RGB, 0, 0, 512, "Ore 1 - Noise");

            ore = new MapLayerPerlinWobble(seed + 2, ore, 5, 0.85f, TerraGenConfig.oreMapWobbleScale, TerraGenConfig.oreMapWobbleScale * 0.15f);
            ore.DebugDrawBitmap(DebugDrawMode.RGB, 0, 0, 512, "Ore 1 - Perlin Wobble");

            return(ore);
        }
示例#3
0
        public static MapLayerBase GetOreMap(long seed, NoiseOre oreNoise)
        {
            MapLayerBase ore = new MapLayerOre(seed + 1, oreNoise);

            ore.DebugDrawBitmap(0, 0, 0, "Ore 1 - Noise");

            ore = new MapLayerPerlinWobble(seed + 2, ore, 6, 0.7f, TerraGenConfig.oreMapWobbleScale, TerraGenConfig.oreMapWobbleScale * 0.15f);
            ore.DebugDrawBitmap(0, 0, 0, "Ore 1 - Perlin Wobble");

            return(ore);
        }
示例#4
0
        MapLayerBase getOrCreateMapLayer(int seed, string oremapCode, Dictionary <string, MapLayerBase> maplayersByCode, float scaleMul, float contrastMul, float sub)
        {
            MapLayerBase ml;

            if (!maplayersByCode.TryGetValue(oremapCode, out ml))
            {
                NoiseOre noiseOre = new NoiseOre(seed + oremapCode.GetHashCode());
                maplayersByCode[oremapCode] = ml = GenMaps.GetOreMap(seed + oremapCode.GetHashCode() + 1, noiseOre, scaleMul, contrastMul, sub);
            }

            return(ml);
        }
示例#5
0
        MapLayerBase getOrCreateMapLayer(int seed, string oremapCode, Dictionary <string, MapLayerBase> maplayersByCode)
        {
            MapLayerBase ml = null;

            if (!maplayersByCode.TryGetValue(oremapCode, out ml))
            {
                NoiseOre noiseOre = new NoiseOre(seed + oremapCode.GetHashCode());
                maplayersByCode[oremapCode] = ml = GenMaps.GetOreMap(seed + oremapCode.GetHashCode() + 1, noiseOre);
            }

            return(ml);
        }
示例#6
0
        internal override void OnGameWorldLoaded()
        {
            base.OnGameWorldLoaded();

            regionSize       = api.WorldManager.RegionSize;
            regionChunkSize  = api.WorldManager.RegionSize / chunksize;
            noiseSizeClimate = regionSize / TerraGenConfig.climateMapScale;
            noiseSizeOre     = regionSize / TerraGenConfig.oreMapScale;

            int seed = api.WorldManager.Seed;

            for (int i = 0; i < deposits.variants.Length; i++)
            {
                DepositVariant variant = deposits.variants[i];
                variant.Init(api);

                if (variant.WithOreMap)
                {
                    NoiseOre noiseOre = new NoiseOre(seed++);
                    variant.OreMap = GenMaps.GetOreMap(seed++, noiseOre);
                }

                if (variant.ChildDeposits != null)
                {
                    for (int k = 0; k < variant.ChildDeposits.Length; k++)
                    {
                        DepositVariant childVariant = variant.ChildDeposits[k];
                        if (childVariant.WithOreMap)
                        {
                            NoiseOre noiseOre = new NoiseOre(seed++);
                            childVariant.OreMap = GenMaps.GetOreMap(seed++, noiseOre);
                        }
                    }
                }
            }

            depositRand = new FastPositionalRandom(api.WorldManager.Seed + 34613);

            blockTypes = api.World.Blocks;
        }
示例#7
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;
        }
示例#8
0
 public MapLayerOre(long seed, NoiseOre map) : base(seed)
 {
     this.map = map;
 }
示例#9
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;
        }