コード例 #1
0
void Bomb::OnBeforeUpdate()
{
    World& world = World::GetInstance();
    Actor collisionFire;
    if(world.GetFireManager()->IsColliding(*this, &collisionFire))
    {
        SetLifeSpan(0);
    }

    if(CanDelete() && CanTriggerExplosion())
    {
        std::shared_ptr<BombExplodedEvent> bombExplosionEvent(new BombExplodedEvent(GetId(), m_position));
        world.GetEventManager()->QueueEvent(bombExplosionEvent);
        m_bCanTriggerExplosion = false;
    }

    if(CanRenderNextFrame())
    {
        m_animation.NextFrame();
        m_nextFrameWait = BOMB_NEXTFRAME_WAIT;
    }
    else
    {
        m_nextFrameWait = std::max<uint32_t>(0, m_nextFrameWait - 1);
    }
}
コード例 #2
0
void Fire::OnBeforeUpdate()
{
    World& world = World::GetInstance();
    if(CanDelete() && CanTriggerFireExtinguished())
    {
        ActorId fireId = GetId();

        std::shared_ptr<FireExtinguishedEvent> fireExtinguishedEvent =
                std::make_shared<FireExtinguishedEvent>(fireId, m_position);
        world.GetEventManager()->QueueEvent(fireExtinguishedEvent);
        m_bCanTriggerFireExtinguished = false;
    }

    if(CanRenderNextFrame())
    {
        m_animation.NextFrame();
        m_nextFrameWait = FIRE_NEXTFRAME_WAIT;
    }
    else
    {
        m_nextFrameWait = std::max<uint32_t>(0, m_nextFrameWait - 1);
    }
}