Messages.cs 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using CommonLang.IO;
  5. using CommonAI.Zone;
  6. using CommonLang.IO.Attribute;
  7. using CommonAI.Zone.Helper;
  8. using CommonLang;
  9. using CommonAI.Data;
  10. using CommonAI.data;
  11. namespace CommonAI.ZoneClient
  12. {
  13. public static class ClientStruct
  14. {
  15. public struct UnitBuffStatus : IExternalizable
  16. {
  17. public int BuffTemplateID;
  18. public uint SenderID;
  19. public bool IsEquip;
  20. public int TotalTime;
  21. public int PassTime;
  22. public byte OverlayLevel;
  23. public int ext; //扩展字段,目前非网络流字段
  24. public void WriteExternal(IOutputStream output)
  25. {
  26. output.PutS32(BuffTemplateID);
  27. output.PutVU32(SenderID);
  28. output.PutBool(IsEquip);
  29. output.PutVS32(TotalTime);
  30. output.PutVS32(PassTime);
  31. output.PutU8(OverlayLevel);
  32. }
  33. public void ReadExternal(IInputStream input)
  34. {
  35. this.BuffTemplateID = input.GetS32();
  36. this.SenderID = input.GetVU32();
  37. this.IsEquip = input.GetBool();
  38. this.TotalTime = input.GetVS32();
  39. this.PassTime = input.GetVS32();
  40. this.OverlayLevel = input.GetU8();
  41. }
  42. public override string ToString()
  43. {
  44. return "[" + BuffTemplateID + ", " + TotalTime + ", " + PassTime + ", " + OverlayLevel + ", " + ext + "]";
  45. }
  46. }
  47. public struct UnitSkillStatus : IExternalizable
  48. {
  49. public int SkillTemplateID;
  50. public int PassTime;
  51. public int useTimes;
  52. public void WriteExternal(IOutputStream output)
  53. {
  54. output.PutS32(SkillTemplateID);
  55. output.PutVS32(PassTime);
  56. output.PutS32(useTimes);
  57. }
  58. public void ReadExternal(IInputStream input)
  59. {
  60. this.SkillTemplateID = input.GetS32();
  61. this.PassTime = input.GetVS32();
  62. this.useTimes = input.GetS32();
  63. }
  64. }
  65. public struct UnitItemStatus : IExternalizable
  66. {
  67. public int ItemTemplateID;
  68. public int Count;
  69. public void WriteExternal(IOutputStream output)
  70. {
  71. output.PutS32(ItemTemplateID);
  72. output.PutVS32(Count);
  73. }
  74. public void ReadExternal(IInputStream input)
  75. {
  76. this.ItemTemplateID = input.GetS32();
  77. this.Count = input.GetVS32();
  78. }
  79. }
  80. public class ZoneEnvironmentVar : IExternalizable
  81. {
  82. public string Key;
  83. public bool SyncToClient;
  84. public object Value;
  85. public void WriteExternal(IOutputStream output)
  86. {
  87. output.PutUTF(Key);
  88. output.PutBool(SyncToClient);
  89. output.PutData(Value);
  90. }
  91. public void ReadExternal(IInputStream input)
  92. {
  93. DataType dt;
  94. this.Key = input.GetUTF();
  95. this.SyncToClient = input.GetBool();
  96. this.Value = input.GetData(out dt);
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 单位的客户端显示数据,通常存储横向功能,比如Avatar
  102. /// </summary>
  103. public interface IUnitVisibleData : IExternalizable
  104. {
  105. void setVisibleName(String name);
  106. void setVisibleCardData(ICardData datas);
  107. }
  108. abstract public class SyncObjectInfo : IExternalizable
  109. {
  110. public uint ObjectID;
  111. public int TemplateID;
  112. public float x;
  113. public float y;
  114. public float direction;
  115. /// <summary>
  116. /// 用于扩展属性
  117. /// </summary>
  118. public IExternalizable ExtData;
  119. public abstract bool IsHalf { get; protected set; }
  120. public abstract bool HasExtData { get; protected set; }
  121. public virtual void ReadExternal(IInputStream input)
  122. {
  123. this.ObjectID = input.GetVU32();
  124. this.TemplateID = input.GetS32();
  125. MoveHelper.ReadPosAndDirection(IsHalf, out x, out y, out direction, input);
  126. if (HasExtData)
  127. {
  128. this.ExtData = input.GetExtAny();
  129. }
  130. }
  131. public virtual void WriteExternal(IOutputStream output)
  132. {
  133. output.PutVU32(ObjectID);
  134. output.PutS32(TemplateID);
  135. MoveHelper.WritePosAndDirection(IsHalf, x, y, direction, output);
  136. if (HasExtData)
  137. {
  138. output.PutExt(this.ExtData);
  139. }
  140. }
  141. }
  142. /// <summary>
  143. /// 场景中同步单位数据
  144. /// </summary>
  145. [MessageType(0x9010)]
  146. public class SyncUnitInfo : SyncObjectInfo
  147. {
  148. public string Name;
  149. public string Alias;
  150. public int Force;
  151. public int Level;
  152. public string PlayerUUID;
  153. public byte status;
  154. public byte sub_status;
  155. public short sub_flag; //sub_status>0才会有
  156. // 天命属性
  157. public byte fateType;
  158. public UnitFieldChangedEvent fields = new UnitFieldChangedEvent();
  159. public ClientStruct.UnitBuffStatus[] CurrentBuffStatus;
  160. public IUnitVisibleData VisibleInfo;
  161. //---------------------------------------------------
  162. private BitSet8 mask = new BitSet8(0);
  163. public override bool IsHalf
  164. {
  165. get { return mask.Get(0); }
  166. protected set { mask.Set(0, value); }
  167. }
  168. public override bool HasExtData
  169. {
  170. get { return mask.Get(1); }
  171. protected set { mask.Set(1, value); }
  172. }
  173. public bool HasName
  174. {
  175. get { return mask.Get(2); }
  176. private set { mask.Set(2, value); }
  177. }
  178. public bool HasPlayerUUID
  179. {
  180. get { return mask.Get(3); }
  181. private set { mask.Set(3, value); }
  182. }
  183. public bool HasAlias
  184. {
  185. get { return mask.Get(4); }
  186. private set { mask.Set(4, value); }
  187. }
  188. public bool IsTouchObj
  189. {
  190. get { return mask.Get(5); }
  191. set { mask.Set(5, value); }
  192. }
  193. public bool IsTouchMap
  194. {
  195. get { return mask.Get(6); }
  196. set { mask.Set(6, value); }
  197. }
  198. public bool IsStaticBlockable
  199. {
  200. get { return mask.Get(7); }
  201. set { mask.Set(7, value); }
  202. }
  203. //---------------------------------------------------
  204. public SyncUnitInfo(bool is_half) { this.IsHalf = is_half; }
  205. public SyncUnitInfo() { }
  206. public override void ReadExternal(IInputStream input)
  207. {
  208. this.mask.Mask = input.GetU8();
  209. base.ReadExternal(input);
  210. this.Force = input.GetS32();
  211. this.Level = input.GetVS32();
  212. if (HasName) this.Name = input.GetUTF();
  213. if (HasPlayerUUID) this.PlayerUUID = input.GetUTF();
  214. if (HasAlias) this.Alias = input.GetUTF();
  215. this.VisibleInfo = input.GetExtAny() as IUnitVisibleData;
  216. this.CurrentBuffStatus = input.GetStructArray<ClientStruct.UnitBuffStatus>();
  217. this.status = input.GetU8();
  218. this.sub_status = input.GetU8();
  219. this.fateType = input.GetU8();
  220. this.fields.ReadExternal(input);
  221. if(this.sub_status > 0)
  222. {
  223. this.sub_flag = input.GetS16();
  224. }
  225. }
  226. public override void WriteExternal(IOutputStream output)
  227. {
  228. this.HasName = !string.IsNullOrEmpty(Name);
  229. this.HasPlayerUUID = !string.IsNullOrEmpty(PlayerUUID);
  230. this.HasAlias = !string.IsNullOrEmpty(Alias);
  231. this.HasExtData = ExtData != null;
  232. output.PutU8(mask.Mask);
  233. base.WriteExternal(output);
  234. output.PutS32(Force);
  235. output.PutVS32(Level);
  236. if (HasName) output.PutUTF(Name);
  237. if (HasPlayerUUID) output.PutUTF(PlayerUUID);
  238. if (HasAlias) output.PutUTF(Alias);
  239. output.PutExt(VisibleInfo);
  240. output.PutStructArray(this.CurrentBuffStatus);
  241. output.PutU8(status);
  242. output.PutU8(sub_status);
  243. output.PutU8(fateType);
  244. fields.WriteExternal(output);
  245. if(this.sub_status > 0)
  246. {
  247. output.PutS16(this.sub_flag);
  248. }
  249. }
  250. }
  251. /// <summary>
  252. /// 场景中同步物品数据
  253. /// </summary>
  254. [MessageType(0x9011)]
  255. public class SyncItemInfo : SyncObjectInfo
  256. {
  257. public bool bDrop;
  258. public string Name;
  259. public string Alias;
  260. public int Force;
  261. public int ItemTotalTimeMS;
  262. public int ItemExpireTimeMS;
  263. public bool showItemLeftTimes;
  264. public bool isCanPick; //是否还能够拾取
  265. //---------------------------------------------------
  266. private BitSet8 mask = new BitSet8(0);
  267. public override bool IsHalf
  268. {
  269. get { return mask.Get(0); }
  270. protected set { mask.Set(0, value); }
  271. }
  272. public override bool HasExtData
  273. {
  274. get { return mask.Get(4); }
  275. protected set { mask.Set(4, value); }
  276. }
  277. public bool HasName
  278. {
  279. get { return mask.Get(1); }
  280. private set { mask.Set(1, value); }
  281. }
  282. public bool HasAlias
  283. {
  284. get { return mask.Get(3); }
  285. private set { mask.Set(3, value); }
  286. }
  287. //---------------------------------------------------
  288. public SyncItemInfo(bool is_half) { this.IsHalf = is_half; bDrop = false; }
  289. public SyncItemInfo() { bDrop = false; }
  290. public override void ReadExternal(IInputStream input)
  291. {
  292. this.mask.Mask = input.GetU8();
  293. base.ReadExternal(input);
  294. this.Force = input.GetVS32();
  295. this.ItemExpireTimeMS = input.GetVS32();
  296. this.ItemTotalTimeMS = input.GetVS32();
  297. if (HasName) this.Name = input.GetUTF();
  298. if (HasAlias) this.Alias = input.GetUTF();
  299. this.showItemLeftTimes = input.GetBool();
  300. this.isCanPick = input.GetBool();
  301. }
  302. public override void WriteExternal(IOutputStream output)
  303. {
  304. this.HasName = !string.IsNullOrEmpty(Name);
  305. this.HasAlias = !string.IsNullOrEmpty(Alias);
  306. this.HasExtData = ExtData != null;
  307. output.PutU8(mask.Mask);
  308. base.WriteExternal(output);
  309. output.PutVS32(Force);
  310. output.PutVS32(ItemExpireTimeMS);
  311. output.PutVS32(ItemTotalTimeMS);
  312. if (HasName) output.PutUTF(Name);
  313. if (HasAlias) output.PutUTF(Alias);
  314. output.PutBool(this.showItemLeftTimes);
  315. output.PutBool(this.isCanPick);
  316. }
  317. }
  318. /// <summary>
  319. /// 场景中同步法术数据
  320. /// </summary>
  321. [MessageType(0x9012)]
  322. public class SyncSpellInfo : SyncObjectInfo
  323. {
  324. public int Force;
  325. public float CurSpeed;
  326. //---------------------------------------------------
  327. private BitSet8 mask = new BitSet8(0);
  328. public override bool IsHalf
  329. {
  330. get { return mask.Get(0); }
  331. protected set { mask.Set(0, value); }
  332. }
  333. public override bool HasExtData
  334. {
  335. get { return mask.Get(4); }
  336. protected set { mask.Set(4, value); }
  337. }
  338. public bool HasSpeed
  339. {
  340. get { return mask.Get(4); }
  341. set { mask.Set(4, value); }
  342. }
  343. //---------------------------------------------------
  344. public SyncSpellInfo(bool is_half) { this.IsHalf = is_half; }
  345. public SyncSpellInfo() { }
  346. public override void ReadExternal(IInputStream input)
  347. {
  348. this.mask.Mask = input.GetU8();
  349. base.ReadExternal(input);
  350. this.Force = input.GetVS32();
  351. if (HasSpeed)
  352. {
  353. this.CurSpeed = input.GetF32();
  354. }
  355. }
  356. public override void WriteExternal(IOutputStream output)
  357. {
  358. this.HasExtData = ExtData != null;
  359. output.PutU8(mask.Mask);
  360. base.WriteExternal(output);
  361. output.PutVS32(Force);
  362. if (HasSpeed)
  363. {
  364. output.PutF32(CurSpeed);
  365. }
  366. }
  367. }
  368. /*
  369. /// <summary>
  370. /// 场景中同步单位数据
  371. /// </summary>
  372. [MessageType(0x9000)]
  373. public class SyncUnitInfo : IExternalizable
  374. {
  375. public uint ObjectID;
  376. public SyncUnitType ObjectType = SyncUnitType.Unit;
  377. public int TemplateID;
  378. public string Name;
  379. public string Alias;
  380. public byte Force;
  381. public float x;
  382. public float y;
  383. public float direction;
  384. /// <summary>
  385. /// 用于扩展属性
  386. /// </summary>
  387. public IExternalizable ExtData;
  388. //---------------------------------------------------
  389. #region units
  390. public int Level;
  391. public string PlayerUUID;
  392. public byte status;
  393. public byte sub_status;
  394. public UnitFieldChangedEvent fields = new UnitFieldChangedEvent();
  395. public ClientStruct.UnitBuffStatus[] CurrentBuffStatus;
  396. /// <summary>
  397. /// 战斗服玩家属性,通常存储横向功能,比如Avatar
  398. /// </summary>
  399. public CreateUnitInfoR2B PlayerInfo;
  400. #endregion
  401. //---------------------------------------------------
  402. #region items
  403. public int ItemTotalTimeMS;
  404. public int ItemExpireTimeMS;
  405. #endregion
  406. //---------------------------------------------------
  407. private BitSet8 mask = new BitSet8(0);
  408. public bool IsHalf
  409. {
  410. get { return mask.Get(0); }
  411. private set { mask.Set(0, value); }
  412. }
  413. public bool HasName
  414. {
  415. get { return mask.Get(1); }
  416. private set { mask.Set(1, value); }
  417. }
  418. public bool HasPlayerUUID
  419. {
  420. get { return mask.Get(2); }
  421. private set { mask.Set(2, value); }
  422. }
  423. public bool HasAlias
  424. {
  425. get { return mask.Get(3); }
  426. private set { mask.Set(3, value); }
  427. }
  428. public bool HasExtData
  429. {
  430. get { return mask.Get(4); }
  431. private set { mask.Set(4, value); }
  432. }
  433. //---------------------------------------------------
  434. public SyncUnitInfo(bool is_half) { }
  435. public SyncUnitInfo() { }
  436. public void ReadExternal(IInputStream input)
  437. {
  438. this.mask.Mask = input.GetU8();
  439. this.ObjectType = (SyncUnitType)input.GetU8();
  440. this.ObjectID = input.GetVU32();
  441. this.TemplateID = input.GetS32();
  442. if (HasName)
  443. {
  444. this.Name = input.GetUTF();
  445. }
  446. MoveHelper.ReadPosAndDirection(IsHalf, out x, out y, out direction, input);
  447. if (ObjectType == SyncUnitType.Item)
  448. {
  449. this.Force = input.GetU8();
  450. this.ItemExpireTimeMS = input.GetVS32();
  451. this.ItemTotalTimeMS = input.GetVS32();
  452. if (HasAlias)
  453. {
  454. this.Alias = input.GetUTF();
  455. }
  456. }
  457. else if (ObjectType == SyncUnitType.Unit)
  458. {
  459. this.Force = input.GetU8();
  460. this.Level = input.GetVS32();
  461. if (HasPlayerUUID)
  462. {
  463. this.PlayerUUID = input.GetUTF();
  464. }
  465. if (HasAlias)
  466. {
  467. this.Alias = input.GetUTF();
  468. }
  469. this.PlayerInfo = input.GetExt<CreateUnitInfoR2B>();
  470. this.CurrentBuffStatus = input.GetStructArray<ClientStruct.UnitBuffStatus>();
  471. this.status = input.GetU8();
  472. this.sub_status = input.GetU8();
  473. this.fields.ReadExternal(input);
  474. }
  475. if (HasExtData)
  476. {
  477. this.ExtData = input.GetExtAny();
  478. }
  479. }
  480. public void WriteExternal(IOutputStream output)
  481. {
  482. this.HasName = !string.IsNullOrEmpty(Name);
  483. this.HasPlayerUUID = !string.IsNullOrEmpty(PlayerUUID);
  484. this.HasAlias = !string.IsNullOrEmpty(Alias);
  485. this.HasExtData = ExtData != null;
  486. output.PutU8(mask.Mask);
  487. output.PutU8((byte)ObjectType);
  488. output.PutVU32(ObjectID);
  489. output.PutS32(TemplateID);
  490. if (HasName)
  491. {
  492. output.PutUTF(Name);
  493. }
  494. MoveHelper.WritePosAndDirection(IsHalf, x, y, direction, output);
  495. if (ObjectType == SyncUnitType.Item)
  496. {
  497. output.PutU8(Force);
  498. output.PutVS32(ItemExpireTimeMS);
  499. output.PutVS32(ItemTotalTimeMS);
  500. if (HasAlias)
  501. {
  502. output.PutUTF(Alias);
  503. }
  504. }
  505. else if (ObjectType == SyncUnitType.Unit)
  506. {
  507. output.PutU8(Force);
  508. output.PutVS32(Level);
  509. if (HasPlayerUUID)
  510. {
  511. output.PutUTF(PlayerUUID);
  512. }
  513. if (HasAlias)
  514. {
  515. output.PutUTF(Alias);
  516. }
  517. output.PutExt(PlayerInfo);
  518. output.PutStructArray(this.CurrentBuffStatus);
  519. output.PutU8(status);
  520. output.PutU8(sub_status);
  521. fields.WriteExternal(output);
  522. }
  523. if (HasExtData)
  524. {
  525. output.PutExt(ExtData);
  526. }
  527. }
  528. }
  529. */
  530. /// <summary>
  531. /// 同步场景中所有单位
  532. /// </summary>
  533. [MessageType(0x9001)]
  534. public class SyncObjectsEvent : ZoneEvent
  535. {
  536. public List<SyncObjectInfo> Objects;
  537. public SyncObjectsEvent() { }
  538. public SyncObjectsEvent(int count)
  539. {
  540. this.Objects = new List<SyncObjectInfo>(count);
  541. }
  542. override public void WriteExternal(IOutputStream output)
  543. {
  544. int len = Objects.Count;
  545. output.PutVS32(len);
  546. for (int i = 0; i < len; i++)
  547. {
  548. output.PutExt(Objects[i]);
  549. }
  550. }
  551. override public void ReadExternal(IInputStream input)
  552. {
  553. int len = input.GetVS32();
  554. this.Objects = new List<SyncObjectInfo>(len);
  555. for (int i = 0; i < len; i++)
  556. {
  557. SyncObjectInfo add = input.GetExtAny() as SyncObjectInfo;
  558. Objects.Add(add);
  559. }
  560. }
  561. }
  562. /// <summary>
  563. /// 玩家登陆到服务器后,服务器分配对应的单位ID
  564. /// </summary>
  565. [MessageType(0x9002)]
  566. public class LockActorEvent : ZoneEvent
  567. {
  568. /// <summary>
  569. /// 当前房间单位信息
  570. /// </summary>
  571. public SyncUnitInfo UnitData;
  572. /// <summary>
  573. /// 服务端传过来的单位信息
  574. /// </summary>
  575. public IUnitProperties GameServerProp;
  576. /// <summary>
  577. /// 服务端更新速度/秒
  578. /// </summary>
  579. public int ServerUpdateInterval;
  580. /// <summary>
  581. /// 客户端同步范围
  582. /// </summary>
  583. public float ClientSyncObjectRange;
  584. /// <summary>
  585. /// 客户端同步范围
  586. /// </summary>
  587. public float ClientSyncObjectOutRange;
  588. public PlayerSkillChangedEvent Skills;
  589. public ClientStruct.UnitSkillStatus[] CurrentSkillStatus;
  590. public ClientStruct.UnitItemStatus[] CurrentItemStatus;
  591. public ClientStruct.ZoneEnvironmentVar[] CurrentZoneVars;
  592. public ClientStruct.ZoneEnvironmentVar[] CurrentPlayerVars;
  593. override public void WriteExternal(IOutputStream output)
  594. {
  595. output.PutExt(this.UnitData);
  596. output.PutExt(this.GameServerProp);
  597. output.PutVS32(this.ServerUpdateInterval);
  598. output.PutF32(this.ClientSyncObjectRange);
  599. output.PutF32(this.ClientSyncObjectOutRange);
  600. output.PutExt(this.Skills);
  601. output.PutStructArray(this.CurrentSkillStatus);
  602. output.PutStructArray(this.CurrentItemStatus);
  603. output.PutExtArray(this.CurrentZoneVars);
  604. output.PutExtArray(this.CurrentPlayerVars);
  605. }
  606. override public void ReadExternal(IInputStream input)
  607. {
  608. this.UnitData = input.GetExt<SyncUnitInfo>();
  609. this.GameServerProp = input.GetExtAny() as IUnitProperties;
  610. this.ServerUpdateInterval = input.GetVS32();
  611. this.ClientSyncObjectRange = input.GetF32();
  612. this.ClientSyncObjectOutRange = input.GetF32();
  613. this.Skills = input.GetExt<PlayerSkillChangedEvent>();
  614. this.CurrentSkillStatus = input.GetStructArray<ClientStruct.UnitSkillStatus>();
  615. this.CurrentItemStatus = input.GetStructArray<ClientStruct.UnitItemStatus>();
  616. this.CurrentZoneVars = input.GetExtArray<ClientStruct.ZoneEnvironmentVar>();
  617. this.CurrentPlayerVars = input.GetExtArray<ClientStruct.ZoneEnvironmentVar>();
  618. }
  619. }
  620. /// <summary>
  621. /// 连接到代理服务器
  622. /// </summary>
  623. [MessageType(0x9003)]
  624. public class ConnectToProxy : ZoneEvent
  625. {
  626. public string ConnectString;
  627. public ConnectToProxy() { }
  628. public ConnectToProxy(string connect_string)
  629. {
  630. this.ConnectString = connect_string;
  631. }
  632. override public void WriteExternal(IOutputStream output)
  633. {
  634. output.PutUTF(ConnectString);
  635. }
  636. override public void ReadExternal(IInputStream input)
  637. {
  638. this.ConnectString = input.GetUTF();
  639. }
  640. }
  641. /// <summary>
  642. /// 从代理服务器断开
  643. /// </summary>
  644. [MessageType(0x9004)]
  645. public class DisconnectFromProxy : ZoneEvent
  646. {
  647. override public void WriteExternal(IOutputStream output)
  648. {
  649. }
  650. override public void ReadExternal(IInputStream input)
  651. {
  652. }
  653. }
  654. /// <summary>
  655. /// 同步场景中所有Flag状态
  656. /// </summary>
  657. [MessageType(0x9005)]
  658. public class SyncFlagsEvent : ZoneEvent
  659. {
  660. public List<string> ClosedDecorations = new List<string>();
  661. public HashMap<string, string> ChangedTags = new HashMap<string, string>();
  662. public SyncFlagsEvent()
  663. {
  664. }
  665. override public void WriteExternal(IOutputStream output)
  666. {
  667. output.PutList(ClosedDecorations, output.PutUTF);
  668. output.PutMap(ChangedTags, output.PutUTF, output.PutUTF);
  669. }
  670. override public void ReadExternal(IInputStream input)
  671. {
  672. this.ClosedDecorations = input.GetUTFList();
  673. this.ChangedTags = input.GetMap<string, string>(input.GetUTF, input.GetUTF);
  674. }
  675. }
  676. [MessageType(0x9006)]
  677. public class ClientEnterScene : ZoneEvent
  678. {
  679. /// <summary>
  680. /// 场景ID
  681. /// </summary>
  682. public int sceneID;
  683. /// <summary>
  684. /// 分割大小
  685. /// </summary>
  686. public int spaceDiv;
  687. /// <summary>
  688. /// 资源版本
  689. /// </summary>
  690. public string resVersion;
  691. public ClientEnterScene() { }
  692. public ClientEnterScene(int sceneID, int spaceDiv, string resVer)
  693. {
  694. this.sceneID = sceneID;
  695. this.spaceDiv = spaceDiv;
  696. this.resVersion = resVer;
  697. }
  698. override public void WriteExternal(IOutputStream output)
  699. {
  700. output.PutS32(sceneID);
  701. output.PutVS32(spaceDiv);
  702. output.PutUTF(resVersion);
  703. }
  704. override public void ReadExternal(IInputStream input)
  705. {
  706. this.sceneID = input.GetS32();
  707. this.spaceDiv = input.GetVS32();
  708. this.resVersion = input.GetUTF();
  709. }
  710. }
  711. /// <summary>
  712. /// 玩家离开场景.
  713. /// </summary>
  714. [MessageType(0x9007)]
  715. public class PlayerLeaveScene : PlayerEvent
  716. {
  717. public PlayerLeaveScene() { }
  718. public PlayerLeaveScene(uint oid) : base(oid)
  719. {
  720. }
  721. override public void WriteExternal(IOutputStream output)
  722. {
  723. base.WriteExternal(output);
  724. }
  725. override public void ReadExternal(IInputStream input)
  726. {
  727. base.ReadExternal(input);
  728. }
  729. }
  730. [MessageType(0x9008)]
  731. public class AddEffectEvent2 : ZoneEvent, PositionMessage
  732. {
  733. public enum EffectType
  734. {
  735. None,
  736. MoveToTarget,
  737. MoveToPlayer
  738. }
  739. public uint hostId = 0;
  740. public float x;
  741. public float y;
  742. public float direction;
  743. private uint effect_sn = 0;
  744. private EffectType et;
  745. private float targetX;
  746. private float targetY;
  747. private bool followActor;
  748. public LaunchEffect effect { get; set; }
  749. public AddEffectEvent2() { }
  750. public AddEffectEvent2(uint hostId, float x, float y, float dir, LaunchEffect effect, EffectType et, float targetX, float targetY, bool followActor = false)
  751. {
  752. this.hostId = hostId;
  753. this.x = x;
  754. this.y = y;
  755. this.direction = dir;
  756. this.effect = effect;
  757. this.et = et;
  758. this.targetX = targetX;
  759. this.targetY = targetY;
  760. this.followActor = followActor;
  761. }
  762. override public void WriteExternal(IOutputStream output)
  763. {
  764. output.PutVU32(hostId);
  765. output.PutF32(x);
  766. output.PutF32(y);
  767. output.PutF32(direction);
  768. output.PutVU32(effect_sn);
  769. }
  770. override public void ReadExternal(IInputStream input)
  771. {
  772. this.hostId = input.GetVU32();
  773. this.x = input.GetF32();
  774. this.y = input.GetF32();
  775. this.direction = input.GetF32();
  776. this.effect_sn = input.GetVU32();
  777. }
  778. public override void BeforeWrite(TemplateManager templates)
  779. {
  780. if (effect != null)
  781. {
  782. this.effect_sn = effect.SerialNumber;
  783. }
  784. }
  785. public override void EndRead(TemplateManager templates)
  786. {
  787. this.effect = templates.GetSnData<LaunchEffect>(effect_sn);
  788. }
  789. public float X { get { return x; } }
  790. public float Y { get { return y; } }
  791. public float TargetX
  792. {
  793. get { return targetX; }
  794. }
  795. public float TargetY
  796. {
  797. get { return targetY; }
  798. }
  799. public bool FollowActor
  800. {
  801. get { return followActor; }
  802. }
  803. public EffectType ET
  804. {
  805. get { return et; }
  806. }
  807. }
  808. }