public void CalculateResult(MapToolContext ctx, Rectangle tileRect, ItemFieldFragment fragment) { if (tileRect.Size.Encompasses(placedItemSize)) { Rectangle placedItemRect = new Rectangle(tileRect.Location, placedItemSize); fragment.Add(placedItemRect, placedItem, ctx.MapEditingService.IsOccupied(placedItemRect)); if (recipeItem != null) { for (int y = tileRect.Top; y + recipeItemSize.Height <= tileRect.Bottom; y += recipeItemSize.Height) { Rectangle recipeItemRect = new Rectangle(tileRect.Left, y, recipeItemSize.Width, recipeItemSize.Height); if (recipeItemRect.IntersectsWith(placedItemRect)) { continue; } fragment.Add(recipeItemRect, recipeItem, ctx.MapEditingService.IsOccupied(recipeItemRect)); } } int droppedItemTop = placedItemRect.Top + droppedItemSize.Height - (placedItemRect.Height % droppedItemSize.Height); int doppedItemsPerColumn = (tileRect.Bottom - droppedItemTop) / droppedItemSize.Height; if (droppedItems.Count > 0) { for (int x = tileRect.Left + recipeItemSize.Width; x + droppedItemSize.Width <= tileRect.Right; x += droppedItemSize.Width) { for (int y = 0; y < doppedItemsPerColumn; y++) { Rectangle droppedItemRect = new Rectangle(x, droppedItemTop + y * droppedItemSize.Height, droppedItemSize.Width, droppedItemSize.Height); if (droppedItemRect.IntersectsWith(placedItemRect)) { continue; } var droppedItemIndex = (int)(y / ((float)doppedItemsPerColumn / droppedItems.Count)); var droppedItem = droppedItems[droppedItemIndex]; fragment.Add(droppedItemRect, droppedItem, ctx.MapEditingService.IsOccupied(droppedItemRect)); } } } } }
protected override void CalculateResult(MapToolContext ctx, Rectangle marqueeBounds, out ItemFieldFragment fragment, out string hint) { fragment = new ItemFieldFragment(); var tileRect = ctx.ToTiles(marqueeBounds); for (int x = tileRect.Left; x <= tileRect.Right - itemSize.Width; x += itemSize.Width) { for (int y = tileRect.Top; y <= tileRect.Bottom - itemSize.Height; y += itemSize.Height) { Rectangle itemTileRect = new Rectangle(x, y, itemSize.Width, itemSize.Height); fragment.Add(itemTileRect, item, ctx.MapEditingService.IsOccupied(itemTileRect)); } } int itemsX = tileRect.Width / itemSize.Width; int itemsY = tileRect.Height / itemSize.Height; hint = $"{itemsX} × {itemsY}"; }
public void CalculateResult(MapToolContext ctx, Rectangle tileRect, ItemFieldFragment fragment) { Rectangle itemRect = new Rectangle(tileRect.Location, new Size(2, 2)); fragment.Add(itemRect, item, ctx.MapEditingService.IsOccupied(itemRect)); }