/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\misc\staff\cleanupstone.cs
Lines of code: 156
***********************************************************/


using System;
using Server.Items;
using System.Collections;
using Server.Mobiles;

namespace Server.Items
{
	public class cleanupstone : Item
	{
		private int range=100;

		private bool del_corpse=true;
		private bool del_gold=false;
		private bool del_everything=false;
		private bool del_wildmobiles=false;
		private bool del_allmobiles=false;
		
		[CommandProperty( AccessLevel.GameMaster )] 
		public int deleterange
		{
			get { return range; }
			set 
			{ 
				range = value;	Modify();			
			}
		}
		
		[CommandProperty( AccessLevel.GameMaster )] 
		public bool delete_corpses
		{
			get { return del_corpse; }
			set 
			{ 
				del_corpse = value;	Modify();			
			}
		}

		[CommandProperty( AccessLevel.GameMaster )] 
		public bool delete_gold
		{
			get { return del_gold; }
			set 
			{ 
				del_gold=value;		Modify();		
			}
		}

		[CommandProperty( AccessLevel.GameMaster )] 
		public bool delete_everything
		{
			get { return del_everything; }
			set 
			{ 
				del_everything=value;Modify();				
			}
		}
		
		[CommandProperty( AccessLevel.GameMaster )] 
		public bool delete_mobilesall
		{
			get { return del_allmobiles; }
			set 
			{ 
				del_allmobiles=value;Modify();				
			}
		}

		[CommandProperty( AccessLevel.GameMaster )] 
		public bool delete_mobileswild
		{
			get { return del_wildmobiles; }
			set 
			{ 
				del_wildmobiles=value;	Modify();			
			}
		}		

		
	
		public override string DefaultName
		{
			get { return "Cleanup Stone"; }
		}

		[Constructable]
		public cleanupstone() : base( 0xED4 )
		{
			Movable = false;
			Hue = 252;
		}	
		

		public override void OnDoubleClick( Mobile from )
		{
			if(from.AccessLevel<=AccessLevel.Counselor && !Core.Testcenter)
			{
			from.SendMessage("Only staff can invoke this");
			return;
			}
		
				Map map = from.Map;
				
				//items				
				ArrayList targets = new ArrayList();
				
				if ( map != null )
				{
					IPooledEnumerable eable = map.GetItemsInRange( new Point3D( from.Location ), range );

					foreach ( Item i in eable )
					{
					
						if(del_everything)
						{
						targets.Add(i);
						}
						else
						{
							if ((del_corpse)&&(i is Corpse))	targets.Add( i );
							if ((del_gold)&&(i is Gold))	targets.Add( i );
						}	
						

					}

					eable.Free();
				}
				
				
				for ( int i = 0; i < targets.Count; ++i )
				{
				Item todel = (Item)targets[i];
							
				if(todel is Corpse || todel.Movable==true) todel.Delete();  //corpses are not movable
				}
				
				
				//mobs			-----------------------------------------------------------------
				
				ArrayList mobs = new ArrayList();
				
				if ( map != null )
				{
					IPooledEnumerable eable2 = map.GetMobilesInRange( new Point3D( from.Location ), range );

					foreach ( Mobile i in eable2 )
					{
						if(del_wildmobiles && i is BaseCreature &&  (i as BaseCreature).Controlled==false && (i as BaseCreature).Summoned==false )					
							mobs.Add(i);
						else if(del_allmobiles && i is BaseCreature)
							mobs.Add(i);
					}

					eable2.Free();
				}
				
				
				for ( int i = 0; i < mobs.Count; ++i )
				{
				Mobile m = (Mobile)mobs[i];
					
				m.Delete();	
				}				
				
				
				
				
		
		from.SendMessage("Cleanup Complete");		
		}

		public cleanupstone( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );
			writer.Write( (int) 0 ); // version

			writer.Write((int)range);
			writer.Write((bool)del_corpse);
			writer.Write((bool)del_gold);
			writer.Write((bool)del_everything);
			writer.Write((bool)del_wildmobiles);
			writer.Write((bool)del_allmobiles);
			
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();

			range = reader.ReadInt();			
			del_corpse = reader.ReadBool();
			del_gold = reader.ReadBool();
			del_everything = reader.ReadBool();
			del_wildmobiles =  reader.ReadBool();
			del_allmobiles =  reader.ReadBool();
		}
	}
}