1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using KYFramework;
- using KYFramework.Network;
- using Timer = KYFramework.Timer;
- namespace SimulationServer;
- public static class Init
- {
- public static int SimulationSpeed = 1;
- 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>();
-
- Log.Info("服务器启动完成!");
- 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();
- }
- }
|