Program.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using System.IO;
  3. using System.Reflection;
  4. using Base;
  5. using Model;
  6. using Object = Base.Object;
  7. namespace App
  8. {
  9. internal static class Program
  10. {
  11. private static void Main(string[] args)
  12. {
  13. try
  14. {
  15. Log.Info("server start........................");
  16. Object.ObjectManager.Register("Base", typeof(Game).Assembly);
  17. Object.ObjectManager.Register("Model", typeof(Opcode).Assembly);
  18. byte[] dllBytes = File.ReadAllBytes("./Controller.dll");
  19. byte[] pdbBytes = File.ReadAllBytes("./Controller.pdb");
  20. Assembly controller = Assembly.Load(dllBytes, pdbBytes);
  21. Object.ObjectManager.Register("Controller", controller);
  22. Game.Scene.AddComponent<EventComponent>();
  23. TimeComponent timeComponent = Game.Scene.AddComponent<TimeComponent>();
  24. Game.Scene.AddComponent<TimerComponent, TimeComponent>(timeComponent);
  25. Options options = Game.Scene.AddComponent<OptionsComponent, string[]>(args).Options;
  26. Game.Scene.AddComponent<NetworkComponent, NetworkProtocol, string, int>(options.Protocol, options.Host, options.Port);
  27. Game.Scene.AddComponent<MessageHandlerComponent, string>(options.AppType);
  28. while (true)
  29. {
  30. Object.ObjectManager.Update();
  31. }
  32. }
  33. catch (Exception e)
  34. {
  35. Log.Error(e.ToString());
  36. }
  37. }
  38. }
  39. }