private void DebugPanel(SpriteBatch graphics, GameTime time, WorldManager world, ClientEntity entity, List <ClientEntity> entities, ClientSocketManager connection, ControlState input) { const int xPos = 5; const int offset = 24; int yPos = 120; graphics.DrawBackedText($"Client FPS: {System.Math.Round(1f/(float)time.ElapsedGameTime.TotalSeconds)}/60", new BfbVector(xPos, yPos), _content, 0.5f); graphics.DrawBackedText($"Server TPS: {connection.Tps}/20", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText($"X: {entity.Left}, Y: {entity.Top}", new BfbVector(xPos, yPos += offset), _content, 0.5f); Chunk chunk = world.ChunkFromPixelLocation(entity.Left, entity.Top); graphics.DrawBackedText($"Chunk-X: {chunk?.ChunkX ?? 0}, Chunk-Y: {chunk?.ChunkY ?? 0}", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText($"Velocity-X: {entity.Velocity.X}, Velocity-Y: {entity.Velocity.Y}", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText($"Facing: {entity.Facing}", new BfbVector(xPos, yPos += offset), _content, 0.5f); BfbVector mouse = ViewPointToMapPoint(input.Mouse); (int blockX, int blockY) = world.BlockLocationFromPixel((int)mouse.X, (int)mouse.Y) ?? new Tuple <int, int>(0, 0); graphics.DrawBackedText($"Mouse-X: {(int)mouse.X}, Mouse-Y: {(int)mouse.Y}", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText($"Block-X: {blockX}, Block-Y: {blockY}, Block: {world.GetBlock(blockX,blockY)}, Wall: {(WorldTile)world.GetWall(blockX,blockY)}", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText($"Entities: {entities.Count}, Players: {entities.Count(x => x.EntityType == EntityType.Player)}, Items: {entities.Count(x => x.EntityType == EntityType.Item)}, Mobs: {entities.Count(x => x.EntityType == EntityType.Mob)}, Projectiles: {entities.Count(x => x.EntityType == EntityType.Projectile)}, Particles: {entities.Count(x => x.EntityType == EntityType.Particle)}", new BfbVector(xPos, yPos += offset), _content, 0.5f); graphics.DrawBackedText("Press F3 to exit Debug", new BfbVector(xPos, yPos + offset * 2), _content, 0.5f); }
public void DebugDraw(SpriteBatch graphics, BFBContentManager content, float worldScale, float tileSize) { if (EntityType != EntityType.Particle) { int topBlockY = (int)System.Math.Floor(Top / tileSize); int leftBlockX = (int)System.Math.Floor(Left / tileSize); int bottomBlockY = (int)System.Math.Floor((Bottom - 1) / tileSize); int rightBlockX = (int)System.Math.Floor((Right - 1) / tileSize); //left upper graphics.Draw( content.GetTexture("default"), new Rectangle( (int)(leftBlockX * tileSize), (int)(topBlockY * tileSize), (int)tileSize, (int)tileSize), new Color(0, 100, 0, 0.2f)); //left upper graphics.Draw( content.GetTexture("default"), new Rectangle( (int)(leftBlockX * tileSize), (int)(bottomBlockY * tileSize), (int)tileSize, (int)tileSize), new Color(0, 100, 0, 0.2f)); //right lower graphics.Draw( content.GetTexture("default"), new Rectangle( (int)(rightBlockX * tileSize), (int)(bottomBlockY * tileSize), (int)tileSize, (int)tileSize), new Color(0, 100, 0, 0.2f)); //right upper graphics.Draw( content.GetTexture("default"), new Rectangle( (int)(rightBlockX * tileSize), (int)(topBlockY * tileSize), (int)tileSize, (int)tileSize), new Color(0, 100, 0, 0.2f)); } //entity Bounds graphics.DrawBorder( new Rectangle((int)Position.X, (int)Position.Y, (int)Dimensions.X, (int)Dimensions.Y), 1, Color.Black, content.GetTexture("default")); Draw(graphics, content, worldScale); if (EntityType != EntityType.Particle) { //Position graphics.DrawBackedText($"X: {(int) Position.X}, Y: {(int) Position.Y}", new BfbVector(Position.X, Position.Y - 15), content, 0.2f * worldScale); } //velocity vector graphics.DrawVector(new Vector2(Position.X + Dimensions.X / 2, Position.Y + Dimensions.Y / 2), Velocity.ToVector2() * 4 * worldScale, 1, Color.Red, content); //orientation vector graphics.DrawLine(new Vector2(Position.X + Dimensions.X / 2, Position.Y + 10), Facing == DirectionFacing.Left ? new Vector2((Position.X + Dimensions.X / 2) + -30, Position.Y + 10) : new Vector2((Position.X + Dimensions.X / 2) + 30, Position.Y + 10), 1, Color.Green, content); }