12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- using KYFramework;
- using KYFramework.Network;
- using Timer = KYFramework.Timer;
- namespace SimulationServer;
- public static class Init
- {
- public static void Start()
- {
- try
- {
- AppDomain.CurrentDomain.UnhandledException += (sender, e) => { Log.Error(e.ExceptionObject.ToString()); };
- SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);
- Game.EventSystem.Add(typeof(Init).Assembly);
- Game.EventSystem.Add(typeof(Entity).Assembly);
- Game.EventSystem.Add(typeof(NetworkComponent).Assembly);
- Logger.Instance.ILog = new NLogger("Client", "./Config/NLog/NLog.config");
- Game.Scene.AddComponent<Timer>();
- Game.Scene.AddComponent<TimerComponent>();
- //Game.Scene.AddComponent<ConfigComponent>();
- //UDP
- //Game.Scene.AddComponent<MessageDispatcherComponent>();
-
- //TCP
- //Game.Scene.AddComponent<OpcodeTypeComponent>();
- //Game.Scene.AddComponent<MessageDispatcherComponent>();
- //Game.Scene.AddComponent<ServerComponent, string>(File.ReadAllText("Config/ipconfig.txt"));
- Game.Scene.AddComponent<SessionComponent>();
- // 任务
- Game.Scene.AddComponent<TaskComponent>();
-
- Game.EventSystem.Publish(new ServerStart());
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- }
- }
- public static void Update()
- {
- OneThreadSynchronizationContext.Instance.Update();
- Game.EventSystem.Update();
- }
- public static void LateUpdate()
- {
- Game.EventSystem.LateUpdate();
- }
- public static void OnApplicationQuit()
- {
- Game.Close();
- }
- }
|