LeviLamina
Loading...
Searching...
No Matches
VillageManager.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/utility/pub_sub/Subscription.h"
7#include "mc/legacy/ActorUniqueID.h"
8#include "mc/platform/UUID.h"
9#include "mc/world/actor/ai/village/IVillageManager.h"
10#include "mc/world/actor/ai/village/POIType.h"
11#include "mc/world/actor/ai/village/WanderingTraderScheduler.h"
12#include "mc/world/level/BlockPos.h"
13#include "mc/world/level/Tick.h"
14#include "mc/world/level/block/BlockType.h"
15
16// auto generated forward declare list
17// clang-format off
18class Actor;
19class Block;
20class BlockSource;
21class Dimension;
22class HashedString;
24class LevelStorage;
25class POIInstance;
26class Vec3;
27class Village;
28struct POIBlueprint;
29// clang-format on
30
31class VillageManager : public ::IVillageManager {
32public:
33 // VillageManager inner types declare
34 // clang-format off
35 struct VillageInfo;
37 // clang-format on
38
39 // VillageManager inner types define
40 enum class BedAvailabilityState : int {
41 Unknown = 0,
42 SomeAvailable = 1,
43 NoneAvailable = 2,
44 };
45
46 struct VillageInfo {
47 public:
48 // member variables
49 // NOLINTBEGIN
50 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Village>> village;
51 ::ll::TypedStorage<1, 1, bool> positionIsWithinVillageBounds;
52 ::ll::TypedStorage<4, 4, float> distanceToClosestEdgeOfVillage;
53 // NOLINTEND
54
55 public:
56 // member functions
57 // NOLINTBEGIN
58 MCAPI ~VillageInfo();
59 // NOLINTEND
60
61 public:
62 // destructor thunk
63 // NOLINTBEGIN
64 MCFOLD void $dtor();
65 // NOLINTEND
66 };
67
69 public:
70 // member variables
71 // NOLINTBEGIN
72 ::ll::TypedStorage<4, 4, ::VillageManager::BedAvailabilityState> bedAvailability;
73 // NOLINTEND
74 };
75
76 using POIBlueprintMap = ::std::unordered_map<::BlockType const*, ::std::unique_ptr<::POIBlueprint>>;
77
78 using POIMap = ::std::unordered_map<::BlockPos, ::std::shared_ptr<::POIInstance>>;
79
80 using VillageMap = ::std::unordered_map<::mce::UUID, ::std::shared_ptr<::Village>>;
81
82public:
83 // member variables
84 // NOLINTBEGIN
85 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
86 ::ll::TypedStorage<8, 40, ::std::deque<::ActorUniqueID>> mFindPOIQueries;
87 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::POIInstance>>> mUnclusteredPOIs;
88 ::ll::TypedStorage<8, 64, ::std::unordered_map<::mce::UUID, ::std::shared_ptr<::Village>>> mVillages;
89 ::ll::TypedStorage<8, 192, ::std::array<::std::unordered_map<::BlockPos, ::std::shared_ptr<::POIInstance>>, 3>>
90 mClusteredPOIs;
91 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BlockType const*, ::std::unique_ptr<::POIBlueprint>>>
92 mPOIBlueprints;
93 ::ll::TypedStorage<8, 8, ::Tick> mTickCount;
94 ::ll::TypedStorage<8, 32, ::WanderingTraderScheduler> mWanderingTraderScheduler;
95 ::ll::TypedStorage<1, 1, bool> mFinishedQueryScan;
96 ::ll::TypedStorage<4, 4, int> mCurrentXScan;
97 ::ll::TypedStorage<4, 4, int> mCurrentYScan;
98 ::ll::TypedStorage<4, 4, int> mCurrentZScan;
99 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
100 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageManagerStartLeaveGameSubscription;
101 // NOLINTEND
102
103public:
104 // prevent constructor by default
105 VillageManager& operator=(VillageManager const&);
106 VillageManager(VillageManager const&);
107 VillageManager();
108
109public:
110 // virtual functions
111 // NOLINTBEGIN
112 virtual ~VillageManager() /*override*/;
113
114 virtual ::std::weak_ptr<::Village>
115 fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const /*override*/;
116
117 virtual ::std::weak_ptr<::Village> getVillageByID(::mce::UUID const& villageID) const /*override*/;
118 // NOLINTEND
119
120public:
121 // member functions
122 // NOLINTBEGIN
123 MCAPI explicit VillageManager(::Dimension& dimension);
124
125 MCAPI void _addPOIWithinRadius(::BlockPos const& pos, ::BlockSource& region);
126
127 MCAPI void _assignPOIOnly(::std::shared_ptr<::POIInstance>&& pi);
128
129 MCAPI float
130 _calculateDistanceFromPositionToEdgeOfVillage(::BlockPos const& position, ::Village const& village) const;
131
132 MCAPI ::std::shared_ptr<::Village> _createOrGetVillage(::mce::UUID const& id, ::BlockPos const& newVillagePos);
133
134 MCAPI void _loadPOIBlueprints();
135
136 MCAPI void _processNextUnclusteredPOIQuery();
137
138 MCAPI void _removeEligibleVillages();
139
140 MCAPI void _removeVillage(::Village& village);
141
142 MCAPI void _saveAllVillages(::LevelStorage& levelStorage);
143
144 MCAPI void _tryAssignPOIOrCreateVillage(::std::shared_ptr<::POIInstance>&& pi);
145
146 MCAPI void _unclusterDerelictPOIs(::std::vector<::std::weak_ptr<::POIInstance>>& pois);
147
148 MCAPI ::std::weak_ptr<::Village> fetchClosestVillageMostSuitableForDweller(
149 ::BlockPos const& position,
150 int maxDistFromVillageBounds,
151 uint searchRadius
152 ) const;
153
154 MCAPI ::std::weak_ptr<::Village> getClosestVillageWithRaid(::BlockPos const& pos);
155
156 MCAPI ::HashedString const& getPOINameFromBlueprint(::Block const& block) const;
157
158 MCAPI ::POIType getPOITypeFromBlueprint(::Block const& block) const;
159
160 MCAPI bool hasPOI(::BlockPos const& position, ::POIType type) const;
161
162 MCAPI void
163 initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector& levelStorageManagerConnector);
164
165 MCAPI bool isWanderingTraderManagedByScheduler(::Actor const& actor);
166
167 MCAPI void loadAllVillages();
168
169 MCAPI void submitFindPOIQuery(::ActorUniqueID const& actorID);
170
171 MCAPI void tick(::Tick const& tick);
172
173 MCAPI void tickVillages(::Tick const& tick, ::Vec3 const& position, ::BlockSource& region);
174
175 MCAPI ::std::shared_ptr<::POIInstance> tryCreatePOI(::BlockPos const& position, ::Block const& block);
176 // NOLINTEND
177
178public:
179 // static functions
180 // NOLINTBEGIN
181 MCAPI static bool shouldCreateNewVillageUsingPOI(
182 ::std::shared_ptr<::POIInstance> const& poi,
183 ::std::shared_ptr<::Village> const& nearestExistingVillage
184 );
185 // NOLINTEND
186
187public:
188 // static variables
189 // NOLINTBEGIN
190 MCAPI static int const& MAX_POI_TOLERANCE_DIST();
191 // NOLINTEND
192
193public:
194 // constructor thunks
195 // NOLINTBEGIN
196 MCAPI void* $ctor(::Dimension& dimension);
197 // NOLINTEND
198
199public:
200 // destructor thunk
201 // NOLINTBEGIN
202 MCAPI void $dtor();
203 // NOLINTEND
204
205public:
206 // virtual function thunks
207 // NOLINTBEGIN
208 MCAPI ::std::weak_ptr<::Village>
209 $fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const;
210
211 MCAPI ::std::weak_ptr<::Village> $getVillageByID(::mce::UUID const& villageID) const;
212
213
214 // NOLINTEND
215
216public:
217 // vftables
218 // NOLINTBEGIN
219 MCAPI static void** $vftable();
220 // NOLINTEND
221};
Definition Actor.h:125
static MCAPI void ** $vftable()
Definition BlockPos.h:21
Definition BlockSource.h:73
Definition Block.h:69
Definition Dimension.h:89
Definition HashedString.h:5
Definition ILevelStorageManagerConnector.h:13
Definition IVillageManager.h:15
Definition LevelStorage.h:26
Definition POIInstance.h:19
Definition Vec3.h:10
Definition Village.h:34
Definition UUID.h:7
Definition ActorUniqueID.h:10
Definition POIBlueprint.h:9
Definition Tick.h:5
Definition VillageManager.h:68
Definition VillageManager.h:46