Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Globalization;
- using System.Linq;
- using System.Media;
- using System;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_MissingBuff : BasePlugin, IInGameWorldPainter {
- public float xPos { get; set; }
- public float yPos { get; set; }
- public float partyOffsetX { get; set; }
- public float partyOffsetY { get; set; }
- public bool GRonly { get; set; }
- public int SpeakInterval { get; set; }
- public DAV_NoBuffLsit HeroNoBuffList { get; set; } = new DAV_NoBuffLsit();
- public DAV_MissingBuff() {
- Enabled = true;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- }
- public void PaintWorld(WorldLayer layer) {
- if (Hud.Game.IsInTown) return;
- if (GRonly && Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
- foreach(var player in Hud.Game.Players.Where(x => x.CoordinateKnown)){
- if (player.IsMe) {
- var soundMessage = "";
- HeroNoBuffList.PaintVerticalFull(player, xPos, yPos, ref soundMessage);
- if (soundMessage != "" && Hud.Sound.LastSpeak.TimerTest(SpeakInterval))
- Hud.Sound.Speak(soundMessage);
- }
- else {
- var portraitRect = player.PortraitUiElement.Rectangle;
- var xref = portraitRect.Right + portraitRect.Width * partyOffsetX;
- var yref = portraitRect.Top + portraitRect.Height * partyOffsetY;
- HeroNoBuffList.PaintHorizontal(player, xref, yref);
- }
- }
- }
- }
- public class DAV_NoBuffLsit {
- public Dictionary<HeroClass, List<DAV_NoBuffRule>> FullNoBuffList { get; set; }
- public DAV_NoBuffLsit() {
- FullNoBuffList = new Dictionary<HeroClass, List<DAV_NoBuffRule>> {
- {HeroClass.DemonHunter, new List<DAV_NoBuffRule>()},
- {HeroClass.Barbarian, new List<DAV_NoBuffRule>()},
- {HeroClass.Wizard, new List<DAV_NoBuffRule>()},
- {HeroClass.WitchDoctor, new List<DAV_NoBuffRule>()},
- {HeroClass.Monk, new List<DAV_NoBuffRule>()},
- {HeroClass.Crusader, new List<DAV_NoBuffRule>()},
- {HeroClass.Necromancer, new List<DAV_NoBuffRule>()}
- };
- }
- public void Add(HeroClass Hclass, DAV_NoBuffRule newRule) {
- if (Hclass == HeroClass.None) {
- FullNoBuffList[HeroClass.DemonHunter].Add(newRule);
- FullNoBuffList[HeroClass.Barbarian].Add(newRule);
- FullNoBuffList[HeroClass.Wizard].Add(newRule);
- FullNoBuffList[HeroClass.WitchDoctor].Add(newRule);
- FullNoBuffList[HeroClass.Monk].Add(newRule);
- FullNoBuffList[HeroClass.Crusader].Add(newRule);
- FullNoBuffList[HeroClass.Necromancer].Add(newRule);
- }
- else FullNoBuffList[Hclass].Add(newRule);
- }
- public void PaintHorizontal(IPlayer player, float x, float y) {
- var hereNoBuff = FullNoBuffList[player.HeroClassDefinition.HeroClass];
- var xref = x;
- foreach (var noBuff in hereNoBuff) {
- if (!noBuff.ShowOnList(player)) continue;
- noBuff.PaintIcon(player, xref, y);
- xref += noBuff.IconSize;
- }
- }
- public void PaintVerticalFull(IPlayer player, float x, float y, ref string speak) {
- var hereNoBuff = FullNoBuffList[player.HeroClassDefinition.HeroClass];
- var yref = y;
- foreach (var noBuff in hereNoBuff) {
- if (!noBuff.ShowOnList(player)) continue;
- noBuff.PaintIconFull(player, x, yref);
- yref += noBuff.IconSize;
- if (noBuff.SpeakEnable)
- speak += noBuff.Message + "\n";
- }
- }
- }
- public class DAV_NoBuffRule {
- public bool InCombatOnly { get; set; }
- public Func<IPlayer, bool> IsRelevant { get; set; }
- public Func<IPlayer, bool> IsBuffOn { get; set; }
- public Func<IPlayer, string> IconMsg { get; set; }
- public bool SpeakEnable { get; set; }
- public string Message { get; set; }
- public IFont warmFont { get; set; }
- public float IconSize { get; set; }
- public IBrush Icon_Brush { get; set; }
- public ITexture Icon_BG { get; set; }
- public ITexture Icon_Texture { get; set; }
- public DAV_NoBuffRule() {}
- public bool ShowOnList(IPlayer player) {
- if (InCombatOnly && !player.InCombat)
- return false;
- if (!IsRelevant(player))
- return false;
- return !IsBuffOn(player);
- }
- public void PaintIconFull(IPlayer player, float x, float y) {
- PaintIcon(player, x, y);
- var layout = warmFont.GetTextLayout(Message);
- warmFont.DrawText(layout, x + IconSize + 3, y + (IconSize - (float)layout.Metrics.Height)/2);
- }
- public void PaintIcon(IPlayer player, float x, float y) {
- if (Icon_BG != null) Icon_BG.Draw(x, y, IconSize, IconSize);
- if (Icon_Texture != null) {
- Icon_Texture.Draw(x, y, IconSize, IconSize);
- if (IconMsg != null) {
- var layout = warmFont.GetTextLayout(IconMsg(player));
- warmFont.DrawText(layout, x + (IconSize - layout.Metrics.Width)/2, y + (IconSize - (float)layout.Metrics.Height)/2);
- }
- }
- if (Icon_Brush != null) Icon_Brush.DrawRectangle(x, y, IconSize, IconSize);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement