2021-04-08 20:09:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using CommandLine;
|
|
|
|
|
using NLog;
|
|
|
|
|
|
|
|
|
|
namespace ET
|
|
|
|
|
{
|
|
|
|
|
internal static class Program
|
|
|
|
|
{
|
|
|
|
|
private static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
// 异步方法全部会回掉到主线程
|
|
|
|
|
SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);
|
2021-05-01 11:27:41 +08:00
|
|
|
|
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
|
2021-04-08 20:09:59 +08:00
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Game.EventSystem.Add(typeof(Game).Assembly);
|
|
|
|
|
Game.EventSystem.Add(DllHelper.GetHotfixAssembly());
|
|
|
|
|
|
|
|
|
|
ProtobufHelper.Init();
|
|
|
|
|
MongoHelper.Init();
|
|
|
|
|
|
|
|
|
|
// 命令行参数
|
|
|
|
|
Options options = null;
|
|
|
|
|
Parser.Default.ParseArguments<Options>(args)
|
|
|
|
|
.WithNotParsed(error => throw new Exception($"命令行格式错误!"))
|
|
|
|
|
.WithParsed(o => { options = o; });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Game.Options = options;
|
|
|
|
|
|
|
|
|
|
LogManager.Configuration.Variables["appIdFormat"] = $"{Game.Scene.Id:0000}";
|
|
|
|
|
|
|
|
|
|
Log.Info($"server start........................ {Game.Scene.Id}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 先加这里,后面删掉
|
|
|
|
|
Game.EventSystem.Publish(new EventType.AppStart()).Coroutine();
|
|
|
|
|
|
|
|
|
|
while (true)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Thread.Sleep(1);
|
|
|
|
|
Game.Update();
|
|
|
|
|
Game.LateUpdate();
|
|
|
|
|
Game.FrameFinish();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-05-01 11:27:41 +08:00
|
|
|
|
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e.ExceptionObject.ToString());
|
|
|
|
|
Environment.Exit(-1); //有此句则不弹异常对话框
|
|
|
|
|
}
|
2021-04-08 20:09:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|