using System.Collections.Generic;
using System.Linq;
using Turbo.Plugins.Default;

namespace Turbo.Plugins.User
{
    public class CommandSkeletonsMarkPlugin : BasePlugin, IInGameWorldPainter
    {
        public bool ShowInTown { get; set; }
        public WorldDecoratorCollection PlayerGargs { get; set; }
        public WorldDecoratorCollection OtherPlayersGargs { get; set; }
        public HashSet<uint> GargSno = new HashSet<uint>
        {
            
			//Necromancer
			//Command Skeletons P6_Necro_Trait_SkeletonSpawner ID:453793
			473147, //No Rune
			473428, //Enforcer Rune
			473426, //Frenzy Rune
			473420, //Dark Mending Rune
			473417, //Freezing Grasps Rune
			473418,	//Kill Command Rune
			
			472275, // Skeleton Mage - No Rune
            472588, // Skeleton Mage - Gift of Death
            472769, // Skeleton Mage - Contamination
            472801, // Skeleton Mage - Archer
            472606, // Skeleton Mage - Singularity
            472715  // Skeleton Mage - Life Support
			
        }; 
  
        public CommandSkeletonsMarkPlugin()
        {
            Enabled = true;
        }

        public override void Load(IController hud)
        {
            base.Load(hud);
            ShowInTown = true;

            PlayerGargs = new WorldDecoratorCollection(
                new GroundCircleDecorator(Hud)
                {
                    Brush = Hud.Render.CreateBrush(255, 0, 255, 0, 0),
                    Radius = 0.75f
				},
				new GroundCircleDecorator(Hud)
                {
                    Brush = Hud.Render.CreateBrush(255, 0, 0, 0, 0),
                    Radius = 0.5f
				},
				new GroundCircleDecorator(Hud)
                {
                    Brush = Hud.Render.CreateBrush(255, 255, 255, 255, 0),
                    Radius = 0.25f
                });

            OtherPlayersGargs = new WorldDecoratorCollection(
                new GroundCircleDecorator(Hud)
                {
                    Brush = Hud.Render.CreateBrush(255, 0, 0, 0, 0),
                    Radius = 0.5f
                },
				new GroundCircleDecorator(Hud)
                {
                    Brush = Hud.Render.CreateBrush(255, 255, 255, 255, 0),
                    Radius = 0.25f
                });
				
        }

        public void PaintWorld(WorldLayer layer)
        {
            if (Hud.Game.IsInGame && !(Hud.Game.Me.IsInTown && !ShowInTown))
            {
                var player = Hud.Game.Me;
                var actors = Hud.Game.Actors.Where(a => GargSno.Contains((uint)a.SnoActor.Sno));

                foreach (var actor in actors)
                {
                    if (actor.SummonerAcdDynamicId == player.SummonerId)
                        PlayerGargs.Paint(layer, actor, actor.FloorCoordinate, "");
                    else                
                        OtherPlayersGargs.Paint(layer, actor, actor.FloorCoordinate, "");
                }
            }
        }
    } // class
}