Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
LevelStreamingSubsystem.h
이 파일의 문서화 페이지로 가기
1// Fill out your copyright notice in the Description page of Project Settings.
2
3#pragma once
4
5#include "Containers/Ticker.h"
6#include "CoreMinimal.h"
13#include "LevelStreamingSubsystem.generated.h"
14
18class ULevelStreaming;
22class UWorld;
23
26struct FStreamableHandle;
27
28DECLARE_MULTICAST_DELEGATE(FOnLevelStreamingDataMapReady);
30
32
33DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnPlacePlayerTheWorld, ULevelPlayerPlacer*, Placer, UWorld*, World);
34
35
36UCLASS()
37class CK_UE_API ULevelStreamingSubsystem : public UGameInstanceSubsystem, public FTickableGameObject
38{
39 GENERATED_BODY()
40
41public:
42 virtual void Initialize(FSubsystemCollectionBase& Collection) override;
43 virtual void Deinitialize() override;
44 virtual void Tick(float DeltaTime) override;
45 virtual bool IsTickable() const override;
46
47public:
48 void PlacePlayerInLevel();
49 AUStageFlowDefinition* GetCurrentFlowDefinition() const;
50
51public:
52 UFUNCTION(BlueprintCallable, Category = "Level|Streaming")
53 void RequestLevelLoad(ULevelStreamingData* ReqLevelLoadPipelineData);
54
55 UFUNCTION()
56 void OnLevelLoaded();
57
58 UFUNCTION()
59 void OnLevelShown();
60
61 UFUNCTION()
62 void OnLevelHidden();
63
64public:
65 // true: Persistent 레벨에서 시작되어 스트리밍 sublevel이 존재함.
66 // false: sublevel 자체로 직접 PIE 진입 — 스트리밍 파이프라인 비대상.
67 FORCEINLINE bool IsLaunchedFromPersistentLevel() const
68 {
69 return GetWorld() && !GetWorld()->GetStreamingLevels().IsEmpty();
70 }
71
72 FORCEINLINE const UStageDictionary* GetStageDictionary() const
73 {
74 return CachedStageDictionary.Get();
75 }
76
77 FORCEINLINE virtual TStatId GetStatId() const override
78 {
79 RETURN_QUICK_DECLARE_CYCLE_STAT(ULevelStreamingSubsystem, STATGROUP_Tickables);
80 }
81
82 FORCEINLINE bool IsLevelLoadRequested() const
83 {
84 return StreamingStateMachine.IsBusy();
85 }
86
87 FORCEINLINE bool IsInitialStageInitialized() const
88 {
89 return InitialStageBootstrap.IsInitializedForCurrentWorld();
90 }
91
92private:
93 AUStageFlowDefinition* GetPreviousFlowDefinition() const;
94 bool InvalidateLevelLoadRequest(const ULevelStreamingData* ReqLevelLoadPipelineData, ULevelStreaming*& PreviousLevelStreaming) const;
95 void HandleLevelLoading(const ULevelStreamingData* ReqLevelStreamingData, ULevelStreaming* TargetLevel);
96 bool CacheStreamingDataFromStageDictionary();
97
98 void EnterPreLoadingState();
99 void EnterDuringLoadState();
100 void EnterAwaitShownState();
101 void EnterIdleState();
102
103 bool HandleAsyncLoadCompleted();
104 void HandleDuringLoadChainCompleted();
105 void HandleLevelShown();
106 void HandleLevelHidden();
107
108 void StartChain(ELevelStreamingPhase Phase);
109 void NotifyLevelLoaded(ULevelStreamingData* StreamingData) const;
110 void PreloadNiagaraEffectsAsync(TWeakObjectPtr<ULevelStreamingData> RequestedStreamingData);
111 void ReleaseNiagaraEffectsPreload();
112 void ForEachSendStreamingEvent(const ULevel* LoadedLevel, const TFunctionRef<void(IStreamingEventListenerInterface&)>& Callback) const;
113
114public:
115 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
116 FOnLevelLoadCompleted OnLevelLoadCompleted;
117
118 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
119 FOnLevelLoadedInMemory OnLevelLoadedInMemory;
120
121 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
122 FOnPlacePlayerTheWorld OnPlacePlayerTheWorld;
123
124private:
126 {
127 static ULevelStreaming* FindVisible(const UWorld* World);
128 static ULevelStreaming* FindByName(const UWorld* World, FName LevelName);
129 static void PrepareLevelForLoad(ULevelStreaming* StreamingLevel, bool bShouldBeLoaded);
130 static ULevelStreaming* ResolveTargetLevel(UObject* WorldContextObject, FName LevelName, bool& bOutAlreadyLoaded, bool& bOutSuccess);
131 };
132
134 {
135 void Initialize(ULevelStreamingSubsystem* InOwner);
136 void Reset();
137 void TryInitializeCurrentStage();
138 bool IsInitializedForCurrentWorld() const;
139
140 private:
141 ULevelStreamingData* ResolveCurrentStageDataFromWorld() const;
142 bool OnWaitForPlayTick(float DeltaTime);
143
144 private:
145 TWeakObjectPtr<UWorld> InitializedWorld;
146 TWeakObjectPtr<ULevelStreamingSubsystem> Owner;
147 FTSTicker::FDelegateHandle InitTickerHandle;
148 };
149
150private:
151 UPROPERTY(Transient)
152 TObjectPtr<UStageDictionary> CachedStageDictionary;
153
154 UPROPERTY(Transient)
155 TArray<TObjectPtr<ULevelStreamingEffect>> AllRegisteredEffects;
156
157 UPROPERTY(Transient)
158 TObjectPtr<ULevelStreamingData> LevelStreamingData;
159
160 UPROPERTY(Transient)
161 TObjectPtr<ULevelPlayerPlacer> ActivePlayerPlacer;
162
163 UPROPERTY(Transient)
164 TWeakObjectPtr<ULevelStreaming> LevelToLoad;
165
166 UPROPERTY(Transient)
167 TWeakObjectPtr<ULevelStreaming> LevelToUnload;
168
169 UPROPERTY(Transient)
170 TObjectPtr<UDataBundleRegistry> BundleRegistry;
171
172 FEffectChainExecutor ChainExecutor;
173 FInitialStageBootstrapper InitialStageBootstrap;
174 FLevelStreamingStateMachine StreamingStateMachine;
175
176 // 타이틀에서 프리로드한 Niagara 에셋의 로드 핸들. 세션 동안 로드 상태를 유지한다.
177 TSharedPtr<FStreamableHandle> NiagaraPreloadHandle;
178
179private:
181};
ELevelStreamingPhase
Definition ELevelStreamingEnums.h:7
DECLARE_MULTICAST_DELEGATE(FOnLevelStreamingDataMapReady)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnPlacePlayerTheWorld, ULevelPlayerPlacer *, Placer, UWorld *, World)
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOnLevelLoadCompleted)
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnLevelLoadedInMemory, ULevelStreamingData *, StreamingData)
Definition StageFlowDefinition.h:27
Definition StreamingEventListenerInterface.h:23
DataBundle의 로드/언로드를 관리하는 GameInstance 서브시스템.
Definition DataBundleRegistry.h:42
Definition LevelPlayerPlacer.h:17
Definition LevelStreamingData.h:19
Definition LevelStreamingEffect.h:121
Definition LevelStreamingSubsystem.h:38
FORCEINLINE bool IsLevelLoadRequested() const
Definition LevelStreamingSubsystem.h:82
FORCEINLINE const UStageDictionary * GetStageDictionary() const
Definition LevelStreamingSubsystem.h:72
virtual FORCEINLINE TStatId GetStatId() const override
Definition LevelStreamingSubsystem.h:77
FORCEINLINE bool IsLaunchedFromPersistentLevel() const
Definition LevelStreamingSubsystem.h:67
FORCEINLINE bool IsInitialStageInitialized() const
Definition LevelStreamingSubsystem.h:87
Definition StageDictionary.h:14
레벨 스트리밍 이펙트 체인의 순차 실행을 담당합니다.
Definition LevelStreamingEffect.h:23
Definition LevelStreamingContext.h:16
Definition LevelStreamingStateMachine.h:11
Definition LevelStreamingSubsystem.h:134
FTSTicker::FDelegateHandle InitTickerHandle
Definition LevelStreamingSubsystem.h:147
TWeakObjectPtr< ULevelStreamingSubsystem > Owner
Definition LevelStreamingSubsystem.h:146
TWeakObjectPtr< UWorld > InitializedWorld
Definition LevelStreamingSubsystem.h:145
Definition LevelStreamingSubsystem.h:126