57 lines
1.7 KiB
C++
57 lines
1.7 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "LuckyRobotsFunctionLibrary.h"
|
|
#include "LuckyRobotsGameInstance.h"
|
|
|
|
TArray<FRobotData> ULuckyRobotsFunctionLibrary::GetActiveRobotDataList(const UObject* WorldContextObject)
|
|
{
|
|
TArray<FRobotData> RobotDataList;
|
|
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(WorldContextObject->GetWorld()->GetGameInstance());
|
|
if (LuckyRobotsGameInstance)
|
|
{
|
|
if (LuckyRobotsGameInstance->RobotDataDataTable)
|
|
{
|
|
FString ContextString;
|
|
TArray<FName> RowNames = LuckyRobotsGameInstance->RobotDataDataTable->GetRowNames();
|
|
for (auto RowString : RowNames)
|
|
{
|
|
FRobotData* pRow = LuckyRobotsGameInstance->RobotDataDataTable->FindRow<FRobotData>(FName(RowString), ContextString);
|
|
if (pRow)
|
|
{
|
|
if (pRow->bActive)
|
|
{
|
|
RobotDataList.Add(*pRow);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return RobotDataList;
|
|
}
|
|
|
|
TArray<FLevelData> ULuckyRobotsFunctionLibrary::GetActiveLevelDataList(const UObject* WorldContextObject)
|
|
{
|
|
TArray<FLevelData> LevelDataList;
|
|
ULuckyRobotsGameInstance* LuckyRobotsGameInstance = Cast<ULuckyRobotsGameInstance>(WorldContextObject->GetWorld()->GetGameInstance());
|
|
if (LuckyRobotsGameInstance)
|
|
{
|
|
if (LuckyRobotsGameInstance->LevelDataTable)
|
|
{
|
|
FString ContextString;
|
|
TArray<FName> RowNames = LuckyRobotsGameInstance->LevelDataTable->GetRowNames();
|
|
for (auto RowString : RowNames)
|
|
{
|
|
FLevelData* pRow = LuckyRobotsGameInstance->LevelDataTable->FindRow<FLevelData>(FName(RowString), ContextString);
|
|
if (pRow)
|
|
{
|
|
if (pRow->bActive)
|
|
{
|
|
LevelDataList.Add(*pRow);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return LevelDataList;
|
|
} |