ModuleReconnect.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using CommonAI.ZoneClient;
  2. using CommonLang.Property;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace XmdsBotTest.Runner
  9. {
  10. public class ModuleReconnect : BotRunner.RunnerModule
  11. {
  12. public ModuleReconnect() {
  13. module_name = "断线重连";
  14. }
  15. public ModuleReconnect(BotRunner r) : base(r)
  16. {
  17. }
  18. protected internal override void OnBattleActorReady(ZoneLayer layer, ZoneActor actor)
  19. {
  20. layer.AddTimePeriodicMS(bot.Random.Next(Config.IntervalMS_Min, Config.IntervalMS_Max), (t) =>
  21. {
  22. if (Enable)
  23. {
  24. runner.reconnect();
  25. }
  26. });
  27. }
  28. [Desc("重连配置")]
  29. [Expandable]
  30. public class Config : ConfigBase
  31. {
  32. [Desc("重连间隔")]
  33. public static int IntervalMS_Min = 300000;
  34. [Desc("重连间隔")]
  35. public static int IntervalMS_Max = 1200000;
  36. public override string ToString()
  37. {
  38. return "重连配置";
  39. }
  40. public override void popG2DPropertyDialog()
  41. {
  42. CommonFroms.G2D.G2DPropertyDialog<ModuleReconnect.Config>.Show("修改配置", this);
  43. }
  44. }
  45. }
  46. }