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