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 BlockPos;
17class BlockSource;
18class BlockType;
19class Dimension;
20class HashedString;
22class LevelStorage;
23class POIInstance;
24class Village;
25struct EffectDuration;
26struct POIBlueprint;
27namespace mce { class UUID; }
28// clang-format on
29
30class VillageManager : public ::IVillageManager {
31public:
32 // VillageManager inner types declare
33 // clang-format off
34 struct VillageInfo;
36 // clang-format on
37
38 // VillageManager inner types define
39 enum class BedAvailabilityState : int {
40 Unknown = 0,
41 SomeAvailable = 1,
42 NoneAvailable = 2,
43 };
44
45 struct VillageInfo {
46 public:
47 // member variables
48 // NOLINTBEGIN
49 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Village>> village;
50 ::ll::TypedStorage<1, 1, bool> positionIsWithinVillageBounds;
51 ::ll::TypedStorage<4, 4, float> distanceToClosestEdgeOfVillage;
52 // NOLINTEND
53 };
54
56 public:
57 // member variables
58 // NOLINTBEGIN
59 ::ll::TypedStorage<4, 4, ::VillageManager::BedAvailabilityState> bedAvailability;
60 // NOLINTEND
61
62 public:
63 // member functions
64 // NOLINTBEGIN
66 // NOLINTEND
67
68 public:
69 // destructor thunk
70 // NOLINTBEGIN
71 MCFOLD void $dtor();
72 // NOLINTEND
73 };
74
75 using POIBlueprintMap = ::std::unordered_map<::BlockType const*, ::std::unique_ptr<::POIBlueprint>>;
76
77 using POIMap = ::std::unordered_map<::BlockPos, ::std::shared_ptr<::POIInstance>>;
78
79 using VillageMap = ::std::unordered_map<::mce::UUID, ::std::shared_ptr<::Village>>;
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<::BlockType 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&);
105 VillageManager(VillageManager const&);
106 VillageManager();
107
108public:
109 // virtual functions
110 // NOLINTBEGIN
111 virtual ~VillageManager() /*override*/ = default;
112
113 virtual ::std::weak_ptr<::Village>
114 fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const /*override*/;
115
116 virtual ::std::weak_ptr<::Village> getVillageByID(::mce::UUID const& villageID) const /*override*/;
117 // NOLINTEND
118
119public:
120 // member functions
121 // NOLINTBEGIN
122 MCAPI explicit VillageManager(::Dimension& dimension);
123
124 MCAPI void _addPOIWithinRadius(::BlockPos const& pos, ::BlockSource& region);
125
126 MCAPI void _assignPOIOnly(::std::shared_ptr<::POIInstance>&& pi);
127
128 MCAPI float
129 _calculateDistanceFromPositionToEdgeOfVillage(::BlockPos const& position, ::Village const& village) const;
130
131 MCAPI ::std::shared_ptr<::Village> _createOrGetVillage(::mce::UUID const& id, ::BlockPos const& newVillagePos);
132
133 MCAPI ::std::unordered_map<::Village const*, ::VillageManager::BedAvailabilityState>
134 _getVillageWithBedsAvailableMap() const;
135
136 MCAPI void _loadPOIBlueprints();
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 ::std::weak_ptr<::POIInstance> getPOI(::BlockPos const& position) const;
157
158 MCAPI ::HashedString getPOIInitEventFromName(::HashedString const& name) const;
159
160 MCAPI bool hasPOI(::BlockPos const& position, ::POIType type) const;
161
162 MCAPI void
163 initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector& levelStorageManagerConnector);
164
165 MCAPI void insertPOI(::std::shared_ptr<::POIInstance>&& poi);
166
167 MCAPI bool isValidPOIType(::BlockPos const& pos, ::Block const& block) const;
168
169 MCAPI void removePOI(::std::weak_ptr<::POIInstance> poi);
170
171 MCAPI void tick(::Tick const& tick);
172
173 MCAPI ::std::shared_ptr<::POIInstance> tryCreatePOI(::BlockPos const& position, ::Block const& block);
174 // NOLINTEND
175
176public:
177 // static variables
178 // NOLINTBEGIN
179 MCAPI static int const& MAX_POI_TOLERANCE_DIST();
180
181 MCAPI static ::EffectDuration const& VILLAGE_HERO_EFFECT_DURATION();
182 // NOLINTEND
183
184public:
185 // constructor thunks
186 // NOLINTBEGIN
187 MCAPI void* $ctor(::Dimension& dimension);
188 // NOLINTEND
189
190public:
191 // virtual function thunks
192 // NOLINTBEGIN
193 MCAPI ::std::weak_ptr<::Village>
194 $fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const;
195
196 MCAPI ::std::weak_ptr<::Village> $getVillageByID(::mce::UUID const& villageID) const;
197
198
199 // NOLINTEND
200
201public:
202 // vftables
203 // NOLINTBEGIN
204 MCAPI static void** $vftable();
205 // NOLINTEND
206};
static MCAPI void ** $vftable()
Definition BlockPos.h:19
Definition BlockSource.h:68
Definition BlockType.h:84
Definition Block.h:43
Definition Dimension.h:85
Definition HashedString.h:5
Definition ILevelStorageManagerConnector.h:13
Definition IVillageManager.h:15
Definition LevelStorage.h:25
Definition POIInstance.h:19
Definition Village.h:33
Definition UUID.h:7
Definition EffectDuration.h:5
Definition POIBlueprint.h:9
Definition Tick.h:5
Definition VillageManager.h:55
Definition VillageManager.h:45