LuckyRobotsUnreal/Source/Luckyrobots/Private/LuckyRobotsGameMode.cpp
martinluckyrobots 8e1c017515 Optimize gamemode and gamestate code
2025-04-01 11:04:11 +08:00

41 lines
1.1 KiB
C++

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