Ejemplo n.º 1
0
void Effect::startAnimation()
{
    m_animationTimer.restart();

    // schedule removal
    auto self = asEffect();
    g_eventDispatcher.scheduleEvent([self]() { g_map.removeThing(self); }, Otc::EFFECT_TICKS_PER_FRAME * getAnimationPhases());
}
Ejemplo n.º 2
0
void Effect::onAppear()
{
    m_animationTimer.restart();
    m_phaseDuration = EFFECT_TICKS_PER_FRAME;

    // hack to fix some animation phases duration, currently there is no better solution
    if(m_id == 33)
        m_phaseDuration <<= 2;

    // schedule removal
    auto self = asEffect();
    g_dispatcher.scheduleEvent([self]() { g_map.removeThing(self); }, m_phaseDuration * getAnimationPhases());
}
Ejemplo n.º 3
0
void Effect::updateAnimation()
{
    int animationPhase = (g_clock.ticks() - m_animationStartTicks) / TICKS_PER_FRAME;

    if(animationPhase < getAnimationPhases())
        m_animation = animationPhase;

    if(animationPhase < getAnimationPhases() - 1) {
        auto self = asEffect();
        g_dispatcher.scheduleEvent([self]() {
            self->updateAnimation();
        }, TICKS_PER_FRAME);
    }
}
Ejemplo n.º 4
0
void Effect::start()
{
    m_animationStartTicks = g_clock.ticks();

    auto self = asEffect();

    // schedule update
    if(getAnimationPhases() > 1) {
        g_dispatcher.scheduleEvent([self]() {
            self->updateAnimation();
        }, TICKS_PER_FRAME);
    }

    // schedule removal
    g_dispatcher.scheduleEvent([self]() {
        g_map.removeThing(self);
    }, TICKS_PER_FRAME * getAnimationPhases());
}