| 264 | } |
| 265 | |
| 266 | void WorldPainter::drawEntityLayer(List<Drawable> drawables, EntityHighlightEffect highlightEffect) { |
| 267 | highlightEffect.level *= m_highlightConfig.getFloat("maxHighlightLevel", 1.0); |
| 268 | if (m_highlightDirectives.contains(highlightEffect.type) && highlightEffect.level > 0) { |
| 269 | // first pass, draw underlay |
| 270 | auto underlayDirectives = m_highlightDirectives[highlightEffect.type].first; |
| 271 | if (!underlayDirectives.empty()) { |
| 272 | for (auto& d : drawables) { |
| 273 | if (d.isImage()) { |
| 274 | auto underlayDrawable = Drawable(d); |
| 275 | underlayDrawable.fullbright = true; |
| 276 | underlayDrawable.color = Color::rgbaf(1, 1, 1, highlightEffect.level * d.color.alphaF()); |
| 277 | underlayDrawable.imagePart().addDirectives(underlayDirectives, true); |
| 278 | drawDrawable(std::move(underlayDrawable)); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | // second pass, draw main drawables and overlays |
| 284 | auto overlayDirectives = m_highlightDirectives[highlightEffect.type].second; |
| 285 | for (auto& d : drawables) { |
| 286 | drawDrawable(d); |
| 287 | if (!overlayDirectives.empty() && d.isImage()) { |
| 288 | auto overlayDrawable = Drawable(d); |
| 289 | overlayDrawable.fullbright = true; |
| 290 | overlayDrawable.color = Color::rgbaf(1, 1, 1, highlightEffect.level * d.color.alphaF()); |
| 291 | overlayDrawable.imagePart().addDirectives(overlayDirectives, true); |
| 292 | drawDrawable(std::move(overlayDrawable)); |
| 293 | } |
| 294 | } |
| 295 | } else { |
| 296 | for (auto& d : drawables) |
| 297 | drawDrawable(std::move(d)); |
| 298 | } |
| 299 | } |
| 300 | |
| 301 | void WorldPainter::drawDrawable(Drawable drawable) { |
| 302 | drawable.position = m_camera.worldToScreen(drawable.position); |