|
1 | 1 | // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt
|
2 | 2 |
|
3 | 3 | using Content.Shared.SS220.Discord;
|
| 4 | +using Robust.Client.State; |
4 | 5 | using Robust.Shared.Network;
|
5 | 6 |
|
6 |
| -namespace Content.Client.SS220.Discord |
| 7 | +namespace Content.Client.SS220.Discord; |
| 8 | + |
| 9 | +public sealed class DiscordPlayerInfoManager |
7 | 10 | {
|
8 |
| - public sealed class DiscordPlayerInfoManager |
9 |
| - { |
10 |
| - [Dependency] private readonly IClientNetManager _netMgr = default!; |
| 11 | + [Dependency] private readonly IClientNetManager _netMgr = default!; |
| 12 | + [Dependency] private readonly IStateManager _stateManager = default!; |
11 | 13 |
|
12 |
| - private DiscordSponsorInfo? _info; |
| 14 | + private DiscordSponsorInfo? _info; |
13 | 15 |
|
14 |
| - public event Action? SponsorStatusChanged; |
| 16 | + public event Action? SponsorStatusChanged; |
15 | 17 |
|
16 |
| - public void Initialize() |
17 |
| - { |
18 |
| - _netMgr.RegisterNetMessage<MsgUpdatePlayerDiscordStatus>(UpdateSponsorStatus); |
19 |
| - } |
| 18 | + public string AuthUrl { get; private set; } = string.Empty; |
20 | 19 |
|
21 |
| - private void UpdateSponsorStatus(MsgUpdatePlayerDiscordStatus message) |
22 |
| - { |
23 |
| - _info = message.Info; |
| 20 | + public void Initialize() |
| 21 | + { |
| 22 | + _netMgr.RegisterNetMessage<MsgUpdatePlayerDiscordStatus>(UpdateSponsorStatus); |
| 23 | + _netMgr.RegisterNetMessage<MsgDiscordLinkRequired>(OnDiscordLinkRequired); |
| 24 | + _netMgr.RegisterNetMessage<MsgRecheckDiscordLink>(); |
24 | 25 |
|
25 |
| - SponsorStatusChanged?.Invoke(); |
26 |
| - } |
| 26 | + _netMgr.RegisterNetMessage<MsgByPassDiscordCheck>(); |
| 27 | + } |
| 28 | + |
| 29 | + private void UpdateSponsorStatus(MsgUpdatePlayerDiscordStatus message) |
| 30 | + { |
| 31 | + _info = message.Info; |
27 | 32 |
|
28 |
| - public SponsorTier[] GetSponsorTier() |
| 33 | + SponsorStatusChanged?.Invoke(); |
| 34 | + } |
| 35 | + |
| 36 | + public SponsorTier[] GetSponsorTier() |
| 37 | + { |
| 38 | + return _info?.Tiers ?? Array.Empty<SponsorTier>(); |
| 39 | + } |
| 40 | + |
| 41 | + private void OnDiscordLinkRequired(MsgDiscordLinkRequired msg) |
| 42 | + { |
| 43 | + if (_stateManager.CurrentState is not DiscordLinkRequiredState) |
29 | 44 | {
|
30 |
| - return _info?.Tiers ?? Array.Empty<SponsorTier>(); |
| 45 | + AuthUrl = msg.AuthUrl; |
| 46 | + _stateManager.RequestStateChange<DiscordLinkRequiredState>(); |
31 | 47 | }
|
32 | 48 | }
|
| 49 | + |
| 50 | + public void ByPassCheck() |
| 51 | + { |
| 52 | + _netMgr.ClientSendMessage(new MsgByPassDiscordCheck()); |
| 53 | + } |
33 | 54 | }
|
0 commit comments