CARLA
 
载入中...
搜索中...
未找到
CarlaStatics.h
浏览该文件的文档.
1// Copyright (c) 2017 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
13
14#include "Kismet/GameplayStatics.h"
15#include "Kismet/BlueprintFunctionLibrary.h"
16
17#include "CarlaStatics.generated.h"
18
19// =============================================================================
20// -- UCarlaStatics declaration ------------------------------------------------
21// =============================================================================
22
23UCLASS()
25{
26 GENERATED_BODY()
27
28public:
29
30 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
31 static ACarlaGameModeBase *GetGameMode(const UObject *WorldContextObject);
32
33 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
34 static UCarlaGameInstance *GetGameInstance(const UObject *WorldContextObject);
35
36 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
37 static UCarlaEpisode *GetCurrentEpisode(const UObject *WorldContextObject);
38
39 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
40 static UCarlaSettings *GetCarlaSettings(const UObject *WorldContextObject);
41
42 UFUNCTION(BlueprintPure, Category="CARLA")
43 static TArray<FString> GetAllMapNames();
44
45 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
46 static ACarlaRecorder* GetRecorder(const UObject *WorldContextObject);
47
48 static CarlaReplayer* GetReplayer(const UObject *WorldContextObject);
49
50 UFUNCTION(BlueprintPure, Category="CARLA", meta=(WorldContext="WorldContextObject"))
51 static ALargeMapManager* GetLargeMapManager(const UObject *WorldContextObject);
52};
53
54// =============================================================================
55// -- UCarlaStatics implementation ---------------------------------------------
56// =============================================================================
57
59{
60 return Cast<ACarlaGameModeBase>(UGameplayStatics::GetGameMode(WorldContext));
61}
62
64{
65 return Cast<UCarlaGameInstance>(UGameplayStatics::GetGameInstance(WorldContext));
66}
67
69{
70 auto GameInstance = GetGameInstance(WorldContext);
71 return GameInstance != nullptr ? GameInstance->GetCarlaEpisode() : nullptr;
72}
73
75{
76 auto GameInstance = GetGameInstance(WorldContext);
77 return GameInstance != nullptr ? GameInstance->GetCARLASettings() : nullptr;
78}
79
80inline ACarlaRecorder* UCarlaStatics::GetRecorder(const UObject *WorldContextObject)
81{
82 auto* Episode = UCarlaStatics::GetCurrentEpisode(WorldContextObject);
83 if (Episode)
84 {
85 return Episode->GetRecorder();
86 }
87 return nullptr;
88}
89
90inline CarlaReplayer* UCarlaStatics::GetReplayer(const UObject *WorldContextObject)
91{
92 auto* Episode = UCarlaStatics::GetCurrentEpisode(WorldContextObject);
93 if (Episode)
94 {
95 return Episode->GetReplayer();
96 }
97 return nullptr;
98}
99
101{
102 ACarlaGameModeBase* GameMode = GetGameMode(WorldContextObject);
103 if (GameMode)
104 {
105 return GameMode->GetLMManager();
106 }
107 return nullptr;
108}
Base class for the CARLA Game Mode.
ALargeMapManager * GetLMManager() const
Recorder for the simulation
A simulation episode.
The game instance contains elements that must be kept alive in between levels.
Global settings for CARLA.
static UCarlaGameInstance * GetGameInstance(const UObject *WorldContextObject)
static UCarlaSettings * GetCarlaSettings(const UObject *WorldContextObject)
static CarlaReplayer * GetReplayer(const UObject *WorldContextObject)
static ALargeMapManager * GetLargeMapManager(const UObject *WorldContextObject)
static UCarlaEpisode * GetCurrentEpisode(const UObject *WorldContextObject)
static ACarlaGameModeBase * GetGameMode(const UObject *WorldContextObject)
static ACarlaRecorder * GetRecorder(const UObject *WorldContextObject)