#pragma once

#include "MW4.hpp"

#include <Adept\Entity.hpp>
#include <Adept\State.hpp>

namespace MechWarrior4
{

	//##########################################################################
	//###########################   NavPoint    ################################
	//##########################################################################

	typedef MWObject__ClassData					NavPoint__ClassData;
	typedef MWObject__Message					NavPoint__Message;
	typedef MWObject__CreateMessage				NavPoint__CreateMessage;
	typedef MWObject__GameModel					NavPoint__GameModel;
	typedef MWObject__ExecutionStateEngine		NavPoint__ExecutionStateEngine;
	

	class NavPoint:
		public MWObject
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Inheritance support
	//
	public:
		typedef NavPoint__ClassData							ClassData;
		typedef NavPoint__GameModel							GameModel;
		typedef NavPoint__Message							Message;
		typedef NavPoint__ExecutionStateEngine				ExecutionStateEngine;
		typedef NavPoint__CreateMessage						CreateMessage;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Static Methods
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		typedef MWObject BaseClass;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Run-time Construction and Destruction Support
	//
	public:
		static NavPoint*
			Make(
				CreateMessage *message,
				ReplicatorID *base_id
			);

	protected:
		NavPoint(
			ClassData *class_data,
			CreateMessage *message,
			ReplicatorID *base_id,
			ElementRenderer::Element *element
		);

		~NavPoint();

		void
			Reuse(
				const CreateMessage *message,
				ReplicatorID *base_id
			);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Flag Support
	//
	public:
		enum
		{
			IsVisibleBit = Entity::NextFlagBit,
			NextFlagBit
		};

		enum
		{
			IsVisibleFlag = 1<<IsVisibleBit
		};

		enum
		{
			DefaultFlags = ~IsVisibleFlag
		};

		bool
			IsVisible()
				{Check_Object(this); return (replicatorFlags&IsVisibleFlag) != 0;}
		void
			SetVisibleFlag()
				{Check_Object(this); replicatorFlags |= IsVisibleFlag;}
		void
			ClearVisibleFlag()
				{Check_Object(this); replicatorFlags &= ~IsVisibleFlag;}
		void
			SaveInstanceText(Stuff::Page *page);

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Shared Data support
	//
	public:
		static ClassData
			*DefaultData;
	

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Simulation Support
	//
	public:
		int GetExecutionSlot();

		void Reveal();

		void AddToNavList();
		void RemoveFromNavList();
		
		void SetToDisplay()
			{Check_Object(this); visualRepresentation=PrestineState; ExecuteComponentWebs();}

		int
			GetTableArray()
				{Check_Object(this); return NameTable::NavArray;}
		static NavPoint
			*GetNextNavPoint();
		static NavPoint
			*GetPreviousNavPoint();

		static Stuff::ChainOf<NavPoint *>
			*s_RevealedNavPoints;
		static Stuff::ChainIteratorOf<NavPoint *>
			*s_RevealedNavPointsIterator;

		static NavPoint
			*s_CurrentNavPoint;

		int m_RadarID;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Test Support
	//
	public:
		void
      		TestInstance() const;
	};
}


