Rename entire project to LuckyWorldV2, including uproject file, folders and so on

This commit is contained in:
martinluckyrobots
2025-04-12 11:24:29 +08:00
parent cc578afffb
commit 8556492849
57 changed files with 40 additions and 39 deletions

View File

@ -0,0 +1,34 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class LuckyWorldV2 : ModuleRules
{
public LuckyWorldV2(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput",
"ChaosVehicles",
"PhysicsCore",
"AsyncLoadingScreen",
"BlueprintJson",
"FileHelper",
"LuckyMujoco",
"LuckyTextWrite",
"SocketIOClient",
"VaRest",
"SIOJson"
});
PrivateDependencyModuleNames.AddRange(new string[] { });
// Uncomment if you are using Slate UI
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
// Uncomment if you are using online features
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
}
}

View File

@ -0,0 +1,7 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "LuckyWorldV2.h"
#include "Modules/ModuleManager.h"
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, LuckyWorldV2, "LuckyWorldV2" );

View File

@ -0,0 +1,5 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"

View File

@ -0,0 +1,5 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Controllers/LuckyRobotsPlayerController.h"

View File

@ -0,0 +1,583 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Core/LuckyRobotsGameInstance.h"
#include "GameModes/LuckyRobotsGameState.h"
#include "Kismet/GameplayStatics.h"
#include "UI/GameUserWidget.h"
#include "Kismet/KismetSystemLibrary.h"
#include "GameFramework/GameUserSettings.h"
#include "Kismet/KismetMathLibrary.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "VaRestSubsystem.h"
#include "Subsystems/SubsystemBlueprintLibrary.h"
#include "Gameplay/TargetSelector.h"
void ULuckyRobotsGameInstance::DoSendMessage(const FString& SendValue)
{
if (ALuckyRobotsGameState* GameState = Cast<ALuckyRobotsGameState>(UGameplayStatics::GetGameState(this)))
{
GameState->DoSendMessage(SendValue);
}
DoLogItemAdd(TEXT("Receive"), SendValue, ELogItemType::Debug);
}
void ULuckyRobotsGameInstance::DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType)
{
if (GameUserWidget)
{
GameUserWidget->DoLogItemAdd(Topic, MsgText, LogItemType);
}
}
void ULuckyRobotsGameInstance::SwitchGamePaused()
{
bool bPaused = UGameplayStatics::IsGamePaused(this);
UGameplayStatics::SetGamePaused(this, !bPaused);
if (!bPaused)
{
UKismetSystemLibrary::ExecuteConsoleCommand(this, TEXT("r.SceneRendering 0"));
}
else
{
UKismetSystemLibrary::ExecuteConsoleCommand(this, TEXT("r.SceneRendering 1"));
}
}
void ULuckyRobotsGameInstance::ClearTaskList()
{
CurrentCaptureSettingsData.TaskList.Empty();
}
void ULuckyRobotsGameInstance::AddTask(const FGoalsTaskData& TaskData)
{
CurrentCaptureSettingsData.TaskList.Add(TaskData);
}
void ULuckyRobotsGameInstance::RemoveTask(const FGoalsTaskData& TaskData)
{
CurrentCaptureSettingsData.TaskList.Remove(TaskData);
}
void ULuckyRobotsGameInstance::RemoveTaskByGoalType(EGoalType GoalType)
{
for (FGoalsTaskData Task : CurrentCaptureSettingsData.TaskList)
{
if (Task.GoalType == GoalType)
{
RemoveTask(Task);
break;
}
}
}
int32 ULuckyRobotsGameInstance::GetTaskNum() const
{
return CurrentCaptureSettingsData.TaskList.Num();
}
void ULuckyRobotsGameInstance::SetTask(int32 Index, const FGoalsTaskData& TaskData)
{
if (CurrentCaptureSettingsData.TaskList.IsValidIndex(Index))
{
CurrentCaptureSettingsData.TaskList[Index] = TaskData;
}
else
{
while (CurrentCaptureSettingsData.TaskList.Num() < Index)
{
FGoalsTaskData TempTaskData;
AddTask(TempTaskData);
}
AddTask(TaskData);
}
}
bool ULuckyRobotsGameInstance::GetTask(int32 Index, FGoalsTaskData& OutTaskData) const
{
if (CurrentCaptureSettingsData.TaskList.IsValidIndex(Index))
{
OutTaskData = CurrentCaptureSettingsData.TaskList[Index];
return true;
}
return false;
}
void ULuckyRobotsGameInstance::ReSetTaskList()
{
TArray<FGoalsTaskData> TempTaskList;
for (FGoalsTaskData& Task : CurrentCaptureSettingsData.TaskList)
{
Task.bIsStart = false;
Task.bIsComplete = false;
Task.bActive = false;
TempTaskList.Add(Task);
}
CurrentCaptureSettingsData.TaskList = TempTaskList;
}
TArray<FGoalsTaskData> ULuckyRobotsGameInstance::GetTaskList() const
{
return CurrentCaptureSettingsData.TaskList;
}
void ULuckyRobotsGameInstance::DoSetTempTaskValueChange(bool bIsClear)
{
if (bIsClear)
{
ClearTaskList();
}
else
{
AddTask(TempTask);
}
if (GameUserWidget)
{
GameUserWidget->DoRefreshListView();
}
}
void ULuckyRobotsGameInstance::DoResolutionChange(bool bIsFullscreen)
{
UGameUserSettings* GameUserSettings = UGameUserSettings::GetGameUserSettings();
if (!GameUserSettings)
{
return;
}
FIntPoint LastResolution = FIntPoint(1280, 720);
if (bIsFullscreen)
{
TArray<FIntPoint> SupportedResolutions;
if (UKismetSystemLibrary::GetSupportedFullscreenResolutions(SupportedResolutions))
{
if (SupportedResolutions.Num() > 0)
{
LastResolution = SupportedResolutions.Last();
}
}
}
else
{
FString PlatformName = UGameplayStatics::GetPlatformName();
if(PlatformName == "Linux")
{
LastResolution = FIntPoint(720, 405);
}
else if (PlatformName == "Mac")
{
LastResolution = FIntPoint(720, 405);
}
else if(PlatformName == "Windows")
{
LastResolution = FIntPoint(1280, 720);
}
}
GameUserSettings->SetScreenResolution(LastResolution);
GameUserSettings->SetFullscreenMode(bIsFullscreen ? EWindowMode::Fullscreen : EWindowMode::Windowed);
GameUserSettings->ApplyResolutionSettings(false);
}
FString ULuckyRobotsGameInstance::DoRandomString(FString StartString)
{
FString TempString = "";
for (int32 Index = 0; Index < 7; Index++)
{
int32 RandomIndex = UKismetMathLibrary::RandomInteger(AlphabetForRandomList.Num());
if (AlphabetForRandomList.IsValidIndex(RandomIndex))
{
TempString.Append(AlphabetForRandomList[RandomIndex]);
}
}
return StartString + "#" + TempString;
}
void ULuckyRobotsGameInstance::UpdateQualitySettings()
{
if (UGameUserSettings* GameUserSettings = GEngine->GetGameUserSettings())
{
GameUserSettings->SetOverallScalabilityLevel(static_cast<int32>(CurrentSelectQuality));
GameUserSettings->SaveSettings();
GameUserSettings->ApplySettings(true);
}
}
void ULuckyRobotsGameInstance::DoQualitySettings(int32 Quality, bool Auto)
{
if (Auto)
{
bIsFirstOpenGame = false;
}
else
{
UpdateQualitySettings();
}
}
FString ULuckyRobotsGameInstance::GetWriteFolderPath()
{
FString Directory = FPaths::ConvertRelativePathToFull(FPaths::ProjectDir());
FString WriteFolderPath = FPaths::Combine(Directory, GetCurrentFolderName()) + "/";
return WriteFolderPath;
}
TSoftObjectPtr<UStaticMesh> ULuckyRobotsGameInstance::GetRandomMesh()
{
int32 MeshCount = GetCurrentRandomMeshes().Num();
if (MeshCount > 0)
{
int32 RandomIndex = UKismetMathLibrary::RandomIntegerInRange(0, MeshCount - 1);
if (GetCurrentRandomMeshes().IsValidIndex(RandomIndex))
{
return GetCurrentRandomMeshes()[RandomIndex];
}
}
return nullptr;
}
TArray<FSelectableItemData> ULuckyRobotsGameInstance::GetSelectableItemList(EItemCategory ItemCategory)
{
TArray<FSelectableItemData> SelectableItemList;
UDataTable* SelectedDataTable = nullptr;
switch (ItemCategory)
{
case EItemCategory::Furniture:
SelectedDataTable = FurnitureDataTable;
break;
case EItemCategory::Decoration:
SelectedDataTable = DecorationDataTable;
break;
case EItemCategory::Kitchenware:
SelectedDataTable = KitchenwareDataTable;
break;
case EItemCategory::Electronics:
SelectedDataTable = ElectronicsDataTable;
break;
case EItemCategory::Bathroom:
SelectedDataTable = BathroomDataTable;
break;
default:
break;
}
if (SelectedDataTable)
{
FString ContextString;
TArray<FName> RowNames = SelectedDataTable->GetRowNames();
for (const FName& RowName : RowNames)
{
FSelectableItemData* ItemData = SelectedDataTable->FindRow<FSelectableItemData>(RowName, ContextString);
if (ItemData)
{
if (ItemData->Category == ItemCategory && UKismetSystemLibrary::IsValidSoftObjectReference(ItemData->Mesh))
{
SelectableItemList.Add(*ItemData);
}
}
}
}
return SelectableItemList;
}
void ULuckyRobotsGameInstance::GetMessageParse(FString Json)
{
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
if (VaRestSubsystem)
{
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
if (VaRestJsonObject)
{
if (VaRestJsonObject->DecodeJson(Json, true))
{
TArray<UVaRestJsonValue*> VaRestJsonValueList = VaRestJsonObject->GetArrayField("LuckyCode");
if (VaRestJsonValueList.Num() > 0)
{
LuckyCodeList.Empty();
for (auto VaRestJsonValue : VaRestJsonValueList)
{
if (VaRestJsonValue)
{
UVaRestJsonObject* TempObject = VaRestJsonValue->AsObject();
if (TempObject)
{
FLuckyCode TempLuckyCode;
TempLuckyCode.ID = FCString::Atoi(*(TempObject->GetStringField("ID")));
TempLuckyCode.Code = TempObject->GetStringField("code");
TempLuckyCode.Time = FCString::Atof(*(TempObject->GetStringField("time")));
TempLuckyCode.bCallback = (TempObject->GetStringField("callback") == "on");
LuckyCodeList.Add(TempLuckyCode);
}
}
}
}
else
{
UVaRestJsonValue* VaRestJsonValue = VaRestJsonObject->GetField("LuckyCapture");
if (VaRestJsonValue)
{
UVaRestJsonObject* TempObject = VaRestJsonValue->AsObject();
if (TempObject)
{
bIsCapture = (TempObject->GetStringField("capture") == "on");
bIsCaptureHand = (TempObject->GetStringField("is_capture_hand") == "on");
bIsCaptureHead = (TempObject->GetStringField("is_capture_head") == "on");
bScenarioCapture = (TempObject->GetStringField("scenario_capture") == "on");
TargetPosition = FTransform();
SetCurrentFileName(TempObject->GetStringField("file_name"));
SetCurrentFolderName(TempObject->GetStringField("folder_name"));
SetCurrentCaptureNumber(FCString::Atoi(*TempObject->GetStringField("capture_name")));
SetCurrentIsInfiniteCapture(TempObject->GetStringField("infinite_capture") == "on");
SetCurrentWritesPerSec(FCString::Atoi(*TempObject->GetStringField("per_second")));
SetCurrentIsRandomPeople(TempObject->GetStringField("random_people") == "on");
}
}
}
}
}
}
}
FParsedData ULuckyRobotsGameInstance::DoJsonParse(const FString& JsonString)
{
FParsedData ParsedData;
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
if (!VaRestSubsystem)
{
return ParsedData;
}
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
if (!VaRestJsonObject)
{
return ParsedData;
}
if (VaRestJsonObject->DecodeJson(JsonString, true))
{
UVaRestJsonObject* TempJsonObject = VaRestJsonObject->GetObjectField("startup_instructions");
if (TempJsonObject)
{
ParsedData.LevelName = TempJsonObject->GetStringField("level");
ParsedData.CharacterName = TempJsonObject->GetStringField("character");
ParsedData.Quality = TempJsonObject->GetStringField("quality");
}
}
else
{
UE_LOG(LogTemp, Error, TEXT("Parse Problem"));
}
return ParsedData;
}
void ULuckyRobotsGameInstance::UpdateTargetSelector()
{
TArray<AActor*> AllTargetSelector;
UGameplayStatics::GetAllActorsOfClass(this, ATargetSelector::StaticClass(), AllTargetSelector);
for (auto TargetSelector : AllTargetSelector)
{
if (TargetSelector)
{
TargetSelector->Destroy();
}
}
TArray<FGoalsTaskData> GoalsTaskList = GetTaskList();
for (int i = 0; i < GoalsTaskList.Num() ; ++i)
{
if (GoalsTaskList[i].GoalType == EGoalType::NavigateSimpleEnvironments)
{
if (i == 0)
{
TargetPosition = GoalsTaskList[i].TargetLocation;
}
ATargetSelector* TargetSelector = GetWorld()->SpawnActorDeferred<ATargetSelector>(TargetSelectorClass, GoalsTaskList[i].TargetLocation, nullptr, nullptr,
ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
if (TargetSelector)
{
TargetSelector->FinishSpawning(GoalsTaskList[i].TargetLocation);
TargetSelector->bIsTracing = false;
}
}
}
}
void ULuckyRobotsGameInstance::SetCurrentFolderName(const FString& FolderName)
{
CurrentCaptureSettingsData.FolderName = FText::FromString(FolderName);
}
void ULuckyRobotsGameInstance::SetCurrentFileName(const FString& FileName)
{
CurrentCaptureSettingsData.FileName = FText::FromString(FileName);
}
void ULuckyRobotsGameInstance::SetCurrentWritesPerSec(int32 WritesPerSec)
{
CurrentCaptureSettingsData.WritesPerSec = FText::FromString(FString::FromInt(WritesPerSec));
}
void ULuckyRobotsGameInstance::SetCurrentIsScenario(bool IsScenario)
{
CurrentCaptureSettingsData.IsScenario = IsScenario;
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomLight(bool bLight)
{
CurrentCaptureSettingsData.bLight = bLight;
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomMaterials(bool bMaterials)
{
CurrentCaptureSettingsData.bMaterials = bMaterials;
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomRobotPosition(bool bRobotPosition)
{
CurrentCaptureSettingsData.bRobotPosition = bRobotPosition;
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomPets(bool bPets)
{
CurrentCaptureSettingsData.bPets = bPets;
}
void ULuckyRobotsGameInstance::SetCurrentPetsNumber(int32 PetsNumber)
{
CurrentCaptureSettingsData.NumberOfPets = FText::FromString(FString::FromInt(PetsNumber));
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomPeople(bool bPeople)
{
CurrentCaptureSettingsData.bPeople = bPeople;
}
void ULuckyRobotsGameInstance::SetCurrentPeopleNumber(int32 PeopleNumber)
{
CurrentCaptureSettingsData.NumberOfPeople = FText::FromString(FString::FromInt(PeopleNumber));
}
void ULuckyRobotsGameInstance::SetCurrentIsRandomObjects(bool bObjects)
{
CurrentCaptureSettingsData.bObjects = bObjects;
}
void ULuckyRobotsGameInstance::SetCurrentObjectsNumber(int32 ObjectsNumber)
{
CurrentCaptureSettingsData.NumberOfObjects = FText::FromString(FString::FromInt(ObjectsNumber));
}
void ULuckyRobotsGameInstance::SetCurrentRandomMeshes(const TArray<TSoftObjectPtr<UStaticMesh>>& RandomMeshes)
{
CurrentCaptureSettingsData.RandomMeshes = RandomMeshes;
}
void ULuckyRobotsGameInstance::SetCurrentIsInfiniteCapture(bool bInfiniteCapture)
{
CurrentCaptureSettingsData.bInfiniteCapture = bInfiniteCapture;
}
void ULuckyRobotsGameInstance::SetCurrentCaptureNumber(int32 CaptureNumber)
{
CurrentCaptureSettingsData.NumberOfCaptures = FText::FromString(FString::FromInt(CaptureNumber));
}
FString ULuckyRobotsGameInstance::GetCurrentFolderName() const
{
return CurrentCaptureSettingsData.FolderName.ToString();
}
FString ULuckyRobotsGameInstance::GetCurrentFileName() const
{
return CurrentCaptureSettingsData.FileName.ToString();
}
int32 ULuckyRobotsGameInstance::GetCurrentWritesPerSec() const
{
return FCString::Atoi(*CurrentCaptureSettingsData.WritesPerSec.ToString());
}
bool ULuckyRobotsGameInstance::GetCurrentIsScenario() const
{
return CurrentCaptureSettingsData.IsScenario;
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomLight() const
{
return CurrentCaptureSettingsData.bLight;
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomMaterials() const
{
return CurrentCaptureSettingsData.bMaterials;
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomRobotPosition() const
{
return CurrentCaptureSettingsData.bRobotPosition;
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomPets() const
{
return CurrentCaptureSettingsData.bPets;
}
int32 ULuckyRobotsGameInstance::GetCurrentPetsNumber() const
{
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfPets.ToString());
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomPeople() const
{
return CurrentCaptureSettingsData.bPeople;
}
int32 ULuckyRobotsGameInstance::GetCurrentPeopleNumber() const
{
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfPeople.ToString());
}
bool ULuckyRobotsGameInstance::GetCurrentIsRandomObjects() const
{
return CurrentCaptureSettingsData.bObjects;
}
int32 ULuckyRobotsGameInstance::GetCurrentObjectsNumber() const
{
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfObjects.ToString());
}
TArray<TSoftObjectPtr<UStaticMesh>> ULuckyRobotsGameInstance::GetCurrentRandomMeshes() const
{
return CurrentCaptureSettingsData.RandomMeshes;
}
bool ULuckyRobotsGameInstance::GetCurrentIsInfiniteCapture() const
{
return CurrentCaptureSettingsData.bInfiniteCapture;
}
int32 ULuckyRobotsGameInstance::GetCurrentCaptureNumber() const
{
return FCString::Atoi(*CurrentCaptureSettingsData.NumberOfCaptures.ToString());
}
void ULuckyRobotsGameInstance::SetWidgetTotalHit(int32 Value)
{
WidgetTotalHit = Value;
}
int32 ULuckyRobotsGameInstance::GetWidgetTotalHit() const
{
return WidgetTotalHit;
}

View File

@ -0,0 +1,120 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "GameFramework/GameUserSettings.h"
#include "Kismet/GameplayStatics.h"
#include "Settings/SG_CaptureSetting.h"
ULuckyRobotsGameInstance* ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(const UObject* WorldContextObject)
{
if (WorldContextObject && WorldContextObject->GetWorld())
{
return Cast<ULuckyRobotsGameInstance>(WorldContextObject->GetWorld()->GetGameInstance());
}
return nullptr;
}
TArray<FRobotData> ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(const UObject* WorldContextObject)
{
TArray<FRobotData> RobotDataList;
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
{
if (GameInstance->RobotDataDataTable)
{
FString ContextString;
TArray<FName> RowNames = GameInstance->RobotDataDataTable->GetRowNames();
for (const FName& RowName : RowNames)
{
FRobotData* pRow = GameInstance->RobotDataDataTable->FindRow<FRobotData>(RowName, ContextString);
if (pRow && pRow->bActive)
{
RobotDataList.Add(*pRow);
}
}
}
}
return RobotDataList;
}
TArray<FLevelData> ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(const UObject* WorldContextObject)
{
TArray<FLevelData> LevelDataList;
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
{
if (GameInstance->LevelDataTable)
{
FString ContextString;
TArray<FName> RowNames = GameInstance->LevelDataTable->GetRowNames();
for (const FName& RowName : RowNames)
{
FLevelData* pRow = GameInstance->LevelDataTable->FindRow<FLevelData>(RowName, ContextString);
if (pRow && pRow->bActive)
{
LevelDataList.Add(*pRow);
}
}
}
}
return LevelDataList;
}
void ULuckyRobotsFunctionLibrary::UpdateQualitySettings(const UObject* WorldContextObject)
{
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
{
GameInstance->UpdateQualitySettings();
}
}
FCaptureSettingsData ULuckyRobotsFunctionLibrary::LoadCaptureSettings(const UObject* WorldContextObject)
{
FCaptureSettingsData DefaultCaptureSetting;
DefaultCaptureSetting.FolderName = FText::FromString("robotdata");
DefaultCaptureSetting.FileName = FText::FromString("FILE");
DefaultCaptureSetting.WritesPerSec = FText::FromString("1");
DefaultCaptureSetting.NumberOfPeople = FText::FromString("1");
DefaultCaptureSetting.NumberOfObjects = FText::FromString("1");
DefaultCaptureSetting.NumberOfCaptures = FText::FromString("1");
USG_CaptureSetting* SaveGame = Cast<USG_CaptureSetting>(UGameplayStatics::LoadGameFromSlot("SGCaptureSettings", 0));
if (SaveGame)
{
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
{
GameInstance->CurrentCaptureSettingsData = SaveGame->CaptureSetting;
}
return SaveGame->CaptureSetting;
}
else
{
SaveGame = Cast<USG_CaptureSetting>(UGameplayStatics::CreateSaveGameObject(USG_CaptureSetting::StaticClass()));
if (SaveGame)
{
SaveGame->CaptureSetting = DefaultCaptureSetting;
UGameplayStatics::SaveGameToSlot(SaveGame, "SGCaptureSettings", 0);
}
}
return DefaultCaptureSetting;
}
void ULuckyRobotsFunctionLibrary::SaveCaptureSettings(const UObject* WorldContextObject, FCaptureSettingsData CaptureSetting)
{
if (ULuckyRobotsGameInstance* GameInstance = GetLuckyRobotsGameInstance(WorldContextObject))
{
GameInstance->CurrentCaptureSettingsData = CaptureSetting;
}
USG_CaptureSetting* SaveGame = Cast<USG_CaptureSetting>(UGameplayStatics::LoadGameFromSlot("SGCaptureSettings", 0));
if (!SaveGame)
{
SaveGame = Cast<USG_CaptureSetting>(UGameplayStatics::CreateSaveGameObject(USG_CaptureSetting::StaticClass()));
}
if (SaveGame)
{
SaveGame->CaptureSetting = CaptureSetting;
UGameplayStatics::SaveGameToSlot(SaveGame, "SGCaptureSettings", 0);
}
}

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GameModes/LuckyRobotsGameMode.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
void ALuckyRobotsGameMode::BeginPlay()
{
Super::BeginPlay();
ULuckyRobotsFunctionLibrary::UpdateQualitySettings(this);
}
UClass* ALuckyRobotsGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
{
UClass* RobotClass = Super::GetDefaultPawnClassForController_Implementation(InController);
ERobotsName CurrentRobot = ERobotsName::None;
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
CurrentRobot = GameInstance->CurrentSelectRobot;
}
if (CurrentRobot != ERobotsName::None)
{
TArray<FRobotData> ActiveRobotDataList = ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(this);
for (const FRobotData& RobotData : ActiveRobotDataList)
{
if (RobotData.Name == CurrentRobot)
{
RobotClass = RobotData.RobotClass;
break;
}
}
}
return RobotClass;
}

View File

@ -0,0 +1,48 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "GameModes/LuckyRobotsGameState.h"
#include "SocketIOClientComponent.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "SIOJLibrary.h"
ALuckyRobotsGameState::ALuckyRobotsGameState()
{
SocketIOClientComponent = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("SocketIOClientComponent"));
}
void ALuckyRobotsGameState::BeginPlay()
{
Super::BeginPlay();
if (SocketIOClientComponent)
{
SocketIOClientComponent->Connect(L"http://localhost:3000/");
}
}
void ALuckyRobotsGameState::DoSendMessage(FString SendValue)
{
if (SocketIOClientComponent && SocketIOClientComponent->bIsConnected)
{
USIOJsonValue* SIOJsonValue = USIOJsonValue::ConstructJsonValueString(this, SendValue);
SocketIOClientComponent->Emit(TEXT("message"), SIOJsonValue);
}
}
void ALuckyRobotsGameState::DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection)
{
if (SocketIOClientComponent && SocketIOClientComponent->bIsConnected)
{
SocketIOClientComponent->BindEventToGenericEvent(TEXT("response"));
}
}
void ALuckyRobotsGameState::DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData)
{
if (ULuckyRobotsGameInstance* GameInstance = ULuckyRobotsFunctionLibrary::GetLuckyRobotsGameInstance(this))
{
GameInstance->OnMessageDispatched.Broadcast(EventName);
GameInstance->GetMessageParse(USIOJLibrary::Conv_SIOJsonValueToString(EventData));
}
}

View File

@ -0,0 +1,27 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Gameplay/TargetSelector.h"
// Sets default values
ATargetSelector::ATargetSelector()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
}
// Called when the game starts or when spawned
void ATargetSelector::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void ATargetSelector::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}

View File

@ -0,0 +1,12 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Lobby/LobbyGameMode.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
void ALobbyGameMode::BeginPlay()
{
Super::BeginPlay();
ULuckyRobotsFunctionLibrary::UpdateQualitySettings(this);
}

View File

@ -0,0 +1,25 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Lobby/LobbyPlayerController.h"
void ALobbyPlayerController::BeginPlay()
{
Super::BeginPlay();
Init();
}
void ALobbyPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
InputComponent->BindAction("LobbyInit", IE_Pressed, this, &ALobbyPlayerController::Init).bConsumeInput = false;
InputComponent->BindAction("LobbyInit", IE_Released, this, &ALobbyPlayerController::Init).bConsumeInput = false;
}
void ALobbyPlayerController::Init()
{
bShowMouseCursor = true;
SetIgnoreMoveInput(true);
}

View File

@ -0,0 +1,243 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Menus/MainScreenUserWidget.h"
#include "Engine/DataTable.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "FunctionLibraries/LuckyRobotsFunctionLibrary.h"
#include "Subsystems/SubsystemBlueprintLibrary.h"
#include "VaRestSubsystem.h"
#include "Kismet/GameplayStatics.h"
void UMainScreenUserWidget::NativeConstruct()
{
Super::NativeConstruct();
InitData();
DoSendReadyJson();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->bIsFirstOpenGame = false;
GameInstance->DoResolutionChange(bIsFullScreen);
GameInstance->OnMessageDispatched.AddDynamic(this, &UMainScreenUserWidget::OnMessageDispatchedHandler);
}
}
void UMainScreenUserWidget::InitData()
{
InitRobotData();
InitLevelData();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
CurrentQualityIndex = static_cast<int32>(GameInstance->CurrentSelectQuality);
}
}
void UMainScreenUserWidget::InitRobotData()
{
RobotDataList = ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(this);
CurrentRobotIndex = 0;
UpdateSelectRobot();
}
void UMainScreenUserWidget::InitLevelData()
{
LevelDataList = ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(this);
FRobotData CurrentRobotData = GetCurrentRobotData();
if (CurrentRobotData.Name != ERobotsName::None)
{
TArray<FLevelData> FilteredLevels;
for (const FLevelData& LevelData : LevelDataList)
{
if (LevelData.RobotTypeList.Contains(CurrentRobotData.RobotType))
{
FilteredLevels.Add(LevelData);
}
}
LevelDataList = FilteredLevels;
}
CurrentLevelIndex = 0;
UpdateSelectLevel();
}
FRobotData UMainScreenUserWidget::GetCurrentRobotData() const
{
if (RobotDataList.IsValidIndex(CurrentRobotIndex))
{
return RobotDataList[CurrentRobotIndex];
}
return FRobotData();
}
FLevelData UMainScreenUserWidget::GetCurrentLevelData() const
{
if (LevelDataList.IsValidIndex(CurrentLevelIndex))
{
return LevelDataList[CurrentLevelIndex];
}
return FLevelData();
}
void UMainScreenUserWidget::SelectNextRobot()
{
CurrentRobotIndex = FMath::Clamp(CurrentRobotIndex + 1, 0, RobotDataList.Num() - 1);
UpdateSelectRobot();
}
void UMainScreenUserWidget::SelectPreviousRobot()
{
CurrentRobotIndex = FMath::Clamp(CurrentRobotIndex - 1, 0, RobotDataList.Num() - 1);
UpdateSelectRobot();
}
void UMainScreenUserWidget::SelectNextLevel()
{
CurrentLevelIndex = FMath::Clamp(CurrentLevelIndex + 1, 0, LevelDataList.Num() - 1);
UpdateSelectLevel();
}
void UMainScreenUserWidget::SelectPreviousLevel()
{
CurrentLevelIndex = FMath::Clamp(CurrentLevelIndex - 1, 0, LevelDataList.Num() - 1);
UpdateSelectLevel();
}
void UMainScreenUserWidget::SelectNextQuality()
{
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
int32 EnumCount = QualityEnum->NumEnums() - 1;
CurrentQualityIndex = FMath::Clamp(CurrentQualityIndex - 1, 0, EnumCount - 1);
UpdateSelectQuality();
}
void UMainScreenUserWidget::SelectPreviousQuality()
{
UEnum* QualityEnum = StaticEnum<EQualityEnum>();
int32 EnumCount = QualityEnum->NumEnums() - 1;
CurrentQualityIndex = FMath::Clamp(CurrentQualityIndex + 1, 0, EnumCount - 1);
UpdateSelectQuality();
}
void UMainScreenUserWidget::DoResolutionChange()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
bIsFullScreen = !bIsFullScreen;
GameInstance->DoResolutionChange(bIsFullScreen);
}
}
void UMainScreenUserWidget::GameStart()
{
if (UKismetSystemLibrary::IsValidSoftObjectReference(CurrentSelectLevelObject))
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->bIsFirstOpenGame = true;
UGameplayStatics::OpenLevelBySoftObjectPtr(this, CurrentSelectLevelObject);
}
}
}
void UMainScreenUserWidget::UpdateSelectRobot()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->CurrentSelectRobot = GetCurrentRobotData().Name;
}
BPUpdateSelectRobot();
InitLevelData();
}
void UMainScreenUserWidget::UpdateSelectLevel()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->CurrentSelectLevel = GetCurrentLevelData().LevelEnum;
}
BPUpdateSelectLevel();
}
void UMainScreenUserWidget::UpdateSelectQuality()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->CurrentSelectQuality = static_cast<EQualityEnum>(CurrentQualityIndex);
}
BPUpdateSelectQuality();
}
void UMainScreenUserWidget::OnMessageDispatchedHandler(const FString& Message)
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
FParsedData ParsedData = GameInstance->DoJsonParse(Message);
if (ParsedData.CharacterName == "DRONE")
{
GameInstance->CurrentSelectRobot = ERobotsName::LuckyDrone;
}else if(ParsedData.CharacterName == "Stretch Robot V1")
{
GameInstance->CurrentSelectRobot = ERobotsName::StretchRobotV1;
}
GameInstance->bIsFirstOpenGame = true;
ELevelEnum TempLevelEnum = ELevelEnum::None;
if (ParsedData.LevelName == "LOFT")
{
TempLevelEnum = ELevelEnum::Loft;
}else if(ParsedData.LevelName == "ISTANBUL")
{
TempLevelEnum = ELevelEnum::Istanbul;
}
if (TempLevelEnum != ELevelEnum::None)
{
TArray<FLevelData> TempLevelDataList = ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(this);
for (const FLevelData& LevelData : TempLevelDataList)
{
if (LevelData.LevelEnum == TempLevelEnum && LevelData.LevelObject)
{
UGameplayStatics::OpenLevelBySoftObjectPtr(this, LevelData.LevelObject);
break;
}
}
}
}
}
void UMainScreenUserWidget::DoSendReadyJson()
{
auto VaRestSubsystem = CastChecked<UVaRestSubsystem>(USubsystemBlueprintLibrary::GetEngineSubsystem(UVaRestSubsystem::StaticClass()), ECastCheckedType::NullChecked);
if (!VaRestSubsystem)
{
return;
}
UVaRestJsonObject* VaRestJsonObject = VaRestSubsystem->ConstructVaRestJsonObject();
if (!VaRestJsonObject)
{
return;
}
VaRestJsonObject->SetStringField("name", "game_is_loaded");
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
FString SendedString = VaRestJsonObject->EncodeJsonToSingleString();
GameInstance->DoSendMessage(SendedString);
UE_LOG(LogTemp, Log, TEXT("Sended: %s"), *SendedString);
}
}

View File

@ -0,0 +1,4 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "Settings/SG_CaptureSetting.h"

View File

@ -0,0 +1,51 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/GameUserWidget.h"
#include "Core/LuckyRobotsGameInstance.h"
void UGameUserWidget::NativeConstruct()
{
Super::NativeConstruct();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->GameUserWidget = this;
}
}
void UGameUserWidget::DoWaitSecond()
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
if (GameInstance->bIsFirstOpenGame)
{
DownCount = 3;
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
GetWorld()->GetTimerManager().SetTimer(UpdateDownCountTimerHandle, this, &UGameUserWidget::UpdateDownCount, 1.0f, true);
UpdateDownCount();
}
}
}
void UGameUserWidget::UpdateDownCount()
{
if (DownCount > 0)
{
DownCountStr = FString::FromInt(DownCount);
DownCount--;
}
else
{
DownCountStr = "";
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->DoQualitySettings(0, true);
}
GetWorld()->GetTimerManager().ClearTimer(UpdateDownCountTimerHandle);
}
}

View File

@ -0,0 +1,40 @@
// Fill out your copyright notice in the Description page of Project Settings.
#include "UI/Settings/CaptureSettingsUserWidget.h"
#include "Core/LuckyRobotsGameInstance.h"
#include "UI/GameUserWidget.h"
void UCaptureSettingsUserWidget::NativeConstruct()
{
Super::NativeConstruct();
BPRefreshTaskList();
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance)
{
GameInstance->OnRandomMeshesUpdated.AddDynamic(this, &UCaptureSettingsUserWidget::BPOnRandomMeshesUpdated);
}
}
void UCaptureSettingsUserWidget::ToggleMenu()
{
bIsOpen = !bIsOpen;
if (bIsOpen)
{
BPLoadSettings();
}
else
{
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
if (GameInstance && GameInstance->GameUserWidget)
{
GameInstance->GameUserWidget->DoAutoConfirm();
}
}
OnOpenMenuStateChanged.Broadcast(bIsOpen);
ToggleMenuDisplay();
}

View File

@ -0,0 +1,17 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "LuckyRobotsPlayerController.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ALuckyRobotsPlayerController : public APlayerController
{
GENERATED_BODY()
};

View File

@ -0,0 +1,315 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/GameInstance.h"
#include "SharedDef.h"
#include "LuckyRobotsGameInstance.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnMessageDispatched, const FString&, Message);
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnRandomMeshesUpdated);
class USIOJsonValue;
class UGameUserWidget;
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ULuckyRobotsGameInstance : public UGameInstance
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* RobotDataDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* LevelDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* FurnitureDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* DecorationDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* KitchenwareDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* ElectronicsDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
UDataTable* BathroomDataTable;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
TSubclassOf<AActor> TargetSelectorClass;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Config")
TArray<FString> AlphabetForRandomList;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Resulation")
bool bIsFirstOpenGame;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "WebSocket")
bool bIsStartConnect;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ESaveDataType SelectSaveDataType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsDebug;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsWidgetTestMode;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsShowPath;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 WidgetTotalHit;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfiniteTime;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float FastEndTaskTime = 180.0f;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bIsCapture;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bIsCaptureHand;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bIsCaptureHead;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bScenarioCapture;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bIsMouseOpen;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
bool bIsChanged;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
int32 FolderCount;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
FTransform TargetPosition;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Capture")
FCaptureSettingsData CurrentCaptureSettingsData;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Random Mesh")
bool bIsRandomPannel;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName CurrentSelectRobot = ERobotsName::None;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelEnum CurrentSelectLevel = ELevelEnum::None;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EQualityEnum CurrentSelectQuality = EQualityEnum::Epic;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FGoalsTaskData TempTask;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UGameUserWidget* GameUserWidget;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FLuckyCode> LuckyCodeList;
public:
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
FOnMessageDispatched OnMessageDispatched;
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
FOnRandomMeshesUpdated OnRandomMeshesUpdated;
public:
UFUNCTION(BlueprintCallable)
void DoSendMessage(const FString& SendValue);
UFUNCTION(BlueprintCallable)
void DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType);
UFUNCTION(BlueprintCallable)
void SwitchGamePaused();
public:
UFUNCTION(BlueprintCallable)
void ClearTaskList();
UFUNCTION(BlueprintCallable)
void AddTask(const FGoalsTaskData& TaskData);
UFUNCTION(BlueprintCallable)
void RemoveTask(const FGoalsTaskData& TaskData);
UFUNCTION(BlueprintCallable)
void RemoveTaskByGoalType(EGoalType GoalType);
UFUNCTION(BlueprintPure)
int32 GetTaskNum() const;
UFUNCTION(BlueprintCallable)
void SetTask(int32 Index, const FGoalsTaskData& TaskData);
UFUNCTION(BlueprintCallable)
bool GetTask(int32 Index, FGoalsTaskData& OutTaskData) const;
UFUNCTION(BlueprintCallable)
void ReSetTaskList();
UFUNCTION(BlueprintPure)
TArray<FGoalsTaskData> GetTaskList() const;
UFUNCTION(BlueprintCallable)
void DoSetTempTaskValueChange(bool bIsClear);
UFUNCTION(BlueprintCallable, Category = "Resolution")
void DoResolutionChange(bool bIsFullscreen);
UFUNCTION(BlueprintCallable)
FString DoRandomString(FString StartString);
UFUNCTION(BlueprintCallable)
void UpdateQualitySettings();
UFUNCTION(BlueprintCallable)
void DoQualitySettings(int32 Quality, bool Auto);
UFUNCTION(BlueprintPure)
FString GetWriteFolderPath();
UFUNCTION(BlueprintPure)
TSoftObjectPtr<UStaticMesh> GetRandomMesh();
UFUNCTION(BlueprintPure, Category = "Selectable Items")
TArray<FSelectableItemData> GetSelectableItemList(EItemCategory ItemCategory);
UFUNCTION(BlueprintCallable)
void GetMessageParse(FString Json);
UFUNCTION(BlueprintCallable)
FParsedData DoJsonParse(const FString& JsonString);
UFUNCTION(BlueprintCallable)
void UpdateTargetSelector();
public:
UFUNCTION(BlueprintCallable)
void SetCurrentFolderName(const FString& FolderName);
UFUNCTION(BlueprintCallable)
void SetCurrentFileName(const FString& FileName);
UFUNCTION(BlueprintCallable)
void SetCurrentWritesPerSec(int32 WritesPerSec);
UFUNCTION(BlueprintCallable)
void SetCurrentIsScenario(bool IsScenario);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomLight(bool bLight);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomMaterials(bool bMaterials);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomRobotPosition(bool bRobotPosition);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomPets(bool bPets);
UFUNCTION(BlueprintCallable)
void SetCurrentPetsNumber(int32 PetsNumber);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomPeople(bool bPeople);
UFUNCTION(BlueprintCallable)
void SetCurrentPeopleNumber(int32 PeopleNumber);
UFUNCTION(BlueprintCallable)
void SetCurrentIsRandomObjects(bool bObjects);
UFUNCTION(BlueprintCallable)
void SetCurrentObjectsNumber(int32 ObjectsNumber);
UFUNCTION(BlueprintCallable)
void SetCurrentRandomMeshes(const TArray<TSoftObjectPtr<UStaticMesh>>& RandomMeshes);
UFUNCTION(BlueprintCallable)
void SetCurrentIsInfiniteCapture(bool bInfiniteCapture);
UFUNCTION(BlueprintCallable)
void SetCurrentCaptureNumber(int32 CaptureNumber);
public:
UFUNCTION(BlueprintPure)
FString GetCurrentFolderName() const;
UFUNCTION(BlueprintPure)
FString GetCurrentFileName() const;
UFUNCTION(BlueprintPure)
int32 GetCurrentWritesPerSec() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsScenario() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomLight() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomMaterials() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomRobotPosition() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomPets() const;
UFUNCTION(BlueprintPure)
int32 GetCurrentPetsNumber() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomPeople() const;
UFUNCTION(BlueprintPure)
int32 GetCurrentPeopleNumber() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsRandomObjects() const;
UFUNCTION(BlueprintPure)
int32 GetCurrentObjectsNumber() const;
UFUNCTION(BlueprintPure)
TArray<TSoftObjectPtr<UStaticMesh>> GetCurrentRandomMeshes() const;
UFUNCTION(BlueprintPure)
bool GetCurrentIsInfiniteCapture() const;
UFUNCTION(BlueprintPure)
int32 GetCurrentCaptureNumber() const;
public:
UFUNCTION(BlueprintCallable)
void SetWidgetTotalHit(int32 Value);
UFUNCTION(BlueprintPure)
int32 GetWidgetTotalHit() const;
};

View File

@ -0,0 +1,37 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "SharedDef.h"
#include "LuckyRobotsFunctionLibrary.generated.h"
class ULuckyRobotsGameInstance;
class USG_CaptureSetting;
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ULuckyRobotsFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static ULuckyRobotsGameInstance* GetLuckyRobotsGameInstance(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FRobotData> GetActiveRobotDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintPure, meta = (WorldContext = "WorldContextObject"))
static TArray<FLevelData> GetActiveLevelDataList(const UObject* WorldContextObject);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
static void UpdateQualitySettings(const UObject* WorldContextObject);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
static FCaptureSettingsData LoadCaptureSettings(const UObject* WorldContextObject);
UFUNCTION(BlueprintCallable, meta = (WorldContext = "WorldContextObject"))
static void SaveCaptureSettings(const UObject* WorldContextObject, FCaptureSettingsData CaptureSetting);
};

View File

@ -0,0 +1,21 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "LuckyRobotsGameMode.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ALuckyRobotsGameMode : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
virtual UClass* GetDefaultPawnClassForController_Implementation(AController* InController) override;
};

View File

@ -0,0 +1,35 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameStateBase.h"
#include "LuckyRobotsGameState.generated.h"
class USocketIOClientComponent;
class USIOJsonValue;
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ALuckyRobotsGameState : public AGameStateBase
{
GENERATED_BODY()
protected:
ALuckyRobotsGameState();
virtual void BeginPlay() override;
public:
UPROPERTY(Category = Character, VisibleAnywhere, BlueprintReadOnly, meta = (AllowPrivateAccess = "true"))
USocketIOClientComponent* SocketIOClientComponent;
public:
UFUNCTION(BlueprintCallable)
void DoSendMessage(FString SendValue);
UFUNCTION(BlueprintCallable)
void DoSocketOnConnect(FString SocketId, FString SessionId, bool IsReconnection);
UFUNCTION(BlueprintCallable)
void DoSocketOnGenericEvent(FString EventName, USIOJsonValue* EventData);
};

View File

@ -0,0 +1,29 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "TargetSelector.generated.h"
UCLASS()
class LUCKYWORLDV2_API ATargetSelector : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ATargetSelector();
protected:
// Called when the game starts or when spawned
virtual void BeginPlay() override;
public:
// Called every frame
virtual void Tick(float DeltaTime) override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsTracing = true;
};

View File

@ -0,0 +1,19 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "LobbyGameMode.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ALobbyGameMode : public AGameModeBase
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
};

View File

@ -0,0 +1,24 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "LobbyPlayerController.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API ALobbyPlayerController : public APlayerController
{
GENERATED_BODY()
protected:
virtual void BeginPlay() override;
virtual void SetupInputComponent() override;
public:
void Init();
};

View File

@ -0,0 +1,92 @@
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "SharedDef.h"
#include "MainScreenUserWidget.generated.h"
UCLASS()
class LUCKYWORLDV2_API UMainScreenUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FRobotData> RobotDataList;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FLevelData> LevelDataList;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 CurrentRobotIndex;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 CurrentLevelIndex;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 CurrentQualityIndex;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsFullScreen = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UWorld> CurrentSelectLevelObject;
public:
UFUNCTION(BlueprintCallable)
void InitData();
UFUNCTION(BlueprintCallable)
void InitRobotData();
UFUNCTION(BlueprintCallable)
void InitLevelData();
UFUNCTION(BlueprintCallable)
FRobotData GetCurrentRobotData() const;
UFUNCTION(BlueprintCallable)
FLevelData GetCurrentLevelData() const;
UFUNCTION(BlueprintCallable)
void SelectNextRobot();
UFUNCTION(BlueprintCallable)
void SelectPreviousRobot();
UFUNCTION(BlueprintCallable)
void SelectNextLevel();
UFUNCTION(BlueprintCallable)
void SelectPreviousLevel();
UFUNCTION(BlueprintCallable)
void SelectNextQuality();
UFUNCTION(BlueprintCallable)
void SelectPreviousQuality();
UFUNCTION(BlueprintCallable)
void DoResolutionChange();
UFUNCTION(BlueprintCallable)
void GameStart();
void UpdateSelectRobot();
void UpdateSelectLevel();
void UpdateSelectQuality();
public:
void OnMessageDispatchedHandler(const FString& Message);
void DoSendReadyJson();
public:
UFUNCTION(BlueprintImplementableEvent)
void BPUpdateSelectRobot();
UFUNCTION(BlueprintImplementableEvent)
void BPUpdateSelectLevel();
UFUNCTION(BlueprintImplementableEvent)
void BPUpdateSelectQuality();
};

View File

@ -0,0 +1,22 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/SaveGame.h"
#include "SharedDef.h"
#include "SG_CaptureSetting.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API USG_CaptureSetting : public USaveGame
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FCaptureSettingsData CaptureSetting;
};

View File

@ -0,0 +1,688 @@
#pragma once
#include "SharedDef.generated.h"
UENUM(BlueprintType)
enum class ERobotsCategories : uint8
{
Wheeled UMETA(DisplayName = "Wheeled Robots"),
FourLegged UMETA(DisplayName = "Four-Legged Robots"),
TwoLegged UMETA(DisplayName = "Two-Legged Robots"),
Stationary UMETA(DisplayName = "Stationary Robots"),
IndoorFlying UMETA(DisplayName = "Indoor Flying Robots"),
SwimmingUnderwater UMETA(DisplayName = "Swimming/Underwater Robots"),
CrawlingModular UMETA(DisplayName = "Crawling/Modular Robots"),
Arm UMETA(DisplayName = "Arm-Robots"),
OutdoorFlying UMETA(DisplayName = "Outdoor Flying Robots")
};
UENUM(BlueprintType)
enum class ERobotsName : uint8
{
None UMETA(DisplayName = "None"),
Luck_e UMETA(DisplayName = "Luck-e"),
Stretch UMETA(DisplayName = "Stretch"),
LuckyDrone UMETA(DisplayName = "Lucky Drone"),
DJIDrone UMETA(DisplayName = "DJI Drone"),
ArmLucky UMETA(DisplayName = "Arm Lucky"),
UnitreeG1 UMETA(DisplayName = "Unitree G1"),
StretchRobotV1 UMETA(DisplayName = "Stretch Robot V1"),
PandaArmRobot UMETA(DisplayName = "Panda Arm Robot"),
PuralinkRobot UMETA(DisplayName = "Puralink Robot"),
UnitreeGo2 UMETA(DisplayName = "Unitree Go 2"),
RevoluteRobot UMETA(DisplayName = "Revolute Robot"),
BostonSpotRobot UMETA(DisplayName = "Boston Spot Robot")
};
UENUM(BlueprintType)
enum class ELevelType : uint8
{
Home UMETA(DisplayName = "Home"),
Office UMETA(DisplayName = "Office"),
Street UMETA(DisplayName = "Street"),
TestLevel UMETA(DisplayName = "TestLevel")
};
UENUM(BlueprintType)
enum class ELevelEnum : uint8
{
None UMETA(DisplayName = "None"),
TestLevel UMETA(DisplayName = "Test Level"),
Loft UMETA(DisplayName = "Loft"),
Rome UMETA(DisplayName = "Rome"),
Paris UMETA(DisplayName = "Paris"),
Marseille UMETA(DisplayName = "Marseille"),
Istanbul UMETA(DisplayName = "Istanbul"),
Office UMETA(DisplayName = "Office"),
BasicForest UMETA(DisplayName = "Basic Forest"),
NaturalForest UMETA(DisplayName = "Natural Forest"),
KitchenForArmRobot UMETA(DisplayName = "Kitchen for Arm Robot"),
PipeFabric UMETA(DisplayName = "Pipe Fabric")
};
UENUM(BlueprintType)
enum class EQualityEnum : uint8
{
Low UMETA(DisplayName = "Low"),
Middle UMETA(DisplayName = "Middle"),
High UMETA(DisplayName = "High"),
Epic UMETA(DisplayName = "Epic")
};
UENUM(BlueprintType)
enum class EGoalType : uint8
{
GrabAndPull UMETA(DisplayName = "Grab and Pull"),
GrabAndRotate UMETA(DisplayName = "Grab and Rotate"),
GrabAndOpen UMETA(DisplayName = "Grab and Open"),
PickAndPlace UMETA(DisplayName = "Pick and Place"),
Pick UMETA(DisplayName = "Pick"),
GrabAndInsert UMETA(DisplayName = "Grab and Insert"),
Find UMETA(DisplayName = "Find"),
Point UMETA(DisplayName = "Point"),
PointWithLaserPointer UMETA(DisplayName = "Point with Laser Pointer"),
RotateHand UMETA(DisplayName = "Rotate Hand"),
SliceDice UMETA(DisplayName = "Slice/Dice"),
Wipe UMETA(DisplayName = "Wipe"),
FoldUnfold UMETA(DisplayName = "Fold/Unfold"),
ArrangeOrganize UMETA(DisplayName = "Arrange/Organize"),
PressButton UMETA(DisplayName = "Press Button"),
PourDispense UMETA(DisplayName = "Pour/Dispense"),
NavigateSimpleEnvironments UMETA(DisplayName = "Navigate Simple Environments"),
NavigateComplexTerrain UMETA(DisplayName = "Navigate Complex Terrain"),
ClimbStairsOrRamps UMETA(DisplayName = "Climb Stairs or Ramps"),
BalanceStabilize UMETA(DisplayName = "Balance/Stabilize"),
DockingAndCharging UMETA(DisplayName = "Docking and Charging"),
ChangeGripper UMETA(DisplayName = "Change Gripper"),
Place UMETA(DisplayName = "Place")
};
UENUM(BlueprintType)
enum class ESaveDataType : uint8
{
None UMETA(DisplayName = "None"),
File UMETA(DisplayName = "File"),
Webserver UMETA(DisplayName = "Webserver"),
Http UMETA(DisplayName = "Http"),
Debug UMETA(DisplayName = "Debug")
};
UENUM(BlueprintType)
enum class ELogItemType : uint8
{
Debug UMETA(DisplayName = "Debug"),
War UMETA(DisplayName = "War"),
Error UMETA(DisplayName = "Error"),
Consol UMETA(DisplayName = "Consol")
};
UENUM(BlueprintType)
enum class EFurniture : uint8
{
None UMETA(DisplayName = "None"),
Sofas UMETA(DisplayName = "Sofas"),
Chairs UMETA(DisplayName = "Chairs"),
Tables UMETA(DisplayName = "Tables"),
Beds UMETA(DisplayName = "Beds"),
Cabinets UMETA(DisplayName = "Cabinets"),
Shelves UMETA(DisplayName = "Shelves"),
Desks UMETA(DisplayName = "Desks"),
Doors UMETA(DisplayName = "Doors"),
Drawers UMETA(DisplayName = "Drawers")
};
UENUM(BlueprintType)
enum class EDecoration : uint8
{
None UMETA(DisplayName = "None"),
Carpets UMETA(DisplayName = "Carpets"),
Paintings UMETA(DisplayName = "Paintings"),
Vases UMETA(DisplayName = "Vases"),
Lamps UMETA(DisplayName = "Lamps"),
Mirrors UMETA(DisplayName = "Mirrors"),
Curtains UMETA(DisplayName = "Curtains"),
Plants UMETA(DisplayName = "Plants"),
Textiles UMETA(DisplayName = "Textiles"),
Lighting UMETA(DisplayName = "Lighting"),
Outdoor UMETA(DisplayName = "Outdoor"),
OfficeSupplies UMETA(DisplayName = "Office Supplies"),
Books UMETA(DisplayName = "Books"),
ToolsAndEquipment UMETA(DisplayName = "Tools And Equipment"),
Dressing UMETA(DisplayName = "Dressing"),
BasketsAndBoxes UMETA(DisplayName = "Baskets And Boxes")
};
UENUM(BlueprintType)
enum class EKitchenware : uint8
{
None UMETA(DisplayName = "None"),
Plates UMETA(DisplayName = "Plates"),
Glasses UMETA(DisplayName = "Glasses"),
Cutlery UMETA(DisplayName = "Cutlery"),
Pots UMETA(DisplayName = "Pots"),
SmallAppliances UMETA(DisplayName = "Small Appliances"),
Cups UMETA(DisplayName = "Cups"),
Bottles UMETA(DisplayName = "Bottles")
};
UENUM(BlueprintType)
enum class EElectronics : uint8
{
None UMETA(DisplayName = "None"),
Television UMETA(DisplayName = "Television"),
LargeAppliances UMETA(DisplayName = "Large Appliances"),
Oven UMETA(DisplayName = "Oven"),
Computer UMETA(DisplayName = "Computer"),
KitchenGadgets UMETA(DisplayName = "Kitchen Gadgets"),
MusicGadgets UMETA(DisplayName = "Music Gadgets"),
SmallElectronics UMETA(DisplayName = "Small Electronics")
};
UENUM(BlueprintType)
enum class EBathroom : uint8
{
None UMETA(DisplayName = "None"),
Towels UMETA(DisplayName = "Towels"),
SoapDispenser UMETA(DisplayName = "Soap Dispenser"),
ShowerCurtains UMETA(DisplayName = "Shower Curtains"),
BathMats UMETA(DisplayName = "Bath Mats"),
Toiletries UMETA(DisplayName = "Toiletries")
};
UENUM(BlueprintType)
enum class EItemCategory : uint8
{
Furniture UMETA(DisplayName = "Furniture"),
Decoration UMETA(DisplayName = "Decoration"),
Kitchenware UMETA(DisplayName = "Kitchenware"),
Electronics UMETA(DisplayName = "Electronics"),
Bathroom UMETA(DisplayName = "Bathroom")
};
UENUM(BlueprintType)
enum class EHoldItemType : uint8
{
None UMETA(DisplayName = "None"),
HoldObject UMETA(DisplayName = "Hold Object"),
DontTouch UMETA(DisplayName = "Don't Touch")
};
UENUM(BlueprintType)
enum class EScenarioEnum : uint8
{
None UMETA(DisplayName = "None"),
TidyUp UMETA(DisplayName = "Tidy Up"),
Draw UMETA(DisplayName = "Draw"),
StoveOff UMETA(DisplayName = "Stove Off")
};
USTRUCT(BlueprintType)
struct FRobotData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsName Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<AActor> RobotClass;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform Transform;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bActive;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* RobotImage;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ERobotsCategories RobotType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText HelpText;
};
USTRUCT(BlueprintType)
struct FLevelData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ID;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelEnum LevelEnum;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
ELevelType LevelType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UWorld> LevelObject;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
UTexture2D* LevelImage;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bActive;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<ERobotsCategories> RobotTypeList;
bool operator==(const FLevelData& Other) const
{
return ID == Other.ID &&
LevelEnum == Other.LevelEnum &&
LevelType == Other.LevelType &&
LevelObject == Other.LevelObject &&
LevelImage == Other.LevelImage &&
bActive == Other.bActive &&
RobotTypeList == Other.RobotTypeList;
}
FLevelData& operator=(const FLevelData& Other)
{
if (this != &Other)
{
ID = Other.ID;
LevelEnum = Other.LevelEnum;
LevelType = Other.LevelType;
LevelObject = Other.LevelObject;
LevelImage = Other.LevelImage;
bActive = Other.bActive;
RobotTypeList = Other.RobotTypeList;
}
return *this;
}
};
USTRUCT(BlueprintType)
struct FGoalsTaskData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EGoalType GoalType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsStart;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform TargetLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSoftObjectPtr<UObject> TargetActor;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsComplete;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FVector DropOffLocation;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString ObjectName;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bActive;
bool operator==(const FGoalsTaskData& Other) const
{
return GoalType == Other.GoalType &&
bIsStart == Other.bIsStart &&
TargetLocation.Equals(Other.TargetLocation, 0.01f) &&
TargetActor == Other.TargetActor &&
bIsComplete == Other.bIsComplete &&
DropOffLocation.Equals(Other.DropOffLocation, 0.01f) &&
ObjectName == Other.ObjectName &&
bActive == Other.bActive;
}
FGoalsTaskData& operator=(const FGoalsTaskData& Other)
{
if (this != &Other)
{
GoalType = Other.GoalType;
bIsStart = Other.bIsStart;
TargetLocation = Other.TargetLocation;
TargetActor = Other.TargetActor;
bIsComplete = Other.bIsComplete;
DropOffLocation = Other.DropOffLocation;
ObjectName = Other.ObjectName;
bActive = Other.bActive;
}
return *this;
}
};
USTRUCT(BlueprintType)
struct FCaptureSettingsData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FolderName = FText::FromString("robotdata");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText FileName = FText::FromString("FILE");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText WritesPerSec = FText::FromString("1");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool IsScenario;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<FGoalsTaskData> TaskList;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bLight;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bMaterials;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bRobotPosition;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPets;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bPeople;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfPeople = FText::FromString("1");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bObjects;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfObjects = FText::FromString("1");
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSoftObjectPtr<UStaticMesh>> RandomMeshes;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bInfiniteCapture;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FText NumberOfCaptures = FText::FromString("1");
bool operator==(const FCaptureSettingsData& Other) const
{
return FolderName.EqualTo(Other.FolderName) &&
FileName.EqualTo(Other.FileName) &&
WritesPerSec.EqualTo(Other.WritesPerSec) &&
IsScenario == Other.IsScenario &&
TaskList == Other.TaskList &&
bLight == Other.bLight &&
bMaterials == Other.bMaterials &&
bRobotPosition == Other.bRobotPosition &&
bPets == Other.bPets &&
NumberOfPets.EqualTo(Other.NumberOfPets) &&
bPeople == Other.bPeople &&
NumberOfPeople.EqualTo(Other.NumberOfPeople) &&
bObjects == Other.bObjects &&
NumberOfObjects.EqualTo(Other.NumberOfObjects) &&
RandomMeshes == Other.RandomMeshes &&
bInfiniteCapture == Other.bInfiniteCapture &&
NumberOfCaptures.EqualTo(Other.NumberOfCaptures);
}
FCaptureSettingsData& operator=(const FCaptureSettingsData& Other)
{
if (this != &Other)
{
FolderName = Other.FolderName;
FileName = Other.FileName;
WritesPerSec = Other.WritesPerSec;
IsScenario = Other.IsScenario;
TaskList = Other.TaskList;
bLight = Other.bLight;
bMaterials = Other.bMaterials;
bRobotPosition = Other.bRobotPosition;
bPets = Other.bPets;
NumberOfPets = Other.NumberOfPets;
bPeople = Other.bPeople;
NumberOfPeople = Other.NumberOfPeople;
bObjects = Other.bObjects;
NumberOfObjects = Other.NumberOfObjects;
RandomMeshes = Other.RandomMeshes;
bInfiniteCapture = Other.bInfiniteCapture;
NumberOfCaptures = Other.NumberOfCaptures;
}
return *this;
}
};
USTRUCT(BlueprintType)
struct FAllGoalListData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
EGoalType GoalType;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Example;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TSubclassOf<UUserWidget> Widget;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsActive;
};
USTRUCT(BlueprintType)
struct FLuckyCode : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 ID;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Code;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
float Time;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bCallback;
};
USTRUCT(BlueprintType)
struct FSelectableItemData : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
int32 ID;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
EItemCategory Category;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (EditCondition = "Category == EItemCategory::Furniture", EditConditionHides))
EFurniture FurnitureType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (EditCondition = "Category == EItemCategory::Decoration", EditConditionHides))
EDecoration DecorationType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (EditCondition = "Category == EItemCategory::Kitchenware", EditConditionHides))
EKitchenware KitchenwareType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (EditCondition = "Category == EItemCategory::Electronics", EditConditionHides))
EElectronics ElectronicsType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item", meta = (EditCondition = "Category == EItemCategory::Bathroom", EditConditionHides))
EBathroom BathroomType;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
TSoftObjectPtr<UTexture2D> Icon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
TSoftObjectPtr<UStaticMesh> Mesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FString Description;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
bool bIsStatic;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FTransform Transform;
FSelectableItemData()
: ID(0)
, Category(EItemCategory::Furniture)
, FurnitureType(EFurniture::None)
, DecorationType(EDecoration::None)
, KitchenwareType(EKitchenware::None)
, ElectronicsType(EElectronics::None)
, BathroomType(EBathroom::None)
, Name(TEXT(""))
, Icon(nullptr)
, Mesh(nullptr)
, Description(TEXT(""))
, bIsStatic(false)
, Transform(FTransform::Identity)
{
}
};
USTRUCT(BlueprintType)
struct FHoldItemStruct : public FTableRowBase
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
int32 ID;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
TSoftObjectPtr<UTexture2D> Icon;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
TSoftObjectPtr<UStaticMesh> Mesh;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FString Description;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
EHoldItemType Type;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
EScenarioEnum ScenarioEnum;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Item")
FTransform Transform;
FHoldItemStruct()
: ID(0)
, Name(TEXT(""))
, Icon(nullptr)
, Mesh(nullptr)
, Description(TEXT(""))
, Type(EHoldItemType::None)
, ScenarioEnum(EScenarioEnum::None)
, Transform(FTransform::Identity)
{
}
};
USTRUCT(BlueprintType)
struct FStretchRobotActuator
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actuator")
FString Name;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actuator")
float Min;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actuator")
float Max;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Actuator")
int32 Index;
};
USTRUCT(BlueprintType)
struct FRandomMaterialTexture
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSoftObjectPtr<UStaticMesh>> Meshs;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSoftObjectPtr<UMaterialInstance>> Materials;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<TSoftObjectPtr<UTexture>> Textures;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool RandomMaterial;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool RandomTexture;
};
USTRUCT(BlueprintType)
struct FAllTransformCapture
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform Position;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString Name;
};
USTRUCT(BlueprintType)
struct FPipeType
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool IsOpen;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FTransform Transform;
};
USTRUCT(BlueprintType)
struct FParsedData
{
GENERATED_BODY()
UPROPERTY(BlueprintReadWrite, Category = "Parsed Data")
FString LevelName;
UPROPERTY(BlueprintReadWrite, Category = "Parsed Data")
FString CharacterName;
UPROPERTY(BlueprintReadWrite, Category = "Parsed Data")
FString Quality;
};

View File

@ -0,0 +1,53 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "SharedDef.h"
#include "GameUserWidget.generated.h"
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API UGameUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
public:
FTimerHandle UpdateDownCountTimerHandle;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsCrash;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsGoalMenuVis;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsTracing;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
int32 DownCount = 0;
UPROPERTY(EditAnywhere, BlueprintReadWrite)
FString DownCountStr;
public:
UFUNCTION(BlueprintCallable)
void DoWaitSecond();
void UpdateDownCount();
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoLogItemAdd(const FString& Topic, const FString& MsgText, ELogItemType LogItemType);
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoRefreshListView();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void DoAutoConfirm();
};

View File

@ -0,0 +1,45 @@
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "SharedDef.h"
#include "CaptureSettingsUserWidget.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnOpenMenuStateChanged, bool, Open);
/**
*
*/
UCLASS()
class LUCKYWORLDV2_API UCaptureSettingsUserWidget : public UUserWidget
{
GENERATED_BODY()
protected:
virtual void NativeConstruct() override;
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite)
bool bIsOpen;
UPROPERTY(BlueprintCallable, BlueprintAssignable, Category = "Event")
FOnOpenMenuStateChanged OnOpenMenuStateChanged;
public:
UFUNCTION(BlueprintCallable)
void ToggleMenu();
public:
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPRefreshTaskList();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPOnRandomMeshesUpdated();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void BPLoadSettings();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent)
void ToggleMenuDisplay();
};

View File

@ -0,0 +1,9 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvGameMode.h"
#include "TP_VehicleAdvPlayerController.h"
ATP_VehicleAdvGameMode::ATP_VehicleAdvGameMode()
{
PlayerControllerClass = ATP_VehicleAdvPlayerController::StaticClass();
}

View File

@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/GameModeBase.h"
#include "TP_VehicleAdvGameMode.generated.h"
UCLASS(MinimalAPI)
class ATP_VehicleAdvGameMode : public AGameModeBase
{
GENERATED_BODY()
public:
ATP_VehicleAdvGameMode();
};

View File

@ -0,0 +1,85 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvOffroadCar.h"
#include "TP_VehicleAdvOffroadWheelFront.h"
#include "TP_VehicleAdvOffroadWheelRear.h"
#include "ChaosWheeledVehicleMovementComponent.h"
#include "GameFramework/SpringArmComponent.h"
ATP_VehicleAdvOffroadCar::ATP_VehicleAdvOffroadCar()
{
// construct the mesh components
Chassis = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Chassis"));
Chassis->SetupAttachment(GetMesh());
// NOTE: tire sockets are set from the Blueprint class
TireFrontLeft = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Tire Front Left"));
TireFrontLeft->SetupAttachment(GetMesh(), FName("VisWheel_FL"));
TireFrontLeft->SetCollisionProfileName(FName("NoCollision"));
TireFrontRight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Tire Front Right"));
TireFrontRight->SetupAttachment(GetMesh(), FName("VisWheel_FR"));
TireFrontRight->SetCollisionProfileName(FName("NoCollision"));
TireFrontRight->SetRelativeRotation(FRotator(0.0f, 180.0f, 0.0f));
TireRearLeft = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Tire Rear Left"));
TireRearLeft->SetupAttachment(GetMesh(), FName("VisWheel_BL"));
TireRearLeft->SetCollisionProfileName(FName("NoCollision"));
TireRearRight = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Tire Rear Right"));
TireRearRight->SetupAttachment(GetMesh(), FName("VisWheel_BR"));
TireRearRight->SetCollisionProfileName(FName("NoCollision"));
TireRearRight->SetRelativeRotation(FRotator(0.0f, 180.0f, 0.0f));
// adjust the cameras
GetFrontSpringArm()->SetRelativeLocation(FVector(-5.0f, -30.0f, 135.0f));
GetBackSpringArm()->SetRelativeLocation(FVector(0.0f, 0.0f, 75.0f));
// Note: for faster iteration times, the vehicle setup can be tweaked in the Blueprint instead
// Set up the chassis
GetChaosVehicleMovement()->ChassisHeight = 160.0f;
GetChaosVehicleMovement()->DragCoefficient = 0.1f;
GetChaosVehicleMovement()->DownforceCoefficient = 0.1f;
GetChaosVehicleMovement()->CenterOfMassOverride = FVector(0.0f, 0.0f, 75.0f);
GetChaosVehicleMovement()->bEnableCenterOfMassOverride = true;
// Set up the wheels
GetChaosVehicleMovement()->bLegacyWheelFrictionPosition = true;
GetChaosVehicleMovement()->WheelSetups.SetNum(4);
GetChaosVehicleMovement()->WheelSetups[0].WheelClass = UTP_VehicleAdvOffroadWheelFront::StaticClass();
GetChaosVehicleMovement()->WheelSetups[0].BoneName = FName("PhysWheel_FL");
GetChaosVehicleMovement()->WheelSetups[0].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[1].WheelClass = UTP_VehicleAdvOffroadWheelFront::StaticClass();
GetChaosVehicleMovement()->WheelSetups[1].BoneName = FName("PhysWheel_FR");
GetChaosVehicleMovement()->WheelSetups[1].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[2].WheelClass = UTP_VehicleAdvOffroadWheelRear::StaticClass();
GetChaosVehicleMovement()->WheelSetups[2].BoneName = FName("PhysWheel_BL");
GetChaosVehicleMovement()->WheelSetups[2].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[3].WheelClass = UTP_VehicleAdvOffroadWheelRear::StaticClass();
GetChaosVehicleMovement()->WheelSetups[3].BoneName = FName("PhysWheel_BR");
GetChaosVehicleMovement()->WheelSetups[3].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
// Set up the engine
// NOTE: Check the Blueprint asset for the Torque Curve
GetChaosVehicleMovement()->EngineSetup.MaxTorque = 600.0f;
GetChaosVehicleMovement()->EngineSetup.MaxRPM = 5000.0f;
GetChaosVehicleMovement()->EngineSetup.EngineIdleRPM = 1200.0f;
GetChaosVehicleMovement()->EngineSetup.EngineBrakeEffect = 0.05f;
GetChaosVehicleMovement()->EngineSetup.EngineRevUpMOI = 5.0f;
GetChaosVehicleMovement()->EngineSetup.EngineRevDownRate = 600.0f;
// Set up the differential
GetChaosVehicleMovement()->DifferentialSetup.DifferentialType = EVehicleDifferential::AllWheelDrive;
GetChaosVehicleMovement()->DifferentialSetup.FrontRearSplit = 0.5f;
// Set up the steering
// NOTE: Check the Blueprint asset for the Steering Curve
GetChaosVehicleMovement()->SteeringSetup.SteeringType = ESteeringType::AngleRatio;
GetChaosVehicleMovement()->SteeringSetup.AngleRatio = 0.7f;
}

View File

@ -0,0 +1,40 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvPawn.h"
#include "TP_VehicleAdvOffroadCar.generated.h"
/**
* Offroad car wheeled vehicle implementation
*/
UCLASS(abstract)
class LUCKYWORLDV2_API ATP_VehicleAdvOffroadCar : public ATP_VehicleAdvPawn
{
GENERATED_BODY()
/** Chassis static mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Meshes, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* Chassis;
/** FL Tire static mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Meshes, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* TireFrontLeft;
/** FR Tire static mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Meshes, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* TireFrontRight;
/** RL Tire static mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Meshes, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* TireRearLeft;
/** RR Tire static mesh */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Meshes, meta = (AllowPrivateAccess = "true"))
UStaticMeshComponent* TireRearRight;
public:
ATP_VehicleAdvOffroadCar();
};

View File

@ -0,0 +1,22 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvOffroadWheelFront.h"
UTP_VehicleAdvOffroadWheelFront::UTP_VehicleAdvOffroadWheelFront()
{
WheelRadius = 50.0f;
CorneringStiffness = 750.0f;
FrictionForceMultiplier = 4.0f;
bAffectedByEngine = true;
SuspensionMaxRaise = 20.0f;
SuspensionMaxDrop = 20.0f;
WheelLoadRatio = 1.0f;
SpringRate = 100.0f;
SpringPreload = 100.0f;
SweepShape = ESweepShape::Shapecast;
MaxBrakeTorque = 3000.0f;
MaxHandBrakeTorque = 6000.0f;
}

View File

@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvWheelFront.h"
#include "TP_VehicleAdvOffroadWheelFront.generated.h"
/**
* Front wheel definition for Offroad Car.
*/
UCLASS()
class LUCKYWORLDV2_API UTP_VehicleAdvOffroadWheelFront : public UTP_VehicleAdvWheelFront
{
GENERATED_BODY()
public:
UTP_VehicleAdvOffroadWheelFront();
};

View File

@ -0,0 +1,21 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvOffroadWheelRear.h"
UTP_VehicleAdvOffroadWheelRear::UTP_VehicleAdvOffroadWheelRear()
{
WheelRadius = 50.f;
CorneringStiffness = 750.0f;
FrictionForceMultiplier = 4.0f;
SuspensionMaxRaise = 20.0f;
SuspensionMaxDrop = 20.0f;
WheelLoadRatio = 1.0f;
SpringRate = 100.0f;
SpringPreload = 100.0f;
SweepShape = ESweepShape::Shapecast;
MaxBrakeTorque = 3000.0f;
MaxHandBrakeTorque = 6000.0f;
}

View File

@ -0,0 +1,20 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvWheelRear.h"
#include "TP_VehicleAdvOffroadWheelRear.generated.h"
/**
* Rear wheel definition for Offroad Car.
*/
UCLASS()
class LUCKYWORLDV2_API UTP_VehicleAdvOffroadWheelRear : public UTP_VehicleAdvWheelRear
{
GENERATED_BODY()
public:
UTP_VehicleAdvOffroadWheelRear();
};

View File

@ -0,0 +1,207 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvPawn.h"
#include "TP_VehicleAdvWheelFront.h"
#include "TP_VehicleAdvWheelRear.h"
#include "Components/SkeletalMeshComponent.h"
#include "GameFramework/SpringArmComponent.h"
#include "Camera/CameraComponent.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputActionValue.h"
#include "ChaosWheeledVehicleMovementComponent.h"
#define LOCTEXT_NAMESPACE "VehiclePawn"
DEFINE_LOG_CATEGORY(LogTemplateVehicle);
ATP_VehicleAdvPawn::ATP_VehicleAdvPawn()
{
// construct the front camera boom
FrontSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Front Spring Arm"));
FrontSpringArm->SetupAttachment(GetMesh());
FrontSpringArm->TargetArmLength = 0.0f;
FrontSpringArm->bDoCollisionTest = false;
FrontSpringArm->bEnableCameraRotationLag = true;
FrontSpringArm->CameraRotationLagSpeed = 15.0f;
FrontSpringArm->SetRelativeLocation(FVector(30.0f, 0.0f, 120.0f));
FrontCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("Front Camera"));
FrontCamera->SetupAttachment(FrontSpringArm);
FrontCamera->bAutoActivate = false;
// construct the back camera boom
BackSpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("Back Spring Arm"));
BackSpringArm->SetupAttachment(GetMesh());
BackSpringArm->TargetArmLength = 650.0f;
BackSpringArm->SocketOffset.Z = 150.0f;
BackSpringArm->bDoCollisionTest = false;
BackSpringArm->bInheritPitch = false;
BackSpringArm->bInheritRoll = false;
BackSpringArm->bEnableCameraRotationLag = true;
BackSpringArm->CameraRotationLagSpeed = 2.0f;
BackSpringArm->CameraLagMaxDistance = 50.0f;
BackCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("Back Camera"));
BackCamera->SetupAttachment(BackSpringArm);
// Configure the car mesh
GetMesh()->SetSimulatePhysics(true);
GetMesh()->SetCollisionProfileName(FName("Vehicle"));
// get the Chaos Wheeled movement component
ChaosVehicleMovement = CastChecked<UChaosWheeledVehicleMovementComponent>(GetVehicleMovement());
}
void ATP_VehicleAdvPawn::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
// steering
EnhancedInputComponent->BindAction(SteeringAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::Steering);
EnhancedInputComponent->BindAction(SteeringAction, ETriggerEvent::Completed, this, &ATP_VehicleAdvPawn::Steering);
// throttle
EnhancedInputComponent->BindAction(ThrottleAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::Throttle);
EnhancedInputComponent->BindAction(ThrottleAction, ETriggerEvent::Completed, this, &ATP_VehicleAdvPawn::Throttle);
// break
EnhancedInputComponent->BindAction(BrakeAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::Brake);
EnhancedInputComponent->BindAction(BrakeAction, ETriggerEvent::Started, this, &ATP_VehicleAdvPawn::StartBrake);
EnhancedInputComponent->BindAction(BrakeAction, ETriggerEvent::Completed, this, &ATP_VehicleAdvPawn::StopBrake);
// handbrake
EnhancedInputComponent->BindAction(HandbrakeAction, ETriggerEvent::Started, this, &ATP_VehicleAdvPawn::StartHandbrake);
EnhancedInputComponent->BindAction(HandbrakeAction, ETriggerEvent::Completed, this, &ATP_VehicleAdvPawn::StopHandbrake);
// look around
EnhancedInputComponent->BindAction(LookAroundAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::LookAround);
// toggle camera
EnhancedInputComponent->BindAction(ToggleCameraAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::ToggleCamera);
// reset the vehicle
EnhancedInputComponent->BindAction(ResetVehicleAction, ETriggerEvent::Triggered, this, &ATP_VehicleAdvPawn::ResetVehicle);
}
else
{
UE_LOG(LogTemplateVehicle, Error, TEXT("'%s' Failed to find an Enhanced Input component! This template is built to use the Enhanced Input system. If you intend to use the legacy system, then you will need to update this C++ file."), *GetNameSafe(this));
}
}
void ATP_VehicleAdvPawn::Tick(float Delta)
{
Super::Tick(Delta);
// add some angular damping if the vehicle is in midair
bool bMovingOnGround = ChaosVehicleMovement->IsMovingOnGround();
GetMesh()->SetAngularDamping(bMovingOnGround ? 0.0f : 3.0f);
// realign the camera yaw to face front
float CameraYaw = BackSpringArm->GetRelativeRotation().Yaw;
CameraYaw = FMath::FInterpTo(CameraYaw, 0.0f, Delta, 1.0f);
BackSpringArm->SetRelativeRotation(FRotator(0.0f, CameraYaw, 0.0f));
}
void ATP_VehicleAdvPawn::Steering(const FInputActionValue& Value)
{
// get the input magnitude for steering
float SteeringValue = Value.Get<float>();
// add the input
ChaosVehicleMovement->SetSteeringInput(SteeringValue);
}
void ATP_VehicleAdvPawn::Throttle(const FInputActionValue& Value)
{
// get the input magnitude for the throttle
float ThrottleValue = Value.Get<float>();
// add the input
ChaosVehicleMovement->SetThrottleInput(ThrottleValue);
}
void ATP_VehicleAdvPawn::Brake(const FInputActionValue& Value)
{
// get the input magnitude for the brakes
float BreakValue = Value.Get<float>();
// add the input
ChaosVehicleMovement->SetBrakeInput(BreakValue);
}
void ATP_VehicleAdvPawn::StartBrake(const FInputActionValue& Value)
{
// call the Blueprint hook for the break lights
BrakeLights(true);
}
void ATP_VehicleAdvPawn::StopBrake(const FInputActionValue& Value)
{
// call the Blueprint hook for the break lights
BrakeLights(false);
// reset brake input to zero
ChaosVehicleMovement->SetBrakeInput(0.0f);
}
void ATP_VehicleAdvPawn::StartHandbrake(const FInputActionValue& Value)
{
// add the input
ChaosVehicleMovement->SetHandbrakeInput(true);
// call the Blueprint hook for the break lights
BrakeLights(true);
}
void ATP_VehicleAdvPawn::StopHandbrake(const FInputActionValue& Value)
{
// add the input
ChaosVehicleMovement->SetHandbrakeInput(false);
// call the Blueprint hook for the break lights
BrakeLights(false);
}
void ATP_VehicleAdvPawn::LookAround(const FInputActionValue& Value)
{
// get the flat angle value for the input
float LookValue = Value.Get<float>();
// add the input
BackSpringArm->AddLocalRotation(FRotator(0.0f, LookValue, 0.0f));
}
void ATP_VehicleAdvPawn::ToggleCamera(const FInputActionValue& Value)
{
// toggle the active camera flag
bFrontCameraActive = !bFrontCameraActive;
FrontCamera->SetActive(bFrontCameraActive);
BackCamera->SetActive(!bFrontCameraActive);
}
void ATP_VehicleAdvPawn::ResetVehicle(const FInputActionValue& Value)
{
// reset to a location slightly above our current one
FVector ResetLocation = GetActorLocation() + FVector(0.0f, 0.0f, 50.0f);
// reset to our yaw. Ignore pitch and roll
FRotator ResetRotation = GetActorRotation();
ResetRotation.Pitch = 0.0f;
ResetRotation.Roll = 0.0f;
// teleport the actor to the reset spot and reset physics
SetActorTransform(FTransform(ResetRotation, ResetLocation, FVector::OneVector), false, nullptr, ETeleportType::TeleportPhysics);
GetMesh()->SetPhysicsAngularVelocityInDegrees(FVector::ZeroVector);
GetMesh()->SetPhysicsLinearVelocity(FVector::ZeroVector);
UE_LOG(LogTemplateVehicle, Error, TEXT("Reset Vehicle"));
}
#undef LOCTEXT_NAMESPACE

View File

@ -0,0 +1,139 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "WheeledVehiclePawn.h"
#include "TP_VehicleAdvPawn.generated.h"
class UCameraComponent;
class USpringArmComponent;
class UInputAction;
class UChaosWheeledVehicleMovementComponent;
struct FInputActionValue;
DECLARE_LOG_CATEGORY_EXTERN(LogTemplateVehicle, Log, All);
/**
* Vehicle Pawn class
* Handles common functionality for all vehicle types,
* including input handling and camera management.
*
* Specific vehicle configurations are handled in subclasses.
*/
UCLASS(abstract)
class ATP_VehicleAdvPawn : public AWheeledVehiclePawn
{
GENERATED_BODY()
/** Spring Arm for the front camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* FrontSpringArm;
/** Front Camera component */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
UCameraComponent* FrontCamera;
/** Spring Arm for the back camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
USpringArmComponent* BackSpringArm;
/** Back Camera component */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
UCameraComponent* BackCamera;
/** Cast pointer to the Chaos Vehicle movement component */
TObjectPtr<UChaosWheeledVehicleMovementComponent> ChaosVehicleMovement;
protected:
/** Steering Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* SteeringAction;
/** Throttle Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* ThrottleAction;
/** Brake Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* BrakeAction;
/** Handbrake Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* HandbrakeAction;
/** Look Around Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* LookAroundAction;
/** Toggle Camera Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* ToggleCameraAction;
/** Reset Vehicle Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputAction* ResetVehicleAction;
/** Keeps track of which camera is active */
bool bFrontCameraActive = false;
public:
ATP_VehicleAdvPawn();
// Begin Pawn interface
virtual void SetupPlayerInputComponent(UInputComponent* InputComponent) override;
// End Pawn interface
// Begin Actor interface
virtual void Tick(float Delta) override;
// End Actor interface
protected:
/** Handles steering input */
void Steering(const FInputActionValue& Value);
/** Handles throttle input */
void Throttle(const FInputActionValue& Value);
/** Handles brake input */
void Brake(const FInputActionValue& Value);
/** Handles brake start/stop inputs */
void StartBrake(const FInputActionValue& Value);
void StopBrake(const FInputActionValue& Value);
/** Handles handbrake start/stop inputs */
void StartHandbrake(const FInputActionValue& Value);
void StopHandbrake(const FInputActionValue& Value);
/** Handles look around input */
void LookAround(const FInputActionValue& Value);
/** Handles toggle camera input */
void ToggleCamera(const FInputActionValue& Value);
/** Handles reset vehicle input */
void ResetVehicle(const FInputActionValue& Value);
/** Called when the brake lights are turned on or off */
UFUNCTION(BlueprintImplementableEvent, Category="Vehicle")
void BrakeLights(bool bBraking);
public:
/** Returns the front spring arm subobject */
FORCEINLINE USpringArmComponent* GetFrontSpringArm() const { return FrontSpringArm; }
/** Returns the front camera subobject */
FORCEINLINE UCameraComponent* GetFollowCamera() const { return FrontCamera; }
/** Returns the back spring arm subobject */
FORCEINLINE USpringArmComponent* GetBackSpringArm() const { return BackSpringArm; }
/** Returns the back camera subobject */
FORCEINLINE UCameraComponent* GetBackCamera() const { return BackCamera; }
/** Returns the cast Chaos Vehicle Movement subobject */
FORCEINLINE const TObjectPtr<UChaosWheeledVehicleMovementComponent>& GetChaosVehicleMovement() const { return ChaosVehicleMovement; }
};

View File

@ -0,0 +1,57 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvPlayerController.h"
#include "TP_VehicleAdvPawn.h"
#include "TP_VehicleAdvUI.h"
#include "EnhancedInputSubsystems.h"
#include "ChaosWheeledVehicleMovementComponent.h"
void ATP_VehicleAdvPlayerController::BeginPlay()
{
Super::BeginPlay();
// spawn the UI widget and add it to the viewport
VehicleUI = CreateWidget<UTP_VehicleAdvUI>(this, VehicleUIClass);
check(VehicleUI);
VehicleUI->AddToViewport();
}
void ATP_VehicleAdvPlayerController::SetupInputComponent()
{
Super::SetupInputComponent();
// get the enhanced input subsystem
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(GetLocalPlayer()))
{
// add the mapping context so we get controls
Subsystem->AddMappingContext(InputMappingContext, 0);
// optionally add the steering wheel context
if (bUseSteeringWheelControls && SteeringWheelInputMappingContext)
{
Subsystem->AddMappingContext(SteeringWheelInputMappingContext, 1);
}
}
}
void ATP_VehicleAdvPlayerController::Tick(float Delta)
{
Super::Tick(Delta);
if (IsValid(VehiclePawn) && IsValid(VehicleUI))
{
VehicleUI->UpdateSpeed(VehiclePawn->GetChaosVehicleMovement()->GetForwardSpeed());
VehicleUI->UpdateGear(VehiclePawn->GetChaosVehicleMovement()->GetCurrentGear());
}
}
void ATP_VehicleAdvPlayerController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
// get a pointer to the controlled pawn
VehiclePawn = CastChecked<ATP_VehicleAdvPawn>(InPawn);
}

View File

@ -0,0 +1,68 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "TP_VehicleAdvPlayerController.generated.h"
class UInputMappingContext;
class ATP_VehicleAdvPawn;
class UTP_VehicleAdvUI;
/**
* Vehicle Player Controller class
* Handles input mapping and user interface
*/
UCLASS(abstract)
class LUCKYWORLDV2_API ATP_VehicleAdvPlayerController : public APlayerController
{
GENERATED_BODY()
protected:
/** Input Mapping Context to be used for player input */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
UInputMappingContext* InputMappingContext;
/** If true, the optional steering wheel input mapping context will be registered */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input)
bool bUseSteeringWheelControls = false;
/** Optional Input Mapping Context to be used for steering wheel input.
* This is added alongside the default Input Mapping Context and does not block other forms of input.
*/
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta=(EditCondition="bUseSteeringWheelControls"))
UInputMappingContext* SteeringWheelInputMappingContext;
/** Pointer to the controlled vehicle pawn */
TObjectPtr<ATP_VehicleAdvPawn> VehiclePawn;
/** Type of the UI to spawn */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = UI)
TSubclassOf<UTP_VehicleAdvUI> VehicleUIClass;
/** Pointer to the UI widget */
TObjectPtr<UTP_VehicleAdvUI> VehicleUI;
// Begin Actor interface
protected:
virtual void BeginPlay() override;
virtual void SetupInputComponent() override;
public:
virtual void Tick(float Delta) override;
// End Actor interface
// Begin PlayerController interface
protected:
virtual void OnPossess(APawn* InPawn) override;
// End PlayerController interface
};

View File

@ -0,0 +1,69 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvSportsCar.h"
#include "TP_VehicleAdvSportsWheelFront.h"
#include "TP_VehicleAdvSportsWheelRear.h"
#include "ChaosWheeledVehicleMovementComponent.h"
ATP_VehicleAdvSportsCar::ATP_VehicleAdvSportsCar()
{
// Note: for faster iteration times, the vehicle setup can be tweaked in the Blueprint instead
// Set up the chassis
GetChaosVehicleMovement()->ChassisHeight = 144.0f;
GetChaosVehicleMovement()->DragCoefficient = 0.31f;
// Set up the wheels
GetChaosVehicleMovement()->bLegacyWheelFrictionPosition = true;
GetChaosVehicleMovement()->WheelSetups.SetNum(4);
GetChaosVehicleMovement()->WheelSetups[0].WheelClass = UTP_VehicleAdvSportsWheelFront::StaticClass();
GetChaosVehicleMovement()->WheelSetups[0].BoneName = FName("Phys_Wheel_FL");
GetChaosVehicleMovement()->WheelSetups[0].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[1].WheelClass = UTP_VehicleAdvSportsWheelFront::StaticClass();
GetChaosVehicleMovement()->WheelSetups[1].BoneName = FName("Phys_Wheel_FR");
GetChaosVehicleMovement()->WheelSetups[1].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[2].WheelClass = UTP_VehicleAdvSportsWheelRear::StaticClass();
GetChaosVehicleMovement()->WheelSetups[2].BoneName = FName("Phys_Wheel_BL");
GetChaosVehicleMovement()->WheelSetups[2].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
GetChaosVehicleMovement()->WheelSetups[3].WheelClass = UTP_VehicleAdvSportsWheelRear::StaticClass();
GetChaosVehicleMovement()->WheelSetups[3].BoneName = FName("Phys_Wheel_BR");
GetChaosVehicleMovement()->WheelSetups[3].AdditionalOffset = FVector(0.0f, 0.0f, 0.0f);
// Set up the engine
// NOTE: Check the Blueprint asset for the Torque Curve
GetChaosVehicleMovement()->EngineSetup.MaxTorque = 750.0f;
GetChaosVehicleMovement()->EngineSetup.MaxRPM = 7000.0f;
GetChaosVehicleMovement()->EngineSetup.EngineIdleRPM = 900.0f;
GetChaosVehicleMovement()->EngineSetup.EngineBrakeEffect = 0.2f;
GetChaosVehicleMovement()->EngineSetup.EngineRevUpMOI = 5.0f;
GetChaosVehicleMovement()->EngineSetup.EngineRevDownRate = 600.0f;
// Set up the transmission
GetChaosVehicleMovement()->TransmissionSetup.bUseAutomaticGears = true;
GetChaosVehicleMovement()->TransmissionSetup.bUseAutoReverse = true;
GetChaosVehicleMovement()->TransmissionSetup.FinalRatio = 2.81f;
GetChaosVehicleMovement()->TransmissionSetup.ChangeUpRPM = 6000.0f;
GetChaosVehicleMovement()->TransmissionSetup.ChangeDownRPM = 2000.0f;
GetChaosVehicleMovement()->TransmissionSetup.GearChangeTime = 0.2f;
GetChaosVehicleMovement()->TransmissionSetup.TransmissionEfficiency = 0.9f;
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios.SetNum(5);
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios[0] = 4.25f;
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios[1] = 2.52f;
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios[2] = 1.66f;
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios[3] = 1.22f;
GetChaosVehicleMovement()->TransmissionSetup.ForwardGearRatios[4] = 1.0f;
GetChaosVehicleMovement()->TransmissionSetup.ReverseGearRatios.SetNum(1);
GetChaosVehicleMovement()->TransmissionSetup.ReverseGearRatios[0] = 4.04f;
// Set up the steering
// NOTE: Check the Blueprint asset for the Steering Curve
GetChaosVehicleMovement()->SteeringSetup.SteeringType = ESteeringType::Ackermann;
GetChaosVehicleMovement()->SteeringSetup.AngleRatio = 0.7f;
}

View File

@ -0,0 +1,20 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvPawn.h"
#include "TP_VehicleAdvSportsCar.generated.h"
/**
* Sports car wheeled vehicle implementation
*/
UCLASS(abstract)
class LUCKYWORLDV2_API ATP_VehicleAdvSportsCar : public ATP_VehicleAdvPawn
{
GENERATED_BODY()
public:
ATP_VehicleAdvSportsCar();
};

View File

@ -0,0 +1,14 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvSportsWheelFront.h"
UTP_VehicleAdvSportsWheelFront::UTP_VehicleAdvSportsWheelFront()
{
WheelRadius = 39.0f;
WheelWidth = 35.0f;
FrictionForceMultiplier = 3.0f;
MaxBrakeTorque = 4500.0f;
MaxHandBrakeTorque = 6000.0f;
}

View File

@ -0,0 +1,20 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvWheelFront.h"
#include "TP_VehicleAdvSportsWheelFront.generated.h"
/**
* Front wheel definition for Sports Car.
*/
UCLASS()
class LUCKYWORLDV2_API UTP_VehicleAdvSportsWheelFront : public UTP_VehicleAdvWheelFront
{
GENERATED_BODY()
public:
UTP_VehicleAdvSportsWheelFront();
};

View File

@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvSportsWheelRear.h"
UTP_VehicleAdvSportsWheelRear::UTP_VehicleAdvSportsWheelRear()
{
WheelRadius = 40.f;
WheelWidth = 40.0f;
FrictionForceMultiplier = 4.0f;
SlipThreshold = 100.0f;
SkidThreshold = 100.0f;
MaxSteerAngle = 0.0f;
MaxHandBrakeTorque = 6000.0f;
}

View File

@ -0,0 +1,20 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "TP_VehicleAdvWheelRear.h"
#include "TP_VehicleAdvSportsWheelRear.generated.h"
/**
* Rear wheel definition for Sports Car.
*/
UCLASS()
class LUCKYWORLDV2_API UTP_VehicleAdvSportsWheelRear : public UTP_VehicleAdvWheelRear
{
GENERATED_BODY()
public:
UTP_VehicleAdvSportsWheelRear();
};

View File

@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvUI.h"
void UTP_VehicleAdvUI::UpdateSpeed(float NewSpeed)
{
// format the speed to KPH or MPH
float FormattedSpeed = FMath::Abs(NewSpeed) * (bIsMPH ? 0.022f : 0.036f);
// call the Blueprint handler
OnSpeedUpdate(FormattedSpeed);
}
void UTP_VehicleAdvUI::UpdateGear(int32 NewGear)
{
// call the Blueprint handler
OnGearUpdate(NewGear);
}

View File

@ -0,0 +1,42 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Blueprint/UserWidget.h"
#include "TP_VehicleAdvUI.generated.h"
/**
* Simple Vehicle HUD class
* Displays the current speed and gear.
* Widget setup is handled in a Blueprint subclass.
*/
UCLASS(abstract)
class LUCKYWORLDV2_API UTP_VehicleAdvUI : public UUserWidget
{
GENERATED_BODY()
protected:
/** Controls the display of speed in Km/h or MPH */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Vehicle)
bool bIsMPH = false;
public:
/** Called to update the speed display */
void UpdateSpeed(float NewSpeed);
/** Called to update the gear display */
void UpdateGear(int32 NewGear);
protected:
/** Implemented in Blueprint to display the new speed */
UFUNCTION(BlueprintImplementableEvent, Category = Vehicle)
void OnSpeedUpdate(float NewSpeed);
/** Implemented in Blueprint to display the new gear */
UFUNCTION(BlueprintImplementableEvent, Category = Vehicle)
void OnGearUpdate(int32 NewGear);
};

View File

@ -0,0 +1,11 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvWheelFront.h"
#include "UObject/ConstructorHelpers.h"
UTP_VehicleAdvWheelFront::UTP_VehicleAdvWheelFront()
{
AxleType = EAxleType::Front;
bAffectedBySteering = true;
MaxSteerAngle = 40.f;
}

View File

@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ChaosVehicleWheel.h"
#include "TP_VehicleAdvWheelFront.generated.h"
/**
* Base front wheel definition.
*/
UCLASS()
class UTP_VehicleAdvWheelFront : public UChaosVehicleWheel
{
GENERATED_BODY()
public:
UTP_VehicleAdvWheelFront();
};

View File

@ -0,0 +1,11 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "TP_VehicleAdvWheelRear.h"
#include "UObject/ConstructorHelpers.h"
UTP_VehicleAdvWheelRear::UTP_VehicleAdvWheelRear()
{
AxleType = EAxleType::Rear;
bAffectedByHandbrake = true;
bAffectedByEngine = true;
}

View File

@ -0,0 +1,19 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "ChaosVehicleWheel.h"
#include "TP_VehicleAdvWheelRear.generated.h"
/**
* Base rear wheel definition.
*/
UCLASS()
class UTP_VehicleAdvWheelRear : public UChaosVehicleWheel
{
GENERATED_BODY()
public:
UTP_VehicleAdvWheelRear();
};