少年修仙传客户端代码仓库
hch
2025-04-03 c154ac0832fe4379a00d3e1cda700e7d2a7383c7
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Threading;
using LitJson;
 
public class ServerListParser : SingletonMonobehaviour<ServerListParser>
{
 
    bool hasCommonResult = false;
    ServerInfoCommon serverInfoCommon;
    bool hasPlayerResult = false;
    ServerInfoPlayer serverInfoPlayer;
 
    List<string> serverGroupTitlesNoShow = new List<string>();  //不显示的区服组
    Dictionary<string, string> areaSpecialServerDict = new Dictionary<string, string>(); //根据地区特殊附加的区服组
 
    public void PushCommonServerListRawData(string content)
    {
        hasCommonResult = false;
        ThreadPool.QueueUserWorkItem((object aaa) =>
        {
            serverInfoCommon = JsonMapper.ToObject<ServerInfoCommon>(content);
            //FilterServerList();
            hasCommonResult = true;
        });
    }
 
    //过滤不显示的服务器
    public void FilterServerList()
    {
        if (serverInfoCommon == null)
            return;
 
        if (serverGroupTitlesNoShow.IsNullOrEmpty())
        {
            var config = InitialFunctionConfig.Get("serverListGroup");
            serverGroupTitlesNoShow = JsonMapper.ToObject<List<string>>(config.Numerical1);
            areaSpecialServerDict = JsonMapper.ToObject<Dictionary<string, string>>(config.Numerical2);
        }
 
        //按 group_title删除不显示的服务器组
        List<ServerGroup> common = new List<ServerGroup>();
        for (int i = serverInfoCommon.common.Length - 1; i >= 0; i--)
        {
            ServerGroup serverGroup = serverInfoCommon.common[i];
 
            var title = serverInfoCommon.common[i].group_title;
            if (serverGroupTitlesNoShow.Contains(title))
            {
                if (areaSpecialServerDict.ContainsKey(VersionConfig.Get().sdkFileName)
                && areaSpecialServerDict[VersionConfig.Get().sdkFileName] == title)
                {
                    //特殊指定的服务器组
                    common.Add(serverGroup);
                }
                continue;
            }
            else
            {
                common.Add(serverGroup);
            }
 
        }
 
        serverInfoCommon.common = common.ToArray();
 
    }
 
 
    public void PushPlayerServerListRawData(string content)
    {
        hasPlayerResult = false;
        Debug.Log("ServerListParser:" + content);
        if (content == "" || content == "{}")
            return;
        JsonData RankArr = JsonMapper.ToObject(content);
        if (RankArr["player"]["group_list"].Count == 0)
            return;
 
        ThreadPool.QueueUserWorkItem((object aaa) =>
        {
            serverInfoPlayer = JsonMapper.ToObject<ServerInfoPlayer>(content);
            hasPlayerResult = true;
            SetIsInWhiteList();
        });
    }
 
    public void ReportCommonResult()
    {
        if (serverInfoCommon != null)
        {
            ServerListCenter.Instance.SetServerlistCommon(serverInfoCommon);
        }
    }
 
    public void ReportPlayerResult()
    {
        if (serverInfoPlayer != null)
        {
            ServerListCenter.Instance.SetServerListPlayer(serverInfoPlayer);
        }
    }
 
    public void SetIsInWhiteList()
    {
        DebugUtility.Instance.isWhiteListAccount = serverInfoPlayer.white == 1;
    }
 
 
    private void Update()
    {
        if (hasCommonResult)
        {
            ReportCommonResult();
            hasCommonResult = false;
        }
 
        if (hasPlayerResult)
        {
            ReportPlayerResult();
            hasPlayerResult = false;
        }
    }
 
}