private void GenerateWorld() { genTask = Task.Run(() => { KeyPreview = false; move.Enabled = false; world.Engine.Stop(); dinamincCamera.Clear(this); miniCamera.Clear(mini_map); normalCamera.Clear(normal_map); tempCamera.Clear(temp_map); progressBar1.Value = 0; progressBar1.Visible = true; progressBar1.Enabled = true; progressBar1.Value = 8; world.Generate(progressBar1, type); optimize = new Optimize(world); optimize.Ready(dinamincCamera.Bound); world.Engine.AddPre(optimize); progressBar1.Value = 98; AddContentOnCamers(); world.Engine.Start(); progressBar1.Value = 99; world.Engine.Work(null, () => { PaintCamera(dinamincCamera, this); PaintCamera(tempCamera, temp_map); long time = world.Engine.Watch.ElapsedMilliseconds; if (iterrations != 0) averageTime = (averageTime * iterrations + time) * 1.0 / ++iterrations; else ++iterrations; Text = "crrnt tm: " + time + " avrg tm: " + averageTime; }, (Exception e) => { MessageBox.Show(e.StackTrace + "\n" + e.InnerException); }); progressBar1.Value = 100; progressBar1.Visible = false; progressBar1.Enabled = false; KeyPreview = true; }); }
/// <summary> /// Renders all renderable components using the specified camera. /// </summary> public void Render(ICamera camera) { lock (_renderables) { _renderables.Sort(delegate(RenderComponent drawable, RenderComponent otherDrawable) { return drawable.CompareTo(otherDrawable); }); camera.Clear(); foreach (RenderComponent renderable in _renderables) { if (renderable.IsHidden) { continue; } Render(camera, renderable); } if (_currentlyEnabledState != null) { _currentlyEnabledState(false); _currentlyEnabledState = null; } } }