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


using System;
using System.Xml;
using Server;

namespace Server.Regions
{
	public class DemolishedHouseRegion : BaseRegion
	{
		Mobile m_owner;

		public DemolishedHouseRegion(Mobile owner,Map map,  params Rectangle3D[] area) : base( "", map, Region.DefaultPriority + 2, area )
		{
			m_owner=owner;
			new internaltimer(this).Start();
		}

		public override bool AllowHousing( Mobile from, Point3D p )
		{
			return (from==m_owner || (from.Account!=null && m_owner.Account!=null && from.Account==m_owner.Account));
		}
		
		
		
		private class internaltimer : Timer
		{
			private DemolishedHouseRegion m_owner;
					

			public internaltimer(DemolishedHouseRegion owner ) : base( TimeSpan.FromMinutes( 30 + Utility.Random(30) ) )
			{
				m_owner=owner;

				Priority = TimerPriority.FiveSeconds;
			}

			protected override void OnTick()
			{
				m_owner.Unregister();
				Stop();
			}
		}		
		
	}
}