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
44 public:
45 // static variables
46 // NOLINTBEGIN
47 MCNAPI static int const& GOLEM_DEATH_PENALTY();
48
49 MCNAPI static int const& LARGE_PENALTY();
50
51 MCNAPI static int const& LARGE_REWARD();
52
53 MCNAPI static int const& MEDIUM_PENALTY();
54
55 MCNAPI static int const& SMALL_PENALTY();
56
57 MCNAPI static int const& SMALL_REWARD();
58 // NOLINTEND
59 };
60
61 enum class VillageVersion : uchar {
62 Base = 0,
63 WorksiteInitEventFix = 1,
64 Count = 2,
65 };
66
67 struct DwellerData {
68 public:
69 // member variables
70 // NOLINTBEGIN
71 ::ll::TypedStorage<8, 8, ::Tick> mLastTicked;
72 ::ll::TypedStorage<4, 12, ::BlockPos> mLastSavedPosition;
73 // NOLINTEND
74 };
75
76 using UnclaimedPOIList = ::std::array<::std::vector<::std::weak_ptr<::POIInstance>>, 3>;
77
78 using DwellerMap = ::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>;
79
80 using ClaimedPOIList = ::std::unordered_map<::ActorUniqueID, ::std::array<::std::weak_ptr<::POIInstance>, 3>>;
81
82 using DwellerTimestamp = ::std::pair<::ActorUniqueID, ::Tick>;
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 _calcPOIDist();
128
129 MCAPI void _claimUnclaimedPOIs();
130
131 MCAPI void _clearVillagerPOIs(::ActorUniqueID const& villager);
132
133 MCAPI void _createRaid();
134
135 MCAPI void _deleteOldDataIfNeeded(::LevelStorage& levelStorage, ::std::string const& key) const;
136
137 MCAPI bool _findAvailablePOI(uint64 index, ::Level& level, ::Random& random, ::ActorUniqueID id);
138
139 MCAPI bool _findPlayerCentricSpawnPointForRaid(::Vec3& outSpawnPoint, bool snapToSurface) const;
140
141 MCAPI bool _findSpawnPointForRaid(
142 ::Vec3& outSpawnPoint,
143 float distanceTolerance,
144 float boundsScaling,
145 bool snapToSurface,
146 bool outsideOfVillage
147 ) const;
148
149 MCAPI ::BlockSource*
150 _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool& outHasSpawnAreaLoaded) const;
151
152 MCAPI void _findWeightedPOI(
153 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
154 ::Random& random,
156 );
157
158 MCAPI void _helpLocateRaiders(::Raid const& raid);
159
160 MCAPI void _loadVillageData(::CompoundTag const& tag);
161
162 MCAPI void _loadVillageDwellers(::CompoundTag const& tag);
163
164 MCAPI void _loadVillagePOIs(::CompoundTag const& tag);
165
166 MCAPI void _playSoundFrom(::Vec3 const& soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound);
167
168 MCAPI void _readyRaidGroup(::std::unordered_set<::ActorUniqueID>& spawnedMobs);
169
170 MCAPI void _ringBells(::BlockSource& region, ::Random& random) const;
171
172 MCAPI void _saveVillageData(::LevelStorage& levelStorage) const;
173
174 MCAPI void _saveVillageDwellers(::LevelStorage& levelStorage) const;
175
176 MCAPI void _saveVillagePOIs(::LevelStorage& levelStorage) const;
177
178 MCAPI void _saveVillagePOIsToTag(::CompoundTag& tag) const;
179
180 MCAPI void _saveVillagePlayerStanding(::LevelStorage& levelStorage) const;
181
182 MCAPI void _saveVillageRaid(::LevelStorage& levelStorage) const;
183
184 MCAPI void _sendSoundTheAlarmAchievement(::Player const& player) const;
185
186 MCAPI void _spawnPassiveDwellers(::BlockSource& region, int);
187
188 MCAPI bool
189 _spawnRaidGroup(::Vec3 spawnPosition, uchar groupNumber, ::std::unordered_set<::ActorUniqueID>& spawnedMobs) const;
190
191 MCAPI void _tryAddPoiToVillage(::ActorUniqueID const& villager, ::std::weak_ptr<::POIInstance> pi);
192
193 MCAPI void _tryShiftStandingsTowardNeutral(::Tick& updateTick, uint64 updateInterval, bool positiveShift);
194
195 MCAPI void _trySpawnDefenderDwellers(::BlockSource& region, uint64 bedCount);
196
197 MCAPI void _updateAndRemoveInactiveDwellers(uint64 villagerPurgeTime, float villageBorderTolerance);
198
199 MCAPI void _updateClaimedPOIs(::BlockSource& region);
200
201 MCAPI void _updateUnclaimedPOIs(::BlockSource& region);
202
203 MCAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const& actorID);
204
205 MCAPI void addAggressor(::Mob const& mob);
206
207 MCAPI bool addPOI(::std::weak_ptr<::POIInstance> pi);
208
209 MCAPI void addVillager(::ActorUniqueID const& villagerID);
210
211 MCAPI bool checkNeedMoreVillagers() const;
212
213 MCAPI void debugDraw();
214
215 MCAPI ::std::weak_ptr<::POIInstance> fetchOwnedPOI(::ActorUniqueID const& id, ::POIType type);
216
217 MCAPI uint64 getBedPOICount() const;
218
219 MCAPI ::Actor* getClosestAggressor(::Actor* from);
220
221 MCAPI ::std::weak_ptr<::POIInstance> getClosestPOI(::POIType type, ::BlockPos const& position);
222
223 MCAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const& id) const;
224
225 MCAPI void loadDataByKey(::std::string const& key, ::CompoundTag const& tag);
226
227 MCAPI int modifyStanding(::ActorUniqueID const& playerID, int delta);
228
229 MCAPI ::std::_List_iterator<
230 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
231 removeActorFromVillage(::DwellerRole role, ::ActorUniqueID const& actor);
232
233 MCAPI void removeAllInstancesofActorFromVillage(::ActorUniqueID const& actor);
234
235 MCAPI void removeVillageSavedData();
236
237 MCAPI void rewardAllPlayers(int deltaAmount);
238
239 MCAPI void tick(::Tick tick, ::BlockSource& region);
240
241 MCAPI void tickRaid(::Tick gameTick);
242
243 MCAPI void triggerRaid();
244
245 MCAPI void unlinkMismatchedJobsites(::Actor const& villager);
246
247 MCAPI bool villagerLivesHere(::ActorUniqueID const& villager) const;
248
249 MCAPI ~Village();
250 // NOLINTEND
251
252public:
253 // static functions
254 // NOLINTBEGIN
255 MCAPI static ::std::shared_ptr<::POIInstance> _findPreferredPOI(
256 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
257 ::HashedString const& preferredPOI
258 );
259
260 MCAPI static bool isVillagePOI(::VillageManager const& villageManager, ::Block const& block);
261 // NOLINTEND
262
263public:
264 // static variables
265 // NOLINTBEGIN
266 MCAPI static ::std::string const& CELEBRATION_EVENT();
267
268 MCAPI static bool& DEBUG_DRAWING();
269
270 MCAPI static ::Vec3 const& RAID_BOUNDS_PADDING();
271
272 MCAPI static ::std::string const& RAID_EXPIRY_EVENT();
273
274 MCAPI static int const& RAID_FINISHED_DELAY_IN_TICKS();
275
276 MCAPI static int const& RAID_GROUP_COMPLETE_DELAY_IN_TICKS();
277
278 MCAPI static int const& RAID_LOCATION_HELP_DELAY_IN_TICKS();
279
280 MCAPI static uchar const& RAID_MAX_SPAWN_FAILURES();
281
282 MCAPI static int const& RAID_PREP_TIME_IN_TICKS();
283
284 MCAPI static ::Tick const& RAID_TIMEOUT_IN_TICKS();
285
286 MCAPI static ::std::string const& STORAGE_KEY_DWELLERS();
287
288 MCAPI static ::std::string const& STORAGE_KEY_PLAYERS();
289
290 MCAPI static ::std::string const& STORAGE_KEY_POI();
291
292 MCAPI static ::std::string const& STORAGE_KEY_PREFIX();
293
294 MCAPI static ::std::string const& STORAGE_KEY_RAID();
295
296 MCAPI static ::std::string const& STORAGE_KEY_VILLAGE();
297 // NOLINTEND
298
299public:
300 // constructor thunks
301 // NOLINTBEGIN
302 MCAPI void* $ctor(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
303 // NOLINTEND
304
305public:
306 // destructor thunk
307 // NOLINTBEGIN
308 MCAPI void $dtor();
309 // NOLINTEND
310};
Definition Actor.h:103
Definition BlockPos.h:18
Definition BlockSource.h:67
Definition Block.h:38
Definition CompoundTag.h:13
Definition Dimension.h:83
Definition HashedString.h:5
Definition LevelStorage.h:25
Definition Level.h:238
Definition Mob.h:47
Definition POIInstance.h:19
Definition Player.h:119
Definition Raid.h:16
Definition Random.h:11
Definition Vec3.h:10
Definition VillageManager.h:30
Definition Village.h:34
Definition UUID.h:7
Definition ActorUniqueID.h:5
Definition Tick.h:5
Definition Village.h:67
Definition Village.h:43
static MCAPI int const & SMALL_PENALTY()
static MCAPI int const & LARGE_REWARD()
static MCAPI int const & GOLEM_DEATH_PENALTY()
static MCAPI int const & LARGE_PENALTY()
static MCAPI int const & MEDIUM_PENALTY()
static MCAPI int const & SMALL_REWARD()