| 165 | } |
| 166 | |
| 167 | void AnimationSystem::CombineAnimation(drape_ptr<Animation> && animation) |
| 168 | { |
| 169 | #ifdef DEBUG_ANIMATIONS |
| 170 | LOG(LINFO, ("Combine animation", animation->GetType())); |
| 171 | #endif |
| 172 | TAnimationList interruptedAnimations; |
| 173 | bool startImmediately = true; |
| 174 | for (auto & pList : m_animationChain) |
| 175 | { |
| 176 | auto & lst = *pList; |
| 177 | bool couldBeBlended = animation->CouldBeBlended(); |
| 178 | |
| 179 | for (auto it = lst.begin(); it != lst.end();) |
| 180 | { |
| 181 | auto & anim = *it; |
| 182 | if (anim->GetInterruptedOnCombine() && anim->HasSameObjects(*animation)) |
| 183 | { |
| 184 | #ifdef DEBUG_ANIMATIONS |
| 185 | LOG(LINFO, ("Interrupted on combine", anim->GetType())); |
| 186 | #endif |
| 187 | interruptedAnimations.splice(interruptedAnimations.end(), lst, it++); |
| 188 | } |
| 189 | else if (!anim->CouldBeBlendedWith(*animation)) |
| 190 | { |
| 191 | if (!anim->CouldBeInterrupted()) |
| 192 | { |
| 193 | couldBeBlended = false; |
| 194 | break; |
| 195 | } |
| 196 | #ifdef DEBUG_ANIMATIONS |
| 197 | LOG(LINFO, ("Couldn't be blended, interrupted", anim->GetType())); |
| 198 | #endif |
| 199 | interruptedAnimations.splice(interruptedAnimations.end(), lst, it++); |
| 200 | } |
| 201 | else |
| 202 | { |
| 203 | ++it; |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | for (auto & anim : interruptedAnimations) |
| 208 | { |
| 209 | anim->Interrupt(); |
| 210 | SaveAnimationResult(*anim); |
| 211 | } |
| 212 | |
| 213 | if (couldBeBlended) |
| 214 | { |
| 215 | #ifdef DEBUG_ANIMATIONS |
| 216 | LOG(LINFO, ("Animation blended")); |
| 217 | #endif |
| 218 | lst.emplace_back(std::move(animation)); |
| 219 | if (startImmediately) |
| 220 | lst.back()->OnStart(); |
| 221 | #ifdef DEBUG_ANIMATIONS |
| 222 | Print(); |
| 223 | #endif |
| 224 | return; |
no test coverage detected