16 USignComponent::USignComponent()
18 PrimaryComponentTick.bCanEverTick =
false;
22 void USignComponent::BeginPlay()
29 void USignComponent::TickComponent(
float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
31 Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
35 const FString& USignComponent::GetSignId()
const 40 void USignComponent::SetSignId(
const FString &Id) {
44 void USignComponent::InitializeSign(
const cr::Map &Map)
49 TArray<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();
89 UBoxComponent* 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);
103 UBoxComponent* 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);
117 void USignComponent::AddEffectTriggerVolume(UBoxComponent* TriggerVolume)
119 EffectTriggerVolumes.Add(TriggerVolume);
122 const TArray<UBoxComponent*> USignComponent::GetEffectTriggerVolume()
const 124 return EffectTriggerVolumes;
const Lane & GetLane(Waypoint waypoint) const
======================================================================== – Road information --------...
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
std::vector< const T * > GetInfos() const