Advertisement
Guest User

LegendaryCountPlugin.cs

a guest
Apr 7th, 2017
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using System.Text;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.Csavo // Plugin for counting legendary drops
  7. {
  8.     public class LegendaryCountPlugin : BasePlugin, IInGameTopPainter // beta 1.0
  9.     {
  10.         public bool ShowPerHour { get; set; }
  11.         public int LegendaryCount { get; private set; }
  12.         public int AncientCount { get; private set; }
  13.         public int PrimalCount { get; private set; }
  14.         public IFont TextFont { get; set; }
  15.         private StringBuilder textBuilder;
  16.  
  17.         public LegendaryCountPlugin()
  18.         {
  19.             Enabled = true;
  20.         }
  21.  
  22.         public override void Load(IController hud)
  23.         {
  24.             base.Load(hud);
  25.  
  26.             ShowPerHour = false;
  27.  
  28.             LegendaryCount = 0;
  29.             AncientCount = 0;
  30.             PrimalCount = 0;
  31.  
  32.             TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 235, 170, false, false, true);
  33.  
  34.             textBuilder = new StringBuilder();
  35.         }
  36.  
  37.         public void PaintTopInGame(ClipState clipState)
  38.         {
  39.             if (clipState != ClipState.BeforeClip) return;
  40.             if (TextFont == null) return;
  41.  
  42.             var items = Hud.Game.Items.Where(i => i.Location == ItemLocation.Floor && i.Unidentified && i.SetSno != uint.MaxValue && i.AncientRank >= 0);
  43.             foreach (var item in items)
  44.             {
  45.                 if (item.AncientRank >= 0) LegendaryCount++;
  46.                 if (item.AncientRank == 1) AncientCount++;
  47.                 if (item.AncientRank == 2) PrimalCount++;
  48.             }
  49.  
  50.             textBuilder.Clear();
  51.             textBuilder.AppendFormat("Legs: {0} / {1} / {2}", LegendaryCount, AncientCount, PrimalCount);
  52.  
  53.             var layout = TextFont.GetTextLayout(textBuilder.ToString());
  54.             var uiMinimap = Hud.Render.MinimapUiElement.Rectangle;
  55.             TextFont.DrawText(layout, uiMinimap.Left, uiMinimap.Top);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement