public static Clipboard CopyFrom([NotNull] Extent extent, [NotNull] Region region) { if (extent == null) { throw new ArgumentNullException(nameof(extent)); } if (region == null) { throw new ArgumentNullException(nameof(region)); } var dimensions = region.Dimensions; var clipboard = new Clipboard(new Tile?[dimensions.X, dimensions.Y]); foreach (var position in region.Where(extent.IsInBounds)) { var offsetPosition = position - region.LowerBound; clipboard.SetTile(offsetPosition, extent.GetTile(position)); } foreach (var entity in extent.GetTileEntities().Where(e => region.Contains(e.Position))) { var offsetPosition = entity.Position - region.LowerBound; clipboard.AddTileEntity(entity.WithPosition(offsetPosition)); } return(clipboard); }