Ejemplo n.º 1
0
        public void GenerateWorld(GenerationProgress progress = null)
        {
            Stopwatch stopwatch = new Stopwatch();
            float     num       = 0.0f;

            foreach (GenPass pass in this._passes)
            {
                num += pass.Weight;
            }
            if (progress == null)
            {
                progress = new GenerationProgress();
            }
            WorldGenerator.CurrentGenerationProgress = progress;
            progress.TotalWeight = num;
            foreach (GenPass pass in this._passes)
            {
                WorldGen._genRand = new UnifiedRandom(this._seed);
                Main.rand         = new UnifiedRandom(this._seed);
                stopwatch.Start();
                progress.Start(pass.Weight);
                pass.Apply(progress, this._configuration.GetPassConfiguration(pass.Name));
                progress.End();
                stopwatch.Reset();
            }
            WorldGenerator.CurrentGenerationProgress = (GenerationProgress)null;
        }
Ejemplo n.º 2
0
        public void GenerateWorld(GenerationProgress progress = null)
        {
            Stopwatch stopwatch = new Stopwatch();
            float     num       = 0f;

            foreach (GenPass pass in _passes)
            {
                num += pass.Weight;
            }
            if (progress == null)
            {
                progress = new GenerationProgress();
            }
            progress.TotalWeight = num;
            Main.menuMode        = 888;
            Main.MenuUI.SetState(new UIWorldLoad(progress));
            foreach (GenPass pass2 in _passes)
            {
                WorldGen._genRand = new UnifiedRandom(_seed);
                Main.rand         = new UnifiedRandom(_seed);
                stopwatch.Start();
                progress.Start(pass2.Weight);
                pass2.Apply(progress, _configuration.GetPassConfiguration(pass2.Name));
                progress.End();
                stopwatch.Reset();
            }
        }
Ejemplo n.º 3
0
 public void Apply(GenerationProgress progress, GameConfiguration configuration)
 {
     if (_onBegin != null)
     {
         _onBegin(this);
     }
     ApplyPass(progress, configuration);
     if (_onComplete != null)
     {
         _onComplete(this);
     }
 }
Ejemplo n.º 4
0
            protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
            {
                int num = _count;

                while (num > 0)
                {
                    if (_perUnit(GenBase._random.Next(1, GenBase._worldWidth), GenBase._random.Next(1, GenBase._worldHeight)))
                    {
                        num--;
                    }
                }
            }
Ejemplo n.º 5
0
 public void Apply(GenerationProgress progress, GameConfiguration configuration)
 {
     if (this._onBegin != null)
     {
         this._onBegin(this);
     }
     this.ApplyPass(progress, configuration);
     if (this._onComplete == null)
     {
         return;
     }
     this._onComplete(this);
 }
Ejemplo n.º 6
0
            protected override void ApplyPass(
                GenerationProgress progress,
                GameConfiguration configuration)
            {
                int count = this._count;

                while (count > 0)
                {
                    if (this._perUnit(GenBase._random.Next(1, GenBase._worldWidth), GenBase._random.Next(1, GenBase._worldHeight), new object[0]))
                    {
                        --count;
                    }
                }
            }
Ejemplo n.º 7
0
 protected override void ApplyPass(GenerationProgress progress, GameConfiguration configuration)
 {
     for (int i = 0; i < GenBase._worldWidth; i++)
     {
         for (int j = 0; j < GenBase._worldHeight; j++)
         {
             if (GenBase._tiles[i, j] == null)
             {
                 GenBase._tiles[i, j] = new Tile();
             }
             else
             {
                 GenBase._tiles[i, j].ClearEverything();
             }
         }
     }
 }
Ejemplo n.º 8
0
 protected override void ApplyPass(
     GenerationProgress progress,
     GameConfiguration configuration)
 {
     for (int index1 = 0; index1 < GenBase._worldWidth; ++index1)
     {
         for (int index2 = 0; index2 < GenBase._worldHeight; ++index2)
         {
             if (GenBase._tiles[index1, index2] == null)
             {
                 GenBase._tiles[index1, index2] = new Tile();
             }
             else
             {
                 GenBase._tiles[index1, index2].ClearEverything();
             }
         }
     }
 }
Ejemplo n.º 9
0
 protected abstract void ApplyPass(GenerationProgress progress, GameConfiguration configuration);