RealtimeStyleTransferRuntime/Source/LyraGame/GameModes/AsyncAction_ExperienceReady.h

50 lines
1.5 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Delegates/Delegate.h"
#include "Kismet/BlueprintAsyncActionBase.h"
#include "UObject/Object.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/WeakObjectPtrTemplates.h"
#include "AsyncAction_ExperienceReady.generated.h"
class AGameStateBase;
class ULyraExperienceDefinition;
class UWorld;
struct FFrame;
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FExperienceReadyAsyncDelegate);
/**
* Asynchronously waits for the game state to be ready and valid and then calls the OnReady event. Will call OnReady
* immediately if the game state is valid already.
*/
UCLASS()
class UAsyncAction_ExperienceReady : public UBlueprintAsyncActionBase
{
GENERATED_UCLASS_BODY()
public:
// Waits for the experience to be determined and loaded
UFUNCTION(BlueprintCallable, meta=(WorldContext = "WorldContextObject", BlueprintInternalUseOnly="true"))
static UAsyncAction_ExperienceReady* WaitForExperienceReady(UObject* WorldContextObject);
virtual void Activate() override;
public:
// Called when the experience has been determined and is ready/loaded
UPROPERTY(BlueprintAssignable)
FExperienceReadyAsyncDelegate OnReady;
private:
void Step1_HandleGameStateSet(AGameStateBase* GameState);
void Step2_ListenToExperienceLoading(AGameStateBase* GameState);
void Step3_HandleExperienceLoaded(const ULyraExperienceDefinition* CurrentExperience);
void Step4_BroadcastReady();
TWeakObjectPtr<UWorld> WorldPtr;
};