Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using SharpDX;
- using SharpDX.Direct2D1;
- using System;
- using System.Linq;
- using System.Globalization;
- using System.Collections.Generic;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DAV
- {
- public class DAV_PlayersLifeArcPlugin : BasePlugin, IInGameWorldPainter, ICustomizer {
- public Dictionary<HeroClass, DAV_Hero> Decorator_Hero { get; set; }
- public int Arc_Start { get; set; }
- public int Arc_End { get; set; }
- private bool[] playerIsMale { get; set; }
- private Dictionary<ActorSnoEnum, bool> heroIsMale { get; set; }
- public DAV_PlayersLifeArcPlugin() {
- Enabled = true;
- Order = 2009;
- }
- public void PaintWorld(WorldLayer layer) {
- var players = Hud.Game.Players.Where(x => x.CoordinateKnown && Hud.Game.Me.SnoArea.Sno == x.SnoArea.Sno && x.HeadStone == null);
- foreach(var player in players) {
- if (player.IsOnScreen && player.SnoActor != null)
- playerIsMale[player.PortraitIndex] = heroIsMale[player.SnoActor.Sno];
- Decorator_Hero[player.HeroClassDefinition.HeroClass].Paint(layer, player, playerIsMale[player.PortraitIndex], Arc_Start, Arc_End);
- }
- }
- public override void Load(IController hud) {
- base.Load(hud);
- Arc_Start = -45;
- Arc_End = 180;
- var stdIconSize = Hud.Window.Size.Height * 30 / 1080;
- var stdMapSize = Hud.Window.Size.Height * 20 / 1080;
- var stdPlayerSize = 3.3f;
- // DAV_Hero(Hud, iconMale, iconFemale, playerArcSize, iconSize, iconSizeMap, r, g, b, bg_r = 255, bg_g = 255, bg_b = 255, LabelOffset = 50)
- Decorator_Hero = new Dictionary<HeroClass, DAV_Hero>();
- Decorator_Hero.Add(HeroClass.Barbarian, new DAV_Hero(Hud, 3921484788, 1030273087, stdPlayerSize, stdIconSize, stdMapSize, 255, 128, 64));
- Decorator_Hero.Add(HeroClass.Crusader, new DAV_Hero(Hud, 3742271755, 3435775766, stdPlayerSize, stdIconSize, stdMapSize, 240, 240, 240, 51, 51, 51));
- Decorator_Hero.Add(HeroClass.Monk, new DAV_Hero(Hud, 2227317895, 2918463890, stdPlayerSize, stdIconSize, stdMapSize, 255, 255, 0, 51, 51, 51));
- Decorator_Hero.Add(HeroClass.DemonHunter, new DAV_Hero(Hud, 3785199803, 2939779782, stdPlayerSize, stdIconSize, stdMapSize, 0, 255, 255, 51, 51, 51));
- Decorator_Hero.Add(HeroClass.Necromancer, new DAV_Hero(Hud, 3285997023, 473831658, stdPlayerSize, stdIconSize, stdMapSize, 0, 190, 190));
- Decorator_Hero.Add(HeroClass.WitchDoctor, new DAV_Hero(Hud, 3925954876, 1603231623, stdPlayerSize, stdIconSize, stdMapSize, 0, 255, 0));
- Decorator_Hero.Add(HeroClass.Wizard, new DAV_Hero(Hud, 44435619, 876580014, stdPlayerSize, stdIconSize, stdMapSize, 255, 0, 255));
- playerIsMale = new bool[4] { true, true, true, true };
- heroIsMale = new Dictionary<ActorSnoEnum, bool>() {
- { ActorSnoEnum._barbarian_male, true }, // Male
- { ActorSnoEnum._x1_crusader_male, true },
- { ActorSnoEnum._demonhunter_male, true },
- { ActorSnoEnum._monk_male, true },
- { ActorSnoEnum._p6_necro_male, true },
- { ActorSnoEnum._witchdoctor_male, true },
- { ActorSnoEnum._wizard_male, true },
- { ActorSnoEnum._barbarian_female, false }, // Female
- { ActorSnoEnum._x1_crusader_female, false },
- { ActorSnoEnum._demonhunter_female, false },
- { ActorSnoEnum._monk_female, false },
- { ActorSnoEnum._p6_necro_female, false },
- { ActorSnoEnum._witchdoctor_female, false },
- { ActorSnoEnum._wizard_female, false },
- };
- }
- public void Customize() {
- Hud.TogglePlugin<OtherPlayersPlugin>(false);
- }
- }
- public class DAV_Hero {
- public IController Hud { get; set; }
- public IBrush Brush_BG { get; set; }
- public IBrush Brush_Life { get; set; }
- public IBrush Brush_InnerSan { get; set; }
- public ITexture Hero_male { get; set; }
- public ITexture Hero_female { get; set; }
- public float IconSize { get; set; }
- public float IconSizeMap { get; set; }
- public float LifeArcSize { get; set; }
- public WorldDecoratorCollection HeroDecorator { get; set; }
- public DAV_Hero(IController hud, uint iconMale, uint iconFemale, float playerSize, float iconSize, float mapSize, int r, int g, int b, int bg_r = 51, int bg_g = 51, int bg_b = 51, float offset = 60) {
- Hud = hud;
- IconSize = iconSize;
- IconSizeMap = mapSize;
- LifeArcSize = playerSize;
- Hero_male = Hud.Texture.GetTexture(iconMale);
- Hero_female = Hud.Texture.GetTexture(iconFemale);
- Brush_BG = Hud.Render.CreateBrush(255, bg_r, bg_g, bg_b, 5, DashStyle.Solid, CapStyle.Round, CapStyle.Round);
- Brush_Life = Hud.Render.CreateBrush(255, r, g, b, 2, DashStyle.Solid, CapStyle.Round, CapStyle.Round);
- Brush_InnerSan = Hud.Render.CreateBrush(153, r, g, b, 0);
- HeroDecorator = new WorldDecoratorCollection(
- new GroundLabelDecorator(Hud) {
- BackgroundBrush = Hud.Render.CreateBrush(255, r, g, b, 0),
- BorderBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 1),
- TextFont = Hud.Render.CreateFont("arial", 8f, 255, 0, 0, 0, true, false, 128, 255, 255, 255, true),
- OffsetY = offset,
- },
- new MapLabelDecorator(Hud) {
- LabelFont = Hud.Render.CreateFont("arial", 7f, 255, r, g, b, false, false, true),
- Up = false,
- RadiusOffset = 10
- }
- );
- }
- public void Paint(WorldLayer layer, IPlayer player, bool IsMale, int start, int end) {
- if (!player.IsMe)
- HeroDecorator.Paint(layer, null, player.FloorCoordinate, player.BattleTagAbovePortrait);
- if (player.Powers.BuffIsActive(317076, 1) || player.Powers.BuffIsActive(266254, 0)) {
- var screenCoord = player.FloorCoordinate.ToScreenCoordinate(true);
- var size = IconSize * 0.6f;
- Brush_BG.DrawEllipse(screenCoord.X, screenCoord.Y, size, size, -2);
- Brush_InnerSan.DrawEllipse(screenCoord.X, screenCoord.Y, size, size);
- }
- PaintHeroIcon(player, IsMale);
- PaintLifeArc(player, start, end);
- }
- public void PaintHeroIcon(IPlayer player, bool IsMale) {
- var heroIcon = IsMale ? Hero_male : Hero_female;
- if (heroIcon == null) return;
- Hud.Render.GetMinimapCoordinates(player.FloorCoordinate.X, player.FloorCoordinate.Y, out var mapX, out var mapY);
- heroIcon.Draw(mapX - IconSizeMap / 2, mapY - IconSizeMap / 2, IconSizeMap, IconSizeMap);
- if (player.IsOnScreen) {
- var screenCoord = player.FloorCoordinate.ToScreenCoordinate(true);
- heroIcon.Draw(screenCoord.X - IconSize / 2, screenCoord.Y - IconSize / 2, IconSize, IconSize);
- }
- }
- public void PaintLifeArc(IPlayer player, int Angle_Start, int Angle_End) {
- if (!player.IsOnScreen) return;
- var worldCoord = player.FloorCoordinate;
- var lifeArc = (int)(player.Defense.HealthPct * (Angle_End - Angle_Start) / 100f) + Angle_Start;
- using (var pg1 = Hud.Render.CreateGeometry()) {
- using (var pg2 = Hud.Render.CreateGeometry()) {
- using (var gs1 = pg1.Open()) {
- using (var gs2 = pg2.Open()) {
- var mx = LifeArcSize * (float)Math.Cos(Angle_Start * Math.PI / 180f);
- var my = LifeArcSize * (float)Math.Sin(Angle_Start * Math.PI / 180f);
- var screenCoord = worldCoord.Offset(mx, my, 0).ToScreenCoordinate(true);
- var vector = new Vector2(screenCoord.X, screenCoord.Y);
- gs1.BeginFigure(vector, FigureBegin.Filled); // FigureBegin.Filled , FigureBegin.Hollow
- gs2.BeginFigure(vector, FigureBegin.Filled);
- for (int angle = Angle_Start + 1; angle <= Angle_End; angle++) {
- mx = LifeArcSize * (float)Math.Cos(angle * Math.PI / 180f);
- my = LifeArcSize * (float)Math.Sin(angle * Math.PI / 180f);
- screenCoord = worldCoord.Offset(mx, my, 0).ToScreenCoordinate(true);
- vector = new Vector2(screenCoord.X, screenCoord.Y);
- gs1.AddLine(vector);
- if (angle <= lifeArc)
- gs2.AddLine(vector);
- }
- gs1.EndFigure(FigureEnd.Open);
- gs1.Close();
- gs2.EndFigure(FigureEnd.Open);
- gs2.Close();
- }}
- Brush_BG.DrawGeometry(pg1);
- Brush_Life.DrawGeometry(pg2);
- }}
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement