RealtimeStyleTransferRuntime/Source/LyraGame/AbilitySystem/LyraGameplayCueManager.h

89 lines
2.8 KiB
C
Raw Permalink Normal View History

2022-05-23 18:41:30 +00:00
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
2022-09-13 07:18:28 +00:00
#include "Containers/Array.h"
#include "Containers/Map.h"
#include "Containers/Set.h"
2022-05-23 18:41:30 +00:00
#include "GameplayCueManager.h"
2022-09-13 07:18:28 +00:00
#include "GameplayTagContainer.h"
#include "HAL/CriticalSection.h"
#include "UObject/SoftObjectPath.h"
#include "UObject/UObjectGlobals.h"
#include "UObject/WeakObjectPtr.h"
#include "UObject/WeakObjectPtrTemplates.h"
2022-05-23 18:41:30 +00:00
#include "LyraGameplayCueManager.generated.h"
2022-09-13 07:18:28 +00:00
class FString;
class UClass;
class UObject;
class UWorld;
struct FObjectKey;
2022-05-23 18:41:30 +00:00
/**
* ULyraGameplayCueManager
*
* Game-specific manager for gameplay cues
*/
UCLASS()
class ULyraGameplayCueManager : public UGameplayCueManager
{
GENERATED_BODY()
public:
ULyraGameplayCueManager(const FObjectInitializer& ObjectInitializer = FObjectInitializer::Get());
static ULyraGameplayCueManager* Get();
//~UGameplayCueManager interface
virtual void OnCreated() override;
virtual bool ShouldAsyncLoadRuntimeObjectLibraries() const override;
virtual bool ShouldSyncLoadMissingGameplayCues() const override;
virtual bool ShouldAsyncLoadMissingGameplayCues() const override;
//~End of UGameplayCueManager interface
static void DumpGameplayCues(const TArray<FString>& Args);
// When delay loading cues, this will load the cues that must be always loaded anyway
void LoadAlwaysLoadedCues();
// Updates the bundles for the singular gameplay cue primary asset
void RefreshGameplayCuePrimaryAsset();
private:
void OnGameplayTagLoaded(const FGameplayTag& Tag);
void HandlePostGarbageCollect();
void ProcessLoadedTags();
void ProcessTagToPreload(const FGameplayTag& Tag, UObject* OwningObject);
void OnPreloadCueComplete(FSoftObjectPath Path, TWeakObjectPtr<UObject> OwningObject, bool bAlwaysLoadedCue);
void RegisterPreloadedCue(UClass* LoadedGameplayCueClass, UObject* OwningObject);
void HandlePostLoadMap(UWorld* NewWorld);
void UpdateDelayLoadDelegateListeners();
bool ShouldDelayLoadGameplayCues() const;
private:
struct FLoadedGameplayTagToProcessData
{
FGameplayTag Tag;
TWeakObjectPtr<UObject> WeakOwner;
FLoadedGameplayTagToProcessData() {}
FLoadedGameplayTagToProcessData(const FGameplayTag& InTag, const TWeakObjectPtr<UObject>& InWeakOwner) : Tag(InTag), WeakOwner(InWeakOwner) {}
};
private:
// Cues that were preloaded on the client due to being referenced by content
UPROPERTY(transient)
2022-09-13 07:18:28 +00:00
TSet<TObjectPtr<UClass>> PreloadedCues;
2022-05-23 18:41:30 +00:00
TMap<FObjectKey, TSet<FObjectKey>> PreloadedCueReferencers;
// Cues that were preloaded on the client and will always be loaded (code referenced or explicitly always loaded)
UPROPERTY(transient)
2022-09-13 07:18:28 +00:00
TSet<TObjectPtr<UClass>> AlwaysLoadedCues;
2022-05-23 18:41:30 +00:00
TArray<FLoadedGameplayTagToProcessData> LoadedGameplayTagsToProcess;
FCriticalSection LoadedGameplayTagsToProcessCS;
bool bProcessLoadedTagsAfterGC = false;
};