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