Advertisement
Guest User

RainbowGobAlert

a guest
Jan 21st, 2018
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using System.Globalization;
  5. using SharpDX;
  6. using SharpDX.Direct2D1;
  7.  
  8. using Turbo.Plugins.Default;
  9.  
  10. namespace Turbo.Plugins.User
  11. {
  12.  
  13. public class RainbowGobAlert : BasePlugin, IInGameWorldPainter
  14. {
  15.  
  16. public WorldDecoratorCollection PortalDecorator { get; set; }
  17. public WorldDecoratorCollection DefaultGoblinDecorator { get; set; }
  18. public WorldDecoratorCollection RainbowGoblinDecorator { get; set; }
  19. public Dictionary<uint, WorldDecoratorCollection> SnoMapping { get; private set; }
  20.  
  21. public bool EnableSpeak { get; set; }
  22.  
  23. public RainbowGobAlert()
  24. {
  25. Enabled = true;
  26. SnoMapping = new Dictionary<uint, WorldDecoratorCollection>();
  27. EnableSpeak = true;
  28. }
  29.  
  30. public override void Load(IController hud)
  31. {
  32. base.Load(hud);
  33.  
  34. CreateDecorators();
  35.  
  36. SnoMapping.Add(405186, RainbowGoblinDecorator);
  37. }
  38.  
  39. private void CreateDecorators()
  40. {
  41.  
  42. PortalDecorator = new WorldDecoratorCollection(
  43. new MapShapeDecorator(Hud)
  44. {
  45. Brush = Hud.Render.CreateBrush(180, 255, 255, 255, 0),
  46. ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
  47. Radius = 8.0f,
  48. ShapePainter = new CircleShapePainter(Hud),
  49. },
  50. new MapShapeDecorator(Hud)
  51. {
  52. Brush = Hud.Render.CreateBrush(180, 120, 0, 0, 0),
  53. ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
  54. Radius = 2.5f,
  55. ShapePainter = new CircleShapePainter(Hud),
  56. }
  57. );
  58.  
  59. RainbowGoblinDecorator = new WorldDecoratorCollection(
  60. new GroundCircleDecorator(Hud)
  61. {
  62. Brush = Hud.Render.CreateBrush(180, 255, 255, 0, -2),
  63. Radius = 1.5f,
  64. },
  65. new GroundLabelDecorator(Hud)
  66. {
  67. BackgroundBrush = Hud.Render.CreateBrush(180, 255, 255, 0, 0),
  68. BorderBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0),
  69. TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 0, 0, 0, true, false, false)
  70. },
  71. new MapShapeDecorator(Hud)
  72. {
  73. ShapePainter = new CircleShapePainter(Hud),
  74. Brush = Hud.Render.CreateBrush(180, 150, 150, 225, 3),
  75. ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
  76. Radius = 8f,
  77. },
  78. new MapShapeDecorator(Hud)
  79. {
  80. ShapePainter = new CircleShapePainter(Hud),
  81. Brush = Hud.Render.CreateBrush(180, 200, 0, 0, 3),
  82. ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
  83. Radius = 4.5f,
  84. }
  85. );
  86. }
  87.  
  88. public void PaintWorld(WorldLayer layer)
  89. {
  90. var portals = Hud.Game.Actors.Where(x => x.SnoActor.Sno == 410460);
  91. foreach (var actor in portals)
  92. {
  93. PortalDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
  94. }
  95.  
  96. var goblins = Hud.Game.AliveMonsters.Where(x => x.SnoMonster.Priority == MonsterPriority.goblin);
  97. foreach (var goblin in goblins)
  98. {
  99. if (EnableSpeak && (goblin.LastSpeak == null) && Hud.Sound.LastSpeak.TimerTest(5000))
  100. {
  101. Hud.Sound.Speak(goblin.SnoMonster.NameLocalized);
  102. goblin.LastSpeak = Hud.Time.CreateAndStartWatch();
  103. }
  104.  
  105. WorldDecoratorCollection decorator;
  106. if (!SnoMapping.TryGetValue(goblin.SnoActor.Sno, out decorator))
  107. {
  108. decorator = DefaultGoblinDecorator;
  109. }
  110.  
  111. decorator.Paint(layer, goblin, goblin.FloorCoordinate, goblin.SnoMonster.NameLocalized);
  112. }
  113. }
  114.  
  115. public IEnumerable<WorldDecoratorCollection> AllGoblinDecorators()
  116. {
  117. yield return RainbowGoblinDecorator;
  118. }
  119.  
  120. }
  121.  
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement