LuckyRobotsUnreal/Source/Luckyrobots/Private/LuckyRobotsGameInstance.cpp
martinluckyrobots 4b116bf9da Optimize CaptureSetting, GoalTask, etc.
2025-04-02 13:40:55 +08:00

82 lines
1.4 KiB
C++

// Fill out your copyright notice in the Description page of Project Settings.
#include "LuckyRobotsGameInstance.h"
void ULuckyRobotsGameInstance::ClearTaskList()
{
TaskList.Empty();
}
void ULuckyRobotsGameInstance::AddTask(FGoalsTaskData TaskData)
{
TaskList.Add(TaskData);
}
void ULuckyRobotsGameInstance::RemoveTask(FGoalsTaskData TaskData)
{
TaskList.Remove(TaskData);
}
void ULuckyRobotsGameInstance::RemoveTaskByGoalType(EGoalType GoalType)
{
for (auto Task : TaskList)
{
if (Task.GoalType == GoalType)
{
RemoveTask(Task);
break;
}
}
}
int ULuckyRobotsGameInstance::GetTaskNum()
{
return TaskList.Num();
}
void ULuckyRobotsGameInstance::SetTask(int Index, FGoalsTaskData TaskData)
{
if (TaskList.IsValidIndex(Index))
{
TaskList[Index] = TaskData;
}
else
{
for (int i = TaskList.Num(); i < Index; i++)
{
FGoalsTaskData TempTaskData;
AddTask(TempTaskData);
}
AddTask(TaskData);
}
}
bool ULuckyRobotsGameInstance::GetTask(int Index, FGoalsTaskData& TaskData)
{
if (TaskList.IsValidIndex(Index))
{
TaskData = TaskList[Index];
return true;
}
return false;
}
void ULuckyRobotsGameInstance::ReSetTaskList()
{
TArray<FGoalsTaskData> TempTaskList;
for (auto Task : TaskList)
{
Task.bIsStart = false;
Task.bIsStart = false;
Task.bActive = false;
TempTaskList.Add(Task);
}
TaskList = TempTaskList;
}
TArray<FGoalsTaskData> ULuckyRobotsGameInstance::GetTaskList()
{
return TaskList;
}