fix: PaintingBeamTool turning invisible after switching color

This commit is contained in:
Kae 2024-04-25 02:09:10 +10:00
parent f547774c5c
commit 1b86da7f36
2 changed files with 5 additions and 3 deletions

View File

@ -497,7 +497,7 @@ void WorldClient::render(WorldRenderData& renderData, unsigned bufferTiles) {
Logger::error("WorldClient: Exception caught in {}::render ({}): {}", EntityTypeNames.getRight(entity->entityType()), entity->entityId(), e.what());
auto toolUser = as<ToolUserEntity>(entity);
String image = toolUser ? strf("/rendering/error_{}.png", DirectionNames.getRight(toolUser->facingDirection())) : "/rendering/error.png";
Color color = Color::rgbf(0.8f + (float)sin(m_currentTime * Constants::pi * 0.5) * 0.2f, 0.0f, 0.0f);
Color color = Color::rgbf(0.8f + (float)sin(m_currentTime * Constants::pi * 2.0) * 0.2f, 0.0f, 0.0f);
auto drawable = Drawable::makeImage(image, 1.0f / TilePixels, true, entity->position(), color);
drawable.fullbright = true;
renderCallback.addDrawable(std::move(drawable), RenderLayerMiddleParticle);

View File

@ -620,8 +620,10 @@ ItemPtr PaintingBeamTool::clone() const {
List<Drawable> PaintingBeamTool::drawables() const {
auto result = BeamItem::drawables();
for (auto& entry : result) {
if (entry.isImage())
entry.imagePart().image.directives += m_colorKeys[m_colorIndex];
if (entry.isImage()) {
auto& image = entry.imagePart().image;
image.subPath = image.subPath.value("0") + m_colorKeys[m_colorIndex];
}
}
return result;
}