ZoneNodeManager.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. using CommonAI;
  2. using CommonAI.Zone;
  3. using CommonAI.Zone.ZoneEditor;
  4. using CommonLang;
  5. using CommonLang.Log;
  6. using CommonLang.Protocol;
  7. using System;
  8. using System.IO;
  9. using xmds_battle_server.JSGModule;
  10. using XmdsServerNode.CheatingDeath;
  11. using XmdsServerNode.Node.Interface;
  12. namespace XmdsServerNode.Node
  13. {
  14. public class ZoneNodeManager
  15. {
  16. public static ZoneNodeManager Instance { get; private set; }
  17. public static DirectoryInfo StartupPath { get; private set; }
  18. public static ZoneNodeConfig NodeConfig { get; private set; }
  19. public static InstanceZoneFactory ZoneFactory { get; private set; }
  20. public static MessageFactoryGenerator MessageFactory { get; private set; }
  21. public static EditorTemplates Templates { get; private set; }
  22. private Logger log = LoggerFactory.GetLogger("ZoneNodeManager");
  23. public IServerProxy ServerProxy { get; private set; }
  24. /// <summary>
  25. /// 全局初始化处
  26. /// </summary>
  27. /// <param name="startup_path"></param>
  28. /// <param name="mb2s2b"></param>
  29. /// <param name="dataPath"></param>
  30. virtual public void Init(string startup_path, IServerProxy mb2s2b, string dataPath = null)
  31. {
  32. Console.WriteLine("logger name : " + log.GetType().Name);
  33. Instance = this;
  34. ServerProxy = mb2s2b;
  35. StartupPath = new DirectoryInfo(startup_path);
  36. //XmdsDllInit.Init();
  37. log.Info("********************************************************");
  38. log.Info("# 加载配置文件");
  39. log.Info("********************************************************");
  40. {
  41. NodeConfig = new ZoneNodeConfig();
  42. Properties zone_server_config = Properties.LoadFromResource(startup_path + "/zone_server_config.properties");
  43. log.Info(startup_path + "/zone_server_config.properties");
  44. foreach (string key in zone_server_config.Keys)
  45. {
  46. log.Info(string.Format(" {0} = {1}", key, zone_server_config[key]));
  47. }
  48. zone_server_config.LoadFields(NodeConfig);
  49. if (dataPath != null)
  50. {
  51. NodeConfig.GAME_DATA_ROOT_PATH = dataPath;
  52. }
  53. EditorTemplates.DEFAULT_LOAD_FROM_BIN = NodeConfig.GAME_DATA_DEFAULT_LOAD_FROM_BIN;
  54. log.Info(" 资源目录 : " + NodeConfig.GAME_DATA_ROOT_PATH);
  55. XmdsConstConfig.GAME_UPDATE_INTERVAL_MS = NodeConfig.GAME_UPDATE_INTERVAL_MS;
  56. }
  57. log.Info("********************************************************");
  58. //log.Info("# 初始化战斗编辑器扩展");
  59. //log.Info("********************************************************");
  60. {
  61. ZoneFactory = new ZoneNodeServerFactory(mb2s2b);
  62. TemplateManager.setFactory(ZoneFactory);
  63. //log.Info(" 战斗编辑器插件 --> " + ZoneFactory);
  64. }
  65. //log.Info("********************************************************");
  66. //log.Info("# 初始化消息编解码器");
  67. //log.Info("********************************************************");
  68. {
  69. MessageFactory = TemplateManager.MessageCodec;
  70. //log.Info("\r\n" + MessageFactory.ListAll(" "));
  71. File.WriteAllText(StartupPath + "\\codec.txt", MessageFactory.ListAll());
  72. }
  73. log.Info("********************************************************");
  74. log.Info("# 加载模板数据");
  75. log.Info("********************************************************");
  76. {
  77. Templates = new EditorTemplates(NodeConfig.GAME_DATA_ROOT_PATH, MessageFactory);
  78. Templates.LoadAllTemplates();
  79. TemplateManager.Formula.BindLogger(LoggerFactory.GetDefLogger());
  80. }
  81. log.Info("********************************************************");
  82. log.Info("# 初始化防作弊");
  83. log.Info("********************************************************");
  84. {
  85. Properties cd_config = Properties.LoadFromResource(startup_path + "/cheating_death_config.properties");
  86. log.Info(startup_path + "/cheating_death_config.properties");
  87. CheatingDeathManager.Init(cd_config);
  88. }
  89. int out_io_tc, out_wk_tc;
  90. System.Threading.ThreadPool.GetMaxThreads(out out_wk_tc, out out_io_tc);
  91. System.Threading.ThreadPool.SetMaxThreads(NodeConfig.SYSTEM_WORK_THREAD_COUNT, out_io_tc);
  92. log.Info("********************************************************");
  93. log.Info("初始化完成");
  94. //反射notifyMessage
  95. R2bNotify.R2bNotifyManager.Init();
  96. //检测单位
  97. //CheckConfigModule.CheckActiveSkillAttackRange(Templates);
  98. //Templates.CheckScenePosInfo();
  99. }
  100. /// <summary>
  101. /// 关闭服务
  102. /// </summary>
  103. public virtual void Shutdown()
  104. {
  105. }
  106. }
  107. }