Files
UnrealEngineUWP/Engine/Source/Runtime/AugmentedReality/Private/ARBlueprintProxy.cpp
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

113 lines
2.9 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include "ARBlueprintProxy.h"
#include "ARSystem.h"
TWeakPtr<FARSupportInterface , ESPMode::ThreadSafe> UARBaseAsyncTaskBlueprintProxy::RegisteredARSystem = nullptr;
UARBaseAsyncTaskBlueprintProxy::UARBaseAsyncTaskBlueprintProxy(const FObjectInitializer& ObjectInitializer)
: Super(ObjectInitializer)
, bShouldTick(true)
{
}
void UARBaseAsyncTaskBlueprintProxy::Tick(float DeltaTime)
{
if (!AsyncTask.IsValid())
{
bShouldTick = false;
ReportFailure();
return;
}
if (AsyncTask->IsDone())
{
bShouldTick = false;
// Fire the right delegate
if (!AsyncTask->HadError())
{
ReportSuccess();
}
else
{
ReportFailure();
}
}
}
void UARBaseAsyncTaskBlueprintProxy::RegisterAsARSystem(const TSharedRef<FARSupportInterface , ESPMode::ThreadSafe>& NewARSystem)
{
RegisteredARSystem = NewARSystem;
}
const TWeakPtr<FARSupportInterface , ESPMode::ThreadSafe>& UARBaseAsyncTaskBlueprintProxy::GetARSystem()
{
return RegisteredARSystem;
}
UARSaveWorldAsyncTaskBlueprintProxy* UARSaveWorldAsyncTaskBlueprintProxy::ARSaveWorld(UObject* WorldContextObject)
{
UARSaveWorldAsyncTaskBlueprintProxy* Proxy = NewObject<UARSaveWorldAsyncTaskBlueprintProxy>();
Proxy->RegisterWithGameInstance(WorldContextObject);
return Proxy;
}
void UARSaveWorldAsyncTaskBlueprintProxy::Activate()
{
auto ARSystem = GetARSystem();
if (ARSystem.IsValid())
{
SaveWorldTask = ARSystem.Pin()->SaveWorld();
AsyncTask = SaveWorldTask;
}
else
{
AsyncTask = MakeShared<FARErrorSaveWorldAsyncTask, ESPMode::ThreadSafe>(TEXT("ARSaveWorld - requires a valid, running session"));
}
}
void UARSaveWorldAsyncTaskBlueprintProxy::ReportSuccess()
{
OnSuccess.Broadcast(SaveWorldTask->GetSavedWorldData());
}
void UARSaveWorldAsyncTaskBlueprintProxy::ReportFailure()
{
OnFailed.Broadcast(TArray<uint8>());
}
UARGetCandidateObjectAsyncTaskBlueprintProxy* UARGetCandidateObjectAsyncTaskBlueprintProxy::ARGetCandidateObject(UObject* WorldContextObject, FVector Location, FVector Extent)
{
UARGetCandidateObjectAsyncTaskBlueprintProxy* Proxy = NewObject<UARGetCandidateObjectAsyncTaskBlueprintProxy>();
Proxy->RegisterWithGameInstance(WorldContextObject);
Proxy->Extent = Extent;
Proxy->Location = Location;
return Proxy;
}
void UARGetCandidateObjectAsyncTaskBlueprintProxy::Activate()
{
auto ARSystem = GetARSystem();
if (ARSystem.IsValid())
{
CandidateObjectTask = ARSystem.Pin()->GetCandidateObject(Location, Extent);
AsyncTask = CandidateObjectTask;
}
else
{
AsyncTask = MakeShared<FARErrorGetCandidateObjectAsyncTask, ESPMode::ThreadSafe>(TEXT("ARGetCandidateObject - requires a valid, running session"));
}
}
void UARGetCandidateObjectAsyncTaskBlueprintProxy::ReportSuccess()
{
OnSuccess.Broadcast(CandidateObjectTask->GetCandidateObject());
}
void UARGetCandidateObjectAsyncTaskBlueprintProxy::ReportFailure()
{
OnFailed.Broadcast(nullptr);
}