本文整理汇总了C++中Opt::SetTargetGUID方法的典型用法代码示例。如果您正苦于以下问题:C++ Opt::SetTargetGUID方法的具体用法?C++ Opt::SetTargetGUID怎么用?C++ Opt::SetTargetGUID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opt
的用法示例。
在下文中一共展示了Opt::SetTargetGUID方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
}
}