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/actor/ai/village/Raid.h"
13#include "mc/world/level/BlockPos.h"
14#include "mc/world/level/Tick.h"
15#include "mc/world/phys/AABB.h"
16
17// auto generated forward declare list
18// clang-format off
19class Actor;
20class Block;
21class BlockSource;
22class Dimension;
23class LevelStorage;
24class POIInstance;
25class Player;
26class Raid;
27class Vec3;
28class VillageManager;
29// clang-format on
30
31class Village {
32public:
33 // Village inner types declare
34 // clang-format off
35 struct DwellerData;
36 struct StandingModifiers;
37 // clang-format on
38
39 // Village inner types define
40 enum class VillageVersion : uchar {
41 Base = 0,
42 WorksiteInitEventFix = 1,
43 Count = 2,
44 };
45
46 struct DwellerData {
47 public:
48 // member variables
49 // NOLINTBEGIN
50 ::ll::TypedStorage<8, 8, ::Tick> mLastTicked;
51 ::ll::TypedStorage<4, 12, ::BlockPos> mLastSavedPosition;
52 // NOLINTEND
53 };
54
56
57 using ClaimedPOIList = ::std::unordered_map<::ActorUniqueID, ::std::array<::std::weak_ptr<::POIInstance>, 3>>;
58
59 using DwellerMap = ::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>;
60
61 using DwellerTimestamp = ::std::pair<::ActorUniqueID, ::Tick>;
62
63 using UnclaimedPOIList = ::std::array<::std::vector<::std::weak_ptr<::POIInstance>>, 3>;
64
65public:
66 // member variables
67 // NOLINTBEGIN
68 ::ll::TypedStorage<8, 16, ::mce::UUID> mUniqueID;
69 ::ll::TypedStorage<8, 8, ::Dimension&> mDimension;
70 ::ll::TypedStorage<8, 72, ::std::array<::std::vector<::std::weak_ptr<::POIInstance>>, 3>> mUnclaimedPOIStacks;
71 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, ::std::array<::std::weak_ptr<::POIInstance>, 3>>>
72 mClaimedPOIs;
73 ::ll::TypedStorage<8, 256, ::std::array<::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>, 4>>
74 mDwellers;
75 ::ll::TypedStorage<4, 24, ::AABB> mBounds;
76 ::ll::TypedStorage<4, 24, ::AABB> mStaticRaidBounds;
77 ::ll::TypedStorage<1, 1, uchar> mVillageVersion;
78 ::ll::TypedStorage<8, 8, ::Tick> mGameTick;
79 ::ll::TypedStorage<8, 8, ::Tick> mSaveTick;
80 ::ll::TypedStorage<8, 8, ::Tick> mRingTick;
81 ::ll::TypedStorage<8, 8, ::Tick> mNoBreedTimer;
82 ::ll::TypedStorage<8, 8, ::Tick> mBadStandingDecayTimer;
83 ::ll::TypedStorage<8, 8, ::Tick> mGoodStandingDecayTimer;
84 ::ll::TypedStorage<8, 8, ::Tick> mPassiveDwellerSpawnTimer;
85 ::ll::TypedStorage<4, 4, int> mInitializationTimer;
86 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, int>> mPlayerStanding;
87 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ActorUniqueID, ::Village::DwellerData>> mAggressors;
88 ::ll::TypedStorage<8, 24, ::std::vector<::std::pair<::ActorUniqueID, ::Tick>>> mVillagerWorkTimestamps;
89 ::ll::TypedStorage<1, 1, bool> mVillageInitialized;
90 ::ll::TypedStorage<8, 48, ::HashedString const> mNitwitFamily;
91 ::ll::TypedStorage<8, 48, ::HashedString const> mVillagePrefix;
92 ::ll::TypedStorage<8, 48, ::HashedString const> mVillagePrefixOld;
93 ::ll::TypedStorage<8, 8, ::std::unique_ptr<::Raid>> mRaid;
94 ::ll::TypedStorage<8, 64, ::std::unordered_set<::ActorUniqueID>> mSoundTheAlarmPlayerList;
95 // NOLINTEND
96
97public:
98 // prevent constructor by default
99 Village& operator=(Village const&);
100 Village(Village const&);
101 Village();
102
103public:
104 // member functions
105 // NOLINTBEGIN
106 MCAPI Village(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
107
108 MCAPI void _calcPOIDist();
109
110 MCAPI void _clearVillagerPOIs(::ActorUniqueID const& villager);
111
112 MCAPI void _createRaid();
113
114 MCAPI bool _findSpawnPointForRaid(
115 ::Vec3& outSpawnPoint,
116 float const distanceTolerance,
117 float const boundsScaling,
118 bool snapToSurface,
119 bool outsideOfVillage
120 ) const;
121
122 MCAPI ::BlockSource*
123 _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool& outHasSpawnAreaLoaded) const;
124
125 MCAPI void _playSoundFrom(::Vec3 const& soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound);
126
127 MCAPI void _saveVillageData(::LevelStorage& levelStorage) const;
128
129 MCAPI void _saveVillageDwellers(::LevelStorage& levelStorage) const;
130
131 MCAPI void _saveVillagePOIs(::LevelStorage& levelStorage) const;
132
133 MCAPI void _saveVillagePlayerStanding(::LevelStorage& levelStorage) const;
134
135 MCAPI void _saveVillageRaid(::LevelStorage& levelStorage) const;
136
137 MCAPI void _tryAddPoiToVillage(::ActorUniqueID const& villager, ::std::weak_ptr<::POIInstance> pi);
138
139 MCAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const& actorID);
140
141 MCAPI bool addPOI(::std::weak_ptr<::POIInstance> pi);
142
143 MCAPI void addVillager(::ActorUniqueID const& villagerID);
144
145 MCAPI bool checkNeedMoreVillagers() const;
146
147 MCAPI ::std::weak_ptr<::POIInstance> fetchOwnedPOI(::ActorUniqueID const& id, ::POIType type);
148
149 MCAPI void fireSoundTheAlarm();
150
151 MCAPI ::Actor* getClosestAggressor(::Actor* from);
152
153 MCAPI ::Player* getClosestBadStandingPlayer(::Actor& from);
154
155 MCAPI ::std::weak_ptr<::POIInstance> getClosestPOI(::POIType type, ::BlockPos const& position);
156
157 MCAPI bool hasInvalidRole(::ActorUniqueID const& actorId, ::DwellerRole const& role);
158
159 MCAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const& id) const;
160
161 MCAPI int modifyStanding(::ActorUniqueID const& playerID, int delta);
162
163 MCAPI ::std::_List_iterator<
164 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
165 removeActorFromVillage(::DwellerRole role, ::ActorUniqueID const& actor);
166
167 MCAPI void removeAllInstancesofActorFromVillage(::ActorUniqueID const& actor);
168
169 MCAPI ::std::_List_iterator<
170 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
171 removeVillager(::ActorUniqueID const& villager);
172
173 MCAPI void resetDwellerTimer(::DwellerRole role, ::ActorUniqueID const& id);
174
175 MCAPI void setSavedDwellerPosition(::DwellerRole role, ::ActorUniqueID const& id, ::BlockPos pos);
176
177 MCAPI void tick(::Tick tick, ::BlockSource& region);
178
179 MCAPI void triggerRaid();
180
181 MCAPI void trySetVillagerWorkTimestamp(::ActorUniqueID const& id);
182
183 MCAPI void unlinkMismatchedJobsites(::Actor const& villager);
184
185 MCAPI bool villagerLivesHere(::ActorUniqueID const& villager) const;
186 // NOLINTEND
187
188public:
189 // static functions
190 // NOLINTBEGIN
191#ifdef LL_PLAT_C
192 MCAPI static bool isValidRegisteredPOI(::BlockSource& region, ::Block const& block, ::BlockPos const& position);
193#endif
194
195 MCAPI static bool isVillagePOI(::VillageManager const& villageManager, ::Block const& block);
196 // NOLINTEND
197
198public:
199 // static variables
200 // NOLINTBEGIN
201 MCAPI static ::std::string const& CELEBRATION_EVENT();
202
203 MCAPI static ::std::string const& RAID_EXPIRY_EVENT();
204
205 MCAPI static ::std::string const& STORAGE_KEY_PREFIX();
206 // NOLINTEND
207
208public:
209 // constructor thunks
210 // NOLINTBEGIN
211 MCAPI void* $ctor(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
212 // NOLINTEND
213};
Definition Actor.h:113
Definition BlockPos.h:17
Definition BlockSource.h:71
Definition Block.h:41
Definition Dimension.h:86
Definition LevelStorage.h:25
Definition POIInstance.h:19
Definition Player.h:129
Definition Raid.h:15
Definition Vec3.h:10
Definition VillageManager.h:28
Definition UUID.h:8
Definition ActorUniqueID.h:5
Definition Tick.h:5
Definition Village.h:46
Definition Village.h:55