LuckyRobotsUnreal/Source/Luckyrobots/Private/LuckyRobotsGameMode.cpp

32 lines
981 B
C++

// Fill out your copyright notice in the Description page of Project Settings.
#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;
}