LeviLamina
Loading...
Searching...
No Matches
ChunkSource.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/EnableNonOwnerReferences.h"
7#include "mc/deps/core/utility/buffer_span.h"
8#include "mc/deps/core/utility/pub_sub/Subscription.h"
9#include "mc/util/GridArea.h"
10#include "mc/world/level/chunk/ChunkSourceViewGenerateMode.h"
11#include "mc/world/level/chunk/ChunkState.h"
12#include "mc/world/level/chunk/LevelChunkGridAreaElement.h"
13
14// auto generated forward declare list
15// clang-format off
17class BlockSource;
18class BoundingBox;
19class ChunkKey;
20class ChunkPos;
21class ChunkViewSource;
22class Dimension;
24class Level;
25class LevelChunk;
28class LevelStorage;
29class Random;
32// clang-format on
33
35public:
36 // ChunkSource inner types define
37 enum class LoadMode : int {
38 None = 0,
39 Deferred = 1,
40 };
41
42public:
43 // member variables
44 // NOLINTBEGIN
45 ::ll::TypedStorage<4, 4, int> mChunkSide;
46 ::ll::TypedStorage<8, 8, ::Level*> mLevel;
47 ::ll::TypedStorage<8, 8, ::Dimension*> mDimension;
48 ::ll::TypedStorage<8, 8, ::ChunkSource*> mParent;
49 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::ChunkSource>> mOwnedParent;
50 ::ll::TypedStorage<8, 8, ::LevelChunkBuilderData*> mLevelChunkBuilderData;
51 ::ll::TypedStorage<1, 1, ::std::atomic<bool>> mShuttingDown;
52 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
53 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageAppSuspendSubscription;
54 // NOLINTEND
55
56public:
57 // prevent constructor by default
59
60public:
61 // virtual functions
62 // NOLINTBEGIN
63 // vIndex: 0
64 virtual ~ChunkSource() /*override*/;
65
66 // vIndex: 1
67 virtual void shutdown();
68
69 // vIndex: 2
70 virtual bool isShutdownDone();
71
72 // vIndex: 3
73 virtual ::std::shared_ptr<::LevelChunk> getExistingChunk(::ChunkPos const&);
74
75 // vIndex: 4
76 virtual ::std::shared_ptr<::LevelChunk> getRandomChunk(::Random& random);
77
78 // vIndex: 5
79 virtual bool isChunkKnown(::ChunkPos const& chunkPos);
80
81 // vIndex: 6
82 virtual bool isChunkSaved(::ChunkPos const& chunkPos);
83
84 // vIndex: 7
85 virtual ::std::shared_ptr<::LevelChunk>
86 createNewChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
87
88 // vIndex: 8
89 virtual ::std::shared_ptr<::LevelChunk>
90 getOrLoadChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
91
92 // vIndex: 9
93 virtual bool postProcess(::ChunkViewSource& neighborhood);
94
95 // vIndex: 10
96 virtual void checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
97
98 // vIndex: 11
99 virtual void loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
100
101 // vIndex: 13
102 virtual void postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random);
103
104 // vIndex: 12
105 virtual void postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const;
106
107 // vIndex: 14
108 virtual bool saveLiveChunk(::LevelChunk& lc);
109
110 // vIndex: 15
111 virtual void writeEntityChunkTransfer(::LevelChunk& levelChunk);
112
113 // vIndex: 16
114 virtual void writeEntityChunkTransfersToUnloadedChunk(
115 ::ChunkKey const& chunkKey,
116 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
117 );
118
119 // vIndex: 17
120 virtual void deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
121
122 // vIndex: 18
123 virtual void hintDiscardBatchBegin();
124
125 // vIndex: 19
126 virtual void hintDiscardBatchEnd();
127
128 // vIndex: 20
129 virtual void acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
130
131 // vIndex: 21
132 virtual void compact();
133
134 // vIndex: 22
135 virtual void flushPendingDiscardedChunkWrites();
136
137 // vIndex: 23
138 virtual void flushThreadBatch();
139
140 // vIndex: 24
141 virtual bool isWithinWorldLimit(::ChunkPos const& cp) const;
142
143 // vIndex: 25
144 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const* getChunkMap();
145
146 // vIndex: 26
147 virtual ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const& getStorage() const;
148
149 // vIndex: 27
150 virtual void clearDeletedEntities();
151
152 // vIndex: 28
153 virtual bool canCreateViews() const;
154
155 // vIndex: 29
156 virtual ::std::unique_ptr<::BlendingDataProvider> tryGetBlendingDataProvider();
157
158 // vIndex: 30
159 virtual ::std::shared_ptr<::LevelChunkMetaDataDictionary> loadLevelChunkMetaDataDictionary();
160
161 // vIndex: 31
162 virtual void setLevelChunk(::std::shared_ptr<::LevelChunk>);
163
164 // vIndex: 32
165 virtual bool canLaunchTasks() const;
166
167 // vIndex: 33
168 virtual bool chunkPosNeedsBlending(::ChunkPos const& cp);
169 // NOLINTEND
170
171public:
172 // member functions
173 // NOLINTBEGIN
174 MCAPI explicit ChunkSource(::std::unique_ptr<::ChunkSource> parent);
175
176 MCAPI bool _checkAndDispatchTaskForLevelChunk(
177 ::std::pair<::ChunkPos, ::ChunkState> const& chunkPosAndExpectedState,
178 bool areInTask
179 );
180
181 MCAPI void _checkForReplacementDataTask(::LevelChunk& lc, ::ChunkViewSource& chunks);
182
183 MCAPI void _checkForUnblockingChunks(::LevelChunk const& lc);
184
185 MCAPI void _checkLevelChunkForNextStage(
186 ::LevelChunk const& lc,
187 ::LevelChunkGridAreaElement<::std::weak_ptr<::LevelChunk>>& grid,
188 ::ChunkState stateToCheck
189 );
190
191 MCAPI void _checkLevelChunkForPostProcessing(
192 ::LevelChunk const& lc,
193 ::LevelChunkGridAreaElement<::std::weak_ptr<::LevelChunk>>& grid
194 );
195
196 MCAPI bool _chunkAtStage(::std::weak_ptr<::LevelChunk> lcwp, ::ChunkState stateToCheck);
197
198 MCAPI void _createOrReplaceGridAreaMap(::std::shared_ptr<::LevelChunk> lc, bool createNeighbourGridsIfMissing);
199
200 MCAPI void _freeChunkGenerationGridMap(::ChunkPos const& cp, bool isLevelChunkDeletion);
201
202 MCAPI void _launchGenerationTask(::std::shared_ptr<::LevelChunk> const& lc, bool areInTask);
203
204 MCAPI void _launchLightingTask(
205 ::std::shared_ptr<::LevelChunk> const& lc,
206 ::std::shared_ptr<::ChunkViewSource> const& chunks,
207 bool areInTask
208 );
209
210 MCAPI void _launchPostProcessingTask(
211 ::std::shared_ptr<::LevelChunk> const& lc,
212 ::std::shared_ptr<::ChunkViewSource> const& chunks,
213 bool areInTask
214 );
215
216 MCAPI void _launchReplacementDataTask(
217 ::std::shared_ptr<::LevelChunk> const& lc,
218 ::std::shared_ptr<::ChunkViewSource> const& chunks,
219 bool areInTask
220 );
221
222 MCAPI void _lightingTask(::std::shared_ptr<::LevelChunk> const& lc, ::ChunkViewSource& chunks);
223
224 MCAPI void _loadChunkTask(::LevelChunk& lc);
225
226 MCAPI void _postProcessingTask(::LevelChunk& lc, ::ChunkViewSource& chunks);
227
228 MCAPI void _saveDirtyChunks(::LevelStorage&);
229
230 MCAPI void _spawnChunkGenerationTasks(int numTasks, bool calledFromTask);
231
232 MCAPI void checkAndLaunchChunkGenerationTasks(bool calledFromTask);
233
234 MCAPI ::GridArea<::std::shared_ptr<::LevelChunk>> createEmptyView(
235 ::ChunkSource::LoadMode lm,
236 bool circle,
237 ::std::function<void(::buffer_span_mut<::std::shared_ptr<::LevelChunk>>, ::buffer_span<uint>)> add,
238 ::ChunkSourceViewGenerateMode chunkViewGenerateMode,
239 float const* serverBuildRatio
240 );
241
242 MCAPI ::std::shared_ptr<::LevelChunk> getAvailableChunk(::ChunkPos const& cp);
243
244 MCAPI void
245 initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector& levelStorageManagerConnector);
246
247 MCAPI bool shouldServerGeneratePos(::ChunkPos const& chunkPos, float serverBuildRatio, int viewRadius);
248 // NOLINTEND
249
250public:
251 // static variables
252 // NOLINTBEGIN
253 MCAPI static bool& gPerfIsClientSide();
254 // NOLINTEND
255
256public:
257 // constructor thunks
258 // NOLINTBEGIN
259 MCAPI void* $ctor(::std::unique_ptr<::ChunkSource> parent);
260 // NOLINTEND
261
262public:
263 // destructor thunk
264 // NOLINTBEGIN
265 MCAPI void $dtor();
266 // NOLINTEND
267
268public:
269 // virtual function thunks
270 // NOLINTBEGIN
271 MCAPI void $shutdown();
272
273 MCAPI bool $isShutdownDone();
274
275 MCFOLD ::std::shared_ptr<::LevelChunk> $getExistingChunk(::ChunkPos const&);
276
277 MCFOLD ::std::shared_ptr<::LevelChunk> $getRandomChunk(::Random& random);
278
279 MCAPI bool $isChunkKnown(::ChunkPos const& chunkPos);
280
281 MCAPI bool $isChunkSaved(::ChunkPos const& chunkPos);
282
283 MCAPI ::std::shared_ptr<::LevelChunk>
284 $createNewChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
285
286 MCAPI ::std::shared_ptr<::LevelChunk>
287 $getOrLoadChunk(::ChunkPos const& cp, ::ChunkSource::LoadMode lm, bool readOnly);
288
289 MCFOLD bool $postProcess(::ChunkViewSource& neighborhood);
290
291 MCFOLD void $checkAndReplaceChunk(::ChunkViewSource& neighborhood, ::LevelChunk& lc);
292
293 MCAPI void $loadChunk(::LevelChunk& lc, bool forceImmediateReplacementDataLoad);
294
295 MCAPI void $postProcessMobsAt(::BlockSource& region, int chunkWestBlock, int chunkNorthBlock, ::Random& random);
296
297 MCAPI void $postProcessMobsAt(::BlockSource& region, ::BoundingBox const& chunkBB) const;
298
299 MCAPI bool $saveLiveChunk(::LevelChunk& lc);
300
301 MCAPI void $writeEntityChunkTransfer(::LevelChunk& levelChunk);
302
303 MCAPI void $writeEntityChunkTransfersToUnloadedChunk(
304 ::ChunkKey const& chunkKey,
305 ::std::vector<::ActorUnloadedChunkTransferEntry> const& transfers
306 );
307
308 MCAPI void $deserializeActorStorageToLevelChunk(::LevelChunk& levelChunk);
309
310 MCAPI void $hintDiscardBatchBegin();
311
312 MCAPI void $hintDiscardBatchEnd();
313
314 MCAPI void $acquireDiscarded(::std::unique_ptr<::LevelChunk, ::LevelChunkFinalDeleter> ptr);
315
316 MCAPI void $compact();
317
318 MCAPI void $flushPendingDiscardedChunkWrites();
319
320 MCAPI void $flushThreadBatch();
321
322 MCFOLD bool $isWithinWorldLimit(::ChunkPos const& cp) const;
323
324 MCFOLD ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const* $getChunkMap();
325
326 MCAPI ::std::unordered_map<::ChunkPos, ::std::weak_ptr<::LevelChunk>> const& $getStorage() const;
327
328 MCFOLD void $clearDeletedEntities();
329
330 MCFOLD bool $canCreateViews() const;
331
332 MCAPI ::std::unique_ptr<::BlendingDataProvider> $tryGetBlendingDataProvider();
333
334 MCAPI ::std::shared_ptr<::LevelChunkMetaDataDictionary> $loadLevelChunkMetaDataDictionary();
335
336 MCFOLD void $setLevelChunk(::std::shared_ptr<::LevelChunk>);
337
338 MCAPI bool $canLaunchTasks() const;
339
340 MCAPI bool $chunkPosNeedsBlending(::ChunkPos const& cp);
341 // NOLINTEND
342
343public:
344 // vftables
345 // NOLINTBEGIN
346 MCNAPI static void** $vftable();
347 // NOLINTEND
348};
Definition EnableNonOwnerReferences.h:7
Definition BlendingDataProvider.h:5
Definition BlockSource.h:67
Definition BoundingBox.h:13
Definition ChunkKey.h:14
Definition ChunkPos.h:11
Definition ChunkSource.h:34
static MCAPI void ** $vftable()
Definition ChunkViewSource.h:22
Definition Dimension.h:83
Definition ILevelStorageManagerConnector.h:13
Definition LevelChunkBuilderData.h:16
Definition LevelChunkGridAreaElement.h:6
Definition LevelChunkMetaDataDictionary.h:11
Definition LevelChunk.h:74
Definition LevelStorage.h:25
Definition Level.h:238
Definition Random.h:11
Definition _HeaderOutputPredefine.h:189
Definition buffer_span.h:6
Definition ActorUnloadedChunkTransferEntry.h:13
Definition LevelChunkFinalDeleter.h:5