MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / previewTiles

Method previewTiles

source/game/items/StarMaterialItem.cpp:458–485  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

456}
457
458List<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
487MaterialHue MaterialItem::placementHueShift(Vec2I const& pos) const {
488 if (auto hue = instanceValue("materialHueShift")) {

Callers

nothing calls this directly

Calls 6

countFunction · 0.85
toRgbMethod · 0.80
canModifyTileMethod · 0.80
favoriteColorMethod · 0.45
aimPositionMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected