blob: 005b7b7017319cacb5d40aedd539b905adad7edb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
#pragma once
#include "StarUuid.hpp"
#include "StarDrawable.hpp"
#include "StarWarping.hpp"
#include "StarJsonRpc.hpp"
namespace Star {
STAR_CLASS(Player);
STAR_CLASS(ClientContext);
STAR_CLASS(TeamClient);
class TeamClient {
public:
struct Member {
String name;
Uuid uuid;
int entity;
float healthPercentage;
float energyPercentage;
WorldId world;
Vec2F position;
WarpMode warpMode;
List<Drawable> portrait;
};
TeamClient(PlayerPtr mainPlayer, ClientContextPtr clientContext);
void invitePlayer(String const& playerName);
void acceptInvitation(Uuid const& inviterUuid);
Maybe<Uuid> currentTeam() const;
void makeLeader(Uuid const& playerUuid);
void removeFromTeam(Uuid const& playerUuid);
bool isTeamLeader();
bool isTeamLeader(Uuid const& playerUuid);
bool isMemberOfTeam();
bool hasInvitationPending();
pair<Uuid, String> pullInvitation();
void update();
void pullFullUpdate();
void statusUpdate();
void forceUpdate();
List<Member> members();
private:
typedef pair<RpcPromise<Json>, function<void(Json const&)>> RpcResponseHandler;
void invokeRemote(String const& method, Json const& args, function<void(Json const&)> responseFunction = {});
void handleRpcResponses();
void writePlayerData(JsonObject& request, PlayerPtr player, bool fullWrite = false) const;
void clearTeam();
PlayerPtr m_mainPlayer;
ClientContextPtr m_clientContext;
Maybe<Uuid> m_teamUuid;
Uuid m_teamLeader;
List<Member> m_members;
bool m_hasPendingInvitation;
pair<Uuid, String> m_pendingInvitation;
double m_pollInvitationsTimer;
bool m_fullUpdateRunning;
double m_fullUpdateTimer;
bool m_statusUpdateRunning;
double m_statusUpdateTimer;
List<RpcResponseHandler> m_pendingResponses;
};
}
|