Advertisement
Jembo33

MonkFireMysticAllyIndicatorPlugin

Feb 19th, 2022
1,191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.27 KB | None | 0 0
  1. namespace Turbo.Plugins.User
  2. {
  3.     using Turbo.Plugins.Default;
  4.     using System.Linq;
  5.     using System.Text;
  6.     using System.Collections.Generic;
  7.  
  8.     public class MonkFireMysticAllyIndicatorPlugin : BasePlugin, IInGameWorldPainter, IInGameTopPainter
  9.     {
  10.         public WorldDecoratorCollection MysticAllyDecorator;
  11.         public TopLabelDecorator MysticAllyCountLabel;
  12.         public string MysticAllyLabel;
  13.         public int MysticAllyCount;
  14.         public float barW, barH, barX, barY;
  15.         public bool MysticAllyEnabled;
  16.  
  17.         private static uint MysticAllySkillSNO = 362102;
  18.         public HashSet<ActorSnoEnum> MysticAllyActorSNOs = new HashSet<ActorSnoEnum>
  19.         {
  20.             ActorSnoEnum._monk_male_mystically_crimson, //169906
  21.         ActorSnoEnum._monk_female_mystically_crimson, //168878
  22.         };
  23.  
  24.  
  25.         public MonkFireMysticAllyIndicatorPlugin()
  26.         {
  27.             Enabled = true;
  28.  
  29.             MysticAllyEnabled = true;
  30.  
  31.             // Inits variables
  32.             MysticAllyCount = 0;
  33.             MysticAllyLabel = "";
  34.  
  35.         }
  36.  
  37.         public override void Load(IController hud)
  38.         {
  39.             base.Load(hud);
  40.  
  41.             // Unlike the old XML system where it draws x,y,w,h in terms of percentage of screen size, the new plugin uses actual pixel coordinates
  42.             // To convert x,y,w,h sizes from the XML system to the new plugin system, multiply the screensize with percentage. ie. XML size of 2 => 0.02f * screensize
  43.  
  44.             // Display coordinates for non-combined indicators
  45.             barW = Hud.Window.Size.Width * 0.012f;
  46.             barH = Hud.Window.Size.Height * 0.0175f;
  47.             barX = Hud.Window.Size.Width * 0.347f;
  48.             barY = Hud.Window.Size.Height * 0.928f;
  49.  
  50.             // Decorator under each MysticAlly
  51.             MysticAllyDecorator = new WorldDecoratorCollection(
  52.                 new GroundCircleDecorator(Hud)
  53.                 {
  54.                     Brush = Hud.Render.CreateBrush(0, 0, 0, 0, 0),
  55.                     Radius = 0f,
  56.                 });
  57.  
  58.  
  59.             // Label Decorator for Indicator
  60.             MysticAllyCountLabel = new TopLabelDecorator(Hud)
  61.             {
  62.                 TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 48, 201, 255, true, false, 255, 0, 0, 0, true)
  63.             };
  64.         }
  65.  
  66.         public void PaintWorld(WorldLayer layer)
  67.         {
  68.             // Don't draw if not playing a Monk
  69.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Monk) return;
  70.  
  71.             // For MysticAlly, only when equipping the skill
  72.             if (MysticAllyEnabled && Hud.Game.Me.Powers.UsedSkills.Where(x => x.SnoPower.Sno == MysticAllySkillSNO) != null)
  73.             {
  74.                 // Iterate all the game actors, find out and count which are MysticAlly summoned by player
  75.                 var MysticAllyActors = Hud.Game.Actors.Where(EachActor => MysticAllyActorSNOs.Contains(EachActor.SnoActor.Sno) && // Find out which are skeleton melees actors
  76.                 EachActor.SummonerAcdDynamicId == Hud.Game.Me.SummonerId); // Then find out if they are summoned by the player
  77.                 MysticAllyCount = MysticAllyActors.Count(); // And then count how many are found
  78.  
  79.                 // Paint circle decorator under each MysticAlly
  80.                 foreach (var EachActor in MysticAllyActors)
  81.                 {
  82.                     var text = string.IsNullOrWhiteSpace(MysticAllyLabel) ? EachActor.SnoActor.NameLocalized : MysticAllyLabel;
  83.                     MysticAllyDecorator.Paint(layer, EachActor, EachActor.FloorCoordinate, text);
  84.                 }
  85.             }
  86.             else
  87.             {
  88.                 MysticAllyCount = 0;
  89.             }
  90.         }
  91.  
  92.         public void PaintTopInGame(ClipState clipState)
  93.         {
  94.             // Don't draw if not playing a Monk
  95.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Monk) return;
  96.             if (clipState != ClipState.BeforeClip) return;
  97.  
  98.             // Drawing count indicator
  99.             if (MysticAllyEnabled && MysticAllyCount != 0)
  100.             {
  101.                 MysticAllyCountLabel.TextFunc = () => MysticAllyCount.ToString();
  102.                 MysticAllyCountLabel.Paint(barX, barY, barW, barH, HorizontalAlign.Center);
  103.             }
  104.         }
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement