You've already forked LuckyWorld
Organize the code related to selecting robots and levels in blueprints into C++, and organize the related referenced blueprints
This commit is contained in:
@ -2,4 +2,31 @@
|
||||
|
||||
|
||||
#include "LuckyRobotsGameMode.h"
|
||||
#include "LuckyRobotsGameInstance.h"
|
||||
#include "LuckyRobotsFunctionLibrary.h"
|
||||
|
||||
UClass* ALuckyRobotsGameMode::GetDefaultPawnClassForController_Implementation(AController* InController)
|
||||
{
|
||||
UClass* RobotClass = Super::GetDefaultPawnClassForController_Implementation(InController);
|
||||
|
||||
ERobotsName CurrentRobot = ERobotsName::None;
|
||||
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (LuckyRobotsGameInstance)
|
||||
{
|
||||
CurrentRobot = LuckyRobotsGameInstance->CurrentSelectRobot;
|
||||
}
|
||||
if (CurrentRobot != ERobotsName::None)
|
||||
{
|
||||
TArray<FRobotData> ActiveRobotDataList = ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(this);
|
||||
for (auto ActiveRobotData : ActiveRobotDataList)
|
||||
{
|
||||
if (ActiveRobotData.Name == CurrentRobot)
|
||||
{
|
||||
RobotClass = ActiveRobotData.RobotClass;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RobotClass;
|
||||
}
|
Reference in New Issue
Block a user