19 return ((Vehicle !=
nullptr) && !Vehicle->IsPendingKill());
26 case ETrafficLightState::Green:
28 case ETrafficLightState::Yellow:
31 case ETrafficLightState::Red:
41 : Super(ObjectInitializer)
43 PrimaryActorTick.bCanEverTick =
false;
44 TrafficLightComponent = CreateDefaultSubobject<UTrafficLightComponent>(TEXT(
"TrafficLightComponent"));
60 return ETrafficLightState::Red;
77 auto Controller = Cast<AWheeledVehicleAIController>(Vehicle->GetController());
78 if (Controller !=
nullptr)
82 Controller->SetTrafficLight(
this);
91 auto Controller = Cast<AWheeledVehicleAIController>(Vehicle->GetController());
92 if (Controller !=
nullptr)
94 Controller->SetTrafficLight(
nullptr);
95 Controller->SetTrafficLightState(ETrafficLightState::Green);
106 check(TrafficLightController)
118 return Controller->GetGreenTime();
132 check(TrafficLightController)
144 return Controller->GetYellowTime();
158 check(TrafficLightController)
159 TrafficLightController->
SetRedTime(InRedTime);
170 return Controller->GetRedTime();
184 return Controller->GetElapsedTime();
198 return Controller->SetElapsedTime(InElapsedTime);
216 return Group->IsFrozen();
235 TArray<ATrafficLightBase *> result;
242 for(
auto& TLComp : Controller->GetTrafficLights())
244 result.Add(Cast<ATrafficLightBase>(TLComp->GetOwner()));
270 if (Recorder && Recorder->IsEnabled())
272 Recorder->AddTrafficLightTime(*
this);
ATrafficLightBase(const FObjectInitializer &ObjectInitializer)
void SetRedTime(float NewTime)
TArray< AWheeledVehicleAIController * > Vehicles
void UnNotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
UTrafficLightComponent * GetTrafficLightComponent()
Class which implements the state changing of traffic lights.
UTrafficLightComponent * TrafficLightComponent
float GetGreenTime() const
void SetYellowTime(float InYellowTime)
ETrafficLightState GetTrafficLightState() const
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
void SetGreenTime(float InGreenTime)
void SetGreenTime(float NewTime)
static ETrafficSignState ToTrafficSignState(ETrafficLightState State)
void OnTrafficLightStateChanged(ETrafficLightState TrafficLightState)
TArray< UTrafficLightController * > & GetControllers()
void SetElapsedTime(float InElapsedTime)
TArray< ATrafficLightBase * > GetGroupTrafficLights() const
void LightChangedCompatibility(ETrafficLightState NewLightState)
float GetElapsedTime() const
TArray< ATrafficLightBase * > GroupTrafficLights
float GetYellowTime() const
void SetGroupTrafficLights(TArray< ATrafficLightBase *> InGroupTrafficLights)
void SetTimeIsFrozen(bool InTimeIsFrozen)
void NotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
void SetYellowTime(float NewTime)
Base class for CARLA wheeled vehicles.
Maps a controller from OpenDrive.
void SetRedTime(float InRedTime)
void SetTrafficLightState(ETrafficLightState State)
void SetTrafficSignState(ETrafficSignState State)
void SetPoleIndex(int InPoleIndex)
bool GetTimeIsFrozen() const
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)