Advertisement
zjqyf

MonsterDensityPlugin.cs

Jun 21st, 2017
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4. namespace Turbo.Plugins.glq
  5. {
  6. public class MonsterDensityPlugin : BasePlugin, IInGameWorldPainter
  7. {
  8. public bool ShowLabel { get; set; }
  9. public bool ShowCircle { get; set; }
  10. public bool ShowProgression { get; set; }
  11. public bool ShowMark { get; set; }
  12. public int Distance { get; set; }
  13. public int MaxRadius
  14. {
  15. get
  16. {
  17. return CircleDecorator.GetDecorators<GroundCircleDecorator>().Select(x => Convert.ToInt32(x.Radius)).FirstOrDefault();
  18. }
  19. set
  20. {
  21. CircleDecorator.GetDecorators<GroundCircleDecorator>().ForEach(x => x.Radius = value);
  22. }
  23. }
  24.  
  25. public int ping
  26. {
  27. get
  28. {
  29. return CircleDecorator.GetDecorators<GroundCircleDecorator>().Select(x => (x.RadiusTransformator as StandardPingRadiusTransformator).PingSpeed).FirstOrDefault();
  30. }
  31. set
  32. {
  33. CircleDecorator.GetDecorators<GroundCircleDecorator>().ForEach(x => (x.RadiusTransformator as StandardPingRadiusTransformator).PingSpeed = value);
  34. }
  35. }
  36. public int DisplayLimit { get; set; }
  37. public WorldDecoratorCollection LabelDecorator { get; set; }
  38. public WorldDecoratorCollection CircleDecorator { get; set; }
  39. public WorldDecoratorCollection MarkDecorator { get; set; }
  40. IWorldCoordinate MCoordinate { get; set; }
  41. int Mcount { get; set; }
  42. public MonsterDensityPlugin()
  43. {
  44. Enabled = true;
  45. }
  46.  
  47. public override void Load(IController hud)
  48. {
  49. base.Load(hud);
  50. DisplayLimit = 1;
  51. ShowLabel = true;
  52. ShowCircle = true;
  53. ShowMark = true;
  54. ShowProgression = true;
  55. Distance = 10;
  56.  
  57. LabelDecorator = new WorldDecoratorCollection(
  58. new GroundLabelDecorator(Hud) {
  59. BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0),
  60. TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 0, 255, 255, true, false, 160, 0, 0, 0, true),
  61. }
  62. );
  63. MarkDecorator = new WorldDecoratorCollection(
  64. new GroundCircleDecorator(Hud)
  65. {
  66. Brush = Hud.Render.CreateBrush(255, 0, 255, 255, 0),
  67. Radius = 1f,
  68. }
  69. );
  70. CircleDecorator = new WorldDecoratorCollection(
  71. new GroundCircleDecorator(Hud)
  72. {
  73. Brush = Hud.Render.CreateBrush(255, 0, 255, 255, 1.5f),
  74. Radius = 15,
  75. RadiusTransformator = new StandardPingRadiusTransformator(Hud, 333),
  76. }
  77. );
  78. }
  79.  
  80. public void PaintWorld(WorldLayer layer)
  81. {
  82. var inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  83. double MRiftProgression = 0;
  84. int density = 0;
  85. var monsters = Hud.Game.AliveMonsters.Where(x => x.IsOnScreen);
  86. foreach (var monster in monsters)
  87. {
  88. double MonsterRiftProgression = 0;
  89. if (monster.IsOnScreen)
  90. {
  91. int count = Hud.Game.AliveMonsters.Count(m => (monster.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate) - m.RadiusBottom) <= Distance);
  92. var monsters2 = Hud.Game.AliveMonsters.Where(mm => (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && mm.SummonerAcdDynamicId == 0 && mm.IsElite || (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && !mm.IsElite);
  93. if (inRift)
  94. {
  95. foreach (var monster2 in monsters2)
  96. {
  97. MonsterRiftProgression += monster2.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  98.  
  99. }
  100. }
  101. if (count >= density && MonsterRiftProgression >= MRiftProgression)
  102. {
  103. MCoordinate = monster.FloorCoordinate;
  104. Mcount = count;
  105. density = count;
  106. MRiftProgression = MonsterRiftProgression;
  107. }
  108. }
  109. }
  110. foreach (var monster in monsters)
  111. {
  112. if (monster.IsOnScreen && Mcount >= DisplayLimit)
  113. {
  114. if (ShowLabel)
  115. {
  116.  
  117. if(!inRift)
  118. {
  119. LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
  120. }
  121. else
  122. {
  123. if(ShowProgression)
  124. {
  125. LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount + "(" + MaxRadius + "yards Progression:" + MRiftProgression.ToString("f2") + ")");
  126. }
  127. else
  128. {
  129. LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
  130. }
  131.  
  132. }
  133. }
  134. if (ShowCircle)
  135. {
  136. CircleDecorator.Paint(layer, monster, MCoordinate, null);
  137. }
  138. if (ShowMark)
  139. {
  140. MarkDecorator.Paint(layer, monster, MCoordinate, null);
  141. }
  142. }
  143. return;
  144. }
  145.  
  146. }
  147. }
  148. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement