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 "CK_UE.h"
7#include "Subsystems/GameInstanceSubsystem.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 void InitializeFromDataRegistry();
98
99 void EnterPreLoadingState();
100 void EnterDuringLoadState();
101 void EnterAwaitShownState();
102 void EnterIdleState();
103
104 bool HandleAsyncLoadCompleted();
105 void HandleDuringLoadChainCompleted();
106 void HandleLevelShown();
107 void HandleLevelHidden();
108
109 void StartChain(ELevelStreamingPhase Phase);
110 void NotifyLevelLoaded(ULevelStreamingData* StreamingData) const;
111 void PreloadNiagaraEffectsAsync(TWeakObjectPtr<ULevelStreamingData> RequestedStreamingData);
112 void ReleaseNiagaraEffectsPreload();
113 void ForEachSendStreamingEvent(const ULevel* LoadedLevel, const TFunctionRef<void(IStreamingEventListenerInterface&)>& Callback) const;
114
115public:
116 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
117 FOnLevelLoadCompleted OnLevelLoadCompleted;
118
119 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
120 FOnLevelLoadedInMemory OnLevelLoadedInMemory;
121
122 UPROPERTY(BlueprintAssignable, Category = "Level|Streaming")
123 FOnPlacePlayerTheWorld OnPlacePlayerTheWorld;
124
125private:
127 {
128 static ULevelStreaming* FindVisible(const UWorld* World);
129 static ULevelStreaming* FindByName(const UWorld* World, FName LevelName);
130 static void PrepareLevelForLoad(ULevelStreaming* StreamingLevel, bool bShouldBeLoaded);
131 static ULevelStreaming* ResolveTargetLevel(UObject* WorldContextObject, FName LevelName, bool& bOutAlreadyLoaded, bool& bOutSuccess);
132 };
133
135 {
136 void Initialize(ULevelStreamingSubsystem* InOwner);
137 void Reset();
138 void TryInitializeCurrentStage();
139 bool IsInitializedForCurrentWorld() const;
140
141 private:
142 ULevelStreamingData* ResolveCurrentStageDataFromWorld() const;
143 bool OnWaitForPlayTick(float DeltaTime);
144
145 private:
146 TWeakObjectPtr<UWorld> InitializedWorld;
147 TWeakObjectPtr<ULevelStreamingSubsystem> Owner;
148 FTSTicker::FDelegateHandle InitTickerHandle;
149 };
150
151private:
152 UPROPERTY(Transient)
153 TObjectPtr<UStageDictionary> CachedStageDictionary;
154
155 UPROPERTY(Transient)
156 TArray<TObjectPtr<ULevelStreamingEffect>> AllRegisteredEffects;
157
158 UPROPERTY(Transient)
159 TObjectPtr<ULevelStreamingData> LevelStreamingData;
160
161 UPROPERTY(Transient)
162 TObjectPtr<ULevelPlayerPlacer> ActivePlayerPlacer;
163
164 UPROPERTY(Transient)
165 TWeakObjectPtr<ULevelStreaming> LevelToLoad;
166
167 UPROPERTY(Transient)
168 TWeakObjectPtr<ULevelStreaming> LevelToUnload;
169
170 FEffectChainExecutor ChainExecutor;
171 FInitialStageBootstrapper InitialStageBootstrap;
172 FLevelStreamingStateMachine StreamingStateMachine;
173
174 // 타이틀에서 프리로드한 Niagara 에셋의 로드 핸들. 세션 동안 로드 상태를 유지한다.
175 TSharedPtr<FStreamableHandle> NiagaraPreloadHandle;
176
177private:
179};
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
Definition LevelPlayerPlacer.h:17
Definition LevelStreamingData.h:17
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:135
FTSTicker::FDelegateHandle InitTickerHandle
Definition LevelStreamingSubsystem.h:148
TWeakObjectPtr< ULevelStreamingSubsystem > Owner
Definition LevelStreamingSubsystem.h:147
TWeakObjectPtr< UWorld > InitializedWorld
Definition LevelStreamingSubsystem.h:146
Definition LevelStreamingSubsystem.h:127