Преглед на файлове

vcmi: use new animation functions in client

Konstantin преди 2 години
родител
ревизия
d83e58f948
променени са 1 файла, в които са добавени 5 реда и са изтрити 23 реда
  1. 5 23
      client/battle/BattleObstacleController.cpp

+ 5 - 23
client/battle/BattleObstacleController.cpp

@@ -42,17 +42,7 @@ BattleObstacleController::BattleObstacleController(BattleInterface & owner):
 
 
 void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
 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)
 	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())))
 		if(!oi->visibleForSide(side.get(),owner.curInt->cb->battleHasNativeStack(side.get())))
 			continue;
 			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();
 		animation->preload();
 
 
 		auto first = animation->getImage(0, 0);
 		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
 		//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
 		// -> if we know how to blit obstacle, let's blit the effect in the same place
 		Point whereTo = getObstaclePosition(first, *oi);
 		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
 		//so when multiple obstacles are added, they show up one after another
 		owner.waitForAnimations();
 		owner.waitForAnimations();
 
 
-		loadObstacleImage(*spellObstacle);
+		loadObstacleImage(*oi);
 	}
 	}
 }
 }