Added off state to traffic lights.
This commit is contained in:
parent
7b914bd13a
commit
ec7b3b63fd
|
@ -97,9 +97,16 @@ void UTrafficLightComponent::SetLightState(ETrafficLightState NewState)
|
|||
{
|
||||
Controller->SetTrafficLight(nullptr);
|
||||
}
|
||||
// workarround for tm not supporting off state
|
||||
if (LightState == ETrafficLightState::Off)
|
||||
{
|
||||
Controller->SetTrafficLightState(ETrafficLightState::Green);
|
||||
Controller->SetTrafficLight(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (LightState == ETrafficLightState::Green)
|
||||
if (LightState == ETrafficLightState::Green ||
|
||||
LightState == ETrafficLightState::Off)
|
||||
{
|
||||
Vehicles.Empty();
|
||||
}
|
||||
|
@ -153,12 +160,18 @@ void UTrafficLightComponent::OnOverlapTriggerBox(UPrimitiveComponent *Overlapped
|
|||
if (VehicleController)
|
||||
{
|
||||
VehicleController->SetTrafficLightState(LightState);
|
||||
if (LightState != ETrafficLightState::Green)
|
||||
if (LightState != ETrafficLightState::Green &&
|
||||
LightState != ETrafficLightState::Off)
|
||||
{
|
||||
Vehicles.Add(VehicleController);
|
||||
VehicleController->SetTrafficLight(
|
||||
Cast<ATrafficLightBase>(GetOwner()));
|
||||
}
|
||||
// workarround for tm not supporting off state
|
||||
if (LightState == ETrafficLightState::Off)
|
||||
{
|
||||
VehicleController->SetTrafficLightState(ETrafficLightState::Green);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,17 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <compiler/disable-ue4-macros.h>
|
||||
#include <carla/rpc/TrafficLightState.h>
|
||||
#include <compiler/enable-ue4-macros.h>
|
||||
|
||||
#include "TrafficLightState.generated.h"
|
||||
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class ETrafficLightState : uint8 {
|
||||
Red UMETA(DisplayName = "Red"),
|
||||
Yellow UMETA(DisplayName = "Yellow"),
|
||||
Green UMETA(DisplayName = "Green")
|
||||
Green UMETA(DisplayName = "Green"),
|
||||
Off UMETA(DisplayName = "Off")
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue