public override void DrawDebug(PlatformContext context, Vector2 world, Renderer renderer, FontTemplate font, Vector2 position) { var s = new StringBuilder(); s.AppendLine($"Current tile : "); s.AppendLine($"{this.layer} "); font.DrawString(renderer.Screen, position, s.ToString(), Color.White); var size = font.Font.MeasureString(s.ToString()); this.Current.Draw(renderer.Screen, new Vector2(size.X + position.X, position.Y), new Vector2(2f, 2f), Color.White, context.BlockStore); if (context.IsInBounds(world)) { var tilePos = context.WorldToTile(world); var tileTopLeft = context.TileToWorld(tilePos); this.Current.Draw(renderer.World, tileTopLeft, Vector2.One, Color.White, context.BlockStore); renderer.World.DrawRectangle(tileTopLeft, new Size2(context.BlockStore.TileSize, context.BlockStore.TileSize), Color.White); var tileText = new StringBuilder(); var cell = context.Map[tilePos]; var flags = context.GetFlags(tilePos); tileText.AppendLine($" Position: {tilePos}"); tileText.AppendLine($" Foreground: " + string.Join(",", cell.Foreground.Select(t => t.DebugString))); tileText.AppendLine($" Background: " + string.Join(",", cell.Background.Select(t => t.DebugString))); tileText.AppendLine($" Block: " + (cell.Block == null ? "null" : cell.Block.DebugString)); tileText.AppendLine($" Flags: " + flags); font.DrawString(renderer.Screen, new Vector2(position.X, position.Y + 200), tileText.ToString(), Color.Wheat); } }
public static void FloodFill(PlatformContext context, Point location, TilePlacement placement) { if (!FloodFillValid(context, location, placement)) { return; } var queue = new Queue <Point>(); var set = new HashSet <Point>(); queue.Enqueue(location); set.Add(location); while (queue.Any()) { var point = queue.Dequeue(); placement.Stamp(context, context.TileToWorld(point)); foreach (var test in FloodFillTestPoints) { var next = point + test; if (!set.Contains(next) && FloodFillValid(context, next, placement)) { queue.Enqueue(next); set.Add(next); } } } }
public override void DrawDebug(PlatformContext context, Vector2 world, Renderer renderer, FontTemplate font, Vector2 position) { if (context.IsInBounds(world)) { var tilePos = context.WorldToTile(world); var tileTopLeft = context.TileToWorld(tilePos); Light.DrawDebug(renderer, world, this.Current.Colour); renderer.World.DrawRectangle(tileTopLeft, new Size2(context.BlockStore.TileSize, context.BlockStore.TileSize), new Color(1f, 1f, 1f, 0.5f)); var tileText = new StringBuilder(); tileText.AppendLine($" Position: {world} ({tilePos})"); font.DrawString(renderer.Screen, new Vector2(position.X, position.Y + 200), tileText.ToString(), Color.Wheat); } }