static bool GenHell(Player p, Level lvl, string seed)
        {
            Random rng = MapGen.MakeRng(seed);
            int    width = lvl.Width, height = lvl.Height, length = lvl.Length;
            int    index = 0;

            byte[] blocks = lvl.blocks;

            for (int y = 0; y < height; ++y)
            {
                for (int z = 0; z < length; ++z)
                {
                    for (int x = 0; x < width; ++x)
                    {
                        if (y == 0)
                        {
                            blocks[index] = Block.Bedrock;
                        }
                        else if (x == 0 || x == width - 1 || z == 0 || z == length - 1 || y == 0 || y == height - 1)
                        {
                            blocks[index] = Block.Obsidian;
                        }
                        else if (x == 1 || x == width - 2 || z == 1 || z == length - 2)
                        {
                            if (rng.Next(1000) != 7)
                            {
                                index++; continue;
                            }

                            int colIndex = z * width + x;
                            for (int i = 1; i < (height - y); ++i)
                            {
                                int yy = height - i;
                                blocks[colIndex + yy * width * length] = Block.Lava;
                            }
                        }
                        index++;
                    }
                }
            }

            lvl.Config.CloudColor   = "#000000";
            lvl.Config.SkyColor     = "#FFCC00";
            lvl.Config.FogColor     = "#FF6600";
            lvl.Config.HorizonBlock = Block.StillLava;
            return(new RealisticMapGen().Gen(p, lvl, seed, RealisticMapGenArgs.hell));
        }
Exemple #2
0
        static bool GenRainbow(Player p, Level lvl, string seed)
        {
            int       maxX = lvl.Width - 1, maxY = lvl.Height - 1, maxZ = lvl.Length - 1;
            Random    rng       = MapGen.MakeRng(seed);
            NextBlock nextBlock = () => (byte)rng.Next(Block.Red, Block.White);

            // Cuboid the four walls
            Cuboid(lvl, 0, 1, 0, maxX, maxY, 0, nextBlock);
            Cuboid(lvl, 0, 1, maxZ, maxX, maxY, maxZ, nextBlock);
            Cuboid(lvl, 0, 1, 0, 0, maxY, maxZ, nextBlock);
            Cuboid(lvl, maxX, 1, 0, maxX, maxY, maxZ, nextBlock);

            // Cuboid base and top
            Cuboid(lvl, 0, 0, 0, maxX, 0, maxZ, nextBlock);
            Cuboid(lvl, 0, maxY, 0, maxX, maxY, maxZ, nextBlock);
            return(true);
        }
Exemple #3
0
        static bool GenSpace(Player p, Level lvl, string seed)
        {
            int       maxX = lvl.Width - 1, maxY = lvl.Height - 1, maxZ = lvl.Length - 1;
            Random    rng       = MapGen.MakeRng(seed);
            NextBlock nextBlock = () => rng.Next(100) == 0 ? Block.Iron : Block.Obsidian;

            // Cuboid the four walls
            Cuboid(lvl, 0, 2, 0, maxX, maxY, 0, nextBlock);
            Cuboid(lvl, 0, 2, maxZ, maxX, maxY, maxZ, nextBlock);
            Cuboid(lvl, 0, 2, 0, 0, maxY, maxZ, nextBlock);
            Cuboid(lvl, maxX, 2, 0, maxX, maxY, maxZ, nextBlock);

            // Cuboid base and top
            Cuboid(lvl, 0, 0, 0, maxX, 0, maxZ, () => Block.Bedrock);
            Cuboid(lvl, 0, 1, 0, maxX, 1, maxZ, nextBlock);
            Cuboid(lvl, 0, maxY, 0, maxX, maxY, maxZ, nextBlock);
            return(true);
        }
Exemple #4
0
        public bool Gen(Player p, Level lvl, string seed, RealisticMapGenArgs args)
        {
            DateTime start = DateTime.UtcNow;

            Logger.Log(LogType.SystemActivity, "Attempting map gen");
            rng       = MapGen.MakeRng(seed);
            this.args = args;

            try {
                terrain = new float[lvl.Width * lvl.Length];
                overlay = new float[lvl.Width * lvl.Length];
                if (args.GenTrees)
                {
                    overlay2 = new float[lvl.Width * lvl.Length];
                }
                LiquidLevel = args.GetLiquidLevel(lvl.Height);

                GenerateFault(terrain, lvl);
                FilterAverage(lvl);
                Logger.Log(LogType.SystemActivity, "Creating overlay");
                GeneratePerlinNoise(overlay, lvl);

                if (args.GenerateOverlay2)
                {
                    Logger.Log(LogType.SystemActivity, "Planning trees");
                    GeneratePerlinNoise(overlay2, lvl);
                }

                Logger.Log(LogType.SystemActivity, "Converting height map, and applying overlays");
                float rangeLo = args.RangeLow;
                float rangeHi = args.RangeHigh;
                treeDens = args.TreeDensity;
                treeDist = args.TreeDistance;

                //loops though evey X/Z coordinate
                for (int index = 0; index < terrain.Length; index++)
                {
                    ushort x = (ushort)(index % lvl.Width);
                    ushort z = (ushort)(index / lvl.Width);
                    ushort y;
                    if (args.FalloffEdges)
                    {
                        float offset = NegateEdge(x, z, lvl);
                        y = Evaluate(lvl, Range(terrain[index], rangeLo - offset, rangeHi - offset));
                    }
                    else
                    {
                        y = Evaluate(lvl, Range(terrain[index], rangeLo, rangeHi));
                    }

                    if (!args.UseLavaLiquid)
                    {
                        GenNonLavaColumn(x, y, z, lvl, index);
                    }
                    else
                    {
                        GenLavaColumn(x, y, z, lvl, index);
                    }
                }
                Logger.Log(LogType.SystemActivity, "Total time was {0} seconds.", (DateTime.UtcNow - start).TotalSeconds);
            } catch (Exception e) {
                Logger.LogError(e);
                p.Message("&WGeneration failed. See error logs.");
                return(false);
            }
            return(true);
        }