Skip to content
LeviMC
English
AutoLightDark
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 MCNAPI explicit VillageManager(::Dimension& dimension);
109
110 MCNAPI void _assignPOIOnly(::std::shared_ptr<::POIInstance>&& pi);
111
112 MCNAPI void _loadPOIBlueprints();
113
115
117
118 MCNAPI void _saveAllVillages(::LevelStorage& levelStorage);
119
120 MCAPI void _tryAssignPOIOrCreateVillage(::std::shared_ptr<::POIInstance>&& pi);
121
122 MCNAPI ::std::weak_ptr<::Village> fetchClosestVillageMostSuitableForDweller(
123 ::BlockPos const& position,
124 int maxDistFromVillageBounds,
125 uint searchRadius
126 ) const;
127
128 MCAPI ::std::weak_ptr<::Village> getClosestVillageWithRaid(::BlockPos const& pos);
129
130 MCNAPI void
132
133 MCNAPI bool isValidPOIType(::BlockPos const& pos, ::Block const& block) const;
134
135 MCNAPI void submitFindPOIQuery(::ActorUniqueID const& actorID);
136
137 MCNAPI void tick(::Tick const& tick);
138
139 MCAPI void tickVillages(::Tick const& tick, ::Vec3 const& position, ::BlockSource& region);
140 // NOLINTEND
141
142public:
143 // constructor thunks
144 // NOLINTBEGIN
145 MCNAPI void* $ctor(::Dimension& dimension);
146 // NOLINTEND
147
148public:
149 // virtual function thunks
150 // NOLINTBEGIN
151 MCNAPI ::std::weak_ptr<::Village>
152 $fetchClosestVillage(::BlockPos const& position, int maxDistFromVillageBounds, uint searchRadius) const;
153
154 MCNAPI ::std::weak_ptr<::Village> $getVillageByID(::mce::UUID const& villageID) const;
155
156
157 // NOLINTEND
158};
Definition BlockPos.h:14
Definition BlockSource.h:72
Definition Block.h:42
Definition Dimension.h:86
Definition ILevelStorageManagerConnector.h:13
Definition IVillageManager.h:15
Definition LevelStorage.h:26
Definition POIInstance.h:18
Definition Vec3.h:10
MCAPI void tick(::Tick const &tick)
MCAPI void _saveAllVillages(::LevelStorage &levelStorage)
MCAPI VillageManager(::Dimension &dimension)
MCAPI bool isValidPOIType(::BlockPos const &pos, ::Block const &block) const
MCAPI ::std::weak_ptr<::Village > $getVillageByID(::mce::UUID const &villageID) const
MCAPI ::std::weak_ptr<::Village > fetchClosestVillageMostSuitableForDweller(::BlockPos const &position, int maxDistFromVillageBounds, uint searchRadius) const
MCAPI ::std::weak_ptr<::Village > $fetchClosestVillage(::BlockPos const &position, int maxDistFromVillageBounds, uint searchRadius) const
MCAPI void _processNextUnclusteredPOIQuery()
MCAPI void * $ctor(::Dimension &dimension)
MCAPI void initializeWithLevelStorageManagerConnector(::ILevelStorageManagerConnector &levelStorageManagerConnector)
MCAPI void submitFindPOIQuery(::ActorUniqueID const &actorID)
MCAPI void _removeEligibleVillages()
MCAPI void _loadPOIBlueprints()
MCAPI void _assignPOIOnly(::std::shared_ptr<::POIInstance > &&pi)
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