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


using System;
using Server;
using Server.Mobiles;

namespace Server.Items
{
	public abstract class BaseOrgano : Item
	{
		private bool m_Opened = false;
		private Item m_Brain;
		private BrainTypes m_BrainType;

		[CommandProperty( AccessLevel.GameMaster )]
		public bool IsOpened
		{
			get {return m_Opened;}
			set {m_Opened = value;}
		}

		public Item MyBrain
		{
			get {return m_Brain;}
			set {m_Brain = value;}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public BrainTypes HeldBrainType
		{
			get {return m_BrainType;}
			set {m_BrainType = value;}
		}

		public BaseOrgano( int itemID, string name, int color, BrainTypes brainType ) : base( itemID )
		{
			Name = name;

			m_BrainType = brainType;
			Hue = color;
			Stackable = false;
			Movable = false;
			Weight = 1;
		}

		public virtual void CreateTissue()
		{
		}

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

		public void PutGuts( Item guts, int offSetX, int offSetY )
		{
			Container c = ( Parent as Container );
			c.AddItem( guts );
			guts.Location = new Point3D( X + offSetX, Y + offSetY, 0 );
		}

		public override bool IsAccessibleTo(Mobile check)
		{
			return true;
		}

		public virtual void OpenOrganTo( Mobile from )
		{
			IsOpened = true;
			if ( m_BrainType != BrainTypes.Brain_None )
			{
				MyBrain.Visible = true;
			}
		}

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

			writer.Write( (int) 0 ); // version
			writer.Write( (bool)m_Opened );
			writer.Write( (int)m_BrainType );
			writer.Write( (Item)m_Brain );
		}

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

			int version = reader.ReadInt();
			m_Opened = reader.ReadBool();
			m_BrainType = (BrainTypes)reader.ReadInt();
			m_Brain = reader.ReadItem();

			if ( m_Brain == null )
				Delete();
		}
	}
}
