Add more function to call from blueprints

This commit is contained in:
nsubiron 2017-06-23 14:45:06 +01:00
parent d6d694e5b1
commit b0d75a7574
5 changed files with 28 additions and 10 deletions

View File

@ -53,6 +53,13 @@ public:
return Weather;
}
UFUNCTION(BlueprintCallable)
void ActivateWeatherDescription(const FWeatherDescription &WeatherDescription)
{
SetWeatherDescription(WeatherDescription);
RefreshWeather();
}
UFUNCTION(BlueprintImplementableEvent)
void RefreshWeather();

View File

@ -33,14 +33,10 @@ APlayerStart *MockGameController::ChoosePlayerStart(
const TArray<APlayerStart *> &AvailableStartSpots)
{
check(AvailableStartSpots.Num() > 0);
uint32 Index;
if (Settings.bRandomPlayerStart) {
Index = FMath::RandRange(0, AvailableStartSpots.Num() - 1);
} else {
static uint32 StaticIndex = 0u;
Index = StaticIndex % AvailableStartSpots.Num();
++StaticIndex;
}
const uint32 Index =
(Settings.bRandomPlayerStart ?
FMath::RandRange(0, AvailableStartSpots.Num() - 1) :
Settings.PlayerStartIndex % AvailableStartSpots.Num());
UE_LOG(LogCarla, Log, TEXT("Spawning player at player start %d/%d"), Index, AvailableStartSpots.Num());
return AvailableStartSpots[Index];
}

View File

@ -14,11 +14,15 @@ struct FMockGameControllerSettings
* Has precedence over options in "Override CARLA Settings".
*/
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
bool bChangeWeatherOnBeginPlay = true;
bool bChangeWeatherOnBeginPlay = false;
/** If true, a random player start position will be chosen every time we start the level. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")
bool bRandomPlayerStart = true;
bool bRandomPlayerStart = false;
/** Index of the player start position. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller", meta = (EditCondition = "!bRandomPlayerStart", ClampMin = 0))
int32 PlayerStartIndex = 0;
/** If true, semantic segmentation will be always enabled even if no camera needs it. */
UPROPERTY(EditAnywhere, Category = "Mock CARLA Controller")

View File

@ -3,6 +3,7 @@
#include "Carla.h"
#include "CommandLine.h"
#include "UnrealMathUtility.h"
#include "DynamicWeather.h"
#include "Settings/CarlaSettings.h"
@ -238,6 +239,13 @@ void UCarlaSettings::GetActiveWeatherDescription(
}
}
const FWeatherDescription &UCarlaSettings::GetWeatherDescriptionByIndex(int32 Index)
{
check(WeatherDescriptions.Num() > 0);
FMath::Clamp(Index, 0, WeatherDescriptions.Num());
return WeatherDescriptions[Index];
}
void UCarlaSettings::ResetCameraDescriptions()
{
CameraDescriptions.Empty();

View File

@ -45,6 +45,9 @@ public:
bool &bWeatherWasChanged,
FWeatherDescription &WeatherDescription) const;
UFUNCTION(BlueprintCallable)
const FWeatherDescription &GetWeatherDescriptionByIndex(int32 Index);
private:
void LoadSettingsFromFile(const FString &FilePath, bool bLogOnFailure);