protected override void OnUpdate(GameTime gameTime) { var args = new UpdateArgs() { Camera = World.Camera, GraphicsDevice = Graphics, GameTime = gameTime }; // if (Alex.IsActive) { var newAspectRatio = Graphics.Viewport.AspectRatio; if (AspectRatio != newAspectRatio) { World.Camera.UpdateAspectRatio(newAspectRatio); AspectRatio = newAspectRatio; } UpdateRayTracer(Alex.GraphicsDevice, World); if (!_playingHud.Chat.Focused) { World.Player.Controller.CheckInput = Alex.IsActive; CheckInput(gameTime); } else { World.Player.Controller.CheckInput = false; } SkyRenderer.Update(args); World.Update(args, SkyRenderer); var now = DateTime.UtcNow; if (now - _previousMemUpdate > TimeSpan.FromSeconds(5)) { _previousMemUpdate = now; //Task.Run(() => { _ramUsage = Environment.WorkingSet; ThreadPool.GetMaxThreads(out int maxThreads, out int maxCompletionPorts); ThreadPool.GetAvailableThreads(out int availableThreads, out int availableComplPorts); _threadsUsed = maxThreads - availableThreads; _complPortUsed = maxCompletionPorts - availableComplPorts; _maxThreads = maxThreads; _maxComplPorts = maxCompletionPorts; var pos = World.Player.KnownPosition.GetCoordinates3D(); var biomeId = World.GetBiome(pos.X, pos.Y, pos.Z); var biome = BiomeUtils.GetBiomeById(biomeId); _currentBiomeId = biomeId; _currentBiome = biome; } //); } } base.OnUpdate(gameTime); }
public void Update(UpdateArgs args) { var camera = Camera; args.Camera = camera; if (Player.FOVModifier != _fovModifier) { _fovModifier = Player.FOVModifier; camera.FOV += _fovModifier; camera.UpdateProjectionMatrix(); camera.FOV -= _fovModifier; } camera.Update(args); BrightnessMod = SkyRenderer.BrightnessModifier; SkyRenderer.Update(args); ChunkManager.Update(args); EntityManager.Update(args, SkyRenderer); PhysicsEngine.Update(args.GameTime); var diffuseColor = Color.White.ToVector3() * SkyRenderer.BrightnessModifier; ChunkManager.AmbientLightColor = diffuseColor; if (Math.Abs(ChunkManager.BrightnessModifier - SkyRenderer.BrightnessModifier) > 0f) { ChunkManager.BrightnessModifier = SkyRenderer.BrightnessModifier; } Player.ModelRenderer.DiffuseColor = diffuseColor; Player.Update(args); if (Player.IsInWater) { ChunkManager.FogColor = new Vector3(0.2666667F, 0.6862745F, 0.9607844F) * BrightnessModifier; ChunkManager.FogDistance = (float)Math.Pow(Options.VideoOptions.RenderDistance, 2) * 0.15f; } else { ChunkManager.FogColor = SkyRenderer.WorldFogColor.ToVector3(); ChunkManager.FogDistance = (float)Options.VideoOptions.RenderDistance * 16f * 0.8f; } if (Ticker.Update(args)) { if (DoDaylightcycle) { Time++; } } }
public void Update(UpdateArgs args) { var camera = Camera; args.Camera = camera; /*if (Math.Abs(Player.FOVModifier - _fovModifier) > 0f) * { * _fovModifier = Player.FOVModifier; * * camera.FOV += _fovModifier; * camera.UpdateProjectionMatrix(); * camera.FOV -= _fovModifier; * }*/ camera.Update(args); //_brightnessMod = SkyRenderer.BrightnessModifier; SkyRenderer.Update(args); ChunkManager.Update(args); EntityManager.Update(args); PhysicsEngine.Update(args.GameTime); if (Math.Abs(_brightnessMod - SkyRenderer.BrightnessModifier) > 0f) { _brightnessMod = SkyRenderer.BrightnessModifier; var diffuseColor = Color.White.ToVector3() * SkyRenderer.BrightnessModifier; ChunkManager.AmbientLightColor = diffuseColor; if (Math.Abs(ChunkManager.Shaders.BrightnessModifier - SkyRenderer.BrightnessModifier) > 0f) { ChunkManager.Shaders.BrightnessModifier = SkyRenderer.BrightnessModifier; } var modelRenderer = Player?.ModelRenderer; if (modelRenderer != null) { modelRenderer.DiffuseColor = diffuseColor; } } Player.Update(args); }