s4000

DAV_NayrsPlugin

Jun 14th, 2019 (edited)
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using SharpDX;
  3. using System.Globalization;
  4. using Turbo.Plugins.Default;
  5. using System.Linq;
  6. using SharpDX.DirectInput;
  7. using System.Text;
  8. using System.Collections.Generic;
  9.  
  10. namespace Turbo.Plugins.DAV
  11. {
  12.     public class DAV_NayrsPlugin : BasePlugin, IInGameTopPainter {
  13.         public IFont TimeFont { get; set; }
  14.         public IBrush GreenBrush { get; set; }
  15.         public IBrush RedBrush { get; set; }
  16.         public IBrush WhiteBrush { get; set; }
  17.         public double Attacktime { get; set; } = 5d;
  18.         public float BrushHigh { get; set; } = 15f;
  19.        
  20.         public DAV_NayrsPlugin() {
  21.             Enabled = true;
  22.         }
  23.  
  24.         public override void Load(IController hud) {
  25.             base.Load(hud);
  26.  
  27.             TimeFont = Hud.Render.CreateFont("arial", 7, 255, 255, 255, 255, false, false, 255, 0, 0, 0, true);
  28.             GreenBrush = Hud.Render.CreateBrush(240, 128, 255, 0, 0);
  29.             RedBrush = Hud.Render.CreateBrush(240, 255, 51, 51, 0);
  30.             WhiteBrush = Hud.Render.CreateBrush(240, 255, 255, 255, 0);
  31.         }
  32.  
  33.         public void PaintTopInGame(ClipState clipState) {
  34.             if (clipState != ClipState.BeforeClip) return;
  35.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer) return;
  36.  
  37.             var Nayrs = Hud.Game.Me.Powers.GetBuff(476587);
  38.             if (Nayrs == null || !Nayrs.Active) return;
  39.            
  40.             var uiSkill1 = Hud.Render.GetPlayerSkillUiElement(ActionKey.Skill1);
  41.             foreach (var skill in Hud.Game.Me.Powers.CurrentSkills) {
  42.                 if (skill.ElementalType != 4) continue;
  43.                
  44.                 var ui = Hud.Render.GetPlayerSkillUiElement(skill.Key);
  45.                 var x = (float)Math.Round(ui.Rectangle.X) + 0.5f;
  46.                 var y = ((float)Math.Round(uiSkill1.Rectangle.Y) + (float)Math.Round(ui.Rectangle.Height) + 0.5f);
  47.                 var w = (float)Math.Round(ui.Rectangle.Width);
  48.                 WhiteBrush.DrawRectangle(x, y, w, BrushHigh);
  49.                
  50.                 var t = Nayrs.TimeLeftSeconds[(int)skill.Key + 1];
  51.                 if (t <= 0) continue;
  52.                
  53.                 var w1 = w * (float)t / 15f;
  54.                 var timeBrush = t > Attacktime ? GreenBrush : RedBrush;
  55.                
  56.                 timeBrush.DrawRectangle(x, y, w1, BrushHigh);
  57.                 var layout = TimeFont.GetTextLayout(t.ToString(t > Attacktime ? "F0" : "F1", CultureInfo.InvariantCulture));
  58.                 TimeFont.DrawText(layout, x + 1, y + (BrushHigh - layout.Metrics.Height)/2);
  59.             }
  60.         }
  61.     }
  62. }
Add Comment
Please, Sign In to add comment