Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using SharpDX;
- using SharpDX.Direct2D1;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Extended.Actors
- {
- public class OculusPlugin2 : BasePlugin, ICustomizer, IInGameWorldPainter
- {
- public WorldDecoratorCollection OculusDecorator { get; set; }
- public WorldDecoratorCollection OculusDecoratorMe { get; set; }
- public WorldDecoratorCollection OculusRingMinimap { get; set; }
- public WorldDecoratorCollection OculusRingMinimapMe { get; set; }
- public OculusPlugin2()
- {
- Enabled = true;
- }
- public void Customize()
- {
- Hud.GetPlugin<Default.OculusPlugin>().Enabled = false;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- var circleColor = Color.Gold;
- var regularStyle = DashStyle.Dash;
- var insideStyle = DashStyle.Solid;
- OculusDecorator = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, regularStyle),
- Radius = 10f,
- },
- new GroundLabelDecorator(Hud)
- {
- CountDownFrom = 7f,
- TextFont = Hud.Render.CreateFont("tahoma", 11, 255, 96, 255, 96, true, false, 128, 0, 0, 0, true),
- },
- new GroundTimerDecorator(Hud)
- {
- CountDownFrom = 7f,
- BackgroundBrushEmpty = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
- BackgroundBrushFill = Hud.Render.CreateBrush(200, 0, 192, 0, 0),
- Radius = 30f,
- }
- );
- OculusDecoratorMe = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, insideStyle),
- Radius = 10f,
- },
- new GroundLabelDecorator(Hud)
- {
- CountDownFrom = 7f,
- TextFont = Hud.Render.CreateFont("tahoma", 11, 255, 96, 255, 96, true, false, 128, 0, 0, 0, true),
- },
- new GroundTimerDecorator(Hud)
- {
- CountDownFrom = 7f,
- BackgroundBrushEmpty = Hud.Render.CreateBrush(128, 0, 0, 0, 0),
- BackgroundBrushFill = Hud.Render.CreateBrush(200, 0, 192, 0, 0),
- Radius = 30f,
- }
- );
- OculusRingMinimap = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, regularStyle),
- ShadowBrush = Hud.Render.CreateBrush(48, 0, 0, 0, 1),
- Radius = 10f,
- });
- OculusRingMinimapMe = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, circleColor.R, circleColor.G, circleColor.B, -1f, insideStyle),
- ShadowBrush = Hud.Render.CreateBrush(48, 0, 0, 0, 1),
- Radius = 10f,
- });
- }
- private readonly float oculusDistanceXY = 10f; // Estimate!
- public void PaintWorld(WorldLayer layer)
- {
- if (Hud.Game.IsInTown)
- return;
- var playerCoordinate = (IWorldCoordinate)null;
- if (!Hud.Game.Me.IsDeadSafeCheck)
- {
- var index = 2;
- var buff = Hud.Game.Me.Powers.AllBuffs.FirstOrDefault(x => x.SnoPower.Sno == Hud.Sno.SnoPowers.OculusRing.Sno);
- if (buff != null && buff.IconCounts[index] == 1)
- {
- playerCoordinate = Hud.Game.Me.FloorCoordinate; // I have Oculus buff on!
- }
- }
- 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();
- foreach (var actor in actors)
- {
- if (playerCoordinate != null && (actors.Count == 1 || !(actor.FloorCoordinate.XYDistanceTo(playerCoordinate) > oculusDistanceXY)))
- {
- // Inside circle - must draw at least once because distance is not really exact!
- OculusDecoratorMe.Paint(layer, actor, actor.FloorCoordinate, null);
- OculusRingMinimapMe.Paint(layer, actor, actor.FloorCoordinate, null);
- }
- else
- {
- OculusDecorator.Paint(layer, actor, actor.FloorCoordinate, null);
- OculusRingMinimap.Paint(layer, actor, actor.FloorCoordinate, null);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement