Advertisement
Guest User

BountyAppearedPopup.cs

a guest
Jul 1st, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.79 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, INewAreaHandler
  8.     {
  9.         public class MyBounty
  10.         {
  11.             public bool Displayed { get; set; }
  12.             public uint Sno { get; set; }
  13.             public string Name { get; set; }
  14.             public string Hint { get; set; }
  15.             public string Title { get; set; }
  16.             public int Duration { get; set; }
  17.             public TopLabelWithTitleDecorator Decorator { get; set; }
  18.            
  19.             public MyBounty(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
  20.             {
  21.                 this.Displayed = false;
  22.                 this.Sno = sno;
  23.                 this.Hint = hint;
  24.                 this.Name = name;
  25.                 this.Title = title;
  26.                 this.Duration = duration;
  27.                 this.Decorator = decorator;
  28.             }
  29.         }
  30.        
  31.         public List<MyBounty> BountiesToPopup { get; set; }
  32.            
  33.         public override void Load(IController hud)
  34.         {
  35.             base.Load(hud);
  36.             BountiesToPopup = new List<MyBounty>();
  37.         }
  38.  
  39.         private bool BountyCheck(MyBounty bountyToCheck)
  40.         {
  41.             bool returnBool = false;
  42.  
  43.             foreach (var quest in Hud.Game.Quests.Where(quest => quest.SnoQuest.Type == QuestType.Bounty))
  44.             {
  45.                 if ((quest != null) && quest.State != QuestState.completed)
  46.                 {
  47.                     if (bountyToCheck.Sno == quest.SnoQuest.Sno && !bountyToCheck.Displayed)
  48.                     {
  49.                         returnBool = true;
  50.                         bountyToCheck.Displayed = true;
  51.                         break;
  52.                     }
  53.                 }
  54.             }
  55.  
  56.             return returnBool;
  57.         }
  58.  
  59.         public void Add(uint sno, string name, string hint, string title, int duration, TopLabelWithTitleDecorator decorator = null)
  60.         {
  61.             BountiesToPopup.Add(new MyBounty(sno, name, hint, title, duration, decorator));
  62.         }
  63.        
  64.         public void OnNewArea(bool newGame, ISnoArea area)
  65.         {
  66.             if (newGame)
  67.             {
  68.                 foreach (MyBounty bounty in BountiesToPopup)
  69.                 {
  70.                     bounty.Displayed = false;
  71.                 }
  72.             }
  73.         }        
  74.  
  75.         public void PaintTopInGame(ClipState clipState)
  76.         {
  77.             foreach (MyBounty bounty in BountiesToPopup)
  78.             {
  79.                 if (BountyCheck(bounty))
  80.                 {
  81.                     Hud.RunOnPlugin<PopupNotifications>(plugin =>
  82.                     {
  83.                         plugin.Show(bounty.Name, bounty.Title, bounty.Duration, bounty.Hint, bounty.Decorator);
  84.                     });
  85.                 }
  86.             }
  87.         }
  88.        
  89.         public BountyAppearedPopup()
  90.         {
  91.             Enabled = true;
  92.         }
  93.        
  94.     }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement