2025-04-22 15:31:25 +08:00

34 lines
1.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Fantasy;
using Fantasy.Assembly;
using Fantasy.ConfigTable;
using Fantasy.DataBase;
using Fantasy.Helper;
using Fantasy.IdFactory;
using Fantasy.Platform.Net;
ConfigTableHelper.Initialize("../../../Config/Binary");
IdFactoryHelper.Initialize(IdFactoryType.World);
// 获取配置文件
// 比如通过远程获取这个配置文件,这样可以多组服务器共享一套配置了
var machineConfigText = await FileHelper.GetTextByRelativePath("../../../Config/Json/Server/MachineConfigData.Json");
var processConfigText = await FileHelper.GetTextByRelativePath("../../../Config/Json/Server/ProcessConfigData.Json");
var worldConfigText = await FileHelper.GetTextByRelativePath("../../../Config/Json/Server/WorldConfigData.Json");
var sceneConfigText = await FileHelper.GetTextByRelativePath("../../../Config/Json/Server/SceneConfigData.Json");
// 初始化配置文件
// 如果重复初始化方法会覆盖掉上一次的数据,非常适合热重载时使用
MachineConfigData.Initialize(machineConfigText);
ProcessConfigData.Initialize(processConfigText);
WorldConfigData.Initialize(worldConfigText);
SceneConfigData.Initialize(sceneConfigText);
// 注册日志模块到框架
// 开发者可以自己注册日志系统到框架只要实现Fantasy.ILog接口就可以。
// 这里用的是NLog日志系统注册到框架中。
Fantasy.Log.Register(new Fantasy.NLog("Server"));
// 初始化框架,添加程序集到框架中
Fantasy.Platform.Net.Entry.Initialize(Fantasy.AssemblyHelper.Assemblies);
// 启动Fantasy.Net
await Fantasy.Platform.Net.Entry.Start();
// 也可以使用下面的Start方法来初始化并且启动Fantasy.Net
// 使用下面这个方法就不用使用上面的两个方法了。
// await Fantasy.Platform.Net.Entry.Start(Fantasy.AssemblyHelper.Assemblies);