Advertisement
jarppaaja

OculusPlugin2

Aug 24th, 2019
453
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.32 KB | None | 0 0
  1. using System.Linq;
  2. using SharpDX;
  3. using SharpDX.Direct2D1;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.Extended.Actors
  7. {
  8.     public class OculusPlugin2 : BasePlugin, ICustomizer, IInGameWorldPainter
  9.     {
  10.         public WorldDecoratorCollection OculusDecorator { get; set; }
  11.         public WorldDecoratorCollection OculusDecoratorMe { get; set; }
  12.         public WorldDecoratorCollection OculusRingMinimap { get; set; }
  13.         public WorldDecoratorCollection OculusRingMinimapMe { get; set; }
  14.  
  15.         public OculusPlugin2()
  16.         {
  17.             Enabled = true;
  18.         }
  19.  
  20.         public void Customize()
  21.         {
  22.             Hud.GetPlugin<Default.OculusPlugin>().Enabled = false;
  23.         }
  24.  
  25.         public override void Load(IController hud)
  26.         {
  27.             base.Load(hud);
  28.  
  29.             var circleColor = Color.Gold;
  30.             var regularStyle = DashStyle.Dash;
  31.             var insideStyle = DashStyle.Solid;
  32.             OculusDecorator = new WorldDecoratorCollection(
  33.                  new GroundCircleDecorator(Hud)
  34.                  {
  35.                      Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, regularStyle),
  36.                      Radius = 10f,
  37.                  },
  38.                  new GroundLabelDecorator(Hud)
  39.                  {
  40.                      CountDownFrom = 7f,
  41.                      TextFont = Hud.Render.CreateFont("tahoma", 11, 255, 96, 255, 96, true, false, 128, 0, 0, 0, true),
  42.                  },
  43.                  new GroundTimerDecorator(Hud)
  44.                  {
  45.                      CountDownFrom = 7f,
  46.                      BackgroundBrushEmpty = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
  47.                      BackgroundBrushFill = Hud.Render.CreateBrush(200, 0, 192, 0, 0),
  48.                      Radius = 30f,
  49.                  }
  50.                  );
  51.             OculusDecoratorMe = new WorldDecoratorCollection(
  52.                  new GroundCircleDecorator(Hud)
  53.                  {
  54.                      Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, insideStyle),
  55.                      Radius = 10f,
  56.                  },
  57.                  new GroundLabelDecorator(Hud)
  58.                  {
  59.                      CountDownFrom = 7f,
  60.                      TextFont = Hud.Render.CreateFont("tahoma", 11, 255, 96, 255, 96, true, false, 128, 0, 0, 0, true),
  61.                  },
  62.                  new GroundTimerDecorator(Hud)
  63.                  {
  64.                      CountDownFrom = 7f,
  65.                      BackgroundBrushEmpty = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
  66.                      BackgroundBrushFill = Hud.Render.CreateBrush(200, 0, 192, 0, 0),
  67.                      Radius = 30f,
  68.                  }
  69.                  );
  70.             OculusRingMinimap = new WorldDecoratorCollection(
  71.                  new MapShapeDecorator(Hud)
  72.                  {
  73.                      ShapePainter = new CircleShapePainter(Hud),
  74.                      Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, regularStyle),
  75.                      ShadowBrush = Hud.Render.CreateBrush(48, 0, 0, 0, 1),
  76.                      Radius = 10f,
  77.                  });
  78.             OculusRingMinimapMe = new WorldDecoratorCollection(
  79.                  new MapShapeDecorator(Hud)
  80.                  {
  81.                      ShapePainter = new CircleShapePainter(Hud),
  82.                      Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, insideStyle),
  83.                      ShadowBrush = Hud.Render.CreateBrush(48, 0, 0, 0, 1),
  84.                      Radius = 10f,
  85.                  });
  86.         }
  87.  
  88.         private readonly float oculusDistanceXY = 10f;      // Estimate!
  89.  
  90.         public void PaintWorld(WorldLayer layer)
  91.         {
  92.             if (Hud.Game.IsInTown)
  93.                 return;
  94.  
  95.             var playerCoordinate = (IWorldCoordinate)null;
  96.             if (!Hud.Game.Me.IsDeadSafeCheck)
  97.             {
  98.                 var index = 2;
  99.                 var buff = Hud.Game.Me.Powers.AllBuffs.FirstOrDefault(x => x.SnoPower.Sno == Hud.Sno.SnoPowers.OculusRing.Sno);
  100.                 if (buff != null && buff.IconCounts[index] == 1)
  101.                 {
  102.                     playerCoordinate = Hud.Game.Me.FloorCoordinate;         // I have Oculus buff on!
  103.                 }
  104.             }
  105.             var actors = Hud.Game.Actors.Where(x => x.SnoActor.Sno == ActorSnoEnum._generic_proxy && x.GetAttributeValueAsInt(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, Hud.Sno.SnoPowers.OculusRing.Sno) == 1).ToList();
  106.             foreach (var actor in actors)
  107.             {
  108.                 if (playerCoordinate != null && (actors.Count == 1 || !(actor.FloorCoordinate.XYDistanceTo(playerCoordinate) > oculusDistanceXY)))
  109.                 {
  110.                     // Inside circle - must draw at least once because distance is not really exact!
  111.                     OculusDecoratorMe.Paint(layer, actor, actor.FloorCoordinate, null);
  112.                     OculusRingMinimapMe.Paint(layer, actor, actor.FloorCoordinate, null);
  113.                 }
  114.                 else
  115.                 {
  116.                     OculusDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
  117.                     OculusRingMinimap.Paint(layer, actor, actor.FloorCoordinate, null);
  118.                 }
  119.             }
  120.         }
  121.     }
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement