// Fill out your copyright notice in the Description page of Project Settings. #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(GetGameInstance()); if (GameInstance) { FTransform SpawnPoint; CreatedTargetSelector = GetWorld()->SpawnActorDeferred(GameInstance->TargetSelectorClass, SpawnPoint, nullptr, nullptr, ESpawnActorCollisionHandlingMethod::AlwaysSpawn); if (CreatedTargetSelector) { CreatedTargetSelector->FinishSpawning(SpawnPoint); } } auto UISubsystem = GetGameInstance()->GetSubsystem(); if (UISubsystem) { UISubsystem->OnStartTracing.Broadcast(); } } void UPathfindingSelectorUserWidget::AddGoal() { if (CreatedTargetSelector) { ULuckyRobotsGameInstance* GameInstance = Cast(GetGameInstance()); if (GameInstance) { FGoalsTaskData addTempTask; addTempTask.GoalType = EGoalType::NavigateSimpleEnvironments; addTempTask.TargetLocation = CreatedTargetSelector->GetActorTransform(); GameInstance->TempTask = addTempTask; GameInstance->bIsChanged = true; } auto UISubsystem = GetGameInstance()->GetSubsystem(); if (UISubsystem) { UISubsystem->OnEndTracing.Broadcast(); } if (OwnerSelectGoalUserWidget) { OwnerSelectGoalUserWidget->DoAddGoalAndStopTracing(); } CreatedTargetSelector->bIsTracing = false; } }