/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Red Squirrel on Mar-16-2011 07:06:10pm
Filepath: scripts\Mobiles\Monsters\Misc\Melee\PlagueBeastLord.cs
Lines of code: 470

Description: 

***********************************************************/


using System;
using System.Collections;
using Server.Items;
using Server.Targeting;
using Server.Network;

using System.Diagnostics; //Needed for stopwatch
using System.Threading;



/*Issues and Minor Details:

- Some items in the bag should act as "statics" They are kind of there but should not really be movable. Although
they are set to false for movable, you can still attempt to drag them (Where they will snap back).

*/

namespace Server.Mobiles
{
	[CorpseName( "a plague beast lord corpse" )]
	public class PlagueBeastLord : BaseCreature
	{
		private Timer m_Time; 
		private Stopwatch stopwatch = new Stopwatch();
	
		//Monster life time, once it is opened.
		public virtual double MortalitySeconds
		{
			get{ return 600; }
		}
		
		public static int[] PosX = new int[]
		{
	   	    142,
			198,
			296,
			362,
			345,
 			299
		};
		
		public static int[] PosY = new int[]
		{
	   	    126,
			76,
			82,
			135,
			209,
 			273
		};
		
		public static OrganTypes[] Tipo_Organos;
		
		// Brain type inside each organ (As there are 7 organs in each Plague Beast, 7 possibilities)
		public static BrainTypes[] Color_Cere = new BrainTypes[]
		{
 			BrainTypes.Brain_Blue,
 			BrainTypes.Brain_Green,
 			BrainTypes.Brain_Purple,
 			BrainTypes.Brain_Yellow,
 			BrainTypes.Brain_None, //That means the organ doesn't have brain inside
 			BrainTypes.Brain_None,
 			BrainTypes.Brain_None
		};
		
		public static Point3D[] Recpt_Connectors = new Point3D[]
		{
			new Point3D(57,10,0), //Brain_None
			new Point3D(217,179,0),
			new Point3D(276,179,0),
			new Point3D(217,229,0),
			new Point3D(276,229,0)
		};

		public override bool DeleteCorpseOnDeath
		{
			get
			{
				return m_Frosted;
			}
		}

		private Item m_Central;
		private Item m_Squid; //To notify it when a healthy gland is placed.
		private bool m_Frosted = false;
		private bool m_CutOpen = false;
		public Timer m_FrozenTimer;
		private Mobile m_CutOpenBy;

		private bool[] m_Receptacles = new bool[4] //Correctly placed brains
		{
			false,
			false,
			false,
			false
		};

		[CommandProperty( AccessLevel.GameMaster )]
		public bool Frosted
		{
			get {return m_Frosted;}
			set
			{
				if ( value )
				{
					if ( !m_Frosted )
						stopwatch.Start(); //TIME DEBUG
						m_FrozenTimer = Timer.DelayCall( TimeSpan.FromSeconds( MortalitySeconds / 2 ), TimeSpan.FromSeconds( MortalitySeconds / 2 ), new TimerCallback( OnFrozenTimerTick ) );
					m_Frosted = true;
					Frostplaguebl();
				}
				else if ( m_Frosted )
				{
					m_Frosted = false;
					CutOpen = false; //Reset puzzle if set by a GM
					m_FrozenTimer.Stop(); //Since Frosted BPLs are deleted on Load the frozentimer will always be != null
					DeFrostplaguebl();
				}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public bool CutOpen
		{
			get {return m_CutOpen;}
			set
			{
				if ( value != m_CutOpen )
				{
            		if ( !m_CutOpen )
            		{
            			if ( !Frosted )
            				Frosted = true;
						InitializePuzzle();
            		}
            		else if ( m_CutOpen )
            		{
						Backpack.Delete();
						AddItem( new PlagueBackpack() );
            		}

					m_CutOpen = value;
				}
			}
		}

		[CommandProperty( AccessLevel.GameMaster )]
		public Mobile CutOpenBy
		{
			get {return m_CutOpenBy;}
			set {m_CutOpenBy = value;}
		}

		public override Poison PoisonImmune{ get{ return Poison.Lethal; } }

		[Constructable]
		public PlagueBeastLord() : base( AIType.AI_Melee, FightMode.Closest, 10, 1, 1, 1 )
		{
			//All strings of plague beast stuff are placed in PlagueHelper.cs.
			Name = PlagueHelper.Line[0];

			Body = 775;
			BaseSoundID = 679;
			SpeechHue=38;
			EmoteHue=38;

			SetStr( 500 );
			SetDex( 100 );
			SetInt( 30 );

			SetHits( 1800 );

			SetDamage( 20, 25 );

			SetDamageType( ResistanceType.Physical, 50 );
			SetDamageType( ResistanceType.Fire, 25 );
			SetDamageType( ResistanceType.Poison, 25 );

			SetResistance( ResistanceType.Physical, 45, 55 );
			SetResistance( ResistanceType.Fire, 40, 50 );
			SetResistance( ResistanceType.Cold, 25, 35 );
			SetResistance( ResistanceType.Energy, 25, 35 );
			SetResistance( ResistanceType.Poison, 75, 85 );

			SetSkill( SkillName.Tactics, 100 );
			SetSkill( SkillName.Wrestling, 100 );

			Fame = 2000;
			Karma = -2000;

			VirtualArmor = 50;

			AddItem( new PlagueBackpack() );
		}

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

		///////////////////////////////////////////////////////////////////
		// CreateGuts:
		//  Adds an item to the creature, and place it on a give position p
		///////////////////////////////////////////////////////////////////
		public void CreateGuts( Item t, Point3D p )
		{
			Backpack.AddItem( t );
			t.Location = p;
		}

		public void CreateOrgan( BaseOrgano t, Point3D p )
		{
			CreateGuts( t, p );
			t.CreateTissue();
		}

		///////////////////////////////////////////////////////////////////
		// OpenOrganTo:
		//  Open the creature. Creates the puzzle.
		///////////////////////////////////////////////////////////////////		
		public void InitializePuzzle()
		{
			m_CutOpen = true; //Cannot be opened twice
			
			//Can add as many varients as we want. The random will decide positioning from this list so just
			//concern yourself with organ types (Not their positions in the array). Calamar organ must ALWAYS
			//Be in the list somewhere (As it will show up only once in every Plague Beast Lord)
			switch (Utility.Random( 10 ))
			{	    
				case 0: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar, //Must always be 1. No more, no less. The rest can have 0-5 instances
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;
		
				case 1: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Venas
				};break;
		
				case 2: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;
		
				case 3: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;
		
				case 4: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;
		
				case 5: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;      
				
				case 6: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;
		
				case 7: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Venas
				};break;
		
				case 8: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Venas,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Maiden,
					OrganTypes.Organo_Venas
				};break;
		
				case 9: 		      	
				Tipo_Organos = new OrganTypes[] {
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Calamar,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Pulpo,
					OrganTypes.Organo_Venas
				};break;                
			}

			//Place decorative stuff. Blood Veins, Receptacles
			//Veins
			CreateGuts( new Plague_deco( 8119, PlagueHelper.Line[26], 1166, false, true), new Point3D(120,118,0));
			CreateGuts( new Plague_deco( 7437, PlagueHelper.Line[26], 32, false, true), new Point3D(215,110,0)); 
			CreateGuts( new Plague_deco( 7432, PlagueHelper.Line[26], 32, false, true), new Point3D(110,115,0)); 
			CreateGuts( new Plague_deco( 7435, PlagueHelper.Line[26], 32, false, true), new Point3D(150,110,0));
			CreateGuts( new Plague_deco( 7440, PlagueHelper.Line[26], 32, false, true), new Point3D(315,205,0)); 
			CreateGuts( new Plague_deco( 7435, PlagueHelper.Line[26], 32, false, true), new Point3D(350,180,0)); 
			CreateGuts( new Plague_deco( 8115, PlagueHelper.Line[26], 32, false, true), new Point3D(355,190,0));
			CreateGuts( new Plague_deco( 7434, PlagueHelper.Line[26], 32, false, true), new Point3D(260,100,0)); 
			CreateGuts( new Plague_deco( 7430, PlagueHelper.Line[26], 32, false, true), new Point3D(300,90,0)); 
			CreateGuts( new Plague_deco( 8119, PlagueHelper.Line[26], 1166, false, true), new Point3D(310,73,0));
			CreateGuts( new Plague_deco( 8119, PlagueHelper.Line[26], 1166, false, true), new Point3D(267,185,0)); 
			CreateGuts( new Plague_deco( 8128, PlagueHelper.Line[26], 1166, false, true), new Point3D(290,240,0)); 
			CreateGuts( new Plague_deco( 8106, PlagueHelper.Line[26], 32, false, true), new Point3D(265,270,0)); 
			CreateGuts( new Plague_deco( 7435, PlagueHelper.Line[26], 32, false, true), new Point3D(275,320,0));
			CreateGuts( new Plague_deco( 8110, PlagueHelper.Line[26], 32, false, true), new Point3D(330,110,0)); 
			CreateGuts( new Plague_deco( 6938, PlagueHelper.Line[26], 32, false, true), new Point3D(265,290,0)); 
			CreateGuts( new Plague_deco( 7440, PlagueHelper.Line[26], 32, false, true), new Point3D(330,170,0)); 
			CreateGuts( new Plague_deco( 8116, PlagueHelper.Line[26], 32, false, true), new Point3D(100,180,0)); 
			CreateGuts( new Plague_deco( 6938, PlagueHelper.Line[26], 32, false, true), new Point3D(100,215,0));  
			CreateGuts( new Plague_deco( 6938, PlagueHelper.Line[26], 32, false, true), new Point3D(150,160,0)); 
			CreateGuts( new Plague_deco( 8111, PlagueHelper.Line[26], 32, false, true), new Point3D(145,190,0)); 
			CreateGuts( new Plague_deco( 8111, PlagueHelper.Line[26], 32, false, true), new Point3D(160,110,0));
			CreateGuts( new Plague_deco( 8115, PlagueHelper.Line[26], 32, false, true), new Point3D(100,130,0)); 
			CreateGuts( new Plague_deco( 7437, PlagueHelper.Line[26], 32, false, true), new Point3D(110,150,0)); 
			CreateGuts( new Plague_deco( 7440, PlagueHelper.Line[26], 32, false, true), new Point3D(120,170,0)); 
			CreateGuts( new Plague_deco( 7440, PlagueHelper.Line[40], 32, false, true), new Point3D(260,140,0)); 
			CreateGuts( new Plague_deco( 7414, PlagueHelper.Line[40], 32, false, true), new Point3D(240,140,0)); 
			
			//Red Blotches
			CreateGuts( new Plague_deco( 4523, PlagueHelper.Line[26], 32, false, true), new Point3D(350,140,0)); 
			CreateGuts( new Plague_deco( 4523, PlagueHelper.Line[26], 32, false, true), new Point3D(130,130,0));
			CreateGuts( new Plague_deco( 4523, PlagueHelper.Line[26], 32, false, true), new Point3D(185,90,0));
			
			//Receptacles
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(150,100,0));  
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(105,110,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(90,130,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(90,160,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(160,170,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(155,190,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(90,180,0)); 
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(85,216,0));
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(320,200,0));
			CreateGuts( new Plague_deco( 2535, PlagueHelper.Line[1], 32, false, true), new Point3D(320,95,0));  
			
			//Beating Heart is mostly for decoration and effect
			CreateOrgan( new Organo_Heart(Color_Cere[6]), new Point3D( 240, 116, 0 ) );

			//We place the organs and brains "randomly"
			int position = Utility.RandomMinMax(0,5); //This is offset by one as the calamar organ's position is static
			int color = Utility.RandomMinMax(0,6);
			int type = Utility.RandomMinMax(0,6);
			
			//In order to keep a uniform counter loop, an offset is required to correct the exception caused by the calamar organ.
			//Otherwise, the positions will be messed up (This cancels out any positioning for the calamar organ cause it always remains
			//in the same location)
			int offset = 0;
			
			//Place organs and other useful things
			for ( int i = 0; i < Tipo_Organos.Length; i++ )
			{
				//Depending on what kind of organ we create one of the four possibilities:
				switch (Tipo_Organos[(type + i)%Tipo_Organos.Length])
				{
					case OrganTypes.Organo_Calamar:
					{
						m_Squid = new Organo_Calamar(Color_Cere[(color + i)%Color_Cere.Length]);
						CreateOrgan( (BaseOrgano)m_Squid, new Point3D( 120, 196, 0 ) ); //Always the same position
						offset = -1; //Resets positioning as it does not use the random like the other organs
						break;
					}
					case OrganTypes.Organo_Maiden: CreateOrgan( new Organo_Maiden(Color_Cere[(color + i)%Color_Cere.Length]), 
					new Point3D( PosX[(position +i + offset)%PosX.Length] - 30, PosY[(position +i + offset)%PosY.Length] - 10, 0 )); break;
						
					case OrganTypes.Organo_Pulpo: CreateOrgan( new Organo_Pulpo(Color_Cere[(color + i)%Color_Cere.Length]), 
					new Point3D( PosX[(position +i + offset)%PosX.Length] - 6, PosY[(position +i + offset)%PosY.Length] - 5, 0 )); break;
					
					case OrganTypes.Organo_Venas: CreateOrgan( new Organo_Venas(Color_Cere[(color + i)%Color_Cere.Length]), 
					new Point3D( PosX[(position +i + offset)%PosX.Length], PosY[(position +i + offset)%PosY.Length], 0 )); break;
				}
			}
			
			//Now we create the receptacles near the core
			
			//First, the veins connecting them to the central organ (2 each)
			CreateGuts( new Plague_deco( 8115, PlagueHelper.Line[26], 258, false, true), new Point3D( 201, 176, 0 )); 
			CreateGuts(new Plague_deco( 6939, PlagueHelper.Line[26], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Green], false ,true), Recpt_Connectors[1]);
			    
			CreateGuts( new Plague_deco( 7430, PlagueHelper.Line[26], 383, false, true), new Point3D( 270, 172, 0 )); 
			CreateGuts(new Plague_deco( 6940, PlagueHelper.Line[26], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Blue], false, true), Recpt_Connectors[2]);    
			
			CreateGuts( new Plague_deco( 7440, PlagueHelper.Line[26], 43, false, true), new Point3D( 205, 213, 0 )); 
			CreateGuts(new Plague_deco( 6940, PlagueHelper.Line[26], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Yellow], false, true), Recpt_Connectors[3]);    
			
			CreateGuts( new Plague_deco( 8116, PlagueHelper.Line[26], 194, false, true), new Point3D( 276, 224, 0 )); 
			CreateGuts(new Plague_deco( 6939, PlagueHelper.Line[26], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Purple], false, true), Recpt_Connectors[4]);
 
			//Then, the 4 receptacles.
			CreateGuts(new Plague_deco( 2527, PlagueHelper.Line[1], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Green], false, true), PlagueHelper.BrainSlotPositions[1]);
			CreateGuts(new Plague_deco( 2527, PlagueHelper.Line[1], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Blue], false, true), PlagueHelper.BrainSlotPositions[2]);
			CreateGuts(new Plague_deco( 2527, PlagueHelper.Line[1], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Yellow], false, true), PlagueHelper.BrainSlotPositions[3]);
			CreateGuts(new Plague_deco( 2527, PlagueHelper.Line[1], PlagueHelper.BrainColors[(int)BrainTypes.Brain_Purple], false, true), PlagueHelper.BrainSlotPositions[4]);
			
			//Create the Central organ.
			m_Central = new OrganoCentral();
			CreateOrgan( (BaseOrgano)m_Central, new Point3D( 245, 176, 0 )); //Previously 153
		}

		///////////////////////////////////////////////////////////////////
		// PlaceGlandCheck:
		//   Check it the healthy gland is correctly placed on the squid organ
		// If yes, call the method OnGlandDrop on Organo_Calamar 
		////////////////////////////////////////////////////////////////////
		public void PlaceGlandCheck( Point3D p, Item gland, Mobile from )
		{
			if ( m_Squid.X - 10 <= p.X && p.X <= m_Squid.X + 30 && m_Squid.Y - 10 <= p.Y && p.Y <= m_Squid.Y + 30 )
			{
				Organo_Calamar squid = m_Squid as Organo_Calamar;
				squid.OnGlandDrop( from, gland );
			}
		}

		///////////////////////////////////////////////////////////////////
		// Frostplaguebl:
		//  Freeze the creature
		///////////////////////////////////////////////////////////////////
		public void Frostplaguebl()
		{
			
			//Forget the combatant (avoid that the frozen beast attacks somebody or its changes Direction)
			FightMode=FightMode.None;
			FocusMob = null;
			Combatant = null;
			
			//We freeze the creature
			Frozen = true;
			CantWalk = true; //Set for the Timer
			Hue = 0x480; //Vorpal Blue Hue
			Emote( PlagueHelper.Line[3] );
			//m_Time = Timer.DelayCall( TimeSpan.FromSeconds( 1 ), TimeSpan.FromSeconds( 1 ), new TimerCallback( OnTimerTick ) );
		}
		
		///DEBUG TIME
		/*public void OnTimerTick()
		{
			//PlagueBeastLord plaguebl = RootParent as PlagueBeastLord;
			if ( Deleted || !this.Hidden || this == null || !this.Alive )
			{
				
				Console.Write(m_Time);
				m_Time.Stop();
				return;
			}
		}*/
		
		public override void OnDeath( Container c )
		{
			stopwatch.Stop();
			
			System.Debugger.Write("plaguebeast", "Time elapsed: {0}", stopwatch.Elapsed);

			base.OnDeath( c );
		}

		///////////////////////////////////////////////////////////////////
		// DeFrostplaguebl:
		//  Unfreeze the creature.
		///////////////////////////////////////////////////////////////////
		public void DeFrostplaguebl()
		{
			FightMode = FightMode.Closest;
			Hue = 0;
			Frozen = false;
			CantWalk = false;
			Emote( PlagueHelper.Line[4] );
		}

		///////////////////////////////////////////////////////////////////
		// CoreCheck:
		//	 Used when a brain is moved.
		//  If all brains are correctly placed. The central organ is opened
		///////////////////////////////////////////////////////////////////
		public void CoreCheck( int spot, bool correct )
		{
			m_Receptacles[spot] = correct;
			for ( int i = 0; i < 4; i++ )
			{
				if ( !m_Receptacles[i] ) 
					return; //If any brain isn't correctly placed we exit
			}
			OrganoCentral central = m_Central as OrganoCentral;
			central.OpenOrganTo( this );
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( (CutOpen && m_CutOpenBy == from) || from.AccessLevel > AccessLevel.Player )
				Backpack.DisplayTo( from );
		}

		public override bool CheckNonlocalDrop( Mobile from, Item item, Item target )
		{
			//Only brains and healthy glands can be drop inside it.
			return ( item is PlagueBrain || item is Plague_gland );
		}

		public override bool CheckNonlocalLift( Mobile from, Item item )
		{
			//We always can move things from its backpack
			return true;
		}

		//If he is damaged, it unfreezes
		public override void OnDamage( int amount, Mobile from, bool willKill )
		{
			if ( Frosted && !CutOpen )
				Frosted = false;
			base.OnDamage( amount, from, willKill );
		}

		private void OnFrozenTimerTick()
		{
			if ( !Deleted && Alive )
			{
				if ( !Frosted ) //!Frosted
					m_FrozenTimer.Stop();

				if ( CantWalk )
				{
					if (CutOpen)
						Say(1053036);//The plague beast begins to dissolve
					else
						Say(1053035);//The plague beast burbles incoherently
					CantWalk = false;
				}
				else
				{
					m_FrozenTimer.Stop();
					if (CutOpen)
					{
						Say( PlagueHelper.Line[5] );
						Kill();
					}
					else
						Frosted = false;
				}
			}
			else
				m_FrozenTimer.Stop();
		}

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

			writer.Write( (bool) m_Frosted );
			writer.Write( (Item) m_Central );
			writer.Write( (Item) m_Squid );
		}

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

			if ( version >= 1 )
			{
				m_Frosted = reader.ReadBool();
				m_Central = reader.ReadItem();
				m_Squid = reader.ReadItem();
			}
			
			

			if ( m_Frosted ) //Delete 'frozen' Plague Beast Lords.
			{
				Delete();
			}
		}
	}
}
