|
@@ -42,17 +42,7 @@ BattleObstacleController::BattleObstacleController(BattleInterface & owner):
|
|
|
|
|
|
void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
|
|
|
{
|
|
|
- std::string animationName;
|
|
|
-
|
|
|
- if (auto spellObstacle = dynamic_cast<const SpellCreatedObstacle*>(&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::vector<std::shared_ptr<
|
|
|
if(!oi->visibleForSide(side.get(),owner.curInt->cb->battleHasNativeStack(side.get())))
|
|
|
continue;
|
|
|
|
|
|
- auto spellObstacle = dynamic_cast<const SpellCreatedObstacle*>(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<CAnimation>(spellObstacle->appearAnimation);
|
|
|
+ auto animation = std::make_shared<CAnimation>(oi->getAppearAnimation());
|
|
|
animation->preload();
|
|
|
|
|
|
auto first = animation->getImage(0, 0);
|
|
@@ -132,13 +114,13 @@ void BattleObstacleController::obstaclePlaced(const std::vector<std::shared_ptr<
|
|
|
//we assume here that effect graphics have the same size as the usual obstacle image
|
|
|
// -> 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);
|
|
|
}
|
|
|
}
|
|
|
|