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);
static bool IsValid(const ACarlaWheeledVehicle *Vehicle)
static ETrafficSignState ToTrafficSignState(ETrafficLightState State)
Base class for CARLA wheeled vehicles.
TArray< ATrafficLightBase * > GroupTrafficLights
void SetGreenTime(float InGreenTime)
UTrafficLightComponent * TrafficLightComponent
void SetRedTime(float InRedTime)
ATrafficLightBase(const FObjectInitializer &ObjectInitializer)
ETrafficLightState GetTrafficLightState() const
void SetTrafficLightState(ETrafficLightState State)
void SetPoleIndex(int InPoleIndex)
void OnTrafficLightStateChanged(ETrafficLightState TrafficLightState)
void LightChangedCompatibility(ETrafficLightState NewLightState)
float GetGreenTime() const
bool GetTimeIsFrozen() const
void SetYellowTime(float InYellowTime)
void NotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
float GetElapsedTime() const
float GetYellowTime() const
void SetElapsedTime(float InElapsedTime)
void UnNotifyWheeledVehicle(ACarlaWheeledVehicle *Vehicle)
void SetGroupTrafficLights(TArray< ATrafficLightBase * > InGroupTrafficLights)
TArray< AWheeledVehicleAIController * > Vehicles
TArray< ATrafficLightBase * > GetGroupTrafficLights() const
void SetTimeIsFrozen(bool InTimeIsFrozen)
UTrafficLightComponent * GetTrafficLightComponent()
Class which implements the state changing of traffic lights
TArray< UTrafficLightController * > & GetControllers()
void SetTrafficSignState(ETrafficSignState State)
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)
Maps a controller from OpenDrive.
void SetGreenTime(float NewTime)
void SetYellowTime(float NewTime)
void SetRedTime(float NewTime)