Removed duplicated props
This commit is contained in:
parent
2639b82658
commit
a25842d924
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue