LeviLamina
Loading...
Searching...
No Matches
Scoreboard.h
1#pragma once
2
3#include "mc/_HeaderOutputPredefine.h"
4#include "mc/world/scores/PlayerScoreSetFunction.h"
5
6// auto generated inclusion list
7#include "mc/deps/core/utility/NonOwnerPointer.h"
8#include "mc/server/commands/CommandOperator.h"
9#include "mc/server/commands/CommandSoftEnumRegistry.h"
10#include "mc/world/events/PlayerScoreboardEventListener.h"
11#include "mc/world/events/ScoreboardEventCoordinator.h"
12#include "mc/world/scores/IdentityDictionary.h"
13#include "mc/world/scores/ObjectiveRenderType.h"
14#include "mc/world/scores/ObjectiveSortOrder.h"
15#include "mc/world/scores/PlayerScoreSetFunction.h"
16#include "mc/world/scores/ScoreboardId.h"
17#include "mc/world/scores/ScoreboardOperationResult.h"
18
19// auto generated forward declare list
20// clang-format off
21class Actor;
22class CompoundTag;
24class Objective;
26class PacketSender;
27class Player;
29struct ActorUniqueID;
30struct PlayerScore;
32struct ScoreInfo;
33// clang-format on
34
35class Scoreboard {
36public:
37 // member variables
38 // NOLINTBEGIN
39 ::ll::TypedStorage<8, 8, ::CommandSoftEnumRegistry> mRegistry;
40 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::DisplayObjective>> mDisplayObjectives;
41 ::ll::TypedStorage<8, 256, ::IdentityDictionary> mIdentityDict;
42 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ScoreboardId, ::ScoreboardIdentityRef>> mIdentityRefs;
43 ::ll::TypedStorage<1, 1, bool> mShouldUpdateUI;
44 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::Objective>>> mObjectives;
45 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::Bedrock::NonOwnerPointer<::Objective>>>
46 mObjectivesHashLookup;
47 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::ObjectiveCriteria>>> mCriteria;
48 ::ll::TypedStorage<8, 96, ::ScoreboardEventCoordinator> mScoreboardEventCoordinator;
49 ::ll::TypedStorage<8, 72, ::PlayerScoreboardEventListener> mPlayerListener;
50 // NOLINTEND
51
52public:
53 // prevent constructor by default
54 Scoreboard();
55
56public:
57 LLAPI int modifyPlayerScore(
58 ScoreboardOperationResult& result,
59 ScoreboardId const& id,
60 Objective& objective,
61 int scoreValue,
62 PlayerScoreSetFunction action
63 );
64
65public:
66 // virtual functions
67 // NOLINTBEGIN
68 virtual ~Scoreboard();
69
70 virtual ::DisplayObjective const* setDisplayObjective(
71 ::std::string const& displaySlotName,
72 ::Objective const& objective,
73 ::ObjectiveSortOrder const order
74 );
75
76 virtual ::Objective* clearDisplayObjective(::std::string const& displaySlotName);
77
78 virtual ::ScoreboardId const& createScoreboardId(::Player const& player);
79
80 virtual ::ScoreboardId const& createScoreboardId(::Actor const& entity);
81
82 virtual ::ScoreboardId const& createScoreboardId(::std::string const& name);
83
84 virtual void onObjectiveAdded(::Objective const& objective);
85
86 virtual void onObjectiveRemoved(::Objective& objective);
87
88 virtual void onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
89
90 virtual void onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
91
92 virtual void onPlayerJoined(::Player const& player);
93
94 virtual void onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
95
96 virtual void tick();
97
98 virtual void setPacketSender(::PacketSender* sender);
99
100 virtual void writeToLevelStorage();
101
102 virtual bool isClientSide() const;
103 // NOLINTEND
104
105public:
106 // member functions
107 // NOLINTBEGIN
108 MCAPI explicit Scoreboard(::CommandSoftEnumRegistry registry);
109
110 MCAPI void _addLoadedCriteria(::std::unique_ptr<::ObjectiveCriteria> newCriteria);
111
112 MCAPI void _addLoadedObjective(::std::unique_ptr<::Objective> newObjective);
113
114 MCAPI void _initCoordinator();
115
116 MCAPI ::Objective*
117 addObjective(::std::string const& name, ::std::string const& displayName, ::ObjectiveCriteria const& criteria);
118
119 MCAPI void addScoreListener(::Player& player, ::std::string const& objective);
120
121 MCAPI int applyPlayerOperation(
122 ::ScoreboardOperationResult& result,
123 ::std::vector<::ScoreboardId>& sourceErrorIds,
124 ::ScoreboardId const& target,
125 ::Objective& targetObjective,
126 ::std::vector<::ScoreboardId>& selector,
127 ::Objective& objective,
128 ::CommandOperator opCode
129 );
130
131#ifdef LL_PLAT_C
132 MCAPI bool clearScoreboardIdentity(::ScoreboardId const& scoreboardId);
133#endif
134
135 MCAPI ::ObjectiveCriteria const&
136 createObjectiveCriteria(::std::string const& name, bool readOnly, ::ObjectiveRenderType renderType);
137
138 MCAPI void forEachIdentityRef(::std::function<void(::ScoreboardIdentityRef&)> callback);
139
140 MCAPI void forEachObjective(::std::function<void(::Objective&)> callback);
141
142 MCAPI ::ObjectiveCriteria* getCriteria(::std::string const& criteriaName) const;
143
144 MCAPI ::std::vector<::std::string> getCriteriaNames() const;
145
146 MCAPI ::ObjectiveCriteria const& getDefaultCriteria() const;
147
148 MCAPI ::std::vector<::PlayerScore> getDisplayInfoFiltered(::std::string const& displaySlot) const;
149
150#ifdef LL_PLAT_C
151 MCAPI ::std::vector<::PlayerScore> getDisplayInfoSorted(
152 ::std::string const& displaySlot,
153 ::std::function<void(::ObjectiveSortOrder, ::std::vector<::PlayerScore>&)> sortMethod
154 ) const;
155#endif
156
157 MCAPI ::DisplayObjective const* getDisplayObjective(::std::string const& displaySlotName) const;
158
159 MCAPI ::std::vector<::std::string> getDisplayObjectiveSlotNames() const;
160
161 MCAPI ::std::vector<::ScoreInfo> getIdScores(::ScoreboardId const& id) const;
162
163 MCAPI ::Objective* getObjective(::std::string const& name) const;
164
165 MCAPI ::std::vector<::std::string> getObjectiveNames() const;
166
167 MCAPI ::std::vector<::Objective const*> getObjectives() const;
168
169 MCFOLD ::ScoreboardEventCoordinator& getScoreboardEventCoordinator();
170
171 MCAPI ::ScoreboardId const& getScoreboardId(::Actor const& entity) const;
172
173 MCAPI ::ScoreboardId const& getScoreboardId(::ActorUniqueID const& entityId) const;
174
175 MCAPI ::ScoreboardId const& getScoreboardId(::std::string const& name) const;
176
177 MCAPI ::ScoreboardId const& getScoreboardId(::Player const& player) const;
178
179 MCAPI ::ScoreboardId const& getScoreboardId(::PlayerScoreboardId const& playerId) const;
180
181 MCAPI ::ScoreboardIdentityRef* getScoreboardIdentityRef(::ScoreboardId const& scoreboardId);
182
183 MCAPI ::std::vector<::ScoreboardIdentityRef> getScoreboardIdentityRefs() const;
184
185 MCAPI ::std::vector<::ScoreboardId> getTrackedIds() const;
186
187 MCAPI bool hasIdentityFor(::ScoreboardId const& scoreboardId) const;
188
189#ifdef LL_PLAT_C
190 MCAPI bool isObjectiveDisplayed(::Objective const& objective) const;
191#endif
192
193 MCAPI int modifyPlayerScore(
194 ::ScoreboardOperationResult& result,
195 ::ScoreboardIdentityRef* identityRef,
196 ::Objective& objective,
197 int scoreValue,
198 ::PlayerScoreSetFunction action
199 );
200
201#ifdef LL_PLAT_C
202 MCAPI void onUpdateUI();
203#endif
204
205 MCAPI ::ScoreboardIdentityRef const& registerScoreboardIdentity(::CompoundTag const& loadedData);
206
207 MCAPI ::ScoreboardIdentityRef const&
208 registerScoreboardIdentity(::ScoreboardId const& scoreboardId, ::ActorUniqueID const& entityId);
209
210#ifdef LL_PLAT_C
211 MCAPI ::ScoreboardIdentityRef const&
212 registerScoreboardIdentity(::ScoreboardId const& scoreboardId, ::std::string const& name);
213#endif
214
215 MCAPI ::ScoreboardIdentityRef const&
216 registerScoreboardIdentity(::ScoreboardId const& scoreboardId, ::PlayerScoreboardId const& playerId);
217
218 MCAPI bool removeObjective(::Objective* objective);
219
220 MCAPI void removeScoreListener(::Player const& player);
221
222 MCAPI void removeScoreListener(::Player const& player, ::std::string const& objective);
223
224#ifdef LL_PLAT_C
225 MCAPI void replaceFakePlayer(::ScoreboardId const& scoreboardId, ::PlayerScoreboardId const& playerId);
226#endif
227
228 MCAPI bool resetPlayerScore(::ScoreboardId const& id, ::Objective& objective);
229
230 MCAPI void resetPlayerScore(::ScoreboardId const& id);
231
232#ifdef LL_PLAT_C
233 MCFOLD bool shouldUpdateUI() const;
234#endif
235
236 MCAPI ::std::optional<::ScoreInfo> tryGetIdScore(::ScoreboardId const& id, uint64 const& objectiveHash) const;
237 // NOLINTEND
238
239public:
240 // static variables
241 // NOLINTBEGIN
242 MCAPI static ::std::string const& DEFAULT_CRITERIA();
243
244 MCAPI static ::std::string const& DISPLAY_SLOT_BELOWNAME();
245
246 MCAPI static ::std::string const& DISPLAY_SLOT_LIST();
247
248 MCAPI static ::std::string const& DISPLAY_SLOT_SIDEBAR();
249
250 MCAPI static char const*& OBJECTIVES_ENUM();
251 // NOLINTEND
252
253public:
254 // constructor thunks
255 // NOLINTBEGIN
256 MCAPI void* $ctor(::CommandSoftEnumRegistry registry);
257 // NOLINTEND
258
259public:
260 // destructor thunk
261 // NOLINTBEGIN
262 MCAPI void $dtor();
263 // NOLINTEND
264
265public:
266 // virtual function thunks
267 // NOLINTBEGIN
268 MCAPI ::DisplayObjective const* $setDisplayObjective(
269 ::std::string const& displaySlotName,
270 ::Objective const& objective,
271 ::ObjectiveSortOrder const order
272 );
273
274 MCAPI ::Objective* $clearDisplayObjective(::std::string const& displaySlotName);
275
276 MCFOLD ::ScoreboardId const& $createScoreboardId(::Player const& player);
277
278 MCFOLD ::ScoreboardId const& $createScoreboardId(::Actor const& entity);
279
280 MCFOLD ::ScoreboardId const& $createScoreboardId(::std::string const& name);
281
282 MCAPI void $onObjectiveAdded(::Objective const& objective);
283
284 MCAPI void $onObjectiveRemoved(::Objective& objective);
285
286 MCAPI void $onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
287
288 MCFOLD void $onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
289
290 MCFOLD void $onPlayerJoined(::Player const& player);
291
292 MCFOLD void $onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
293
294 MCFOLD void $tick();
295
296 MCFOLD void $setPacketSender(::PacketSender* sender);
297
298 MCFOLD void $writeToLevelStorage();
299
300 MCFOLD bool $isClientSide() const;
301
302
303 // NOLINTEND
304
305public:
306 // vftables
307 // NOLINTBEGIN
308 MCAPI static void** $vftable();
309 // NOLINTEND
310};
Definition Actor.h:123
Definition CommandSoftEnumRegistry.h:13
Definition CompoundTag.h:23
Definition DisplayObjective.h:16
Definition ObjectiveCriteria.h:13
Definition Objective.h:17
Definition PacketSender.h:17
Definition Player.h:136
Definition ScoreboardIdentityRef.h:20
Definition ActorUniqueID.h:10
Definition PlayerScore.h:8
Definition PlayerScoreboardId.h:6
Definition ScoreInfo.h:10
Definition ScoreboardId.h:11