本文整理汇总了C++中Opt::SetShootAlt方法的典型用法代码示例。如果您正苦于以下问题:C++ Opt::SetShootAlt方法的具体用法?C++ Opt::SetShootAlt怎么用?C++ Opt::SetShootAlt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Opt
的用法示例。
在下文中一共展示了Opt::SetShootAlt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
void GuardControllerSubSystem::Update(Actor& actor, double DeltaTime)
{
Opt<GuardControllerComponent> guardCC=actor.Get<IControllerComponent>();
if (!guardCC.IsValid()||!guardCC->IsEnabled())
{
return;
}
if (mProgramState.mMode == core::ProgramState::Client)
{
return;
}
auto targetHolderC = actor.Get<ITargetHolderComponent>();
if (!targetHolderC.IsValid())
{
return;
}
auto healthC = actor.Get<IHealthComponent>();
if (!healthC.IsValid() || !healthC->IsAlive())
{
return;
}
UpdateTarget( actor, targetHolderC );
Opt<Actor> currentTarget( mScene.GetActor( targetHolderC->GetTargetGUID() ) );
auto moveC( actor.Get<IMoveComponent>() );
guardCC->SetNextMoveTimer( guardCC->GetNextMoveTimer() - DeltaTime );
if (currentTarget.IsValid())
{
auto positionC( actor.Get<IPositionComponent>() );
auto targetPositionC( currentTarget->Get<IPositionComponent>() );
auto const distSqr = GetDistanceSqr( positionC, targetPositionC );
glm::vec2 const distV( (targetPositionC->GetX() - positionC->GetX()), (targetPositionC->GetY() - positionC->GetY()) );
double const Rot = atan2( distV.y, distV.x );
positionC->SetOrientation( Rot );
auto inventoryC = actor.Get<IInventoryComponent>();
if (inventoryC.IsValid())
{
Opt<Weapon> weapon = inventoryC->GetSelectedWeapon();
if (weapon.IsValid())
{
int32_t const aggroAltDistSqr = guardCC->GetAggroAltDist() * guardCC->GetAggroAltDist();
if (distSqr < aggroAltDistSqr)
{
weapon->SetShoot( false );
weapon->SetShootAlt( true );
}
else
{
weapon->SetShoot( true );
weapon->SetShootAlt( false );
}
}
}
if (guardCC->GetNextMoveTimer() <= 0.0)
{
const int32_t ran = RandomGenerator::global()() % 3;
if (ran == 0)
{
guardCC->SetMoveDirection( GuardControllerComponent::Left );
}
else if (ran == 1)
{
guardCC->SetMoveDirection( GuardControllerComponent::Right );
}
else
{
guardCC->SetMoveDirection( GuardControllerComponent::None );
}
guardCC->SetNextMoveTimer(guardCC->GetNextMoveTimerMax()
+ (RandomGenerator::global()() % 100*0.02*- 1)*guardCC->GetNextMoveTimerVariance() );
}
int32_t const tooCloseDistSqr = guardCC->GetCloseDist() * guardCC->GetCloseDist();
int32_t const walkAwayDistSqr = guardCC->GetWalkAwayDist() * guardCC->GetWalkAwayDist();
double heading = 0.0;
static const double pi = boost::math::constants::pi<double>();
if (distSqr > tooCloseDistSqr)
{
heading = Rot;
if (guardCC->GetMoveDirection() == GuardControllerComponent::Left)
{
heading -= pi / 4;
}
else if (guardCC->GetMoveDirection() == GuardControllerComponent::Right)
{
heading += pi / 4;
}
moveC->SetMoving( true );
}
else if (distSqr < walkAwayDistSqr)
{
heading = Rot-pi;
if (guardCC->GetMoveDirection() == GuardControllerComponent::Left)
{
heading += pi / 4;
}
else if (guardCC->GetMoveDirection() == GuardControllerComponent::Right)
{
//.........这里部分代码省略.........