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