Inheritance: MapGeneratorParameters
Exemplo n.º 1
0
        public override MapGeneratorParameters CreateParameters( string presetName ) {
            if( presetName == null ) {
                throw new ArgumentNullException( "presetName" );

            } else if( presetName.Equals( Presets[0], StringComparison.OrdinalIgnoreCase ) ) {
                // "Default"
                return new FlatMapGenParameters {
                    Preset = Presets[0]
                };

            } else if( presetName.Equals( Presets[1], StringComparison.OrdinalIgnoreCase ) ) {
                // "Ocean"
                return new FlatMapGenParameters {
                    SurfaceThickness = 0,
                    SoilThickness = 0,
                    BedrockThickness = 0,
                    DeepBlock = Block.Water,
                    Preset = Presets[1]
                };

            } else {
                MapGenTheme theme;
                if( EnumUtil.TryParse( presetName, out theme, true ) ) {
                    FlatMapGenParameters genParams = new FlatMapGenParameters();
                    genParams.ApplyTheme( theme );
                    return genParams;
                } else {
                    return null;
                }
            }
        }
Exemplo n.º 2
0
 public FlatMapGenState(FlatMapGenParameters parameters)
 {
     Parameters           = parameters;
     StatusString         = "Ready";
     ReportsProgress      = false;
     SupportsCancellation = false;
 }
Exemplo n.º 3
0
        public override Map Generate()
        {
            if (Finished)
            {
                return(Result);
            }
            try {
                StatusString = "Generating";
                FlatMapGenParameters p = (FlatMapGenParameters)Parameters;

                int layer = Parameters.MapWidth * Parameters.MapLength;

                Map map = new Map(null, Parameters.MapWidth, Parameters.MapLength, Parameters.MapHeight, true);

                int offset = 0;
                if (p.BedrockThickness > 0)
                {
                    int bedrockBlocks = layer * p.BedrockThickness;
                    map.Blocks.MemSet((byte)p.BedrockBlock, 0, bedrockBlocks);
                    offset += bedrockBlocks;
                }

                int rockBlocks = layer * (Parameters.MapHeight / 2 + p.GroundLevelOffset -
                                          p.BedrockThickness - p.SoilThickness - p.SurfaceThickness);
                map.Blocks.MemSet((byte)p.DeepBlock, offset, rockBlocks);
                offset += rockBlocks;

                if (p.SoilThickness > 0)
                {
                    int soilBlocks = layer * p.SoilThickness;
                    map.Blocks.MemSet((byte)p.ShallowBlock, offset, soilBlocks);
                    offset += soilBlocks;
                }

                if (p.SurfaceThickness > 0)
                {
                    int surfaceBlocks = layer * p.SurfaceThickness;
                    map.Blocks.MemSet((byte)p.SurfaceBlock, offset, surfaceBlocks);
                    offset += surfaceBlocks;
                }

                if (p.AirBlock != Block.Air)
                {
                    map.Blocks.MemSet((byte)p.AirBlock, offset, map.Blocks.Length - offset);
                }

                Result       = map;
                StatusString = "Done";
                return(map);
            } finally {
                Finished = true;
            }
        }
Exemplo n.º 4
0
 public override MapGeneratorParameters CreateParameters(string presetName)
 {
     if (presetName == null)
     {
         throw new ArgumentNullException("presetName");
     }
     else if (presetName.Equals(Presets[0], StringComparison.OrdinalIgnoreCase))
     {
         // "Default"
         return(new FlatMapGenParameters {
             Preset = Presets[0]
         });
     }
     else if (presetName.Equals(Presets[1], StringComparison.OrdinalIgnoreCase))
     {
         // "Ocean"
         return(new FlatMapGenParameters {
             SurfaceThickness = 0,
             SoilThickness = 0,
             BedrockThickness = 0,
             DeepBlock = Block.Water,
             Preset = Presets[1]
         });
     }
     else
     {
         MapGenTheme theme;
         if (EnumUtil.TryParse(presetName, out theme, true))
         {
             FlatMapGenParameters genParams = new FlatMapGenParameters();
             genParams.ApplyTheme(theme);
             return(genParams);
         }
         else
         {
             return(null);
         }
     }
 }
Exemplo n.º 5
0
 public FlatMapGenState( FlatMapGenParameters parameters ) {
     Parameters = parameters;
     StatusString = "Ready";
     ReportsProgress = false;
     SupportsCancellation = false;
 }