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/ObjectiveSortOrder.h"
14#include "mc/world/scores/ScoreboardId.h"
15#include "mc/world/scores/ScoreboardOperationResult.h"
16
17// auto generated forward declare list
18// clang-format off
19class Actor;
20class CompoundTag;
22class Objective;
24class PacketSender;
25class Player;
27struct ActorUniqueID;
28struct PlayerScore;
30struct ScoreInfo;
31// clang-format on
32
33class Scoreboard {
34public:
35 // member variables
36 // NOLINTBEGIN
37 ::ll::TypedStorage<8, 8, ::CommandSoftEnumRegistry> mRegistry;
38 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::DisplayObjective>> mDisplayObjectives;
39 ::ll::TypedStorage<8, 256, ::IdentityDictionary> mIdentityDict;
40 ::ll::TypedStorage<8, 64, ::std::unordered_map<::ScoreboardId, ::ScoreboardIdentityRef>> mIdentityRefs;
41 ::ll::TypedStorage<1, 1, bool> mShouldUpdateUI;
42 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::Objective>>> mObjectives;
43 ::ll::TypedStorage<8, 64, ::std::unordered_map<uint64, ::Bedrock::NonOwnerPointer<::Objective>>>
44 mObjectivesHashLookup;
45 ::ll::TypedStorage<8, 64, ::std::unordered_map<::std::string, ::std::unique_ptr<::ObjectiveCriteria>>> mCriteria;
46 ::ll::TypedStorage<8, 96, ::ScoreboardEventCoordinator> mScoreboardEventCoordinator;
47 ::ll::TypedStorage<8, 72, ::PlayerScoreboardEventListener> mPlayerListener;
48 // NOLINTEND
49
50public:
51 // prevent constructor by default
52 Scoreboard();
53
54public:
55 LLAPI int modifyPlayerScore(
56 ScoreboardOperationResult& result,
57 ScoreboardId const& id,
58 Objective& objective,
59 int scoreValue,
60 PlayerScoreSetFunction action
61 );
62
63 LLNDAPI ScoreboardId getId(PlayerScoreboardId const& playerId) const;
64
65 [[nodiscard]] std::vector<::Objective const*> getObjectives() const {
66 std::vector<::Objective const*> result;
67 for (auto const& [name, objective] : *mObjectives) {
68 result.emplace_back(objective.get());
69 }
70 return result;
71 }
72
73 LLAPI bool resetPlayerScore(::ScoreboardId const& id, ::Objective& objective);
74
75public:
76 // virtual functions
77 // NOLINTBEGIN
78#ifdef LL_PLAT_S
79 virtual ~Scoreboard();
80#else // LL_PLAT_C
81 virtual ~Scoreboard() = default;
82#endif
83
84 virtual ::DisplayObjective const* setDisplayObjective(
85 ::std::string const& displaySlotName,
86 ::Objective const& objective,
87 ::ObjectiveSortOrder const order
88 );
89
90 virtual ::Objective* clearDisplayObjective(::std::string const& displaySlotName);
91
92 virtual ::ScoreboardId const& createScoreboardId(::Player const& player);
93
94 virtual ::ScoreboardId const& createScoreboardId(::Actor const& entity);
95
96 virtual ::ScoreboardId const& createScoreboardId(::std::string const& fakePlayer);
97
98 virtual void onObjectiveAdded(::Objective const& objective);
99
100 virtual void onObjectiveRemoved(::Objective& objective);
101
102 virtual void onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
103
104 virtual void onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
105
106 virtual void onPlayerJoined(::Player const& player);
107
108 virtual void onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
109
110 virtual void tick();
111
112 virtual void setPacketSender(::PacketSender* sender);
113
114 virtual void writeToLevelStorage();
115
116 virtual bool isClientSide() const;
117 // NOLINTEND
118
119public:
120 // member functions
121 // NOLINTBEGIN
122 MCAPI explicit Scoreboard(::CommandSoftEnumRegistry registry);
123
124#ifdef LL_PLAT_S
125 MCAPI void _addLoadedCriteria(::std::unique_ptr<::ObjectiveCriteria> newCriteria);
126
127 MCAPI void _addLoadedObjective(::std::unique_ptr<::Objective> newObjective);
128#endif
129
130 MCAPI ::Objective*
131 addObjective(::std::string const& name, ::std::string const& displayName, ::ObjectiveCriteria const& criteria);
132
133 MCAPI int applyPlayerOperation(
134 ::ScoreboardOperationResult& result,
135 ::std::vector<::ScoreboardId>& sourceErrorIds,
136 ::ScoreboardId const& target,
137 ::Objective& targetObjective,
138 ::std::vector<::ScoreboardId>& selector,
139 ::Objective& objective,
140 ::CommandOperator opCode
141 );
142
143#ifdef LL_PLAT_C
144 MCAPI bool clearScoreboardIdentity(::ScoreboardId const& scoreboardId);
145#endif
146
147 MCAPI ::ObjectiveCriteria* getCriteria(::std::string const& criteriaName) const;
148
149 MCAPI ::std::vector<::PlayerScore> getDisplayInfoFiltered(::std::string const& displaySlot) const;
150
151#ifdef LL_PLAT_C
152 MCAPI ::std::vector<::PlayerScore> getDisplayInfoSorted(
153 ::std::string const& displaySlot,
154 ::std::function<void(::ObjectiveSortOrder, ::std::vector<::PlayerScore>&)> sortMethod
155 ) const;
156#endif
157
158 MCAPI ::DisplayObjective const* getDisplayObjective(::std::string const& displaySlotName) const;
159
160 MCAPI ::std::vector<::std::string> getDisplayObjectiveSlotNames() const;
161
162 MCAPI ::Objective* getObjective(::std::string const& name) const;
163
164 MCAPI ::ScoreboardId const& getScoreboardId(::Actor const& entity) const;
165
166#ifdef LL_PLAT_S
167 MCAPI ::ScoreboardId const& getScoreboardId(::ActorUniqueID const& entityId) const;
168#endif
169
170 MCAPI ::ScoreboardId const& getScoreboardId(::std::string const& name) const;
171
172#ifdef LL_PLAT_S
173 MCAPI ::std::vector<::ScoreboardId> getTrackedIds() const;
174
175 MCAPI ::ScoreboardIdentityRef const& registerScoreboardIdentity(::CompoundTag const& loadedData);
176#endif
177
178 MCAPI ::ScoreboardIdentityRef const&
179 registerScoreboardIdentity(::ScoreboardId const& scoreboardId, ::PlayerScoreboardId const& playerId);
180
181 MCAPI bool removeObjective(::Objective* objective);
182
183#ifdef LL_PLAT_S
184 MCAPI void removeScoreListener(::Player const& player);
185#endif
186
187 MCAPI void removeScoreListener(::Player const& player, ::std::string const& objective);
188
189 MCAPI void resetPlayerScore(::ScoreboardId const& id);
190
191 MCAPI ::std::optional<::ScoreInfo> tryGetIdScore(::ScoreboardId const& id, uint64 const& objectiveHash) const;
192 // NOLINTEND
193
194public:
195 // static variables
196 // NOLINTBEGIN
197 MCAPI static ::std::string const& DEFAULT_CRITERIA();
198
199 MCAPI static ::std::string const& DISPLAY_SLOT_BELOWNAME();
200
201 MCAPI static ::std::string const& DISPLAY_SLOT_LIST();
202
203 MCAPI static ::std::string const& DISPLAY_SLOT_SIDEBAR();
204
205 MCAPI static char const*& OBJECTIVES_ENUM();
206 // NOLINTEND
207
208public:
209 // constructor thunks
210 // NOLINTBEGIN
211 MCAPI void* $ctor(::CommandSoftEnumRegistry registry);
212 // NOLINTEND
213
214public:
215 // destructor thunk
216 // NOLINTBEGIN
217#ifdef LL_PLAT_S
218 MCAPI void $dtor();
219#endif
220 // NOLINTEND
221
222public:
223 // virtual function thunks
224 // NOLINTBEGIN
225 MCAPI ::DisplayObjective const* $setDisplayObjective(
226 ::std::string const& displaySlotName,
227 ::Objective const& objective,
228 ::ObjectiveSortOrder const order
229 );
230
231 MCAPI ::Objective* $clearDisplayObjective(::std::string const& displaySlotName);
232
233 MCAPI ::ScoreboardId const& $createScoreboardId(::Player const& player);
234
235 MCAPI ::ScoreboardId const& $createScoreboardId(::Actor const& entity);
236
237 MCAPI ::ScoreboardId const& $createScoreboardId(::std::string const& fakePlayer);
238
239 MCAPI void $onObjectiveAdded(::Objective const& objective);
240
241 MCAPI void $onObjectiveRemoved(::Objective& objective);
242
243 MCAPI void $onScoreChanged(::ScoreboardId const& id, ::Objective const& obj);
244
245 MCFOLD void $onPlayerScoreRemoved(::ScoreboardId const& id, ::Objective const& objective);
246
247 MCFOLD void $onPlayerJoined(::Player const& player);
248
249 MCFOLD void $onPlayerIdentityUpdated(::PlayerScoreboardId const& playerId);
250
251 MCFOLD void $tick();
252
253 MCFOLD void $setPacketSender(::PacketSender* sender);
254
255 MCFOLD void $writeToLevelStorage();
256
257 MCFOLD bool $isClientSide() const;
258
259
260 // NOLINTEND
261};
Definition Actor.h:113
Definition CommandSoftEnumRegistry.h:10
Definition CompoundTag.h:18
Definition DisplayObjective.h:16
Definition ObjectiveCriteria.h:13
Definition Objective.h:17
Definition PacketSender.h:17
Definition Player.h:129
Definition ScoreboardIdentityRef.h:17
Definition ActorUniqueID.h:5
Definition PlayerScore.h:8
Definition PlayerScoreboardId.h:6
Definition ScoreInfo.h:10
Definition ScoreboardId.h:11