You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.3 KiB
67 lines
2.3 KiB
namespace ET |
|
{ |
|
public class ServerInfoManagerComponentAwakeSystem : AwakeSystem<ServerInfoManagerComponent> |
|
{ |
|
public override void Awake(ServerInfoManagerComponent self) |
|
{ |
|
self.Awake().Coroutine(); |
|
} |
|
} |
|
|
|
public class ServerInfoManagerComponentDestroySystem : DestroySystem<ServerInfoManagerComponent> |
|
{ |
|
public override void Destroy(ServerInfoManagerComponent self) |
|
{ |
|
foreach (var serverInfo in self.ServerInfos) |
|
{ |
|
serverInfo?.Dispose(); |
|
} |
|
|
|
self.ServerInfos.Clear(); |
|
} |
|
} |
|
|
|
public class ServerInfoManagerComponentLoadSystem : LoadSystem<ServerInfoManagerComponent> |
|
{ |
|
public override void Load(ServerInfoManagerComponent self) |
|
{ |
|
self.Awake().Coroutine(); |
|
} |
|
} |
|
|
|
[FriendClass(typeof(ServerInfo))] |
|
[FriendClass(typeof(ServerInfoManagerComponent))] |
|
public static class ServerInfoManagerComponentSystem |
|
{ |
|
public static async ETTask Awake(this ServerInfoManagerComponent self) |
|
{ |
|
var serverInfoList = await DBManagerComponent.Instance.GetZoneDB(self.DomainZone()).Query<ServerInfo>(d => true); |
|
if (serverInfoList == null || serverInfoList.Count <= 0) |
|
{ |
|
Log.Error("serverInfo count is zero"); |
|
self.ServerInfos.Clear(); |
|
var serverInfoConfigs = ServerInfoConfigCategory.Instance.GetAll(); |
|
|
|
foreach (var info in serverInfoConfigs.Values) |
|
{ |
|
ServerInfo newServerInfo = self.AddChildWithId<ServerInfo>(info.Id); |
|
newServerInfo.ServerName = info.ServerName; |
|
newServerInfo.Status = (int) ServerStaus.Normal; |
|
self.ServerInfos.Add(newServerInfo); |
|
await DBManagerComponent.Instance.GetZoneDB(self.DomainZone()).Save(newServerInfo); |
|
} |
|
return; |
|
} |
|
self.ServerInfos.Clear(); |
|
|
|
foreach (var serverInfo in serverInfoList) |
|
{ |
|
self.AddChild(serverInfo); |
|
self.ServerInfos.Add(serverInfo); |
|
} |
|
|
|
await ETTask.CompletedTask; |
|
} |
|
|
|
} |
|
} |