| 32 | } |
| 33 | |
| 34 | sp<BattleUnitAnimationPack::AnimationEntry> InitialGameStateExtractor::getAnimationEntry( |
| 35 | const std::vector<AnimationDataAD> &dataAD, const std::vector<AnimationDataUA> &dataUA, |
| 36 | std::vector<AnimationDataUF> &dataUF, int index, Vec2<int> direction, int units_per_100_frames, |
| 37 | int split_point, bool left_side, bool isOverlay, bool removeItem, Vec2<int> targetOffset, |
| 38 | Vec2<int> beginOffset, bool inverse, int extraEndFrames, bool singleFrame, |
| 39 | bool doubleFrames) const |
| 40 | { |
| 41 | static const std::map<Vec2<int>, int> offset_dir_map = { |
| 42 | {{0, -1}, 0}, {{1, -1}, 1}, {{1, 0}, 2}, {{1, 1}, 3}, |
| 43 | {{0, 1}, 4}, {{-1, 1}, 5}, {{-1, 0}, 6}, {{-1, -1}, 7}, |
| 44 | }; |
| 45 | |
| 46 | auto e = mksp<BattleUnitAnimationPack::AnimationEntry>(); |
| 47 | |
| 48 | int offset_dir = offset_dir_map.at(direction); |
| 49 | int offset_ua = dataAD[index * 8 + offset_dir].offset; |
| 50 | int offset_uf = dataUA[offset_ua].offset; |
| 51 | int from = left_side ? 0 : split_point; |
| 52 | int to = singleFrame ? from + 1 : (left_side ? split_point : dataUA[offset_ua].frame_count); |
| 53 | |
| 54 | for (int i = from; i < to; i++) |
| 55 | { |
| 56 | int k = inverse ? to - i - 1 : i; |
| 57 | |
| 58 | int x_offset = (to == from + 1) ? (beginOffset.x + targetOffset.x) / 2 |
| 59 | : beginOffset.x * (to - from - 1 - i) / (to - from - 1) + |
| 60 | targetOffset.x * (i - from) / (to - from - 1); |
| 61 | int y_offset = (to == from + 1) ? (beginOffset.y + targetOffset.y) / 2 |
| 62 | : beginOffset.y * (to - from - 1 - i) / (to - from - 1) + |
| 63 | targetOffset.y * (i - from) / (to - from - 1); |
| 64 | |
| 65 | auto data = dataUF[offset_uf + k]; |
| 66 | |
| 67 | e->frames.push_back(BattleUnitAnimationPack::AnimationEntry::Frame()); |
| 68 | if (doubleFrames) |
| 69 | { |
| 70 | e->frames.push_back(BattleUnitAnimationPack::AnimationEntry::Frame()); |
| 71 | } |
| 72 | for (int j = 0; j < 7; j++) |
| 73 | { |
| 74 | int part_idx = data.draw_order[j]; |
| 75 | auto part_type = BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Shadow; |
| 76 | switch (part_idx) |
| 77 | { |
| 78 | case 0: |
| 79 | part_type = |
| 80 | BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Shadow; |
| 81 | break; |
| 82 | case 1: |
| 83 | part_type = BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Body; |
| 84 | break; |
| 85 | case 2: |
| 86 | part_type = BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Legs; |
| 87 | break; |
| 88 | case 3: |
| 89 | part_type = |
| 90 | BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Helmet; |
| 91 | break; |
no test coverage detected