using System.Linq;
using SharpDX.DirectInput;
using Turbo.Plugins.Default;

namespace Turbo.Plugins.User
{
    public class RangeRound : BasePlugin, IInGameWorldPainter, IKeyEventHandler
    {
        public GroundCircleDecorator Round1 { get; set; }
		public GroundCircleDecorator Round2 { get; set; }
		public IKeyEvent ToggleKeyEvent { get; set; }
		public int on { get; set; }
		
        public RangeRound()
        {
            Enabled = true;
        }
 
        public override void Load(IController hud)
        {
            base.Load(hud);
			on = 0;
			ToggleKeyEvent = Hud.Input.CreateKeyEvent(true, Key.F9, false, false, false);
			
            Round1 = new GroundCircleDecorator(Hud)
            {
                Brush = Hud.Render.CreateBrush(150, 0, 255, 0, 2.0f),
                Radius = 30f
            };
			
			Round2 = new GroundCircleDecorator(Hud)
            {
                Brush = Hud.Render.CreateBrush(150, 0, 255, 0, 2.0f),
                Radius = 24f
            };
		}
			
        public void PaintWorld(WorldLayer layer)
        {
			if (Hud.Game.MapMode != MapMode.Minimap) return;
            if (on==1) Round1.Paint(null, Hud.Game.Me.FloorCoordinate, null);
			else if (on==2) Round2.Paint(null, Hud.Game.Me.FloorCoordinate, null);
        }
		
		public void OnKeyEvent(IKeyEvent keyEvent)
        {
            if (keyEvent.IsPressed && ToggleKeyEvent.Matches(keyEvent))
            {
                on++;
				if (on>2) on = 0;
            }
        }
    }
}