CLre/CLre_server/API/MainServer/ServerEngines.cs

50 lines
No EOL
1.8 KiB
C#

using System;
using CLre_server.API.Engines;
using Game.DataLoader;
using GameServer;
using Svelto.Context;
using Svelto.ECS;
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,
gameGuid = gss.GetGameGuid(),
worldName = gss.GetWorldName(),
});
}
public override IEntitiesDB entitiesDB { get; set; }
public override IEntityFactory entityFactory { get; set; }
public void OnFrameworkInitialized()
{
GameServerSettings gss = Server.Instance.GameServerSettings;
if (serverFrameworkReady != null) serverFrameworkReady(this, new StartedEventArgs
{
photonVersion = PhotonNetwork.gameVersion,
photonRegion = PhotonNetwork.CloudRegion,
gameGuid = gss.GetGameGuid(),
worldName = gss.GetWorldName(),
});
}
public void OnFrameworkDestroyed()
{
if (serverFrameworkDestroyed != null) serverFrameworkDestroyed(this, new StopEventArgs{});
}
}
}