Advertisement
RNNCode

Oculus_Inside

Oct 18th, 2021 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.46 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System.Linq;
  3.  
  4. namespace Turbo.Plugins.RNN
  5. {
  6.     public class Oculus_Inside : BasePlugin, ICustomizer, IInGameWorldPainter
  7.     {
  8.         public WorldDecoratorCollection OculusDecorator { get; set; }
  9.         public WorldDecoratorCollection OculusInsideDecorator { get; set; }
  10.  
  11.         private float _CircleRadius { get; set; } = 10f;
  12.  
  13.         public float CircleRadius
  14.         {
  15.             get { return _CircleRadius; }  
  16.             set
  17.             {
  18.                 if (value == _CircleRadius || value < 10f)   // We will not do anything if the user assigns an invalid value, or if this value matches the current one
  19.                     return;
  20.  
  21.                 _CircleRadius = value;      // We update the value
  22.                 InitDecorators();     // Redefine Decorators
  23.             }
  24.         }      
  25.        
  26.         public Oculus_Inside()
  27.         {
  28.             Enabled = true;        
  29.         }
  30.        
  31.         public override void Load(IController hud)
  32.         {
  33.             base.Load(hud);
  34.  
  35.             CircleRadius = 10f;
  36.         }
  37.  
  38.         public void Customize()
  39.         {
  40.             Hud.TogglePlugin<OculusPlugin>(false);
  41.             InitDecorators();          
  42.         }
  43.        
  44.         private void InitDecorators()
  45.         {
  46.             OculusDecorator = new WorldDecoratorCollection(
  47.                 new GroundCircleDecorator(Hud)
  48.                 {
  49.                     Brush = Hud.Render.CreateBrush(255, 128, 255, 0, -2),
  50.                     Radius = _CircleRadius,
  51.                 },
  52.                 new GroundLabelDecorator(Hud)
  53.                 {
  54.                     CountDownFrom = 7,
  55.                     TextFont = Hud.Render.CreateFont("tahoma", 11, 255, 96, 255, 96, true, false, 128, 0, 0, 0, true),
  56.                 },
  57.                 new GroundTimerDecorator(Hud)
  58.                 {
  59.                     CountDownFrom = 7,
  60.                     BackgroundBrushEmpty = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
  61.                     BackgroundBrushFill = Hud.Render.CreateBrush(200, 0, 192, 0, 0),
  62.                     Radius = 20,
  63.                 },
  64.                 new MapShapeDecorator(Hud)
  65.                 {
  66.                     ShapePainter = new CircleShapePainter(Hud),
  67.                     Brush = Hud.Render.CreateBrush(255, 128, 255, 0, -1f),
  68.                     ShadowBrush = Hud.Render.CreateBrush(35, 255, 255, 255, 1),        
  69.                     Radius = _CircleRadius,
  70.                 }
  71.             );
  72.            
  73.             OculusInsideDecorator = new WorldDecoratorCollection(
  74.                 new GroundCircleDecorator(Hud)
  75.                 {
  76.                     Brush = Hud.Render.CreateBrush(255, 0, 140, 0, -2f, SharpDX.Direct2D1.DashStyle.Dash),
  77.                     Radius = _CircleRadius,
  78.                 },
  79.                 new MapShapeDecorator(Hud)
  80.                 {
  81.                     ShapePainter = new CircleShapePainter(Hud),
  82.                     Brush = Hud.Render.CreateBrush(255, 0, 140, 0, -1f, SharpDX.Direct2D1.DashStyle.Dash),
  83.                     Radius = _CircleRadius,
  84.                 }
  85.             );         
  86.         }  
  87.  
  88.  
  89.        
  90.         public void PaintWorld(WorldLayer layer)
  91.         {
  92.             if (Hud.Game.IsInTown) return;
  93.                
  94.             var actors = Hud.Game.Actors.Where(x => x.SnoActor.Sno == ActorSnoEnum._generic_proxy && x.GetAttributeValueAsInt(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, 402461) == 1);
  95.             if (actors.Any())
  96.             {
  97.                 foreach (var actor in actors)
  98.                 {
  99.                     OculusDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
  100.                 }
  101.                
  102.                 if (Hud.Game.Me.Powers.BuffIsActive(402461, 2))
  103.                 {
  104.                     var actor = actors.OrderBy(d => d.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate)).FirstOrDefault(); // Al menos hay uno, no hace falta comprobar si es != null
  105.                     OculusInsideDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
  106.                 }                                  
  107.             }
  108.         }
  109.     }
  110. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement