LeviLamina
Loading...
Searching...
No Matches
Village.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4
5// auto generated inclusion list
6#include "mc/deps/core/string/HashedString.h"
7#include "mc/deps/shared_types/legacy/LevelSoundEvent.h"
8#include "mc/entity/components_json_legacy/DwellerRole.h"
9#include "mc/legacy/ActorUniqueID.h"
10#include "mc/platform/UUID.h"
11#include "mc/world/actor/ai/village/POIType.h"
12#include "mc/world/level/BlockPos.h"
13#include "mc/world/level/Tick.h"
14#include "mc/world/phys/AABB.h"
15
16// auto generated forward declare list
17// clang-format off
18class Actor;
19class Block;
20class BlockSource;
21class CompoundTag;
22class Dimension;
23class Level;
24class LevelStorage;
25class Mob;
26class POIInstance;
27class Raid;
28class Random;
29class Vec3;
30class VillageManager;
31// clang-format on
32
33class Village {
34public:
35 // Village inner types declare
36 // clang-format off
37 struct DwellerData;
38 struct StandingModifiers;
39 // clang-format on
40
41 // Village inner types define
42 enum class VillageVersion : uchar {
43 Base = 0,
44 WorksiteInitEventFix = 1,
45 Count = 2,
46 };
47
48 struct DwellerData {
49 public:
50 // member variables
51 // NOLINTBEGIN
52 ::ll::TypedStorage<8, 8, ::Tick> mLastTicked;
53 ::ll::TypedStorage<4, 12, ::BlockPos> mLastSavedPosition;
54 // NOLINTEND
55 };
56
58 public:
59 // static variables
60 // NOLINTBEGIN
61 MCAPI static int const& GOLEM_DEATH_PENALTY();
62
63 MCAPI static int const& LARGE_PENALTY();
64
65 MCAPI static int const& LARGE_REWARD();
66
67 MCAPI static int const& MEDIUM_PENALTY();
68
69 MCAPI static int const& SMALL_PENALTY();
70
71 MCAPI static int const& SMALL_REWARD();
72 // NOLINTEND
73 };
74
75 using ClaimedPOIList = ::std::unordered_map<::ActorUniqueID, ::std::array<::std::weak_ptr<::POIInstance>, 3>>;
76
77 using DwellerMap = ::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>;
78
79 using DwellerTimestamp = ::std::pair<::ActorUniqueID, ::Tick>;
80
81 using UnclaimedPOIList = ::std::array<::std::vector<::std::weak_ptr<::POIInstance>>, 3>;
82
83public:
84 // member variables
85 // NOLINTBEGIN
86 ::ll::TypedStorage<8, 16, ::mce::UUID> mUniqueID;
87 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
88 ::ll::TypedStorage<8, 72, ::std::array<::std::vector<::std::weak_ptr<::POIInstance>>, 3>> mUnclaimedPOIStacks;
89 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, ::std::array<::std::weak_ptr<::POIInstance>, 3>>>
90 mClaimedPOIs;
91 ::ll::TypedStorage<8, 256, ::std::array<::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>, 4>>
92 mDwellers;
93 ::ll::TypedStorage<4, 24, ::AABB> mBounds;
94 ::ll::TypedStorage<4, 24, ::AABB> mStaticRaidBounds;
95 ::ll::TypedStorage<1, 1, uchar> mVillageVersion;
96 ::ll::TypedStorage<8, 8, ::Tick> mGameTick;
97 ::ll::TypedStorage<8, 8, ::Tick> mSaveTick;
98 ::ll::TypedStorage<8, 8, ::Tick> mRingTick;
99 ::ll::TypedStorage<8, 8, ::Tick> mNoBreedTimer;
100 ::ll::TypedStorage<8, 8, ::Tick> mBadStandingDecayTimer;
101 ::ll::TypedStorage<8, 8, ::Tick> mGoodStandingDecayTimer;
102 ::ll::TypedStorage<8, 8, ::Tick> mPassiveDwellerSpawnTimer;
103 ::ll::TypedStorage<4, 4, int> mInitializationTimer;
104 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, int>> mPlayerStanding;
105 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>> mAggressors;
106 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::ActorUniqueID, ::Tick>>> mVillagerWorkTimestamps;
107 ::ll::TypedStorage<1, 1, bool> mVillageInitialized;
108 ::ll::TypedStorage<8, 48, ::HashedString const> mNitwitFamily;
109 ::ll::TypedStorage<8, 48, ::HashedString const> mVillagePrefix;
110 ::ll::TypedStorage<8, 48, ::HashedString const> mVillagePrefixOld;
111 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Raid>> mRaid;
112 ::ll::TypedStorage<8, 64, ::std::unordered_set<::ActorUniqueID>> mSoundTheAlarmPlayerList;
113 // NOLINTEND
114
115public:
116 // prevent constructor by default
117 Village& operator=(Village const&);
118 Village(Village const&);
119 Village();
120
121public:
122 // member functions
123 // NOLINTBEGIN
124 MCAPI Village(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
125
126 MCAPI void _calcPOIDist();
127
128 MCAPI void _claimUnclaimedPOIs();
129
130 MCAPI void _clearVillagerPOIs(::ActorUniqueID const& villager);
131
132 MCAPI void _createRaid();
133
134 MCAPI void _deleteOldDataIfNeeded(::LevelStorage& levelStorage, ::std::string const& key) const;
135
136 MCAPI bool _findAvailablePOI(uint64 index, ::Level& level, ::Random& random, ::ActorUniqueID id);
137
138 MCAPI bool _findPlayerCentricSpawnPointForRaid(::Vec3& outSpawnPoint, bool snapToSurface) const;
139
140 MCAPI bool _findSpawnPointForRaid(
141 ::Vec3& outSpawnPoint,
142 float distanceTolerance,
143 float boundsScaling,
144 bool snapToSurface,
145 bool outsideOfVillage
146 ) const;
147
148 MCAPI ::BlockSource*
149 _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool& outHasSpawnAreaLoaded) const;
150
151 MCAPI void _findWeightedPOI(
152 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
153 ::Random& random,
155 );
156
157 MCAPI void _helpLocateRaiders(::Raid const& raid);
158
159 MCAPI void _loadVillageData(::CompoundTag const& tag);
160
161 MCAPI void _loadVillageDwellers(::CompoundTag const& tag);
162
163 MCAPI void _loadVillagePOIs(::CompoundTag const& tag);
164
165 MCAPI void _playSoundFrom(::Vec3 const& soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound);
166
167 MCAPI void _readyRaidGroup(::std::unordered_set<::ActorUniqueID>& spawnedMobs);
168
169 MCAPI void _ringBells(::BlockSource& region, ::Random& random) const;
170
171 MCAPI void _saveVillageData(::LevelStorage& levelStorage) const;
172
173 MCAPI void _saveVillageDwellers(::LevelStorage& levelStorage) const;
174
175 MCAPI void _saveVillagePOIs(::LevelStorage& levelStorage) const;
176
177 MCAPI void _saveVillagePOIsToTag(::CompoundTag& tag) const;
178
179 MCAPI void _saveVillagePlayerStanding(::LevelStorage& levelStorage) const;
180
181 MCAPI void _saveVillageRaid(::LevelStorage& levelStorage) const;
182
183 MCAPI void _spawnPassiveDwellers(::BlockSource& region, int);
184
185 MCAPI bool
186 _spawnRaidGroup(::Vec3 spawnPosition, uchar groupNumber, ::std::unordered_set<::ActorUniqueID>& spawnedMobs) const;
187
188 MCAPI void _tryAddPoiToVillage(::ActorUniqueID const& villager, ::std::weak_ptr<::POIInstance> pi);
189
190 MCAPI void _tryShiftStandingsTowardNeutral(::Tick& updateTick, uint64 updateInterval, bool positiveShift);
191
192 MCAPI void _trySpawnDefenderDwellers(::BlockSource& region, uint64 bedCount);
193
194 MCAPI void _updateAndRemoveInactiveDwellers(uint64 villagerPurgeTime, float villageBorderTolerance);
195
196 MCAPI void _updateClaimedPOIs(::BlockSource& region);
197
198 MCAPI void _updateUnclaimedPOIs(::BlockSource& region);
199
200 MCAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const& actorID);
201
202 MCAPI void addAggressor(::Mob const& mob);
203
204 MCAPI bool addPOI(::std::weak_ptr<::POIInstance> pi);
205
206 MCAPI void addVillager(::ActorUniqueID const& villagerID);
207
208 MCAPI bool checkNeedMoreVillagers() const;
209
210 MCAPI void debugDraw();
211
212 MCAPI ::std::weak_ptr<::POIInstance> fetchOwnedPOI(::ActorUniqueID const& id, ::POIType type);
213
214 MCAPI uint64 getBedPOICount() const;
215
216 MCAPI ::std::weak_ptr<::POIInstance> getClosestPOI(::POIType type, ::BlockPos const& position);
217
218 MCAPI bool hasInvalidRole(::ActorUniqueID const& actorId, ::DwellerRole const& role);
219
220 MCAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const& id) const;
221
222 MCAPI void loadDataByKey(::std::string const& key, ::CompoundTag const& tag);
223
224 MCAPI int modifyStanding(::ActorUniqueID const& playerID, int delta);
225
226 MCAPI ::std::_List_iterator<
227 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
228 removeActorFromVillage(::DwellerRole role, ::ActorUniqueID const& actor);
229
230 MCAPI void removeAllInstancesofActorFromVillage(::ActorUniqueID const& actor);
231
232 MCAPI void removeVillageSavedData();
233
234 MCAPI void rewardAllPlayers(int deltaAmount);
235
236 MCAPI void tick(::Tick tick, ::BlockSource& region);
237
238 MCAPI void tickRaid(::Tick gameTick);
239
240 MCAPI void triggerRaid();
241
242 MCAPI void unlinkMismatchedJobsites(::Actor const& villager);
243
244 MCAPI bool villagerLivesHere(::ActorUniqueID const& villager) const;
245
246 MCAPI ~Village();
247 // NOLINTEND
248
249public:
250 // static functions
251 // NOLINTBEGIN
252 MCAPI static ::std::shared_ptr<::POIInstance> _findPreferredPOI(
253 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
254 ::HashedString const& preferredPOI
255 );
256
257 MCAPI static bool isVillagePOI(::VillageManager const& villageManager, ::Block const& block);
258 // NOLINTEND
259
260public:
261 // static variables
262 // NOLINTBEGIN
263 MCAPI static ::std::string const& CELEBRATION_EVENT();
264
265 MCAPI static bool& DEBUG_DRAWING();
266
267 MCAPI static ::Vec3 const& RAID_BOUNDS_PADDING();
268
269 MCAPI static ::std::string const& RAID_EXPIRY_EVENT();
270
271 MCAPI static int const& RAID_FINISHED_DELAY_IN_TICKS();
272
273 MCAPI static int const& RAID_GROUP_COMPLETE_DELAY_IN_TICKS();
274
275 MCAPI static int const& RAID_LOCATION_HELP_DELAY_IN_TICKS();
276
277 MCAPI static uchar const& RAID_MAX_SPAWN_FAILURES();
278
279 MCAPI static int const& RAID_PREP_TIME_IN_TICKS();
280
281 MCAPI static ::Tick const& RAID_TIMEOUT_IN_TICKS();
282
283 MCAPI static ::std::string const& STORAGE_KEY_DWELLERS();
284
285 MCAPI static ::std::string const& STORAGE_KEY_PLAYERS();
286
287 MCAPI static ::std::string const& STORAGE_KEY_POI();
288
289 MCAPI static ::std::string const& STORAGE_KEY_PREFIX();
290
291 MCAPI static ::std::string const& STORAGE_KEY_RAID();
292
293 MCAPI static ::std::string const& STORAGE_KEY_VILLAGE();
294 // NOLINTEND
295
296public:
297 // constructor thunks
298 // NOLINTBEGIN
299 MCAPI void* $ctor(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
300 // NOLINTEND
301
302public:
303 // destructor thunk
304 // NOLINTBEGIN
305 MCAPI void $dtor();
306 // NOLINTEND
307};
Definition Actor.h:105
Definition BlockPos.h:19
Definition BlockSource.h:68
Definition Block.h:43
Definition CompoundTag.h:23
Definition Dimension.h:85
Definition HashedString.h:5
Definition LevelStorage.h:25
Definition Level.h:249
Definition Mob.h:50
Definition POIInstance.h:19
Definition Raid.h:16
Definition Random.h:10
Definition Vec3.h:10
Definition VillageManager.h:30
Definition UUID.h:7
Definition ActorUniqueID.h:5
Definition Tick.h:5
Definition Village.h:48
Definition Village.h:57