Protocol.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. using DeepCore;
  2. using DeepCore.IO;
  3. using DeepCore.Reflection;
  4. using DeepMMO.Attributes;
  5. using DeepMMO.Data;
  6. using DeepMMO.Protocol;
  7. using System;
  8. using System.Collections.Generic;
  9. namespace DeepMMO.Server.AreaManager
  10. {
  11. // /// <summary>
  12. // /// 寻找一个Area
  13. // /// </summary>
  14. // [ProtocolRoute("*", "AreaManager")]
  15. // public class LookingForAreaRequest : Request
  16. // {
  17. // /// <summary>
  18. // /// 预期的Area服务地址
  19. // /// </summary>
  20. // public string expectAreaName;
  21. // /// <summary>
  22. // /// 预期的Area服务地址
  23. // /// </summary>
  24. // public string expectAreaNode;
  25. // /// <summary>
  26. // /// 预期的场景
  27. // /// </summary>
  28. // public int expectSceneTemplateID;
  29. // /// <summary>
  30. // /// 预期的具体战斗场景
  31. // /// </summary>
  32. // public string expectZoneUUID;
  33. // }
  34. //
  35. // [ProtocolRoute("AreaManager", "*")]
  36. // public class LookingForAreaResponse : Response
  37. // {
  38. // /// <summary>
  39. // /// 返回Area服务地址
  40. // /// </summary>
  41. // public string areaName;
  42. // /// <summary>
  43. // /// 返回Area服务地址
  44. // /// </summary>
  45. // public string areaNode;
  46. // /// <summary>
  47. // /// 返回场景UUID
  48. // /// </summary>
  49. // public string zoneUUID;
  50. // }
  51. //---------------------------------------------------------------------------------
  52. [ProtocolRoute("Area", "AreaManager")]
  53. public class RegistAreaRequest : Request
  54. {
  55. public string areaName;
  56. public string areaNode;
  57. }
  58. [ProtocolRoute("AreaManager", "Area")]
  59. public class RegistAreaResponse : Response { }
  60. [ProtocolRoute("Area", "AreaManager")]
  61. public class AreaStateNotify : Notify
  62. {
  63. public string areaName;
  64. public string areaNode;
  65. public long memoryMB;
  66. public float cpuPercent;
  67. public int zoneCount;
  68. public int roleCount;
  69. public override string ToString()
  70. {
  71. return ("AreaStateNotify:" +
  72. "\n areaName=" + this.areaName +
  73. "\n areaNode=" + this.areaNode +
  74. "\n roleCount=" + this.roleCount +
  75. "\n zoneCount=" + this.zoneCount +
  76. "\n cpuPercent=" + this.cpuPercent +
  77. "\n memoryMB=" + this.memoryMB);
  78. }
  79. }
  80. //---------------------------------------------------------------------------------
  81. [ProtocolRoute("Logic", "AreaManager")]
  82. public class RoleEnterZoneRequest : Request
  83. {
  84. /// <summary>
  85. /// 公会UUID.如果赋值代表单位进公会场景.
  86. /// </summary>
  87. public string guildUUID;
  88. /// <summary>
  89. /// 服务器ID.
  90. /// </summary>
  91. public string serverID;
  92. /// <summary>
  93. /// 服务器组ID.
  94. /// </summary>
  95. public string servergroupID;
  96. /// <summary>
  97. /// 预期的Area服务地址
  98. /// </summary>
  99. public string expectAreaName;
  100. /// <summary>
  101. /// 预期的Area服务地址
  102. /// </summary>
  103. public string expectAreaNode;
  104. /// <summary>
  105. /// 预期的场景
  106. /// 如果为空,表示不知道在哪个场景,一般是第一次注册用户
  107. /// </summary>
  108. public int expectMapTemplateID;
  109. /// <summary>
  110. /// 预期的具体战斗场景
  111. /// 如果为空,表示没有确定的实体场景
  112. /// </summary>
  113. public string expectZoneUUID;
  114. /// <summary>
  115. /// 自定义玩家groupKey,groupkey相同进同一场景
  116. /// </summary>
  117. public string roomKey;
  118. /// <summary>
  119. /// 角色
  120. /// </summary>
  121. public string roleUUID;
  122. public string roleSessionName;
  123. public string roleSessionNode;
  124. public string roleLogicName;
  125. public string roleLogicNode;
  126. public int roleForce;
  127. public int roleUnitTemplateID;
  128. public string roleDisplayName;
  129. public ZonePosition roleScenePos;
  130. public ISerializable LastZoneSaveData;
  131. public ISerializable roleData;
  132. public string teamID;
  133. public string reason;
  134. /// <summary>
  135. /// 预期线.
  136. /// </summary>
  137. public int expectLineIndex;
  138. /// <summary>
  139. /// 上一次的公共场景.
  140. /// </summary>
  141. public int lastPublicMapID;
  142. /// <summary>
  143. /// 上一次的公共场景UUID.
  144. /// </summary>
  145. public string lastPublicMapUUID;
  146. /// <summary>
  147. /// 公共场景坐标.
  148. /// </summary>
  149. public ZonePosition lastPublicPos;
  150. /// <summary>
  151. /// 扩展数据.
  152. /// </summary>
  153. public HashMap<string, string> ext;
  154. }
  155. [ProtocolRoute("AreaManager", "Logic")]
  156. public class RoleEnterZoneResponse : Response
  157. {
  158. [MessageCode("重新进入")]
  159. public const int CODE_OK_REPLACE = CODE_OK + 1;
  160. [MessageCode("场景不存在")]
  161. public const int CODE_ZONE_NOT_EXIST = CODE_ERROR + 1;
  162. [MessageCode("角色已在场景中")]
  163. public const int CODE_ROLE_ALREADY_IN_ZONE = CODE_ERROR + 2;
  164. [MessageCode("场景未开放")]
  165. public const int CODE_ZONE_NOT_OPEN = CODE_ERROR + 3;
  166. [MessageCode("场景已关闭")]
  167. public const int CODE_ZONE_CLOSED = CODE_ERROR + 4;
  168. [DependOnProperty(nameof(IsSuccess))]
  169. public int mapTemplateID;
  170. [DependOnProperty(nameof(IsSuccess))]
  171. public string zoneUUID;
  172. [DependOnProperty(nameof(IsSuccess))]
  173. public int zoneTemplateID;
  174. [DependOnProperty(nameof(IsSuccess))]
  175. public int roleUnitTemplateID;
  176. [DependOnProperty(nameof(IsSuccess))]
  177. public string roleDisplayName;
  178. [DependOnProperty(nameof(IsSuccess))]
  179. public ISerializable roleBattleData;
  180. [DependOnProperty(nameof(IsSuccess))]
  181. public ZonePosition roleScenePos;
  182. [DependOnProperty(nameof(IsSuccess))]
  183. public string areaName;
  184. [DependOnProperty(nameof(IsSuccess))]
  185. public string areaNode;
  186. [DependOnProperty(nameof(IsSuccess))]
  187. public string guildUUID;
  188. }
  189. //---------------------------------------------------------------------------------
  190. [ProtocolRoute("Logic", "AreaManager")]
  191. public class RoleLeaveZoneRequest : Request
  192. {
  193. public string zoneUUID;
  194. public string roleID;
  195. public bool keepObject;
  196. public string reason;
  197. }
  198. [ProtocolRoute("AreaManager", "Logic")]
  199. public class RoleLeaveZoneResponse : Response
  200. {
  201. [MessageCode("场景不存在")]
  202. public const int CODE_ZONE_NOT_EXIST = CODE_ERROR + 1;
  203. [MessageCode("角色不存在")]
  204. public const int CODE_ROLE_NOT_EXIST = CODE_ERROR + 2;
  205. /// <summary>
  206. /// 最后存在场景坐标
  207. /// </summary>
  208. public ZonePosition lastScenePos;
  209. public ISerializable expandData;
  210. public ISerializable LeaveZoneSaveData;
  211. public int curHP;
  212. public int curMP;
  213. }
  214. //---------------------------------------------------------------------------------
  215. [ProtocolRoute("*", "AreaManager -> Area")]
  216. public class CreateZoneNodeRequest : Request
  217. {
  218. public string serverID;
  219. public string serverGroupID;
  220. public string expectAreaNode;
  221. public int mapTemplateID;
  222. public string managerZoneUUID;
  223. public string reason;
  224. public string createRoleID;
  225. public string teamID;
  226. public string guildUUID;
  227. /// <summary>
  228. /// 自定义玩家roomKey,roomKey相同进同一场景
  229. /// </summary>
  230. public string roomKey;
  231. /// <summary>
  232. /// 扩展数据.
  233. /// </summary>
  234. public ISerializable expandData;
  235. }
  236. [ProtocolRoute("Area -> AreaManager", "*")]
  237. public class CreateZoneNodeResponse : Response
  238. {
  239. [MessageCodeAttribute("地图尚未开放!")]
  240. public const int CODE_ERROR_MAP_NOT_OPEN = 501;
  241. public string zoneUUID;
  242. public string areaName;
  243. public string areaNode;
  244. public int TemplateID;
  245. }
  246. [ProtocolRoute("*", "AreaManager -> Area")]
  247. public class DestoryZoneNodeRequest : Request
  248. {
  249. public string zoneUUID;
  250. public string reason;
  251. }
  252. [ProtocolRoute("Area -> AreaManager", "*")]
  253. public class DestoryZoneNodeResponse : Response
  254. {
  255. }
  256. [ProtocolRoute("Area -> AreaManager", "*")]
  257. public class AreaZoneGameOverNotify : Notify
  258. {
  259. public string zoneUUID;
  260. public string reason;
  261. }
  262. [ProtocolRoute("Area -> AreaManager", "*")]
  263. public class AreaZoneDestoryNotify : Notify
  264. {
  265. public string zoneUUID;
  266. public string reason;
  267. }
  268. //---------------------------------------------------------------------------------
  269. //---------------------------------------------------------------------------------
  270. [ProtocolRoute("*", "AreaManager")]
  271. public class GetAllRoleRequest : Request
  272. {
  273. }
  274. [ProtocolRoute("AreaManager", "*")]
  275. public class GetAllRoleResponse : Response
  276. {
  277. public HashMap<string, OnlinePlayerData> uuidMap;
  278. }
  279. [ProtocolRoute("*", "AreaManager")]
  280. public class QueryZoneAreaNameRequest : Request
  281. {
  282. public string zoneUUID;
  283. }
  284. [ProtocolRoute("AreaManager", "*")]
  285. public class QueryZoneAreaNameResponse : Response
  286. {
  287. public string areaName;
  288. }
  289. /// <summary>
  290. /// 获得场景信息快照.
  291. /// </summary>
  292. [ProtocolRoute("logic", "AreaManager")]
  293. public class GetZonesInfoRequest : Request
  294. {
  295. public string servergroupID;
  296. public int mapID;
  297. }
  298. /// <summary>
  299. /// 获得场景信息快照.
  300. /// </summary>
  301. [ProtocolRoute("AreaManager", "logic")]
  302. public class GetZonesInfoResponse : Response
  303. {
  304. public List<ZoneInfoSnap> snaps;
  305. }
  306. [ProtocolRoute("Logic", "AreaManager")]
  307. public class GetRolePositionRequest : Request
  308. {
  309. // public string zoneUUID;
  310. public string roleUUID;
  311. }
  312. [ProtocolRoute("AreaManager", "Logic")]
  313. public class GetRolePositionResponse : Response
  314. {
  315. public int zoneId;
  316. public string zoneUUID;
  317. public float x;
  318. public float y;
  319. public float z;
  320. public int line;
  321. [MessageCode("场景不存在")]
  322. public const int CODE_ZONE_NOT_EXIST = CODE_ERROR + 1;
  323. [MessageCode("角色不存在")]
  324. public const int CODE_ROLE_NOT_EXIST = CODE_ERROR + 2;
  325. }
  326. [ProtocolRoute("Logic", "AreaManager")]
  327. public class RoleNameChangedNotify : Notify
  328. {
  329. public string roleId;
  330. public string newName;
  331. }
  332. [ProtocolRoute("*", "AreaManager -> Area")]
  333. public class BatchCreateZoneLineRequest : Request
  334. {
  335. public List<CreateZoneNodeRequest> zoneList;
  336. }
  337. [ProtocolRoute("Area -> AreaManager", "*")]
  338. public class BatchCreateZoneLineResponse : Response
  339. {
  340. public List<ZoneInfoSnap> zoneList;
  341. }
  342. /// <summary>
  343. /// 获得场景信息快照.
  344. /// </summary>
  345. [ProtocolRoute("logic", "AreaManager")]
  346. public class GetBatchZonesInfoRequest : Request
  347. {
  348. public string servergroupID;
  349. public List<int> mapIDList;
  350. }
  351. /// <summary>
  352. /// 获得场景信息快照.
  353. /// </summary>
  354. [ProtocolRoute("AreaManager", "logic")]
  355. public class GetBatchZonesInfoResponse : Response
  356. {
  357. public HashMap<int, List<ZoneInfoSnap>> snapDic;
  358. }
  359. //当前秘境玩法状态更新通知
  360. [ProtocolRoute("Area -> AreaManager", "*")]
  361. public class CurrentSecretPlacePlayTypeUpdateNotify : Notify
  362. {
  363. public string zoneUUID;
  364. public int update;
  365. public int playID; //玩法ID
  366. }
  367. }