71 lines
2.0 KiB
C#
Raw Normal View History

2024-08-17 14:27:18 +08:00
using AppGame.Systems;
2024-08-31 15:35:12 +08:00
using AppGame.Systems.CServer;
2024-10-17 01:59:25 +08:00
using JNGame.Runtime.System;
using JNGame.Runtime.Util;
using JNGame.Util;
2024-08-17 14:27:18 +08:00
using Service;
namespace AppGame
{
/// <summary>
/// App 环境
/// </summary>
public enum AppEnv
{
Client,
Server,
ServerClient,
2024-08-31 15:35:12 +08:00
SlaveServer,
SlaveServerClient,
2024-08-17 14:27:18 +08:00
}
public class App
{
public static AppEnv Env = AppEnv.ServerClient;
/// <summary>
/// 业务服务器
/// </summary>
public static readonly JNGSocket Business = new JNGSocket();
/// <summary>
/// Tile服务器
/// </summary>
public static readonly JNGServer Server = new JNGServer();
/// <summary>
/// Tile客户端
/// </summary>
public static readonly JNGClientGroup Client = new JNGClientGroup();
public static readonly JNGResService Resource = new JNGResService();
public static readonly JNGGame Game = new JNGGame();
public static readonly JAPI API = new(new JAPIConfig(){BaseURL = "http://127.0.0.1:8080"});
public static readonly GAPI GAPI = new GAPI();
2024-08-31 15:35:12 +08:00
public static readonly EventDispatcher Event = new();
2024-08-17 14:27:18 +08:00
public static int ClientID => Client.ClientID;
public static SystemBase[] AllSystem()
{
return new SystemBase[]
{
Business,
2024-08-31 15:35:12 +08:00
IsServer() || IsSlaveServer() ? Server : null,
2024-08-17 14:27:18 +08:00
Client,
Resource,
Game,
};
}
public static bool IsClient()
{
2024-08-31 15:35:12 +08:00
return Env is AppEnv.Client or AppEnv.ServerClient or AppEnv.SlaveServerClient;
2024-08-17 14:27:18 +08:00
}
public static bool IsServer()
{
return Env is AppEnv.Server or AppEnv.ServerClient;
}
2024-08-31 15:35:12 +08:00
public static bool IsSlaveServer()
{
return Env is AppEnv.SlaveServer or AppEnv.SlaveServerClient;
}
2024-08-17 14:27:18 +08:00
}
}