| 456 | } |
| 457 | |
| 458 | List<PreviewTile> MaterialItem::previewTiles(bool shifting) const { |
| 459 | List<PreviewTile> result; |
| 460 | if (initialized()) { |
| 461 | Color lightColor = owner()->favoriteColor(); |
| 462 | Vec3B light = lightColor.toRgb(); |
| 463 | |
| 464 | auto material = materialId(); |
| 465 | auto color = DefaultMaterialColorVariant; |
| 466 | |
| 467 | size_t c = 0; |
| 468 | for (auto& pos : tileArea(calcRadius(shifting), owner()->aimPosition())) { |
| 469 | MaterialHue hueShift = placementHueShift(pos); |
| 470 | if (c >= count()) |
| 471 | break; |
| 472 | if (world()->canModifyTile(pos, PlaceMaterial{TileLayer::Foreground, material, hueShift}, false)) { |
| 473 | result.append({pos, true, material, hueShift, true}); |
| 474 | c++; |
| 475 | } else if (twoHanded() |
| 476 | && world()->canModifyTile(pos, PlaceMaterial{TileLayer::Background, material, hueShift}, false)) { |
| 477 | result.append({pos, true, material, hueShift, true, light, true, color}); |
| 478 | c++; |
| 479 | } else { |
| 480 | result.append({pos, true, material, hueShift, true}); |
| 481 | } |
| 482 | } |
| 483 | } |
| 484 | return result; |
| 485 | } |
| 486 | |
| 487 | MaterialHue MaterialItem::placementHueShift(Vec2I const& pos) const { |
| 488 | if (auto hue = instanceValue("materialHueShift")) { |
nothing calls this directly
no test coverage detected