Advertisement
Guest User

BountyAppearedPopup.cs

a guest
Jun 26th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.35 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4.  
  5. namespace Turbo.Plugins.Prrovoss.Popups
  6. {
  7.     public class BountyAppearedPopup : BasePlugin, IInGameTopPainter
  8.     {
  9.         public class MyBounty
  10.         {
  11.             public uint Sno { get; set; }
  12.             public string Name { get; set; }
  13.             public string Hint { get; set; }
  14.             public string Title { get; set; }
  15.             public int Duration { get; set; }
  16.             public TopLabelWithTitleDecorator Decorator { get; set; }
  17.            
  18.             public MyBounty(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
  19.             {
  20.                 this.Sno = sno;
  21.                 this.Hint = hint;
  22.                 this.Name = name;
  23.                 this.Title = title;
  24.                 this.Duration = duration;
  25.                 this.Decorator = decorator;
  26.             }
  27.         }
  28.        
  29.         public List<MyBounty> BountiesToPopup { get; set; }
  30.            
  31.         public override void Load(IController hud)
  32.         {
  33.             base.Load(hud);
  34.             BountiesToPopup = new List<MyBounty>();
  35.         }
  36.  
  37.         private bool BountyCheck(MyBounty bountyToCheck)
  38.         {
  39.             bool returnBool = false;
  40.  
  41.             foreach (var quest in Hud.Game.Quests.Where(quest => quest.SnoQuest.Type == QuestType.Bounty))
  42.             {
  43.                 if ((quest != null) && quest.State != QuestState.completed)
  44.                 {
  45.                     if (bountyToCheck.Sno == quest.SnoQuest.Sno)
  46.                     {
  47.                         returnBool = true;
  48.                         break;
  49.                     }
  50.                 }
  51.             }
  52.  
  53.             return returnBool;
  54.         }
  55.  
  56.         public void Add(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
  57.         {
  58.             BountiesToPopup.Add(new MyBounty(sno, name, hint, title, duration, decorator));
  59.         }
  60.  
  61.         public void PaintTopInGame(ClipState clipState)
  62.         {
  63.             foreach (MyBounty bounty in BountiesToPopup)
  64.             {
  65.                 if (BountyCheck(bounty))
  66.                 {
  67.                     Hud.RunOnPlugin<PopupNotifications>(plugin =>
  68.                     {
  69.                         plugin.Show(bounty.Name, bounty.Title, bounty.Duration, bounty.Hint, bounty.Decorator);
  70.                     });
  71.                 }
  72.             }
  73.         }
  74.        
  75.         public BountyAppearedPopup()
  76.         {
  77.             Enabled = true;
  78.         }
  79.        
  80.     }
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement