本文整理汇总了C++中TObjectIterator::GetWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ TObjectIterator::GetWorld方法的具体用法?C++ TObjectIterator::GetWorld怎么用?C++ TObjectIterator::GetWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObjectIterator
的用法示例。
在下文中一共展示了TObjectIterator::GetWorld方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanUpTargets
void ACharacterTargetSystem::cleanUpTargets(UWorld* currentGameWorld)
{
// clean up all previous focused enemies
for (TObjectIterator<ABasicEnemy> enemyFocusIterator; enemyFocusIterator; ++enemyFocusIterator)
{
if (enemyFocusIterator->GetWorld() == currentGameWorld)
{
ABasicEnemy* enemyChar = *enemyFocusIterator;
if (!enemyChar->IsPendingKill())
{
enemyChar->hideFocusComponent();
enemyChar->removeFocus();
enemyChar->disableMenu();
}
}
}
// clean up all previous focused enemies
for (TObjectIterator<ABasicNpc> npcFocusIterator; npcFocusIterator; ++npcFocusIterator)
{
if (npcFocusIterator->GetWorld() == currentGameWorld)
{
ABasicNpc* npcChar = *npcFocusIterator;
npcChar->hideFocusComponent();
npcChar->removeFocus();
}
}
}
示例2: checkFreeTargetEnemies
// check only for enemies which are free to target in the given range
bool ACharacterTargetSystem::checkFreeTargetEnemies(ACharacter* player, UWorld* currentGameWorld, float distance)
{
ABasicEnemy* enemyChar;
bool enemyFreeForTarget = false;
float distanceToTarget = distance;
// TODO
for (TObjectIterator<ABasicEnemy> enemyIterator; enemyIterator; ++enemyIterator)
{
if (enemyIterator->GetWorld() == currentGameWorld)
{
enemyChar = *enemyIterator;
float distanceToPlayer = enemyChar->GetDistanceTo(player);
if (!enemyChar->IsPendingKill() && distanceToPlayer < distanceToTarget)
{
bool isEnemySkipped = enemyChar->bSkippedTarget;
if (!isEnemySkipped)
{
enemyFreeForTarget = true;
}
}
}
}
return enemyFreeForTarget;
}
示例3: SphereTrace
bool ASkill::SphereTrace(AActor* actorToIgnore, const FVector& start, const FVector& end, const float radius, TArray<FHitResult>& hitOut, ECollisionChannel traceChannel /* = ECC_Pawn */)
{
FCollisionQueryParams traceParams(FName(TEXT("Sphere Trace")), true, actorToIgnore);
traceParams.bTraceComplex = true;
traceParams.bReturnPhysicalMaterial = false;
traceParams.AddIgnoredActor(actorToIgnore);
TObjectIterator<APlayerController> pc;
if (!pc)
return false;
DrawDebugSphere(pc->GetWorld(), start, radius, 8, FColor::Red, true);
return pc->GetWorld()->SweepMultiByChannel(hitOut, start, end, FQuat(), traceChannel, FCollisionShape::MakeSphere(radius), traceParams);
}
示例4: GetMyHealth
void AFPSCharacter::GetMyHealth()
{
if (GEngine)
{
TObjectIterator< APlayerController > ThePC;
UWorld* TheWorld = ThePC->GetWorld();
AFPSGM* MyGM = Cast<AFPSGM>(UGameplayStatics::GetGameMode(TheWorld));
if (MyGM != NULL)
{
GEngine->AddOnScreenDebugMessage(1, 5.f, FColor::Red, FString::FromInt(MyGM->Health));
}
}
}
示例5: makeAllNpcsFocusable
void ACharacterTargetSystem::makeAllNpcsFocusable(UWorld* currentGameWorld)
{
ABasicNpc* npcChar;
for (TObjectIterator<ABasicNpc> npcFreeIterator; npcFreeIterator; ++npcFreeIterator)
{
if (npcFreeIterator->GetWorld() == currentGameWorld)
{
npcChar = *npcFreeIterator;
if (npcChar)
{
npcChar->bSkippedTarget = false;
}
}
}
}
示例6: makeAllEnemiesFocusable
void ACharacterTargetSystem::makeAllEnemiesFocusable(UWorld* currentGameWorld)
{
ABasicEnemy* enemyChar;
for (TObjectIterator<ABasicEnemy> enemyFreeIterator; enemyFreeIterator; ++enemyFreeIterator)
{
if (enemyFreeIterator->GetWorld() == currentGameWorld)
{
enemyChar = *enemyFreeIterator;
if (enemyChar && !enemyChar->IsPendingKill())
{
enemyChar->bSkippedTarget = false;
}
}
}
}
示例7: findNPCTargetByDistance
void ACharacterTargetSystem::findNPCTargetByDistance(ACharacter* player, UWorld* currentGameWorld, float distance)
{
ABasicNpc* npcChar;
float distanceToPlayer;
float distanceToTarget = distance;
bool npcFreeForTarget = checkFreeTargetNpcs(currentGameWorld);
// if every enemy has been skipped, set all to be focusable again
if (!npcFreeForTarget)
{
makeAllNpcsFocusable(currentGameWorld);
}
// get distance to enemy that can be focused
for (TObjectIterator<ABasicNpc> npcFocusIterator; npcFocusIterator; ++npcFocusIterator)
{
if (npcFocusIterator->GetWorld() == currentGameWorld)
{
npcChar = *npcFocusIterator;
if (npcChar && player && npcChar->bSkippedTarget == false)
{
distanceToPlayer = npcChar->GetDistanceTo(player);
if (distanceToPlayer < distanceToTarget)
{
npcChar->bSkippedTarget = true;
npcChar->setFocus();
targetedNpc = npcChar;
break;
}
else
{
npcChar->removeFocus();
targetedNpc = nullptr;
}
}
else
{
npcChar->removeFocus();
targetedNpc = nullptr;
}
}
}
}
示例8: findEnemyTargetByDistance
void ACharacterTargetSystem::findEnemyTargetByDistance(ACharacter* player, UWorld* currentGameWorld, float distance)
{
ABasicEnemy* enemyChar;
float distanceToPlayer;
float distanceToTarget = distance;
//TODO CHECK THIS IN DISTANCE
bool enemyFreeForTarget = checkFreeTargetEnemies(player, currentGameWorld, distance);
// if every enemy has been skipped, set all to be focusable again
if (!enemyFreeForTarget)
{
makeAllEnemiesFocusable(currentGameWorld);
}
// get distance to enemy that can be focused
for (TObjectIterator<ABasicEnemy> enemyFocusIterator; enemyFocusIterator; ++enemyFocusIterator)
{
if (enemyFocusIterator->GetWorld() == currentGameWorld)
{
enemyChar = *enemyFocusIterator;
if (enemyChar && !enemyChar->IsPendingKill() && player && enemyChar->bSkippedTarget == false)
{
distanceToPlayer = enemyChar->GetDistanceTo(player);
if (distanceToPlayer < distanceToTarget)
{
enemyChar->bSkippedTarget = true;
enemyChar->setFocus();
targetedEnemy = enemyChar;
break;
}
else
{
enemyChar->removeFocus();
}
}
else
{
enemyChar->removeFocus();
targetedEnemy = nullptr;
}
}
}
}
示例9: checkFreeTargetNpcs
bool ACharacterTargetSystem::checkFreeTargetNpcs(UWorld* currentGameWorld)
{
ABasicNpc* npcChar;
bool npcFreeForTarget = false;
// check if every enemy has been focused yet
for (TObjectIterator<ABasicNpc> npcIterator; npcIterator; ++npcIterator)
{
if (npcIterator->GetWorld() == currentGameWorld)
{
npcChar = *npcIterator;
bool isEnemySkipped = npcChar->bSkippedTarget;
if (!isEnemySkipped)
{
npcFreeForTarget = true;
}
}
}
return npcFreeForTarget;
}
示例10: GetNumberOfNetworkPlayers
void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(int32 &NumNetPlayers)
{
//Get an actor to GetWorld() from
TObjectIterator<AActor> Itr;
if (!Itr)
{
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get iterator!"));
return;
}
//~~~~~~~~~~~~
//Get World
UWorld* TheWorld = Itr->GetWorld();
if (!TheWorld)
{
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetNumberOfNetworkPlayers Failed to get World()!"));
return;
}
TArray<class APlayerState*>& PlayerArray = (TheWorld->GetGameState()->PlayerArray);
NumNetPlayers = PlayerArray.Num();
}