| 86 | } |
| 87 | |
| 88 | void ChatBubbleManager::update(float dt, WorldClientPtr world) { |
| 89 | m_bubbles.forEach([this, dt, &world](BubbleState<Bubble>& bubbleState, Bubble& bubble) { |
| 90 | bubble.age += dt; |
| 91 | if (auto entity = world->get<ChattyEntity>(bubble.entity)) { |
| 92 | bubble.onscreen = m_camera.worldGeometry().rectIntersectsRect( |
| 93 | m_camera.worldScreenRect(), entity->metaBoundBox().translated(entity->position())); |
| 94 | bubbleState.idealDestination = m_camera.worldToScreen(entity->mouthPosition() + m_bubbleOffset); |
| 95 | } |
| 96 | }); |
| 97 | |
| 98 | for (auto& portraitBubble : m_portraitBubbles) { |
| 99 | portraitBubble.age += dt; |
| 100 | if (auto entity = world->entity(portraitBubble.entity)) { |
| 101 | portraitBubble.onscreen = m_camera.worldGeometry().rectIntersectsRect(m_camera.worldScreenRect(), entity->metaBoundBox().translated(entity->position())); |
| 102 | if (auto chatter = as<ChattyEntity>(entity)) |
| 103 | portraitBubble.position = chatter->mouthPosition(); |
| 104 | else |
| 105 | portraitBubble.position = entity->position(); |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | Map<EntityId, int> count; |
| 110 | filter(m_portraitBubbles, [&](PortraitBubble const& portraitBubble) -> bool { |
| 111 | count[portraitBubble.entity] += m_maxMessagePerEntity; |
| 112 | if (count[portraitBubble.entity] > m_maxMessagePerEntity) |
| 113 | return false; |
| 114 | if (world->get<ChattyEntity>(portraitBubble.entity)) |
| 115 | return portraitBubble.age < m_portraitMaxAge; |
| 116 | return false; |
| 117 | }); |
| 118 | |
| 119 | m_bubbles.filter([&](BubbleState<Bubble> const&, Bubble const& bubble) -> bool { |
| 120 | if (++count[bubble.entity] > m_maxMessagePerEntity) |
| 121 | return false; |
| 122 | if (world->get<ChattyEntity>(bubble.entity)) |
| 123 | return bubble.age < m_maxAge; |
| 124 | return false; |
| 125 | }); |
| 126 | |
| 127 | m_bubbles.update(dt); |
| 128 | } |
| 129 | |
| 130 | uint8_t ChatBubbleManager::calcDistanceFadeAlpha(Vec2F bubbleScreenPosition, StoredFunctionPtr fadeFunction) const { |
| 131 | // first calculate bubble position as a factor, distance from center to edge |
nothing calls this directly
no test coverage detected