136 lines
2.6 KiB
C++
136 lines
2.6 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "LuckyRobotsGameInstance.h"
|
|
#include "LuckyRobotsGameState.h"
|
|
#include "Kismet/GameplayStatics.h"
|
|
#include "GameUserWidget.h"
|
|
|
|
void ULuckyRobotsGameInstance::DoSendMessage(FString SendValue)
|
|
{
|
|
ALuckyRobotsGameState* LuckyRobotsGameState = Cast<ALuckyRobotsGameState>(UGameplayStatics::GetGameState(this));
|
|
if (LuckyRobotsGameState)
|
|
{
|
|
LuckyRobotsGameState->DoSendMessage(SendValue);
|
|
}
|
|
|
|
DoLogItemAdd("Receive", SendValue, ELogItemType::Debug);
|
|
}
|
|
|
|
void ULuckyRobotsGameInstance::DoLogItemAdd(FString Topic, FString MsgText, ELogItemType LogItemType)
|
|
{
|
|
if (GameUserWidget)
|
|
{
|
|
GameUserWidget->DoLogItemAdd(Topic, MsgText, LogItemType);
|
|
}
|
|
}
|
|
|
|
void ULuckyRobotsGameInstance::SwitchGamePaused()
|
|
{
|
|
UGameplayStatics::SetGamePaused(this, !UGameplayStatics::IsGamePaused(this));
|
|
|
|
if (UGameplayStatics::IsGamePaused(this))
|
|
{
|
|
UKismetSystemLibrary::ExecuteConsoleCommand(this, "r.SceneRendering 0");
|
|
}
|
|
else
|
|
{
|
|
UKismetSystemLibrary::ExecuteConsoleCommand(this, "r.SceneRendering 1");
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
void ULuckyRobotsGameInstance::DoSetTempTaskValueChange(bool IsClear)
|
|
{
|
|
if (IsClear)
|
|
{
|
|
ClearTaskList();
|
|
}
|
|
else
|
|
{
|
|
AddTask(TempTask);
|
|
}
|
|
|
|
if (GameUserWidget)
|
|
{
|
|
GameUserWidget->DoRefreshListView();
|
|
}
|
|
}
|