| 589 | } |
| 590 | |
| 591 | List<pair<Drawable, float>> NetworkedAnimator::drawablesWithZLevel(Vec2F const& position) const { |
| 592 | size_t partCount = m_animatedParts.constParts().size(); |
| 593 | if (!partCount) |
| 594 | return {}; |
| 595 | |
| 596 | List<Directives> baseProcessingDirectives = { m_processingDirectives.get() }; |
| 597 | for (auto& pair : m_effects) { |
| 598 | auto const& effectState = pair.second; |
| 599 | |
| 600 | if (effectState.enabled.get()) { |
| 601 | auto const& effect = m_effects.get(pair.first); |
| 602 | if (effect.type == "flash") { |
| 603 | if (effectState.timer > effect.time / 2) { |
| 604 | baseProcessingDirectives.append(effect.directives); |
| 605 | } |
| 606 | } else if (effect.type == "directive") { |
| 607 | baseProcessingDirectives.append(effect.directives); |
| 608 | } else { |
| 609 | throw NetworkedAnimatorException(strf("No such NetworkedAnimator effect type '{}'", effect.type)); |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | |
| 614 | List<tuple<AnimatedPartSet::ActivePartInformation const*, String const*, float>> parts; |
| 615 | parts.reserve(partCount); |
| 616 | m_animatedParts.forEachActivePart([&](String const& partName, AnimatedPartSet::ActivePartInformation const& activePart) { |
| 617 | Maybe<float> maybeZLevel; |
| 618 | if (m_flipped.get()) { |
| 619 | if (auto maybeFlipped = activePart.properties.value("flippedZLevel").optFloat()) |
| 620 | maybeZLevel = *maybeFlipped; |
| 621 | } |
| 622 | if (!maybeZLevel) |
| 623 | maybeZLevel = activePart.properties.value("zLevel").optFloat(); |
| 624 | |
| 625 | parts.append(make_tuple(&activePart, &partName, maybeZLevel.value(0.0f))); |
| 626 | }); |
| 627 | |
| 628 | sort(parts, [](auto const& a, auto const& b) { return get<2>(a) < get<2>(b); }); |
| 629 | |
| 630 | List<pair<Drawable, float>> drawables; |
| 631 | drawables.reserve(partCount); |
| 632 | for (auto& entry : parts) { |
| 633 | auto& activePart = *get<0>(entry); |
| 634 | auto& partName = *get<1>(entry); |
| 635 | // Make sure we don't copy the original image |
| 636 | String fallback = ""; |
| 637 | Json jImage = activePart.properties.value("image", {}); |
| 638 | String const& image = jImage.isType(Json::Type::String) ? *jImage.stringPtr() : fallback; |
| 639 | |
| 640 | bool centered = activePart.properties.value("centered").optBool().value(true); |
| 641 | bool fullbright = activePart.properties.value("fullbright").optBool().value(false); |
| 642 | |
| 643 | size_t originalDirectivesSize = baseProcessingDirectives.size(); |
| 644 | if (auto directives = activePart.properties.value("processingDirectives").optString()) { |
| 645 | baseProcessingDirectives.append(*directives); |
| 646 | } |
| 647 | |
| 648 | Maybe<unsigned> frame; |
no test coverage detected