16USignComponent::USignComponent()
18 PrimaryComponentTick.bCanEverTick =
false;
22void USignComponent::BeginPlay()
29void USignComponent::TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
31 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
35const FString& USignComponent::GetSignId()
const
40void USignComponent::SetSignId(
const FString &Id) {
44void USignComponent::InitializeSign(
const cr::Map &Map)
49TArray<std::pair<cr::RoadId, const cre::RoadInfoSignal*>>
50 USignComponent::GetAllReferencesToThisSignal(
const cr::Map &Map)
52 TArray<std::pair<cr::RoadId, const cre::RoadInfoSignal*>> Result;
54 std::unordered_set<cr::RoadId> ExploredRoads;
55 for (
auto & waypoint : waypoints)
58 if (ExploredRoads.count(waypoint.road_id) > 0)
62 ExploredRoads.insert(waypoint.road_id);
65 auto SignalReferences = Map.
GetLane(waypoint).
67 for (
auto *SignalReference : SignalReferences)
69 FString SignalId(SignalReference->GetSignalId().c_str());
70 if(SignalId == GetSignId())
72 Result.Add({waypoint.road_id, SignalReference});
81 std::string std_signal_id = carla::rpc::FromFString(GetSignId());
84 return Map.
GetSignals().at(std_signal_id).get();
89UBoxComponent* USignComponent::GenerateTriggerBox(
const FTransform &BoxTransform,
92 AActor *ParentActor = GetOwner();
93 UBoxComponent *BoxComponent = NewObject<UBoxComponent>(ParentActor);
94 BoxComponent->RegisterComponent();
95 BoxComponent->AttachToComponent(
96 ParentActor->GetRootComponent(),
97 FAttachmentTransformRules::KeepRelativeTransform);
98 BoxComponent->SetWorldTransform(BoxTransform);
99 BoxComponent->SetBoxExtent(FVector(BoxSize, BoxSize, BoxSize),
true);
103UBoxComponent* USignComponent::GenerateTriggerBox(
const FTransform &BoxTransform,
104 const FVector &BoxSize)
106 AActor *ParentActor = GetOwner();
107 UBoxComponent *BoxComponent = NewObject<UBoxComponent>(ParentActor);
108 BoxComponent->RegisterComponent();
109 BoxComponent->AttachToComponent(
110 ParentActor->GetRootComponent(),
111 FAttachmentTransformRules::KeepRelativeTransform);
112 BoxComponent->SetWorldTransform(BoxTransform);
113 BoxComponent->SetBoxExtent(BoxSize,
true);
117void USignComponent::AddEffectTriggerVolume(UBoxComponent*
TriggerVolume)
122const TArray<UBoxComponent*> USignComponent::GetEffectTriggerVolume()
const
124 return EffectTriggerVolumes;
std::vector< const T * > GetInfos() const
std::vector< Waypoint > GenerateWaypointsOnRoadEntries(Lane::LaneType lane_type=Lane::LaneType::Driving) const
Generate waypoints on each lane at the start of each road
const std::unordered_map< SignId, std::unique_ptr< Signal > > & GetSignals() const
const Lane & GetLane(Waypoint waypoint) const
========================================================================