/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\mlpackage\Engines\Community Collections\Vesper Museum\Rewards\OrbOfTheMoons.cs
Lines of code: 67
***********************************************************/


using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Commands;
using Server.Spells;
using Server.Regions;
using Server.Spells.Fourth;

namespace Server.Items
{
	public class OrbOfTheMoons : Item
	{
		public override bool ForceShowProperties{ get{ return ObjectPropertyList.Enabled; } }
		
		[Constructable]
		public OrbOfTheMoons() : base(0xF8B)
		{
		    Name = "Orb Of The Moons";
			Movable = true;
			Layer = Layer.Bracelet;
			LootType=LootType.Blessed;
			Hue=2075;
		}

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

		public override void OnDoubleClick( Mobile from )
		{
			if ( !from.Player )return;

			if ( from.InRange( GetWorldLocation(), 1 ) )
			{
			UseGate( from );
			}
			else
				from.SendLocalizedMessage( 500446 ); // That is too far away.
		}


		

		public override bool OnMoveOver( Mobile m )
		{
			// Changed so criminals are not blocked by it.
			if ( m.Player )
				UseGate( m );

			return true;
		}


		public bool UseGate( Mobile m )
		{
			if(RecallSpell.CheckTravel(null,m.Location,m.Map, m,false))
			{
				m.CloseGump( typeof( MoongateGump ) );
				m.SendGump( new MoongateGump( m, this,true ) );

				if ( !m.Hidden || m.AccessLevel == AccessLevel.Player )
					Effects.PlaySound( m.Location, m.Map, 0x20E );

				return true;
			}
			return false;
		}
		
				
		

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); // version
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}

	}
}