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/shared_types/legacy/LevelSoundEvent.h"
7#include "mc/entity/components_json_legacy/DwellerRole.h"
8#include "mc/world/actor/ai/village/POIType.h"
9
10// auto generated forward declare list
11// clang-format off
12class AABB;
13class Actor;
14class Block;
15class BlockPos;
16class BlockSource;
17class CompoundTag;
18class Dimension;
19class HashedString;
20class Level;
21class LevelStorage;
22class Mob;
23class POIInstance;
24class Player;
25class Raid;
26class Random;
27class Vec3;
28class VillageManager;
29struct ActorUniqueID;
30struct Tick;
31namespace mce { class UUID; }
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 MCAPI static int const& GOLEM_DEATH_PENALTY();
48
49 MCAPI static int const& LARGE_PENALTY();
50
51 MCAPI static int const& LARGE_REWARD();
52
53 MCAPI static int const& MEDIUM_PENALTY();
54
55 MCAPI static int const& SMALL_PENALTY();
56
57 MCAPI 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 // member functions
118 // NOLINTBEGIN
119 MCAPI Village(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
120
121 MCAPI void _calcPOIDist();
122
123 MCAPI void _claimUnclaimedPOIs();
124
125 MCAPI void _clearVillagerPOIs(::ActorUniqueID const& villager);
126
127 MCAPI void _createRaid();
128
129 MCAPI bool _findAvailablePOI(uint64 index, ::Level& level, ::Random& random, ::ActorUniqueID id);
130
131 MCAPI bool _findPlayerCentricSpawnPointForRaid(::Vec3& outSpawnPoint, bool snapToSurface) const;
132
133 MCAPI bool _findSpawnPointForRaid(
134 ::Vec3& outSpawnPoint,
135 float distanceTolerance,
136 float boundsScaling,
137 bool snapToSurface,
138 bool outsideOfVillage
139 ) const;
140
141 MCAPI ::BlockSource*
142 _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool& outHasSpawnAreaLoaded) const;
143
144 MCAPI void _findWeightedPOI(
145 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
146 ::Random& random,
148 );
149
150 MCAPI void _helpLocateRaiders(::Raid const& raid);
151
152 MCAPI void _loadVillageData(::CompoundTag const& tag);
153
154 MCAPI void _loadVillageDwellers(::CompoundTag const& tag);
155
156 MCAPI void _loadVillagePOIs(::CompoundTag const& tag);
157
158 MCAPI void _playSoundFrom(::Vec3 const& soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound);
159
160 MCAPI void _readyRaidGroup(::std::unordered_set<::ActorUniqueID>& spawnedMobs);
161
162 MCAPI void _ringBells(::BlockSource& region, ::Random& random) const;
163
164 MCAPI void _saveVillageData(::LevelStorage& levelStorage) const;
165
166 MCAPI void _saveVillageDwellers(::LevelStorage& levelStorage) const;
167
168 MCAPI void _saveVillagePOIs(::LevelStorage& levelStorage) const;
169
170 MCAPI void _saveVillagePOIsToTag(::CompoundTag& tag) const;
171
172 MCAPI void _saveVillagePlayerStanding(::LevelStorage& levelStorage) const;
173
174 MCAPI void _saveVillageRaid(::LevelStorage& levelStorage) const;
175
176 MCAPI void _sendSoundTheAlarmAchievement(::Player const& player) const;
177
178 MCAPI void _spawnPassiveDwellers(::BlockSource& region, int);
179
180 MCAPI bool
181 _spawnRaidGroup(::Vec3 spawnPosition, uchar groupNumber, ::std::unordered_set<::ActorUniqueID>& spawnedMobs) const;
182
183 MCAPI void _tryAddPoiToVillage(::ActorUniqueID const& villager, ::std::weak_ptr<::POIInstance> pi);
184
185 MCAPI void _tryShiftStandingsTowardNeutral(::Tick& updateTick, uint64 updateInterval, bool positiveShift);
186
187 MCAPI void _trySpawnDefenderDwellers(::BlockSource& region, uint64 bedCount);
188
189 MCAPI void _updateAndRemoveInactiveDwellers(uint64 villagerPurgeTime, float villageBorderTolerance);
190
191 MCAPI void _updateClaimedPOIs(::BlockSource& region);
192
193 MCAPI void _updateUnclaimedPOIs(::BlockSource& region);
194
195 MCAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const& actorID);
196
197 MCAPI void addAggressor(::Mob const& mob);
198
199 MCAPI bool addPOI(::std::weak_ptr<::POIInstance> pi);
200
201 MCAPI void addVillager(::ActorUniqueID const& villagerID);
202
203 MCAPI bool checkNeedMoreVillagers() const;
204
205 MCAPI void debugDraw();
206
207 MCAPI ::std::weak_ptr<::POIInstance> fetchOwnedPOI(::ActorUniqueID const& id, ::POIType type);
208
209 MCAPI uint64 getBedPOICount() const;
210
211 MCAPI ::Actor* getClosestAggressor(::Actor* from);
212
213 MCAPI ::std::weak_ptr<::POIInstance> getClosestPOI(::POIType type, ::BlockPos const& position);
214
215 MCAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const& id) const;
216
217 MCAPI void loadDataByKey(::std::string const& key, ::CompoundTag const& tag);
218
219 MCAPI int modifyStanding(::ActorUniqueID const& playerID, int delta);
220
221 MCAPI ::std::_List_iterator<
222 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
223 removeActorFromVillage(::DwellerRole role, ::ActorUniqueID const& actor);
224
225 MCAPI void removeAllInstancesofActorFromVillage(::ActorUniqueID const& actor);
226
227 MCAPI void removeVillageSavedData();
228
229 MCAPI void rewardAllPlayers(int deltaAmount);
230
231 MCAPI void tick(::Tick tick, ::BlockSource& region);
232
233 MCAPI void tickRaid(::Tick gameTick);
234
235 MCAPI void triggerRaid();
236
237 MCAPI void unlinkMismatchedJobsites(::Actor const& villager);
238
239 MCAPI bool villagerLivesHere(::ActorUniqueID const& villager) const;
240
241 MCAPI ~Village();
242 // NOLINTEND
243
244public:
245 // static functions
246 // NOLINTBEGIN
247 MCAPI static ::std::shared_ptr<::POIInstance> _findPreferredPOI(
248 ::std::vector<::std::weak_ptr<::POIInstance>>& unclaimedPOIStack,
249 ::HashedString const& preferredPOI
250 );
251
252 MCAPI static bool isVillagePOI(::VillageManager const& villageManager, ::Block const& block);
253 // NOLINTEND
254
255public:
256 // static variables
257 // NOLINTBEGIN
258 MCAPI static ::std::string const& CELEBRATION_EVENT();
259
260 MCAPI static bool& DEBUG_DRAWING();
261
262 MCAPI static ::Vec3 const& RAID_BOUNDS_PADDING();
263
264 MCAPI static ::std::string const& RAID_EXPIRY_EVENT();
265
266 MCAPI static int const& RAID_FINISHED_DELAY_IN_TICKS();
267
268 MCAPI static int const& RAID_GROUP_COMPLETE_DELAY_IN_TICKS();
269
270 MCAPI static int const& RAID_LOCATION_HELP_DELAY_IN_TICKS();
271
272 MCAPI static uchar const& RAID_MAX_SPAWN_FAILURES();
273
274 MCAPI static int const& RAID_PREP_TIME_IN_TICKS();
275
276 MCAPI static ::Tick const& RAID_TIMEOUT_IN_TICKS();
277
278 MCAPI static ::std::string const& STORAGE_KEY_DWELLERS();
279
280 MCAPI static ::std::string const& STORAGE_KEY_PLAYERS();
281
282 MCAPI static ::std::string const& STORAGE_KEY_POI();
283
284 MCAPI static ::std::string const& STORAGE_KEY_PREFIX();
285
286 MCAPI static ::std::string const& STORAGE_KEY_RAID();
287
288 MCAPI static ::std::string const& STORAGE_KEY_VILLAGE();
289 // NOLINTEND
290
291public:
292 // constructor thunks
293 // NOLINTBEGIN
294 MCAPI void* $ctor(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
295 // NOLINTEND
296
297public:
298 // destructor thunk
299 // NOLINTBEGIN
300 MCAPI void $dtor();
301 // NOLINTEND
302};
Definition AABB.h:16
Definition Actor.h:104
Definition BlockPos.h:18
Definition BlockSource.h:67
Definition Block.h:36
Definition CompoundTag.h:13
Definition Dimension.h:83
Definition HashedString.h:5
Definition LevelStorage.h:24
Definition Level.h:234
Definition Mob.h:47
Definition POIInstance.h:19
Definition Player.h:119
Definition Raid.h:16
Definition Random.h:16
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