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