| 17 | } |
| 18 | |
| 19 | void QuestIndicatorPainter::update(float dt, WorldClientPtr const& world, WorldCamera const& camera) { |
| 20 | m_camera = camera; |
| 21 | |
| 22 | Set<EntityId> foundIndicators; |
| 23 | for (auto const& entity : world->query<Entity>(camera.worldScreenRect())) { |
| 24 | auto indicator = m_client->questManager()->getQuestIndicator(entity); |
| 25 | if (!indicator) continue; |
| 26 | |
| 27 | foundIndicators.insert(entity->entityId()); |
| 28 | Vec2F screenPos = camera.worldToScreen(indicator->worldPosition); |
| 29 | |
| 30 | if (auto currentIndicator = m_indicators.ptr(entity->entityId())) { |
| 31 | currentIndicator->screenPos = screenPos; |
| 32 | if (currentIndicator->indicatorName == indicator->indicatorImage) { |
| 33 | currentIndicator->animation->update(dt); |
| 34 | } else { |
| 35 | currentIndicator->indicatorName = indicator->indicatorImage; |
| 36 | currentIndicator->animation = indicatorAnimation(indicator->indicatorImage); |
| 37 | } |
| 38 | } else { |
| 39 | m_indicators[entity->entityId()] = Indicator { |
| 40 | entity->entityId(), |
| 41 | screenPos, |
| 42 | indicator->indicatorImage, |
| 43 | indicatorAnimation(indicator->indicatorImage) |
| 44 | }; |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | m_indicators = Map<EntityId, Indicator>::from(m_indicators.pairs().filtered([&foundIndicators](pair<EntityId, Indicator> indicator) { |
| 49 | return foundIndicators.contains(indicator.first); |
| 50 | })); |
| 51 | } |
| 52 | |
| 53 | Drawable QuestIndicatorPainter::Indicator::render(float pixelRatio) const { |
| 54 | return animation->drawable(pixelRatio); |
nothing calls this directly
no test coverage detected