Example #1
0
        public void initWorldGen()
        {
            long seed = api.WorldManager.Seed;

            noiseSizeClimate  = api.WorldManager.RegionSize / TerraGenConfig.climateMapScale;
            noiseSizeForest   = api.WorldManager.RegionSize / TerraGenConfig.forestMapScale;
            noiseSizeShrubs   = api.WorldManager.RegionSize / TerraGenConfig.shrubMapScale;
            noiseSizeGeoProv  = api.WorldManager.RegionSize / TerraGenConfig.geoProvMapScale;
            noiseSizeLandform = api.WorldManager.RegionSize / TerraGenConfig.landformMapScale;

            ITreeAttribute tree    = api.WorldManager.SaveGame.WorldConfiguration;
            string         climate = tree.GetString("worldClimate");
            NoiseClimate   noiseClimate;

            switch (climate)
            {
            case "realistic":
                noiseClimate = new NoiseClimateRealistic(seed, (double)api.WorldManager.MapSizeZ / TerraGenConfig.climateMapScale / TerraGenConfig.climateMapSubScale);
                break;

            default:
                noiseClimate = new NoiseClimatePatchy(seed);
                break;
            }


            climateGen = GetClimateMapGen(seed + 1, noiseClimate);
            forestGen  = GetForestMapGen(seed + 2, TerraGenConfig.forestMapScale);
            bushGen    = GetForestMapGen(seed + 109, TerraGenConfig.shrubMapScale);
            flowerGen  = GetForestMapGen(seed + 223, TerraGenConfig.forestMapScale);


            geologicprovinceGen = GetGeologicProvinceMapGen(seed + 3, api);
            landformsGen        = GetLandformMapGen(seed + 4, noiseClimate, api);
        }
Example #2
0
        public void initWorldGen()
        {
            long seed = api.WorldManager.Seed;

            noiseSizeClimate  = api.WorldManager.RegionSize / TerraGenConfig.climateMapScale;
            noiseSizeForest   = api.WorldManager.RegionSize / TerraGenConfig.forestMapScale;
            noiseSizeShrubs   = api.WorldManager.RegionSize / TerraGenConfig.shrubMapScale;
            noiseSizeGeoProv  = api.WorldManager.RegionSize / TerraGenConfig.geoProvMapScale;
            noiseSizeLandform = api.WorldManager.RegionSize / TerraGenConfig.landformMapScale;
            noiseSizeBeach    = api.WorldManager.RegionSize / TerraGenConfig.beachMapScale;

            ITreeAttribute worldConfig = api.WorldManager.SaveGame.WorldConfiguration;
            string         climate     = worldConfig.GetString("worldClimate", "realistic");
            NoiseClimate   noiseClimate;

            float tempModifier = worldConfig.GetString("globalTemperature", "1").ToFloat(1);
            float rainModifier = worldConfig.GetString("globalPrecipitation", "1").ToFloat(1);

            latdata.polarEquatorDistance = worldConfig.GetString("polarEquatorDistance", "50000").ToInt(50000);

            switch (climate)
            {
            case "realistic":
                int spawnMinTemp = 6;
                int spawnMaxTemp = 14;

                string startingClimate = worldConfig.GetString("startingClimate");
                switch (startingClimate)
                {
                case "hot":
                    spawnMinTemp = 28;
                    spawnMaxTemp = 32;
                    break;

                case "warm":
                    spawnMinTemp = 19;
                    spawnMaxTemp = 23;
                    break;

                case "cool":
                    spawnMinTemp = -5;
                    spawnMaxTemp = 1;
                    break;

                case "icy":
                    spawnMinTemp = -15;
                    spawnMaxTemp = -10;
                    break;
                }

                noiseClimate = new NoiseClimateRealistic(seed, (double)api.WorldManager.MapSizeZ / TerraGenConfig.climateMapScale / TerraGenConfig.climateMapSubScale, latdata.polarEquatorDistance, spawnMinTemp, spawnMaxTemp);
                latdata.isRealisticClimate = true;
                latdata.ZOffset            = (noiseClimate as NoiseClimateRealistic).ZOffset;
                break;

            default:
                noiseClimate = new NoiseClimatePatchy(seed);
                break;
            }

            noiseClimate.rainMul = rainModifier;
            noiseClimate.tempMul = tempModifier;


            climateGen = GetClimateMapGen(seed + 1, noiseClimate);
            forestGen  = GetForestMapGen(seed + 2, TerraGenConfig.forestMapScale);
            bushGen    = GetForestMapGen(seed + 109, TerraGenConfig.shrubMapScale);
            flowerGen  = GetForestMapGen(seed + 223, TerraGenConfig.forestMapScale);
            beachGen   = GetBeachMapGen(seed + 2273, TerraGenConfig.beachMapScale);

            geologicprovinceGen = GetGeologicProvinceMapGen(seed + 3, api);
            landformsGen        = GetLandformMapGen(seed + 4, noiseClimate, api);

            api.ModLoader.GetModSystem <SurvivalCoreSystem>().onGetLatitude = getLatitude;
        }
Example #3
0
        void GenMap(IServerPlayer player, CmdArgs arguments)
        {
            if (arguments.Length < 2)
            {
                player.SendMessage(groupId, "/wgen genmap [climate|forest|wind|gprov|landform|ore]", EnumChatType.CommandError);
                return;
            }

            int      seed = api.World.Seed;
            BlockPos pos  = player.Entity.ServerPos.XYZ.AsBlockPos;

            int noiseSizeClimate  = api.WorldManager.RegionSize / TerraGenConfig.climateMapScale;
            int noiseSizeForest   = api.WorldManager.RegionSize / TerraGenConfig.forestMapScale;
            int noiseSizeShrubs   = api.WorldManager.RegionSize / TerraGenConfig.shrubMapScale;
            int noiseSizeGeoProv  = api.WorldManager.RegionSize / TerraGenConfig.geoProvMapScale;
            int noiseSizeLandform = api.WorldManager.RegionSize / TerraGenConfig.landformMapScale;

            NoiseClimatePatchy noiseClimate = new NoiseClimatePatchy(seed);

            MapLayerBase climateGen          = GenMaps.GetClimateMapGen(seed + 1, noiseClimate);
            MapLayerBase forestGen           = GenMaps.GetForestMapGen(seed + 2, TerraGenConfig.forestMapScale);
            MapLayerBase bushGen             = GenMaps.GetForestMapGen(seed + 109, TerraGenConfig.shrubMapScale);
            MapLayerBase flowerGen           = GenMaps.GetForestMapGen(seed + 223, TerraGenConfig.forestMapScale);
            MapLayerBase geologicprovinceGen = GenMaps.GetGeologicProvinceMapGen(seed + 3, api);
            MapLayerBase landformsGen        = GenMaps.GetLandformMapGen(seed + 4, noiseClimate, api);

            int regionX   = pos.X / api.WorldManager.RegionSize;
            int regionZ   = pos.Z / api.WorldManager.RegionSize;
            int chunkSize = api.WorldManager.ChunkSize;


            NoiseBase.Debug = true;

            switch (arguments[1])
            {
            case "climate":
            {
                int startX = regionX * noiseSizeClimate - 256;
                int startZ = regionZ * noiseSizeClimate - 256;
                climateGen.DebugDrawBitmap(DebugDrawMode.RGB, startX, startZ, "climatemap");
                player.SendMessage(groupId, "Climate map generated", EnumChatType.CommandSuccess);
            }
            break;

            case "forest":
            {
                int startX = regionX * noiseSizeForest - 256;
                int startZ = regionZ * noiseSizeForest - 256;
                forestGen.DebugDrawBitmap(DebugDrawMode.FirstByteGrayscale, startX, startZ, "forestmap");
                player.SendMessage(groupId, "Forest map generated", EnumChatType.CommandSuccess);
            }
            break;


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


            case "gprov":
            {
                int startX = regionX * noiseSizeGeoProv - 256;
                int startZ = regionZ * noiseSizeGeoProv - 256;

                geologicprovinceGen.DebugDrawBitmap(DebugDrawMode.ProvinceRGB, startX, startZ, "gprovmap");
                player.SendMessage(groupId, "Province map generated", EnumChatType.CommandSuccess);
                break;
            }

            case "landform":
            {
                int startX = regionX * noiseSizeLandform - 256;
                int startZ = regionZ * noiseSizeLandform - 256;

                landformsGen.DebugDrawBitmap(DebugDrawMode.LandformRGB, startX, startZ, "landformmap");
                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;
        }
Example #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;
                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;
        }