Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Globalization;
- using System.Collections.Generic;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_GRPylonPlugin : BasePlugin, IInGameWorldPainter, INewAreaHandler {
- public IFont Font_Used { get; set; }
- public IFont Font_SameLvl { get; set; }
- public IFont Font_DiffLvl { get; set; }
- public DAV_PylonInfo[] grPylon { get; set; } = new DAV_PylonInfo[5];
- public double pylonChanceLow { get; set; } = 30d;
- public double pylonChanceHigh { get; set; } = 60d;
- public WorldDecoratorCollection PossiblePylonDecorator_low { get; set; }
- public WorldDecoratorCollection PossiblePylonDecorator_middle { get; set; }
- public WorldDecoratorCollection PossiblePylonDecorator_high { get; set; }
- public string PossiblePylonMessage { get; set; } = "pylon? ";
- public string message_percent { get; set; } = "Last Pylon";
- public string message_pylonChance { get; set; } = "Chance";
- public string replaceArea_from { get; set; } = "Rift Level";
- public string replaceArea_to { get; set; } = "Floor";
- public Func<double, double> CalcPylon { get; set; }
- private bool inGR { get; set; } = false;
- private int PylonNum { get; set; } = 0;
- private double preProgress { get; set; } = 0;
- public float offsetX { get; set; }
- public DAV_GRPylonPlugin() {
- Enabled = true;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- offsetX = Hud.Window.Size.Height * 35 / 1080;
- Font_Used = Hud.Render.CreateFont("arial", 7, 255, 170, 170, 170, false, false, 160, 0, 0, 0, true);
- Font_SameLvl = Hud.Render.CreateFont("arial", 7, 255, 250, 150, 250, false, false, 160, 0, 0, 0, true);
- Font_DiffLvl = Hud.Render.CreateFont("arial", 7, 255, 255, 51, 51, false, false, 160, 0, 0, 0, true);
- CalcPylon = (progress) => {
- var pylonChance = 98d;
- if (progress < 30d)
- pylonChance = 1d + Math.Pow(0.2d * progress + 1d, 2d);
- else if (progress < 60d)
- pylonChance = 99d - Math.Pow(0.2d * progress - 13d, 2d);
- return pylonChance;
- };
- grPylon[0] = new DAV_PylonInfo("Power", Hud.Texture.GetTexture(2350065673), Hud.Sno.SnoPowers.Generic_PagesBuffDamage.Sno); // Power
- grPylon[1] = new DAV_PylonInfo("Speed", Hud.Texture.GetTexture(1927801803), Hud.Sno.SnoPowers.Generic_PagesBuffRunSpeed.Sno); // Speed
- grPylon[2] = new DAV_PylonInfo("Sheild", Hud.Texture.GetTexture(455040081) , Hud.Sno.SnoPowers.Generic_PagesBuffInvulnerable.Sno); // Shield
- grPylon[3] = new DAV_PylonInfo("Channel", Hud.Texture.GetTexture(3254056115), Hud.Sno.SnoPowers.Generic_PagesBuffInfiniteCasting.Sno); // Channeling
- grPylon[4] = new DAV_PylonInfo("Condit", Hud.Texture.GetTexture(1751750314), Hud.Sno.SnoPowers.Generic_PagesBuffElectrifiedTieredRift.Sno); // Condit
- PossiblePylonDecorator_low = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(192, 255, 55, 55, 3),
- ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
- Radius = 5.0f,
- ShapePainter = new CircleShapePainter(Hud),
- },
- new MapLabelDecorator(Hud) {
- LabelFont = Hud.Render.CreateFont("tahoma", 6f, 192, 255, 55, 55, false, false, 128, 0, 0, 0, true),
- RadiusOffset = 5.0f,
- }
- );
- PossiblePylonDecorator_middle = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(192, 255, 255, 55, 3),
- ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
- Radius = 5.0f,
- ShapePainter = new CircleShapePainter(Hud),
- },
- new MapLabelDecorator(Hud) {
- LabelFont = Hud.Render.CreateFont("tahoma", 6f, 192, 255, 255, 55, false, false, 128, 0, 0, 0, true),
- RadiusOffset = 5.0f,
- }
- );
- PossiblePylonDecorator_high = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(192, 55, 255, 55, 3),
- ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
- Radius = 5.0f,
- ShapePainter = new CircleShapePainter(Hud),
- },
- new MapLabelDecorator(Hud) {
- LabelFont = Hud.Render.CreateFont("tahoma", 6f, 192, 55, 255, 55, false, false, 128, 0, 0, 0, true),
- RadiusOffset = 5.0f,
- }
- );
- }
- public void OnNewArea(bool newGame, ISnoArea area) {
- if (newGame)
- PylonClear();
- }
- public void PaintWorld(WorldLayer layer) {
- if (Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
- var percent = Hud.Game.RiftPercentage;
- if (percent <= 0) {
- if (!inGR) {
- PylonClear();
- inGR = true;
- return;
- }
- }
- else inGR = false;
- var ui = Hud.Render.GreaterRiftBarUiElement;
- if (!ui.Visible) return;
- foreach (var actor in Hud.Game.Shrines) {
- var powerRank = -1;
- switch (actor.SnoActor.Sno) {
- case ActorSnoEnum._x1_lr_shrine_damage : powerRank = 0; break;
- case ActorSnoEnum._x1_lr_shrine_run_speed : powerRank = 1; break;
- case ActorSnoEnum._x1_lr_shrine_invulnerable : powerRank = 2; break;
- case ActorSnoEnum._x1_lr_shrine_infinite_casting : powerRank = 3; break;
- case ActorSnoEnum._x1_lr_shrine_electrified_tieredrift : powerRank = 4; break;
- }
- if (powerRank == -1) continue;
- if (actor.IsDisabled || actor.IsOperated) {
- if (grPylon[powerRank].Used(Hud.Game.Me.SnoArea.NameEnglish, percent, PylonNum, preProgress))
- PylonAdd(percent);
- }
- else if (grPylon[powerRank].Add(Hud.Game.Me.SnoArea.NameEnglish, percent, PylonNum, preProgress))
- PylonAdd(percent);
- }
- for (var i = 0; i < 5; i++) {
- if (grPylon[i].state == 2) continue;
- if (Hud.Game.Players.Any(y => y.Powers.BuffIsActive(grPylon[i].sno, 0)))
- if (grPylon[i].Used(Hud.Game.Me.SnoArea.NameEnglish, percent, PylonNum, preProgress))
- PylonAdd(percent);
- }
- var uiRect = ui.Rectangle;
- for (var j = 0; j < 5; j++) {
- if (grPylon[j].state == 0) continue;
- var pylonFont = grPylon[j].state == 2 ? Font_Used : (grPylon[j].area == Hud.Game.Me.SnoArea.NameEnglish ? Font_SameLvl : Font_DiffLvl);
- var layout = pylonFont.GetTextLayout(grPylon[j].getInfo(replaceArea_from, replaceArea_to));
- var size = layout.Metrics.Height;
- var yref = uiRect.Bottom + offsetX + grPylon[j].rank*size;
- grPylon[j].buffIcon.Draw(uiRect.Left, yref, size, size);
- pylonFont.DrawText(layout, uiRect.Left + 1.5f * size, yref);
- size = uiRect.Height / 2;
- var xref = uiRect.Left + (float)(grPylon[j].progress1) * uiRect.Width / 100;
- if (grPylon[j].rank == 1 || grPylon[j].rank == 3)
- yref = uiRect.Top + size;
- else yref = uiRect.Top;
- grPylon[j].buffIcon.Draw(xref, yref, size, size);
- }
- if (PylonNum < 4 && percent < 100) {
- var progressDiff = percent - preProgress;
- var pylonChance = CalcPylon(progressDiff);
- var layout = Font_SameLvl.GetTextLayout(message_percent + " : " + progressDiff.ToString("F1") + "% (" + message_pylonChance + " : " + pylonChance.ToString("F1") + "%)");
- Font_SameLvl.DrawText(layout, uiRect.Left + (uiRect.Width - layout.Metrics.Width) / 2 , uiRect.Bottom + uiRect.Height * 0.2f);
- var PossibleRiftPylonDecorator = pylonChance < pylonChanceLow ? PossiblePylonDecorator_low : (pylonChance < pylonChanceHigh ? PossiblePylonDecorator_middle : PossiblePylonDecorator_high);
- foreach (var actor in Hud.Game.Actors.Where(x1 => x1.SnoActor.Sno == ActorSnoEnum._markerlocation_tieredriftpylon))
- PossibleRiftPylonDecorator.Paint(layer, actor, actor.FloorCoordinate, PossiblePylonMessage + pylonChance.ToString("F1") + "%");
- }
- }
- public void PylonClear() {
- PylonNum = 0;
- preProgress = 0;
- for (var i = 0; i < 5; i++)
- grPylon[i].Clear();
- }
- public void PylonAdd(double curProgress) {
- PylonNum++;
- preProgress = curProgress;
- }
- }
- public class DAV_PylonInfo {
- public string name { get; set; }
- public uint sno { get; set; }
- public int state { get; set; } // 0 no pylon, 1 not used, 2 used
- public int rank { get; set; }
- public string area { get; set; }
- public double progress1 { get; set; }
- public double progress2 { get; set; }
- public ITexture buffIcon { get; set; }
- public DAV_PylonInfo(string desc, ITexture Icon, uint actorSno) {
- name = desc;
- sno = actorSno;
- buffIcon = Icon;
- state = 0;
- }
- public bool Add(string grLvl, double curProgress, int numPylon, double lastProgress) {
- area = grLvl;
- if (state > 0) return false;
- state = 1;
- rank = numPylon;
- progress1 = curProgress;
- progress2 = lastProgress;
- return true;
- }
- public bool Used(string grLvl, double curProgress, int numPylon, double lastProgress) {
- if (state == 2) return false;
- area = grLvl;
- if (state == 0) {
- rank = numPylon;
- progress1 = curProgress;
- progress2 = lastProgress;
- state = 2;
- return true;
- }
- state = 2;
- return false;
- }
- public void Clear() { state = 0; }
- public string getInfo(string A, string B) {
- if (state == 0) return "";
- var message = progress1.ToString("F1") + "%\t" + name + "\t" + area.Replace(A, B);;
- if (rank > 0)
- message += "\t[+" + (progress1 - progress2).ToString("F1") + "%]";
- return message;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement