Removed duplicated props

This commit is contained in:
doterop 2020-04-07 15:43:19 +02:00
parent 2639b82658
commit a25842d924
2 changed files with 43 additions and 0 deletions

View File

@ -136,6 +136,8 @@ void ATrafficLightManager::GenerateSignalsAndTrafficLights()
return;
}
RemoveRoadrunnerProps();
SpawnTrafficLights();
GenerateTriggerBoxesForTrafficLights();
@ -465,3 +467,40 @@ USignComponent* ATrafficLightManager::GetTrafficSign(FString SignId)
}
return TrafficSignComponents[SignId];
}
void ATrafficLightManager::RemoveRoadrunnerProps() const
{
TArray<AActor*> Actors;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AActor::StaticClass(), Actors);
// Detect PropsNode Actor which is the father of all the Props imported from Roadrunner
AActor* PropsNode = nullptr;
for(AActor* Actor : Actors)
{
const FString Name = UKismetSystemLibrary::GetDisplayName(Actor);
if(Name.Equals("PropsNode"))
{
PropsNode = Actor;
break;
}
}
if(PropsNode)
{
PropsNode->GetAttachedActors(Actors, true);
RemoveAttachedProps(Actors);
PropsNode->Destroy();
}
}
void ATrafficLightManager::RemoveAttachedProps(TArray<AActor*> Actors) const
{
for(AActor* Actor : Actors)
{
TArray<AActor*> AttachedActors;
Actor->GetAttachedActors(AttachedActors, true);
RemoveAttachedProps(AttachedActors);
Actor->Destroy();
}
}

View File

@ -62,6 +62,10 @@ private:
UTrafficLightComponent* TrafficLightComponent,
float BoxSize);
void RemoveRoadrunnerProps() const;
void RemoveAttachedProps(TArray<AActor*> Actors) const;
// Cached Carla Game Mode
UPROPERTY()
ACarlaGameModeBase *GameMode = 0;