mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-21 21:17:49 +02:00
Fixed embarking & disembarking timings
This commit is contained in:
parent
b5ad3a0559
commit
57d906a01c
client
@ -455,8 +455,11 @@ void ApplyFirstClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)
|
||||
}
|
||||
}
|
||||
|
||||
if(!CGI->mh)
|
||||
return;
|
||||
if(CGI->mh && pack.result == TryMoveHero::EMBARK)
|
||||
{
|
||||
CGI->mh->onObjectFadeOut(h);
|
||||
CGI->mh->waitForOngoingAnimations();
|
||||
}
|
||||
}
|
||||
|
||||
void ApplyClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)
|
||||
@ -480,7 +483,8 @@ void ApplyClientNetPackVisitor::visitTryMoveHero(TryMoveHero & pack)
|
||||
CGI->mh->onHeroRotated(h, pack.start, pack.end);
|
||||
break;
|
||||
case TryMoveHero::EMBARK:
|
||||
CGI->mh->onObjectFadeOut(h);
|
||||
// handled in ApplyFirst
|
||||
//CGI->mh->onObjectFadeOut(h);
|
||||
break;
|
||||
case TryMoveHero::DISEMBARK:
|
||||
CGI->mh->onObjectFadeIn(h);
|
||||
|
@ -462,9 +462,15 @@ MapViewController::MapViewController(std::shared_ptr<MapRendererContext> context
|
||||
|
||||
void MapViewController::update(uint32_t timeDelta)
|
||||
{
|
||||
static const double fadeOutDuration = 1.0;
|
||||
static const double fadeInDuration = 1.0;
|
||||
static const double heroTeleportDuration = 1.0;
|
||||
// confirmed to match H3 for
|
||||
// - hero embarking on boat (500 ms)
|
||||
// - hero disembarking from boat (500 ms)
|
||||
// - TODO: picking up resources
|
||||
// - TODO: killing mosters
|
||||
// - teleporting ( 250 ms)
|
||||
static const double fadeOutDuration = 500;
|
||||
static const double fadeInDuration = 500;
|
||||
static const double heroTeleportDuration = 250;
|
||||
|
||||
//FIXME: remove code duplication?
|
||||
|
||||
@ -494,14 +500,14 @@ void MapViewController::update(uint32_t timeDelta)
|
||||
|
||||
if (context->teleportAnimation)
|
||||
{
|
||||
context->teleportAnimation->progress += heroTeleportDuration * timeDelta / 1000;
|
||||
context->teleportAnimation->progress += timeDelta / heroTeleportDuration;
|
||||
if (context->teleportAnimation->progress >= 1.0)
|
||||
context->teleportAnimation.reset();
|
||||
}
|
||||
|
||||
if (context->fadeOutAnimation)
|
||||
{
|
||||
context->fadeOutAnimation->progress += fadeOutDuration * timeDelta / 1000;
|
||||
context->fadeOutAnimation->progress += timeDelta / fadeOutDuration;
|
||||
if (context->fadeOutAnimation->progress >= 1.0)
|
||||
{
|
||||
context->removeObject(context->getObject(context->fadeOutAnimation->target));
|
||||
@ -511,7 +517,7 @@ void MapViewController::update(uint32_t timeDelta)
|
||||
|
||||
if (context->fadeInAnimation)
|
||||
{
|
||||
context->fadeInAnimation->progress += fadeInDuration * timeDelta / 1000;
|
||||
context->fadeInAnimation->progress += timeDelta / fadeInDuration;
|
||||
if (context->fadeInAnimation->progress >= 1.0)
|
||||
context->fadeInAnimation.reset();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user