void UEnvQueryGenerator_ActorsOfClass::GenerateItems(FEnvQueryInstance& QueryInstance) const { float RadiusValue = 0.0f; float DensityValue = 0.0f; UWorld* World = GEngine->GetWorldFromContextObject(QueryInstance.Owner.Get()); // @TODO add some logging here if (World == NULL || QueryInstance.GetParamValue(Radius, RadiusValue, TEXT("Radius")) == false || SearchedActorClass == NULL) { return; } const float RadiusSq = FMath::Square(RadiusValue); TArray<FVector> ContextLocations; QueryInstance.PrepareContext(SearchCenter, ContextLocations); for (TActorIterator<AActor> ItActor = TActorIterator<AActor>(World, SearchedActorClass); ItActor; ++ItActor) { for (int32 ContextIndex = 0; ContextIndex < ContextLocations.Num(); ++ContextIndex) { if (FVector::DistSquared(ContextLocations[ContextIndex], ItActor->GetActorLocation()) < RadiusSq) { QueryInstance.AddItemData<UEnvQueryItemType_Actor>(*ItActor); break; } } } }
void UEnvQueryGenerator_ActorsOfClass::GenerateItems(FEnvQueryInstance& QueryInstance) const { SearchRadius.BindData(QueryInstance.Owner.Get(), QueryInstance.QueryID); float RadiusValue = SearchRadius.GetValue(); UWorld* World = GEngine->GetWorldFromContextObject(QueryInstance.Owner.Get()); if (World == NULL || SearchedActorClass == NULL) { return; } const float RadiusSq = FMath::Square(RadiusValue); TArray<FVector> ContextLocations; QueryInstance.PrepareContext(SearchCenter, ContextLocations); for (TActorIterator<AActor> ItActor = TActorIterator<AActor>(World, SearchedActorClass); ItActor; ++ItActor) { for (int32 ContextIndex = 0; ContextIndex < ContextLocations.Num(); ++ContextIndex) { if (FVector::DistSquared(ContextLocations[ContextIndex], ItActor->GetActorLocation()) < RadiusSq) { QueryInstance.AddItemData<UEnvQueryItemType_Actor>(*ItActor); break; } } } }