コード例 #1
0
ファイル: Entry.cs プロジェクト: yfgumaths/ET
        public void Start()
        {
            try
            {
                SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);

                string[] assemblyNames = { "Unity.Model.dll", "Unity.Hotfix.dll", "Unity.ModelView.dll", "Unity.HotfixView.dll" };

                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    string assemblyName = assembly.ManifestModule.Name;
                    if (!assemblyNames.Contains(assemblyName))
                    {
                        continue;
                    }
                    Game.EventSystem.Add(assembly);
                }

                ProtobufHelper.Init();

                Game.Options = new Options();

                Game.EventSystem.Publish(new EventType.AppStart());
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: wqaetly/ET
        private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Log.Error(e.ExceptionObject.ToString());
            };
            // 异步方法全部会回掉到主线程
            SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);

            try
            {
                //初始化EventSystem
                {
                    List <Type> types = new List <Type>();
                    types.AddRange(typeof(Game).Assembly.GetTypes());
                    types.AddRange(DllHelper.GetHotfixAssembly().GetTypes());
                    Game.EventSystem.AddRangeType(types);
                    Game.EventSystem.TypeMonoInit();
                    Game.EventSystem.EventSystemInit();
                }

                ProtobufHelper.Init();
                MongoHelper.Init();

                // 命令行参数
                Options options = null;
                Parser.Default.ParseArguments <Options>(args)
                .WithNotParsed(error => throw new Exception($"命令行格式错误!"))
                .WithParsed(o => { options = o; });

                GlobalDefine.Options = options;

                GlobalDefine.ILog = new NLogger(GlobalDefine.Options.AppType.ToString());

                LogManager.Configuration.Variables["appIdFormat"] = $"{GlobalDefine.Options.Process:000000}";

                Log.Info($"server start........................ {Game.Scene.Id}");

                Game.EventSystem.Publish(new EventType.AppStart());

                while (true)
                {
                    try
                    {
                        Thread.Sleep(1);
                        Game.Update();
                        Game.LateUpdate();
                        Game.FrameFinish();
                    }
                    catch (Exception e)
                    {
                        Log.Error(e);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #3
0
        public void Start()
        {
            try
            {
                string[] assemblyNames = { "Unity.Model.dll", "Unity.Hotfix.dll", "Unity.ModelView.dll", "Unity.HotfixView.dll" };

                foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
                {
                    string assemblyName = $"{assembly.GetName().Name}.dll";
                    if (!assemblyNames.Contains(assemblyName))
                    {
                        continue;
                    }
                    Game.EventSystem.Add(assembly);
                }

                ProtobufHelper.Init();

                Game.Options = new Options();

                Game.EventSystem.Publish(new EventType.AppStart());
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #4
0
ファイル: InitEntry.cs プロジェクト: wqaetly/ET
        public static void Start()
        {
            try
            {
                Log.Info("初始化EventSystem");
                {
                    List <Type> types = new List <Type>();
                    types.AddRange(HotfixHelper.GetAssemblyTypes());
                    Game.EventSystem.AddRangeType(types);
                    if (GlobalDefine.ILRuntimeMode)
                    {
                        Game.EventSystem.TypeIlrInit();
                    }
                    else
                    {
                        Game.EventSystem.TypeMonoInit();
                    }
                    Game.EventSystem.EventSystemInit();
                }
                ProtobufHelper.Init();

                GlobalDefine.Options = new Options();

                Game.EventSystem.Publish(new EventType.AppStart()).Coroutine();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #5
0
        public static void Start()
        {
            try
            {
                TypeHelper.Init();
                Game.EventSystem.Init();

                Log.Info("开始热更");

                // 注册热更层回调
                GameLoop.onUpdate          += Update;
                GameLoop.onLateUpdate      += LateUpdate;
                GameLoop.onApplicationQuit += OnApplicationQuit;

                ProtobufHelper.Init();

                Game.Options = new Options();

                Game.EventSystem.Publish(new EventType.AppStart());
            }
            catch (Exception _e)
            {
                Log.Error(_e);
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: zwinter/ET
        private static int Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
            {
                Log.Error(e.ExceptionObject.ToString());
            };

            ETTask.ExceptionHandler += Log.Error;

            // 异步方法全部会回掉到主线程
            SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);

            try
            {
                Game.EventSystem.Add(typeof(Game).Assembly);

                ProtobufHelper.Init();
                MongoRegister.Init();

                // 命令行参数
                Options options = null;
                Parser.Default.ParseArguments <Options>(args)
                .WithNotParsed(error => throw new Exception($"命令行格式错误!"))
                .WithParsed(o => { options = o; });

                Options.Instance = options;

                Log.ILog = new NLogger(Game.Options.AppType.ToString());
                LogManager.Configuration.Variables["appIdFormat"] = $"{Game.Options.Process:000000}";

                Log.Info($"server start........................ {Game.Scene.Id}");

                switch (Game.Options.AppType)
                {
                case AppType.ExcelExporter:
                {
                    Game.Options.Console = 1;
                    ExcelExporter.Export();
                    return(0);
                }

                case AppType.Proto2CS:
                {
                    Game.Options.Console = 1;
                    Proto2CS.Export();
                    return(0);
                }
                }
            }
            catch (Exception e)
            {
                Log.Console(e.ToString());
            }
            return(1);
        }
コード例 #7
0
        private static void Main(string[] args)
        {
            // 异步方法全部会回掉到主线程
            SynchronizationContext.SetSynchronizationContext(ThreadSynchronizationContext.Instance);

            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;

                Game.ILog = new NLogger(Game.Options.AppType.ToString());

                LogManager.Configuration.Variables["appIdFormat"] = $"{Game.Options.Process:000000}";

                Log.Info($"server start........................ {Game.Scene.Id}");

                Game.EventSystem.Publish(new EventType.AppStart());

                while (true)
                {
                    try
                    {
                        Thread.Sleep(1);
                        Game.Update();
                        Game.LateUpdate();
                        Game.FrameFinish();
                    }
                    catch (Exception e)
                    {
                        Log.Error(e);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
コード例 #8
0
        public static void Start()
        {
            try
            {
                Game.EventSystem.Add(typeof(Entry).Assembly);

                CodeLoader.Instance.Update            = Game.Update;
                CodeLoader.Instance.LateUpdate        = Game.LateUpdate;
                CodeLoader.Instance.OnApplicationQuit = Game.Close;

                ProtobufHelper.Init();

                Game.Options = new Options();

                Game.EventSystem.Publish(new EventType.AppStart()).Coroutine();
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }