| 140 | } |
| 141 | |
| 142 | sp<BattleUnitAnimationPack::AnimationEntry> |
| 143 | InitialGameStateExtractor::makeUpAnimationEntry(int from, int count, int fromS, int countS, |
| 144 | int partCount, Vec2<int> offset, |
| 145 | int units_per_100_frames) const |
| 146 | { |
| 147 | auto e = mksp<BattleUnitAnimationPack::AnimationEntry>(); |
| 148 | bool shadow = countS > 0; |
| 149 | |
| 150 | for (int i = 0; i < count; i++) |
| 151 | { |
| 152 | e->frames.push_back(BattleUnitAnimationPack::AnimationEntry::Frame()); |
| 153 | for (int j = (shadow ? 0 : 1); j <= partCount; j++) |
| 154 | { |
| 155 | int part_idx = j; |
| 156 | int frame = from + i; |
| 157 | auto part_type = BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Shadow; |
| 158 | switch (part_idx) |
| 159 | { |
| 160 | case 0: |
| 161 | part_type = |
| 162 | BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Shadow; |
| 163 | frame = fromS + i; |
| 164 | while (frame >= fromS + countS) |
| 165 | { |
| 166 | frame -= countS; |
| 167 | } |
| 168 | break; |
| 169 | case 1: |
| 170 | part_type = BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Body; |
| 171 | break; |
| 172 | case 2: |
| 173 | part_type = |
| 174 | BattleUnitAnimationPack::AnimationEntry::Frame::UnitImagePart::Helmet; |
| 175 | break; |
| 176 | default: |
| 177 | LogError("If you reached this then OpenApoc programmers made a mistake"); |
| 178 | break; |
| 179 | } |
| 180 | e->frames[i].unit_image_draw_order.push_back(part_type); |
| 181 | e->frames[i].unit_image_parts[part_type] = |
| 182 | BattleUnitAnimationPack::AnimationEntry::Frame::InfoBlock(frame, offset.x, |
| 183 | +offset.y); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | e->is_overlay = false; |
| 188 | e->frame_count = e->frames.size(); |
| 189 | e->units_per_100_frames = units_per_100_frames; |
| 190 | |
| 191 | return e; |
| 192 | } |
| 193 | |
| 194 | sp<BattleUnitAnimationPack> |
| 195 | InitialGameStateExtractor::extractAnimationPack(GameState &state, const UString &path, |
no test coverage detected