CARLA
 
载入中...
搜索中...
未找到
CarlaLightSubsystem.h
浏览该文件的文档.
1// Copyright (c) 2020 Computer Vision Center (CVC) at the Universitat Autonoma
2// de Barcelona (UAB).
3//
4// This work is licensed under the terms of the MIT license.
5// For a copy, see <https://opensource.org/licenses/MIT>.
6
7#pragma once//预处理指令
8
9#include <vector>//<vector>是C++ 标准库中的头文件,包含这个头文件可以使用向量(vector)数据结构。
10
11#include <compiler/disable-ue4-macros.h>//这是一个自定义的包含路径下的头文件(从路径推测可能是某个编译器相关且与UE4相关宏有关的头文件)。
12#include <carla/rpc/LightState.h>//这是一个自定义路径下(carla/rpc)的头文件,与LightState有关。
13#include <compiler/enable-ue4-macros.h>//这是与之前disable - ue4 - macros.h相对应的头文件。
14
15#include "Carla.h"//这是自定义的头文件(从双引号而不是尖括号可知),名为Carla.h。
16#include "CoreMinimal.h"//这是虚幻引擎中的基础头文件。
17#include "CarlaLight.h"//这是自定义的头文件,与CarlaLight相关。
18#include "Subsystems/WorldSubsystem.h"//这是一个自定义路径下(Subsystems)的头文件,与WorldSubsystem相关。
19
20#include "CarlaLightSubsystem.generated.h"//这是一个由代码生成工具(可能是虚幻引擎的代码生成工具)自动生成的头文件,与CarlaLightSubsystem相关。
21
22/**
23 *
24 */
25UCLASS(Blueprintable, BlueprintType)
26class CARLA_API UCarlaLightSubsystem : public UWorldSubsystem
27{
28 GENERATED_BODY()
29
30 //using cr = carla::rpc;
31
32public:
33
34 // 开始 USubsystem
35 void Initialize(FSubsystemCollectionBase& Collection) override;
36 //结束 USubsystem
37 void Deinitialize() override;
38
39 void RegisterLight(UCarlaLight* CarlaLight);
40
41 void UnregisterLight(UCarlaLight* CarlaLight);
42
43 UFUNCTION(BlueprintCallable)
44 bool IsUpdatePending() const;
45
46 UFUNCTION(BlueprintCallable)
47 int32 NumLights() const {
48 return Lights.Num();
49 }
50
51 std::vector<carla::rpc::LightState> GetLights(FString Client);
52
53 void SetLights(
54 FString Client,
55 std::vector<carla::rpc::LightState> LightsToSet,
56 bool DiscardClient = false);
57
58 UCarlaLight* GetLight(int Id);
59
60 TMap<int, UCarlaLight* >& GetLights()
61 {
62 return Lights;
63 }
64
65 void SetDayNightCycle(const bool active);
66
67private:
68
69 void SetClientStatesdirty(FString ClientThatUpdate);
70
71 TMap<int, UCarlaLight* > Lights;
72
73 // 每个客户端的标志,用于指示是否需要进行更新
74 TMap<FString, bool> ClientStates;
75 // 由于客户端在模拟中没有正确的 ID,因此
76 // 我使用 host : 端口对。
77
78};
TMap< int, UCarlaLight * > Lights
TMap< int, UCarlaLight * > & GetLights()
TMap< FString, bool > ClientStates