Ejemplo n.º 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);
        }
        public MapLayerPerlinWobble(long seed, MapLayerBase parent, int octaves, float persistence, float scale, float intensity = 1) : base(seed, parent)
        {
            noisegenX = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1 / scale, persistence, seed);
            noisegenY = NormalizedSimplexNoise.FromDefaultOctaves(octaves, 1 / scale, persistence, seed + 1231296);

            this.scale     = scale;
            this.intensity = intensity;
        }
Ejemplo n.º 3
0
        public MapLayerBlur(long seed, MapLayerBase parent, int range) : base(seed)
        {
            if ((range & 1) == 0)
            {
                throw new InvalidOperationException("Range must be odd!");
            }

            this.parent = parent;
            this.range  = range;
        }
Ejemplo n.º 4
0
        public static MapLayerBase magnify(long seed, MapLayerBase parent, int zoomLevels)
        {
            MapLayerBase genlayer = parent;

            for (int i = 0; i < zoomLevels; ++i)
            {
                genlayer = new MapLayerFuzzyZoom(seed + i, genlayer);
            }


            return(genlayer);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
        public void GameWorldLoaded()
        {
            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;
            //noiseSizeDepositDistortion = api.WorldManager.RegionSize / TerraGenConfig.depositDistortionscale;

            NoiseClimate noiseClimate = new NoiseClimate(seed);

            climateGen = GetClimateMap(seed + 1, noiseClimate);
            forestGen  = GetForestMap(seed + 2, TerraGenConfig.forestMapScale);
            bushGen    = GetForestMap(seed + 109, TerraGenConfig.shrubMapScale);
            flowerGen  = GetForestMap(seed + 223, TerraGenConfig.forestMapScale);
            //depositDistortionGen = GetDepositDistortionMap(seed + 123123);

            geologicprovinceGen = GetGeologicProvinceMap(seed + 3, api);
            landformsGen        = GetLandformMap(seed + 4, noiseClimate, api);
        }
Ejemplo n.º 7
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;
        }
 public MapLayerExactZoom(MapLayerBase parent, int zoomLevel) : base(0)
 {
     this.parent    = parent;
     this.zoomLevel = zoomLevel;
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
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;
        }
Ejemplo n.º 11
0
 public MapLayerFuzzyZoom(long currentSeed, MapLayerBase parent) : base(currentSeed)
 {
     this.parent = parent;
 }
 public MapLayerTransformBase(long seed, MapLayerBase parent) : base(seed)
 {
     this.parent = parent;
 }
Ejemplo n.º 13
0
        public void initWorldGen(bool blockCallbacks)
        {
            base.initWorldGen();

            chanceMultiplier = api.Assets.Get("worldgen/deposits.json").ToObject <Deposits>().ChanceMultiplier;

            Dictionary <AssetLocation, DepositVariant[]> depositFiles = api.Assets.GetMany <DepositVariant[]>(api.World.Logger, "worldgen/deposits/");
            List <DepositVariant> variants = new List <DepositVariant>();


            foreach (var val in depositFiles)
            {
                foreach (var depo in val.Value)
                {
                    depo.fromFile           = val.Key.ToString();
                    depo.WithBlockCallback &= blockCallbacks;

                    variants.Add(depo);

                    if (depo.ChildDeposits != null)
                    {
                        foreach (var childdepo in depo.ChildDeposits)
                        {
                            childdepo.fromFile           = val.Key.ToString();
                            childdepo.parentDeposit      = depo;
                            childdepo.WithBlockCallback &= blockCallbacks;
                        }
                    }
                }
            }

            Deposits = variants.ToArray();


            depositShapeDistortNoise = NormalizedSimplexNoise.FromDefaultOctaves(3, 1 / 10f, 0.9f, 1);

            regionSize       = api.WorldManager.RegionSize;
            noiseSizeClimate = regionSize / TerraGenConfig.climateMapScale;


            int seed = api.WorldManager.Seed;

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

            Dictionary <string, MapLayerBase> maplayersByCode = new Dictionary <string, MapLayerBase>();

            for (int i = 0; i < Deposits.Length; i++)
            {
                DepositVariant variant = Deposits[i];
                variant.Init(api, depositRand, depositShapeDistortNoise);

                if (variant.WithOreMap)
                {
                    variant.OreMapLayer = getOrCreateMapLayer(seed, variant.Code, maplayersByCode, variant.OreMapScale, variant.OreMapContrast, variant.OreMapSub);
                }

                if (variant.ChildDeposits != null)
                {
                    for (int k = 0; k < variant.ChildDeposits.Length; k++)
                    {
                        DepositVariant childVariant = variant.ChildDeposits[k];
                        if (childVariant.WithOreMap)
                        {
                            childVariant.OreMapLayer = getOrCreateMapLayer(seed, childVariant.Code, maplayersByCode, variant.OreMapScale, variant.OreMapContrast, variant.OreMapSub);
                        }
                    }
                }
            }

            verticalDistortBottom = GenMaps.GetDepositVerticalDistort(seed + 12);
            verticalDistortTop    = GenMaps.GetDepositVerticalDistort(seed + 28);
        }
Ejemplo n.º 14
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;
        }