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/WanderingTraderScheduler.h"
11#include "mc/world/level/BlockPos.h"
12#include "mc/world/level/Tick.h"
13#include "mc/world/level/block/BlockType.h"
14
15// auto generated forward declare list
16// clang-format off
17class Block;
18class BlockSource;
19class Dimension;
21class LevelStorage;
22class POIInstance;
23class Vec3;
24class Village;
25struct POIBlueprint;
26// clang-format on
27
28class VillageManager : public ::IVillageManager {
29public:
30 // VillageManager inner types declare
31 // clang-format off
32 struct VillageInfo;
34 // clang-format on
35
36 // VillageManager inner types define
37 enum class BedAvailabilityState : int {
38 Unknown = 0,
39 SomeAvailable = 1,
40 NoneAvailable = 2,
41 };
42
43 struct VillageInfo {
44 public:
45 // member variables
46 // NOLINTBEGIN
47 ::ll::TypedStorage<8, 16, ::std::shared_ptr<::Village>> village;
48 ::ll::TypedStorage<1, 1, bool> positionIsWithinVillageBounds;
49 ::ll::TypedStorage<4, 4, float> distanceToClosestEdgeOfVillage;
50 // NOLINTEND
51 };
52
54 public:
55 // member variables
56 // NOLINTBEGIN
57 ::ll::TypedStorage<4, 4, ::VillageManager::BedAvailabilityState> bedAvailability;
58 // NOLINTEND
59 };
60
61 using POIBlueprintMap = ::std::unordered_map<::BlockType const*, ::std::unique_ptr<::POIBlueprint>>;
62
63 using POIMap = ::std::unordered_map<::BlockPos, ::std::shared_ptr<::POIInstance>>;
64
65 using VillageMap = ::std::unordered_map<::mce::UUID, ::std::shared_ptr<::Village>>;
66
67public:
68 // member variables
69 // NOLINTBEGIN
70 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
71 ::ll::TypedStorage<8, 40, ::std::deque<::ActorUniqueID>> mFindPOIQueries;
72 ::ll::TypedStorage<8, 24, ::std::vector<::std::shared_ptr<::POIInstance>>> mUnclusteredPOIs;
73 ::ll::TypedStorage<8, 64, ::std::unordered_map<::mce::UUID, ::std::shared_ptr<::Village>>> mVillages;
74 ::ll::TypedStorage<8, 192, ::std::array<::std::unordered_map<::BlockPos, ::std::shared_ptr<::POIInstance>>, 3>>
75 mClusteredPOIs;
76 ::ll::TypedStorage<8, 64, ::std::unordered_map<::BlockType const*, ::std::unique_ptr<::POIBlueprint>>>
77 mPOIBlueprints;
78 ::ll::TypedStorage<8, 8, ::Tick> mTickCount;
79 ::ll::TypedStorage<8, 32, ::WanderingTraderScheduler> mWanderingTraderScheduler;
80 ::ll::TypedStorage<1, 1, bool> mFinishedQueryScan;
81 ::ll::TypedStorage<4, 4, int> mCurrentXScan;
82 ::ll::TypedStorage<4, 4, int> mCurrentYScan;
83 ::ll::TypedStorage<4, 4, int> mCurrentZScan;
84 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnSaveSubscription;
85 ::ll::TypedStorage<8, 16, ::Bedrock::PubSub::Subscription> mOnLevelStorageManagerStartLeaveGameSubscription;
86 // NOLINTEND
87
88public:
89 // prevent constructor by default
90 VillageManager& operator=(VillageManager const&);
91 VillageManager(VillageManager const&);
92 VillageManager();
93
94public:
95 // virtual functions
96 // NOLINTBEGIN
97 virtual ~VillageManager() /*override*/ = default;
98
99 virtual ::std::weak_ptr<::Village>
100 fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const /*override*/;
101
102 virtual ::std::weak_ptr<::Village> getVillageByID(::mce::UUID const& villageID) const /*override*/;
103 // NOLINTEND
104
105public:
106 // member functions
107 // NOLINTBEGIN
108 MCAPI explicit VillageManager(::Dimension& dimension);
109
110 MCAPI void _assignPOIOnly(::std::shared_ptr<::POIInstance>&& pi);
111
112#ifdef LL_PLAT_S
113 MCAPI void _clusterPOIs();
114#endif
115
116 MCAPI void _loadPOIBlueprints();
117
118 MCAPI void _processNextUnclusteredPOIQuery();
119
120 MCAPI void _removeEligibleVillages();
121
122 MCAPI void _saveAllVillages(::LevelStorage& levelStorage);
123
124 MCAPI void _tryAssignPOIOrCreateVillage(::std::shared_ptr<::POIInstance>&& pi);
125
126 MCAPI ::std::weak_ptr<::Village> fetchClosestVillageMostSuitableForDweller(
127 ::BlockPos const& position,
128 int maxDistFromVillageBounds,
129 uint searchRadius
130 ) const;
131
132 MCAPI ::std::weak_ptr<::Village> getClosestVillageWithRaid(::BlockPos const& pos);
133
134 MCAPI void
135 initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector& levelStorageManagerConnector);
136
137#ifdef LL_PLAT_S
138 MCAPI bool isValidPOIType(::BlockPos const& pos, ::Block const& block) const;
139#endif
140
141 MCAPI void submitFindPOIQuery(::ActorUniqueID const& actorID);
142
143#ifdef LL_PLAT_C
144 MCAPI void tick(::Tick const& tick);
145#endif
146
147 MCAPI void tickVillages(::Tick const& tick, ::Vec3 const& position, ::BlockSource& region);
148 // NOLINTEND
149
150public:
151 // constructor thunks
152 // NOLINTBEGIN
153 MCAPI void* $ctor(::Dimension& dimension);
154 // NOLINTEND
155
156public:
157 // virtual function thunks
158 // NOLINTBEGIN
159 MCAPI ::std::weak_ptr<::Village>
160 $fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const;
161
162 MCAPI ::std::weak_ptr<::Village> $getVillageByID(::mce::UUID const& villageID) const;
163
164
165 // NOLINTEND
166};
Definition BlockPos.h:17
Definition BlockSource.h:71
Definition Block.h:41
Definition Dimension.h:86
Definition ILevelStorageManagerConnector.h:13
Definition IVillageManager.h:15
Definition LevelStorage.h:25
Definition POIInstance.h:19
Definition Vec3.h:10
Definition Village.h:31
Definition UUID.h:8
Definition ActorUniqueID.h:5
Definition POIBlueprint.h:9
Definition Tick.h:5
Definition VillageManager.h:53
Definition VillageManager.h:43