You've already forked LuckyWorld
Optimize some UI
This commit is contained in:
@ -2,4 +2,63 @@
|
||||
|
||||
|
||||
#include "UI/Settings/PathfindingSelectorUserWidget.h"
|
||||
#include "Gameplay/TargetSelector.h"
|
||||
#include "Core/LuckyRobotsGameInstance.h"
|
||||
#include "Subsystem/UISubsystem.h"
|
||||
#include "UI/Settings/SelectGoalUserWidget.h"
|
||||
|
||||
void UPathfindingSelectorUserWidget::ClickSelectObjectBtn()
|
||||
{
|
||||
if (CreatedTargetSelector)
|
||||
{
|
||||
CreatedTargetSelector->Destroy();
|
||||
CreatedTargetSelector = nullptr;
|
||||
}
|
||||
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
FTransform SpawnPoint;
|
||||
CreatedTargetSelector = GetWorld()->SpawnActorDeferred<ATargetSelector>(GameInstance->TargetSelectorClass, SpawnPoint, nullptr, nullptr,
|
||||
ESpawnActorCollisionHandlingMethod::AlwaysSpawn);
|
||||
if (CreatedTargetSelector)
|
||||
{
|
||||
CreatedTargetSelector->FinishSpawning(SpawnPoint);
|
||||
}
|
||||
}
|
||||
|
||||
auto UISubsystem = GetGameInstance()->GetSubsystem<UUISubsystem>();
|
||||
if (UISubsystem)
|
||||
{
|
||||
UISubsystem->OnStartTracing.Broadcast();
|
||||
}
|
||||
}
|
||||
|
||||
void UPathfindingSelectorUserWidget::AddGoal()
|
||||
{
|
||||
if (CreatedTargetSelector)
|
||||
{
|
||||
ULuckyRobotsGameInstance* GameInstance = Cast<ULuckyRobotsGameInstance>(GetGameInstance());
|
||||
if (GameInstance)
|
||||
{
|
||||
FGoalsTaskData addTempTask;
|
||||
addTempTask.GoalType = EGoalType::NavigateSimpleEnvironments;
|
||||
addTempTask.TargetLocation = CreatedTargetSelector->GetActorTransform();
|
||||
GameInstance->TempTask = addTempTask;
|
||||
GameInstance->bIsChanged = true;
|
||||
}
|
||||
|
||||
auto UISubsystem = GetGameInstance()->GetSubsystem<UUISubsystem>();
|
||||
if (UISubsystem)
|
||||
{
|
||||
UISubsystem->OnEndTracing.Broadcast();
|
||||
}
|
||||
|
||||
if (OwnerSelectGoalUserWidget)
|
||||
{
|
||||
OwnerSelectGoalUserWidget->DoAddGoalAndStopTracing();
|
||||
}
|
||||
|
||||
CreatedTargetSelector->bIsTracing = false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user