Port quality level delegate to new game mode
This commit is contained in:
parent
d2f2c3c650
commit
b58a5988a1
|
@ -7,9 +7,6 @@
|
|||
#include "Carla.h"
|
||||
#include "Carla/Game/TheNewCarlaGameModeBase.h"
|
||||
|
||||
#include "Carla/Game/Tagger.h"
|
||||
#include "Carla/Game/TaggerDelegate.h"
|
||||
|
||||
ATheNewCarlaGameModeBase::ATheNewCarlaGameModeBase(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
{
|
||||
|
@ -20,6 +17,7 @@ ATheNewCarlaGameModeBase::ATheNewCarlaGameModeBase(const FObjectInitializer& Obj
|
|||
Episode = CreateDefaultSubobject<UCarlaEpisode>(TEXT("Episode"));
|
||||
|
||||
TaggerDelegate = CreateDefaultSubobject<UTaggerDelegate>(TEXT("TaggerDelegate"));
|
||||
CarlaSettingsDelegate = CreateDefaultSubobject<UCarlaSettingsDelegate>(TEXT("CarlaSettingsDelegate"));
|
||||
}
|
||||
|
||||
void ATheNewCarlaGameModeBase::InitGame(
|
||||
|
@ -40,7 +38,8 @@ void ATheNewCarlaGameModeBase::InitGame(
|
|||
GameInstance = Cast<UCarlaGameInstance>(GetGameInstance());
|
||||
checkf(
|
||||
GameInstance != nullptr,
|
||||
TEXT("GameInstance is not a UCarlaGameInstance, did you forget to set it in the project settings?"));
|
||||
TEXT("GameInstance is not a UCarlaGameInstance, did you forget to set "
|
||||
"it in the project settings?"));
|
||||
|
||||
if (TaggerDelegate != nullptr) {
|
||||
TaggerDelegate->RegisterSpawnHandler(World);
|
||||
|
@ -48,8 +47,14 @@ void ATheNewCarlaGameModeBase::InitGame(
|
|||
UE_LOG(LogCarla, Error, TEXT("Missing TaggerDelegate!"));
|
||||
}
|
||||
|
||||
if (WeatherClass != nullptr)
|
||||
{
|
||||
if(CarlaSettingsDelegate != nullptr) {
|
||||
CarlaSettingsDelegate->ApplyQualityLevelPostRestart();
|
||||
CarlaSettingsDelegate->RegisterSpawnHandler(World);
|
||||
} else {
|
||||
UE_LOG(LogCarla, Error, TEXT("Missing CarlaSettingsDelegate!"));
|
||||
}
|
||||
|
||||
if (WeatherClass != nullptr) {
|
||||
Episode->Weather = World->SpawnActor<AWeather>(WeatherClass);
|
||||
// Apply default weather.
|
||||
Episode->Weather->ApplyWeather(FWeatherParameters());
|
||||
|
@ -60,6 +65,16 @@ void ATheNewCarlaGameModeBase::InitGame(
|
|||
SpawnActorFactories();
|
||||
}
|
||||
|
||||
void ATheNewCarlaGameModeBase::RestartPlayer(AController *NewPlayer)
|
||||
{
|
||||
if (CarlaSettingsDelegate != nullptr)
|
||||
{
|
||||
CarlaSettingsDelegate->ApplyQualityLevelPreRestart();
|
||||
}
|
||||
|
||||
Super::RestartPlayer(NewPlayer);
|
||||
}
|
||||
|
||||
void ATheNewCarlaGameModeBase::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
@ -86,6 +101,11 @@ void ATheNewCarlaGameModeBase::EndPlay(const EEndPlayReason::Type EndPlayReason)
|
|||
GameInstance->NotifyEndEpisode();
|
||||
|
||||
Super::EndPlay(EndPlayReason);
|
||||
|
||||
if ((CarlaSettingsDelegate != nullptr) && (EndPlayReason != EEndPlayReason::EndPlayInEditor))
|
||||
{
|
||||
CarlaSettingsDelegate->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
void ATheNewCarlaGameModeBase::SpawnActorFactories()
|
||||
|
|
|
@ -9,6 +9,8 @@
|
|||
#include "Carla/Actor/CarlaActorFactory.h"
|
||||
#include "Carla/Game/CarlaEpisode.h"
|
||||
#include "Carla/Game/CarlaGameInstance.h"
|
||||
#include "Carla/Game/TaggerDelegate.h"
|
||||
#include "Carla/Settings/CarlaSettingsDelegate.h"
|
||||
#include "Carla/Weather/Weather.h"
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
@ -16,8 +18,6 @@
|
|||
|
||||
#include "TheNewCarlaGameModeBase.generated.h"
|
||||
|
||||
class UTaggerDelegate;
|
||||
|
||||
/// Base class for the CARLA Game Mode.
|
||||
UCLASS(HideCategories=(ActorTick))
|
||||
class CARLA_API ATheNewCarlaGameModeBase : public AGameModeBase
|
||||
|
@ -32,6 +32,8 @@ protected:
|
|||
|
||||
void InitGame(const FString &MapName, const FString &Options, FString &ErrorMessage) override;
|
||||
|
||||
void RestartPlayer(AController *NewPlayer) override;
|
||||
|
||||
void BeginPlay() override;
|
||||
|
||||
void EndPlay(const EEndPlayReason::Type EndPlayReason) override;
|
||||
|
@ -48,6 +50,9 @@ private:
|
|||
UPROPERTY()
|
||||
UTaggerDelegate *TaggerDelegate = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
UCarlaSettingsDelegate *CarlaSettingsDelegate = nullptr;
|
||||
|
||||
UPROPERTY()
|
||||
UCarlaEpisode *Episode = nullptr;
|
||||
|
||||
|
|
Loading…
Reference in New Issue