RNNCode

SpiritBarrageIconS

Mar 20th, 2020 (edited)
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.55 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.RNN
  7. {
  8.     public class SpiritBarrageIconS : BasePlugin, IInGameTopPainter, ICustomizer, INewAreaHandler
  9.     {
  10.  
  11.         private Dictionary<uint,int> Phantasms { get;set; } = new Dictionary<uint,int>();
  12.         private int MyIndex { get; set; } = -1;
  13.  
  14.         private IFont FontCounter { get; set; }
  15.         private IFont FontExpl { get; set; }
  16.         private IFont FontLimit { get; set; }
  17.         private IFont FontDefault { get; set; } = null;
  18.  
  19.         private float SizeIconWidth  { get; set; }
  20.         private float SizeIconHeight  { get; set; }
  21.         public int duration { get; set; } = 10;
  22.         public float warning { get; set; } = 2.0f;
  23.  
  24.         public float Xpor  { get; set; }
  25.         public float Ypor  { get; set; }
  26.         public float SizeMultiplier  { get; set; }
  27.         public float Opacity { get; set; } = 1f;
  28.         public bool OnlyGR { get; set; }
  29.         public bool Portrait { get; set; }
  30.         public bool Horizontal { get; set; }
  31.         public float PortraitOffsetX { get; set; }
  32.         public float PortraitOffsetY { get; set; }
  33.  
  34.         public SpiritBarrageIconS()
  35.         {
  36.             Enabled = true;
  37.         }
  38.  
  39.         public override void Load(IController hud)
  40.         {
  41.             base.Load(hud);
  42.             Order = 30002;
  43.  
  44.             Portrait = false;           // Show next to portrait
  45.             PortraitOffsetX = 0.103f;   // 0f..1f  Relative offset from portrait
  46.             PortraitOffsetY = 0.105f;   // 0f..1f  Relative offset from portrait
  47.             Xpor = 0.55f;           // 0f..1f To set the x coordinate of the icon. (Portratit == false)
  48.             Ypor = 0.43f;           // 0f..1f To set the y coordinate of the icon. (Portratit == false)
  49.             Horizontal = true;      // Horizontal or vertical (Portratit == false)
  50.             SizeMultiplier = 1f;    // Size multiplier for icons
  51.             Opacity = 0.75f;        // 0..1 Textures
  52.             OnlyGR = false;         // Show in GR only
  53.             warning = 2.0f;         // 9.9f...0.1f Text will take the color yellow when it reaches this value
  54.         }
  55.  
  56.         public void Customize()
  57.         {
  58.             FontCounter = Hud.Render.CreateFont("tahoma", 7f * SizeMultiplier, 255, 0, 255, 0, true, false, 160, 0, 0, 0, true);
  59.             FontLimit = Hud.Render.CreateFont("tahoma", 7f * SizeMultiplier, 255, 255, 255, 0, true, false, 160, 0, 0, 0, true);
  60.             FontExpl = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 50, 150, 255, true, false, 160, 0, 0, 0, true);
  61.  
  62.             if ((warning < 0.1f) || (warning > 9.9f)) { warning = 2; }
  63.         }
  64.  
  65.         public void OnNewArea(bool newGame, ISnoArea area)
  66.         {
  67.             if (newGame || (MyIndex != Hud.Game.Me.Index) )   // Fix partialment the newGame limitation
  68.             {
  69.                 MyIndex = Hud.Game.Me.Index;
  70.                 Phantasms.Clear();
  71.             }
  72.         }
  73.  
  74.         public void PaintTopInGame(ClipState clipState)
  75.         {
  76.             if (clipState != ClipState.BeforeClip) return;
  77.             if (!Hud.Game.IsInGame) return;
  78.             if (OnlyGR && !Hud.Game.Me.InGreaterRift) return;
  79.  
  80.             var players = Hud.Game.Players.Where( p => p.HasValidActor && p.Powers.UsedSkills.Any(s => s.SnoPower.Sno == 108506 && (s.Rune == 2 || p.Powers.BuffIsActive(484270))) ).OrderByDescending(p => p.PortraitIndex);
  81.             if ( players.Any() )
  82.             {
  83.                 float x = 0 ; float y = 0; var n = players.Count();     // if ( (n > 1) && !Portrait )  { players = Horizontal? players.OrderByDescending(p => p.PortraitIndex): players.OrderBy(p => p.PortraitIndex); }
  84.  
  85.                 SizeIconWidth = Hud.Texture.BuffFrameTexture.Width  * 0.60f * SizeMultiplier;
  86.                 SizeIconHeight = Hud.Texture.BuffFrameTexture.Height * 0.68f * SizeMultiplier;
  87.                 foreach(var player in players)
  88.                 {
  89.                     if (Portrait)
  90.                     {
  91.                         x = player.PortraitUiElement.Rectangle.X + Hud.Window.Size.Width * PortraitOffsetX;
  92.                         y = player.PortraitUiElement.Rectangle.Y + Hud.Window.Size.Height * PortraitOffsetY;
  93.                     }
  94.                     else
  95.                     {
  96.                         x = Hud.Window.Size.Width  * Xpor + (Horizontal? (n-1) * SizeIconWidth : 0);
  97.                         y = Hud.Window.Size.Height * Ypor + (Horizontal? 0 : (n-1) * SizeIconHeight);   // y = Hud.Window.Size.Height * Ypor - (Horizontal? 0 : (n-1) * SizeIconHeight);
  98.                         n--;
  99.                     }
  100.                     var actors = Hud.Game.Actors.Where(a => a.SnoActor.Sno == ActorSnoEnum._wd_spiritbarragerune_aoe_ghostmodel && (a.SummonerAcdDynamicId == player.SummonerId));
  101.                     Hud.Texture.GetTexture(1117784160).Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
  102.                     if (actors.Any())
  103.                     {
  104.                         foreach(var a in actors)
  105.                         {
  106.                             if (!Phantasms.ContainsKey(a.AnnId)) { Phantasms[a.AnnId] = a.CreatedAtInGameTick; }
  107.                         }
  108.                         actors = actors.OrderByDescending(a => Phantasms[a.AnnId]);
  109.                         Hud.Texture.BuffFrameTexture.Draw(x, y, SizeIconWidth , SizeIconHeight, Opacity);
  110.                         var c = 0;
  111.                         foreach (var actor in actors)
  112.                         {
  113.                             if (c++ == 3) break;
  114.                             duration = player.Powers.BuffIsActive(484270)? 10 : 5;
  115.                             var t = duration - (Hud.Game.CurrentGameTick - Phantasms[actor.AnnId]) /  60f;
  116.                             if (t <= 0)
  117.                             {
  118.                                 var layout = FontExpl.GetTextLayout("🞴");
  119.                                 FontExpl.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + SizeIconHeight/200 + (layout.Metrics.Height * 0.53f * (c - 1)) );
  120.                             }
  121.                             else
  122.                             {
  123.                                 FontDefault = (t > warning)? FontCounter:FontLimit;
  124.                                 var layout = FontDefault.GetTextLayout( (t < 1)? String.Format("{0:N1}",t) : String.Format("{0:0}",(int) (t + 0.80)) ); // RedondearĂĄ a X si es menor  a X.20
  125.                                 FontDefault.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + SizeIconHeight/50 + (layout.Metrics.Height * 0.72f * (c - 1)) );
  126.                             }
  127.                         }
  128.                     }
  129.                     else { Hud.Texture.DebuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity); }
  130.                 }
  131.             }
  132.         }
  133.     }
  134. }
Advertisement
Add Comment
Please, Sign In to add comment