Messages.cs 26 KB

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