1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

vcmi: use new animation functions in client

This commit is contained in:
Konstantin
2023-03-26 20:15:26 +03:00
parent 179cee3e88
commit d83e58f948

View File

@@ -42,17 +42,7 @@ BattleObstacleController::BattleObstacleController(BattleInterface & owner):
void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi) void BattleObstacleController::loadObstacleImage(const CObstacleInstance & oi)
{ {
std::string animationName; std::string animationName = oi.getAnimation();
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;
}
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()); auto animation = std::make_shared<CAnimation>(oi->getAppearAnimation());
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);
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 ); CCS->soundh->playSound( oi->getAppearSound() );
owner.stacksController->addNewAnim(new EffectAnimation(owner, spellObstacle->appearAnimation, whereTo, oi->pos)); 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);
} }
} }