Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.RNN
- {
- public class SpiritBarrageIconS : BasePlugin, IInGameTopPainter, ICustomizer, INewAreaHandler
- {
- private Dictionary<uint,int> Phantasms { get;set; } = new Dictionary<uint,int>();
- private int MyIndex { get; set; } = -1;
- private IFont FontCounter { get; set; }
- private IFont FontExpl { get; set; }
- private IFont FontLimit { get; set; }
- private IFont FontDefault { get; set; } = null;
- private float SizeIconWidth { get; set; }
- private float SizeIconHeight { get; set; }
- public int duration { get; set; } = 10;
- public float warning { get; set; } = 2.0f;
- public float Xpor { get; set; }
- public float Ypor { get; set; }
- public float SizeMultiplier { get; set; }
- public float Opacity { get; set; } = 1f;
- public bool OnlyGR { get; set; }
- public bool Portrait { get; set; }
- public bool Horizontal { get; set; }
- public float PortraitOffsetX { get; set; }
- public float PortraitOffsetY { get; set; }
- public SpiritBarrageIconS()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30002;
- Portrait = false; // Show next to portrait
- PortraitOffsetX = 0.103f; // 0f..1f Relative offset from portrait
- PortraitOffsetY = 0.105f; // 0f..1f Relative offset from portrait
- Xpor = 0.55f; // 0f..1f To set the x coordinate of the icon. (Portratit == false)
- Ypor = 0.43f; // 0f..1f To set the y coordinate of the icon. (Portratit == false)
- Horizontal = true; // Horizontal or vertical (Portratit == false)
- SizeMultiplier = 1f; // Size multiplier for icons
- Opacity = 0.75f; // 0..1 Textures
- OnlyGR = false; // Show in GR only
- warning = 2.0f; // 9.9f...0.1f Text will take the color yellow when it reaches this value
- }
- public void Customize()
- {
- FontCounter = Hud.Render.CreateFont("tahoma", 7f * SizeMultiplier, 255, 0, 255, 0, true, false, 160, 0, 0, 0, true);
- FontLimit = Hud.Render.CreateFont("tahoma", 7f * SizeMultiplier, 255, 255, 255, 0, true, false, 160, 0, 0, 0, true);
- FontExpl = Hud.Render.CreateFont("tahoma", 8f * SizeMultiplier, 255, 50, 150, 255, true, false, 160, 0, 0, 0, true);
- if ((warning < 0.1f) || (warning > 9.9f)) { warning = 2; }
- }
- public void OnNewArea(bool newGame, ISnoArea area)
- {
- if (newGame || (MyIndex != Hud.Game.Me.Index) ) // Fix partialment the newGame limitation
- {
- MyIndex = Hud.Game.Me.Index;
- Phantasms.Clear();
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- if (OnlyGR && !Hud.Game.Me.InGreaterRift) return;
- 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);
- if ( players.Any() )
- {
- 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); }
- SizeIconWidth = Hud.Texture.BuffFrameTexture.Width * 0.60f * SizeMultiplier;
- SizeIconHeight = Hud.Texture.BuffFrameTexture.Height * 0.68f * SizeMultiplier;
- foreach(var player in players)
- {
- if (Portrait)
- {
- x = player.PortraitUiElement.Rectangle.X + Hud.Window.Size.Width * PortraitOffsetX;
- y = player.PortraitUiElement.Rectangle.Y + Hud.Window.Size.Height * PortraitOffsetY;
- }
- else
- {
- x = Hud.Window.Size.Width * Xpor + (Horizontal? (n-1) * SizeIconWidth : 0);
- y = Hud.Window.Size.Height * Ypor + (Horizontal? 0 : (n-1) * SizeIconHeight); // y = Hud.Window.Size.Height * Ypor - (Horizontal? 0 : (n-1) * SizeIconHeight);
- n--;
- }
- var actors = Hud.Game.Actors.Where(a => a.SnoActor.Sno == ActorSnoEnum._wd_spiritbarragerune_aoe_ghostmodel && (a.SummonerAcdDynamicId == player.SummonerId));
- Hud.Texture.GetTexture(1117784160).Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
- if (actors.Any())
- {
- foreach(var a in actors)
- {
- if (!Phantasms.ContainsKey(a.AnnId)) { Phantasms[a.AnnId] = a.CreatedAtInGameTick; }
- }
- actors = actors.OrderByDescending(a => Phantasms[a.AnnId]);
- Hud.Texture.BuffFrameTexture.Draw(x, y, SizeIconWidth , SizeIconHeight, Opacity);
- var c = 0;
- foreach (var actor in actors)
- {
- if (c++ == 3) break;
- duration = player.Powers.BuffIsActive(484270)? 10 : 5;
- var t = duration - (Hud.Game.CurrentGameTick - Phantasms[actor.AnnId]) / 60f;
- if (t <= 0)
- {
- var layout = FontExpl.GetTextLayout("đ´");
- FontExpl.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + SizeIconHeight/200 + (layout.Metrics.Height * 0.53f * (c - 1)) );
- }
- else
- {
- FontDefault = (t > warning)? FontCounter:FontLimit;
- 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
- FontDefault.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + SizeIconHeight/50 + (layout.Metrics.Height * 0.72f * (c - 1)) );
- }
- }
- }
- else { Hud.Texture.DebuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity); }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment