本文整理汇总了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() );
}
}
示例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 ); } );
}
}
示例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 );
}
}
}
示例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;
}
示例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;
}
示例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();
}
}
}
示例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 );
}
}
}
示例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 ); } );
}
}