protected override void Draw(GameTime gameTime) { GraphicsDevice.SetRenderTarget(RenderTarget); GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; GraphicsDevice.SamplerStates[1] = SamplerState.PointClamp; Mesh.ResetStats(); SkyModule.Draw(gameTime); ChunkModule.Draw(gameTime); HighlightModule.Draw(gameTime); HudModule.Draw(gameTime); ChatModule.Draw(gameTime); WindowModule.Draw(gameTime); DebugInfoModule.Draw(gameTime); _imgui.BeforeLayout(gameTime); ImGuiLayout(); _imgui.AfterLayout(); GraphicsDevice.SetRenderTarget(null); SpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque); SpriteBatch.Draw(RenderTarget, Vector2.Zero, Color.White); SpriteBatch.End(); base.Draw(gameTime); }
protected override void Update(GameTime gameTime) { GameTime = gameTime; if (PendingMainThreadActions.TryTake(out var action)) { action(); } var adjusted = Client.World.World.FindBlockPosition( new Coordinates3D((int)Client.Position.X, 0, (int)Client.Position.Z), out var chunk); if (chunk != null && Client.LoggedIn) { if (chunk.GetHeight((byte)adjusted.X, (byte)adjusted.Z) != 0) { Client.Physics.Update(gameTime.ElapsedGameTime); } } if (NextPhysicsUpdate < DateTime.UtcNow && Client.LoggedIn) { // NOTE: This is to make the vanilla server send us chunk packets // We should eventually make some means of detecting that we're on a vanilla server to enable this // It's a waste of bandwidth to do it on a TrueCraft server Client.QueuePacket(new PlayerGroundedPacket { OnGround = true }); NextPhysicsUpdate = DateTime.UtcNow.AddMilliseconds(50); } if (IsActive) { foreach (var module in InputModules) { module.Update(gameTime); } } SkyModule.Update(gameTime); ChunkModule.Update(gameTime); HighlightModule.Update(gameTime); HudModule.Update(gameTime); ChatModule.Update(gameTime); WindowModule.Update(gameTime); DebugInfoModule.Update(gameTime); UpdateCamera(); base.Update(gameTime); }