diff --git a/client/battle/BattleObstacleController.cpp b/client/battle/BattleObstacleController.cpp index 911e413d6..b29741622 100644 --- a/client/battle/BattleObstacleController.cpp +++ b/client/battle/BattleObstacleController.cpp @@ -42,17 +42,7 @@ BattleObstacleController::BattleObstacleController(BattleInterface & owner): void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi) { - std::string animationName; - - if (auto spellObstacle = dynamic_cast(&oi)) - { - animationName = spellObstacle->animation; - } - else - { - assert( oi.obstacleType == CObstacleInstance::USUAL || oi.obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE); - animationName = oi.getInfo().animation; - } + std::string animationName = oi.getAnimation(); if (animationsCache.count(animationName) == 0) { @@ -114,15 +104,7 @@ void BattleObstacleController::obstaclePlaced(const std::vectorvisibleForSide(side.get(),owner.curInt->cb->battleHasNativeStack(side.get()))) continue; - auto spellObstacle = dynamic_cast(oi.get()); - - if (!spellObstacle) - { - logGlobal->error("I don't know how to animate removal of obstacle of type %d", (int)oi->obstacleType); - continue; - } - - auto animation = std::make_shared(spellObstacle->appearAnimation); + auto animation = std::make_shared(oi->getAppearAnimation()); animation->preload(); auto first = animation->getImage(0, 0); @@ -132,13 +114,13 @@ void BattleObstacleController::obstaclePlaced(const std::vector if we know how to blit obstacle, let's blit the effect in the same place Point whereTo = getObstaclePosition(first, *oi); - CCS->soundh->playSound( spellObstacle->appearSound ); - owner.stacksController->addNewAnim(new EffectAnimation(owner, spellObstacle->appearAnimation, whereTo, oi->pos)); + CCS->soundh->playSound( oi->getAppearSound() ); + owner.stacksController->addNewAnim(new EffectAnimation(owner, oi->getAppearAnimation(), whereTo, oi->pos)); //so when multiple obstacles are added, they show up one after another owner.waitForAnimations(); - loadObstacleImage(*spellObstacle); + loadObstacleImage(*oi); } }