Skip to content
LeviMC
English
AutoLightDark
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 MCNAPI void _calcPOIDist();
109
110 MCNAPI void _clearVillagerPOIs(::ActorUniqueID const& villager);
111
112 MCNAPI void _createRaid();
113
115 ::Vec3& outSpawnPoint,
116 float const distanceTolerance,
117 float const boundsScaling,
118 bool snapToSurface,
119 bool outsideOfVillage
120 ) const;
121
122 MCNAPI ::BlockSource*
123 _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool& outHasSpawnAreaLoaded) const;
124
125 MCNAPI void _playSoundFrom(::Vec3 const& soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound);
126
127 MCNAPI void _saveVillageData(::LevelStorage& levelStorage) const;
128
129 MCNAPI void _saveVillageDwellers(::LevelStorage& levelStorage) const;
130
131 MCNAPI void _saveVillagePOIs(::LevelStorage& levelStorage) const;
132
133 MCNAPI void _saveVillagePlayerStanding(::LevelStorage& levelStorage) const;
134
135 MCNAPI void _saveVillageRaid(::LevelStorage& levelStorage) const;
136
137 MCNAPI void _tryAddPoiToVillage(::ActorUniqueID const& villager, ::std::weak_ptr<::POIInstance> pi);
138
139 MCNAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const& actorID);
140
141 MCNAPI bool addPOI(::std::weak_ptr<::POIInstance> pi);
142
143 MCNAPI void addVillager(::ActorUniqueID const& villagerID);
144
145 MCNAPI bool checkNeedMoreVillagers() const;
146
147 MCNAPI ::std::weak_ptr<::POIInstance> fetchOwnedPOI(::ActorUniqueID const& id, ::POIType type);
148
149 MCNAPI void fireSoundTheAlarm();
150
151 MCNAPI ::Actor* getClosestAggressor(::Actor* from);
152
153 MCNAPI ::Player* getClosestBadStandingPlayer(::Actor& from);
154
155 MCNAPI ::std::weak_ptr<::POIInstance> getClosestPOI(::POIType type, ::BlockPos const& position);
156
157 MCNAPI bool hasInvalidRole(::ActorUniqueID const& actorId, ::DwellerRole const& role);
158
159 MCNAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const& id) const;
160
161 MCNAPI int modifyStanding(::ActorUniqueID const& playerID, int delta);
162
163 MCNAPI ::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
168
169 MCNAPI ::std::_List_iterator<
170 ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData>>>>
172
173 MCNAPI void resetDwellerTimer(::DwellerRole role, ::ActorUniqueID const& id);
174
175 MCNAPI void setSavedDwellerPosition(::DwellerRole role, ::ActorUniqueID const& id, ::BlockPos pos);
176
177 MCAPI void tick(::Tick tick, ::BlockSource& region);
178
179 MCNAPI void triggerRaid();
180
182
183 MCNAPI void unlinkMismatchedJobsites(::Actor const& villager);
184
185 MCNAPI bool villagerLivesHere(::ActorUniqueID const& villager) const;
186 // NOLINTEND
187
188public:
189 // static functions
190 // NOLINTBEGIN
191 MCNAPI static bool isVillagePOI(::VillageManager const& villageManager, ::Block const& block);
192 // NOLINTEND
193
194public:
195 // static variables
196 // NOLINTBEGIN
197 MCNAPI static ::std::string const& CELEBRATION_EVENT();
198
199 MCNAPI static ::std::string const& RAID_EXPIRY_EVENT();
200
201 MCNAPI static ::std::string const& STORAGE_KEY_PREFIX();
202 // NOLINTEND
203
204public:
205 // constructor thunks
206 // NOLINTBEGIN
207 MCAPI void* $ctor(::Dimension& dimension, ::mce::UUID id, ::BlockPos const& origin);
208 // NOLINTEND
209};
Definition Actor.h:116
Definition BlockPos.h:14
Definition BlockSource.h:72
Definition Block.h:42
Definition Dimension.h:86
Definition LevelStorage.h:26
Definition POIInstance.h:18
Definition Player.h:131
Definition Raid.h:15
Definition Vec3.h:10
Definition VillageManager.h:28
static MCAPI bool isVillagePOI(::VillageManager const &villageManager, ::Block const &block)
MCAPI void _saveVillagePOIs(::LevelStorage &levelStorage) const
MCAPI void _clearVillagerPOIs(::ActorUniqueID const &villager)
MCAPI bool _findSpawnPointForRaid(::Vec3 &outSpawnPoint, float const distanceTolerance, float const boundsScaling, bool snapToSurface, bool outsideOfVillage) const
MCAPI int modifyStanding(::ActorUniqueID const &playerID, int delta)
MCAPI void addVillager(::ActorUniqueID const &villagerID)
MCAPI::Actor * getClosestAggressor(::Actor *from)
MCAPI void removeAllInstancesofActorFromVillage(::ActorUniqueID const &actor)
MCAPI ::std::_List_iterator< ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData > > > > removeActorFromVillage(::DwellerRole role, ::ActorUniqueID const &actor)
MCAPI bool addPOI(::std::weak_ptr<::POIInstance > pi)
MCAPI::Player * getClosestBadStandingPlayer(::Actor &from)
static MCAPI ::std::string const & CELEBRATION_EVENT()
MCAPI void _saveVillageRaid(::LevelStorage &levelStorage) const
MCAPI void triggerRaid()
MCAPI bool checkNeedMoreVillagers() const
MCAPI void resetDwellerTimer(::DwellerRole role, ::ActorUniqueID const &id)
MCAPI void trySetVillagerWorkTimestamp(::ActorUniqueID const &id)
MCAPI bool villagerLivesHere(::ActorUniqueID const &villager) const
MCAPI bool hasInvalidRole(::ActorUniqueID const &actorId, ::DwellerRole const &role)
MCAPI void _createRaid()
MCAPI void _saveVillageData(::LevelStorage &levelStorage) const
MCAPI void _calcPOIDist()
static MCAPI ::std::string const & RAID_EXPIRY_EVENT()
MCAPI void _tryAddPoiToVillage(::ActorUniqueID const &villager, ::std::weak_ptr<::POIInstance > pi)
MCAPI ::std::weak_ptr<::POIInstance > fetchOwnedPOI(::ActorUniqueID const &id, ::POIType type)
MCAPI ::std::weak_ptr<::POIInstance > getClosestPOI(::POIType type, ::BlockPos const &position)
MCAPI void addActorToVillage(::DwellerRole role, ::ActorUniqueID const &actorID)
MCAPI void _saveVillagePlayerStanding(::LevelStorage &levelStorage) const
MCAPI::BlockSource * _findSpawnableRegion(::Vec3 spawnPosition, int xzSpreadDistance, bool &outHasSpawnAreaLoaded) const
MCAPI void fireSoundTheAlarm()
MCAPI ::std::_List_iterator< ::std::_List_val<::std::_List_simple_types<::std::pair<::ActorUniqueID const, ::Village::DwellerData > > > > removeVillager(::ActorUniqueID const &villager)
MCAPI void _playSoundFrom(::Vec3 const &soundOrigin, ::SharedTypes::Legacy::LevelSoundEvent sound)
MCAPI void setSavedDwellerPosition(::DwellerRole role, ::ActorUniqueID const &id, ::BlockPos pos)
MCAPI void unlinkMismatchedJobsites(::Actor const &villager)
MCAPI bool hasSpecificDweller(::DwellerRole role, ::ActorUniqueID const &id) const
MCAPI void _saveVillageDwellers(::LevelStorage &levelStorage) const
static MCAPI ::std::string const & STORAGE_KEY_PREFIX()
Definition UUID.h:8
Definition ActorUniqueID.h:5
Definition Tick.h:5
Definition Village.h:46
Definition Village.h:55