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