当前位置: 首页>>代码示例>>C++>>正文


C++ Opt::IsAlive方法代码示例

本文整理汇总了C++中Opt::IsAlive方法的典型用法代码示例。如果您正苦于以下问题:C++ Opt::IsAlive方法的具体用法?C++ Opt::IsAlive怎么用?C++ Opt::IsAlive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Opt的用法示例。


在下文中一共展示了Opt::IsAlive方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Update

void NotifyParentOnDeathSystem::Update( double DeltaTime )
{
    for ( auto actor : mScene.GetActorsFromMap( GetType_static() ) )
    {
        Opt<INotifyParentOnDeathComponent> notifyParentOnDeathC = actor->Get<INotifyParentOnDeathComponent>();
        if ( !notifyParentOnDeathC.IsValid() )
        {
            continue;
        }
        Opt<Actor> parent( mScene.GetActor( notifyParentOnDeathC->GetParentGUID() ) );
        Opt<Actor> killer( mScene.GetActor( notifyParentOnDeathC->GetKillerGUID() ) );

        if( !parent.IsValid() )
        {
            continue;
        }

        Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>();
        if( !healthC.IsValid() || healthC->IsAlive() )
        {
            continue;
        }
        if( !killer.IsValid() )
        {
            continue;
        }
        Opt<IListenChildDeathComponent> listenChildDeathC = parent->Get<IListenChildDeathComponent>();
        if ( !listenChildDeathC.IsValid() )
        {
            continue;
        }
        listenChildDeathC->SetKillerOfChildGUID( killer->GetGUID() );
    }
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:34,代码来源:notify_parent_on_death_system.cpp

示例2: Update

void RemoveComponentsOnDeathSystem::Update( double DeltaTime )
{
    for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
    {
        Actor& actor = **it;
        Opt<IRemoveComponentsOnDeathComponent> removeComponentsOnDeathC = actor.Get<IRemoveComponentsOnDeathComponent>();
        if ( !removeComponentsOnDeathC.IsValid() )
        {
            continue;
        }
        Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>();
        if( !healthC.IsValid() )
        {
            continue;
        }
        if( healthC->IsAlive() )
        {
            continue;
        }
        // create copy, component might drop itself
        std::vector<int32_t> const comps = removeComponentsOnDeathC->GetComponents();
        std::for_each( std::begin( comps ), std::end( comps ),
                [&]( int32_t id ) { actor.DropComponent( id ); } );
    }
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:25,代码来源:remove_components_on_death_system.cpp

示例3: Update

void StopOnDeathSystem::Update( double DeltaTime )
{
    for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(); it != e; ++it )
    {
        Actor& actor = **it;
        Opt<IStopOnDeathComponent> stopOnDeathC = actor.Get<IStopOnDeathComponent>();
        if ( !stopOnDeathC.IsValid() || stopOnDeathC->IsStopped() )
        {
            continue;
        }

        Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>();
        if ( !healthC.IsValid() )
        {
            continue;
        }
        if ( healthC->IsAlive() )
        {
            continue;
        }
        stopOnDeathC->SetStopped( true );
        Opt<IMoveComponent> moveC = actor.Get<IMoveComponent>();
        if( moveC.IsValid() )
        {
            moveC->SetMoving( false );
            moveC->SetHeadingModifier( 0 );
        }
    }
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:29,代码来源:stop_on_death_system.cpp

示例4: clientActor

std::auto_ptr<Actor> SoldierSpawnSystem::Spawn( core::ClientData& clientData, map::SpawnPoint spawnPoint, std::auto_ptr<Actor> player )
{
    Opt<Actor> clientActor( mScene.GetActor( clientData.mClientActorGUID ) );
    if( clientActor.IsValid() )
    {
        Opt<IHealthComponent> healthC = clientActor->Get<IHealthComponent>();
        if ( healthC.IsValid() && healthC->IsAlive() )
        {
            L1( "Cannot spawn soldier for clientData (%s) current soldier still alive!\n", clientData.mClientName.c_str() );
            return std::auto_ptr<Actor>();
        }
    }
    else
    {
        L2( "No actor for clientData(%s). (it might be an error on revive)\n", clientData.mClientName.c_str() );
    }
    L2( "player is valid %d", player.get() );
    Opt<IPositionComponent> positionC = player->Get<IPositionComponent>();
    L2( "positionC is valid %d", positionC.IsValid() );
    positionC->SetX( spawnPoint.mX );
    positionC->SetY( spawnPoint.mY );

    //TODO: temporary till normal inventory sync
//     Opt<IInventoryComponent> inventoryC = player->Get<IInventoryComponent>();
//     if ( inventoryC.IsValid() )
//     {
//         inventoryC->SetSelectedWeapon( AutoId( "pistol" ) );
//     }

    Opt<PlayerControllerComponent> playerControllerC( player->Get<IControllerComponent>() );
    if ( playerControllerC.IsValid() )
    {
        playerControllerC->mControllerId = clientData.mClientId;
        if ( mProgramState.mControlledActorGUID == clientData.mClientActorGUID
             && mProgramState.mMode != core::ProgramState::Server )
        {
            playerControllerC->SetEnabled( true );
            playerControllerC->mActive = true;
            mProgramState.mControlledActorGUID = player->GetGUID();
        }
    }
    clientData.mClientActorGUID = player->GetGUID(); //TODO: might seek for a better place
    L2( "player created clientId:%d clientName:%s actorId:%d\n", clientData.mClientId, clientData.mClientName.c_str(), clientData.mClientActorGUID );

    if ( mProgramState.mMode != core::ProgramState::Server &&
         mProgramState.mClientDatas.begin()->mClientActorGUID == player->GetGUID() )
    {
        Scene::Get().SetPlayerModels( Opt<Actor>( player.get() ) );
    }
    EventServer<SoldierCreatedEvent>::Get().SendEvent( SoldierCreatedEvent( clientData, Opt<Actor>( player.get() ) ) );
    return player;
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:52,代码来源:soldier_spawn_system.cpp

示例5: Recognize

bool HatRecognizer::Recognize( Actor const& actor ) const
{
    Opt<PlayerControllerComponent> playerCC = actor.Get<PlayerControllerComponent>();
    if ( !playerCC.IsValid() )
    {
        return false;
    }
    Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>();
    if ( !healthC.IsValid() || !healthC->IsAlive() )
    {
        return false;
    }
    return true;
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:14,代码来源:hat_recognizer.cpp

示例6: UpdateTarget

void GuardControllerSubSystem::UpdateTarget( Actor& actor, Opt<ITargetHolderComponent> targetHolderC )
{
    Opt<Actor> currentTarget( mScene.GetActor( targetHolderC->GetTargetGUID() ) );
    Opt<GuardControllerComponent> guardCC = actor.Get<IControllerComponent>();
    auto positionC( actor.Get<IPositionComponent>() );
    if (currentTarget.IsValid())
    {
        auto targetPositionC( currentTarget->Get<IPositionComponent>() );
        int32_t const disaggroDistSqr = guardCC->GetPeaceDist()*guardCC->GetPeaceDist();
        if (GetDistanceSqr( positionC, targetPositionC) > disaggroDistSqr )
        {
            targetHolderC->SetTargetGUID( -1 );
            currentTarget.Reset();
        }
    }
    if (!currentTarget.IsValid())
    {
        if (!positionC.IsValid())
        { 
            return;
        }
        for (auto player : ActorListFilter<Scene::CollisionClassActors>( mScene.GetActors(), CollisionClass::Player ))
        {
            auto targetPositionC( player->Get<IPositionComponent>() );
            if (!targetPositionC.IsValid())
            {
                return;
            }
            int32_t const aggroDistSqr = guardCC->GetAggroDist() * guardCC->GetAggroDist();
            if (GetDistanceSqr( positionC, targetPositionC ) < aggroDistSqr )
            {
                targetHolderC->SetTargetGUID( player->GetGUID() );
                currentTarget = mScene.GetActor( targetHolderC->GetTargetGUID() );
                break;
            }
        }
    }
    if (currentTarget.IsValid())
    {
        Opt<IHealthComponent> healthC = currentTarget->Get<IHealthComponent>();
        if (!healthC.IsValid() || !healthC->IsAlive())
        {
            targetHolderC->SetTargetGUID( -1 );
            currentTarget.Reset();
        }
    }

}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:48,代码来源:guard_controller_sub_system.cpp

示例7: Update

void RemoveOnDeathSystem::Update( double DeltaTime )
{
    for( ActorList_t::iterator it = mScene.GetActors().begin(), e = mScene.GetActors().end(), n; ( n = it, it != e ? ( ++n, true ) : false ); it = n )
    {
        Actor& actor = **it;
        Opt<IRemoveOnDeathComponent> removeOnDeathC = actor.Get<IRemoveOnDeathComponent>();
        if ( !removeOnDeathC.IsValid() )
        {
            continue;
        }
        Opt<IHealthComponent> healthC = actor.Get<IHealthComponent>();
        if( !healthC.IsValid() || healthC->IsAlive() )
        {
            continue;
        }
        double RemainingTime = removeOnDeathC->GetRemainingTime() - DeltaTime;
        removeOnDeathC->SetRemainingTime( RemainingTime );
        if( RemainingTime <= 0 )
        {
            mScene.RemoveActor( it );
        }
    }
}
开发者ID:abannerth,项目名称:Reaping2,代码行数:23,代码来源:remove_on_death_system.cpp

示例8: Update

void RemoveComponentsOnDeathSystem::Update( double DeltaTime )
{
    for (auto actor : mScene.GetActorsFromMap( GetType_static() ))
    {
        Opt<IRemoveComponentsOnDeathComponent> removeComponentsOnDeathC = actor->Get<IRemoveComponentsOnDeathComponent>();
        if ( !removeComponentsOnDeathC.IsValid() )
        {
            continue;
        }
        Opt<IHealthComponent> healthC = actor->Get<IHealthComponent>();
        if( !healthC.IsValid() )
        {
            continue;
        }
        if( healthC->IsAlive() )
        {
            continue;
        }
        // create copy, component might drop itself
        std::vector<int32_t> const comps = removeComponentsOnDeathC->GetComponents();
        std::for_each( std::begin( comps ), std::end( comps ),
                [&]( int32_t id ) { actor->DropComponent( id ); } );
    }
}
开发者ID:HalalUr,项目名称:Reaping2,代码行数:24,代码来源:remove_components_on_death_system.cpp


注:本文中的Opt::IsAlive方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。