2021-03-18 18:51:13 +00:00
|
|
|
using System;
|
2021-05-27 01:22:23 +01:00
|
|
|
using System.Collections;
|
2021-08-14 02:26:48 +01:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Reflection;
|
2021-03-18 18:51:13 +00:00
|
|
|
using CLre_server.API.Engines;
|
|
|
|
using Game.DataLoader;
|
|
|
|
using GameServer;
|
2021-08-14 02:26:48 +01:00
|
|
|
using HarmonyLib;
|
2021-03-18 18:51:13 +00:00
|
|
|
using Svelto.Context;
|
2021-08-14 02:26:48 +01:00
|
|
|
using Svelto.DataStructures;
|
2021-03-18 18:51:13 +00:00
|
|
|
using Svelto.ECS;
|
2021-08-14 02:26:48 +01:00
|
|
|
using User.Server;
|
2021-03-18 18:51:13 +00:00
|
|
|
|
|
|
|
namespace CLre_server.API.MainServer
|
|
|
|
{
|
|
|
|
class ServerReadyEngine : ServerEnginePostBuild, IWaitForFrameworkInitialization, IWaitForFrameworkDestruction
|
|
|
|
{
|
|
|
|
internal static event EventHandler<StartedEventArgs> serverEngineReady;
|
|
|
|
|
|
|
|
internal static event EventHandler<StartedEventArgs> serverFrameworkReady;
|
|
|
|
|
|
|
|
internal static event EventHandler<StopEventArgs> serverFrameworkDestroyed;
|
|
|
|
|
|
|
|
public override void Ready()
|
|
|
|
{
|
|
|
|
GameServerSettings gss = Server.Instance.GameServerSettings;
|
|
|
|
if (serverEngineReady != null) serverEngineReady(this, new StartedEventArgs
|
|
|
|
{
|
|
|
|
photonVersion = PhotonNetwork.gameVersion,
|
|
|
|
photonRegion = PhotonNetwork.CloudRegion,
|
2021-05-27 01:22:23 +01:00
|
|
|
gameGuid = gss == null ? "" : gss.GetGameGuid(),
|
|
|
|
worldName = gss == null ? "" : gss.GetWorldName(),
|
2021-03-18 18:51:13 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnFrameworkInitialized()
|
|
|
|
{
|
|
|
|
GameServerSettings gss = Server.Instance.GameServerSettings;
|
|
|
|
if (serverFrameworkReady != null) serverFrameworkReady(this, new StartedEventArgs
|
|
|
|
{
|
|
|
|
photonVersion = PhotonNetwork.gameVersion,
|
|
|
|
photonRegion = PhotonNetwork.CloudRegion,
|
2021-05-27 01:22:23 +01:00
|
|
|
gameGuid = gss == null ? "" : gss.GetGameGuid(),
|
|
|
|
worldName = gss == null ? "" : gss.GetWorldName(),
|
2021-03-18 18:51:13 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnFrameworkDestroyed()
|
|
|
|
{
|
|
|
|
if (serverFrameworkDestroyed != null) serverFrameworkDestroyed(this, new StopEventArgs{});
|
|
|
|
}
|
|
|
|
}
|
2021-08-14 02:26:48 +01:00
|
|
|
|
|
|
|
class ServerDatabaseQueryEngine : ServerEnginePostBuild
|
|
|
|
{
|
|
|
|
public override void Ready()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public AccountIdServerNode[] GetConnectedAccounts()
|
|
|
|
{
|
|
|
|
FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
|
|
|
|
ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
|
|
|
|
ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
|
|
|
|
entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
|
|
|
|
List<AccountIdServerNode> list = new List<AccountIdServerNode>();
|
|
|
|
foreach (var a in accounts)
|
|
|
|
{
|
|
|
|
list.Add(a);
|
|
|
|
}
|
|
|
|
return list.ToArray();
|
|
|
|
}
|
|
|
|
}
|
2021-03-18 18:51:13 +00:00
|
|
|
}
|