//
// Tools_Attractor_Node.h
//
// Created by JGP 10/05/06
//
// Copyright (C) 2006 Rebellion (Derby), All Rights Reserved.
//

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif

#ifndef __TOOLS_ATTRACTOR_NODE_H__
#define __TOOLS_ATTRACTOR_NODE_H__


// base class
#include "Attractors/Asura_Attractor_Node_Data.h"


/*
	Tools_Attractor_Node

	A single node (vertex) of
	an attractor. Links up the
	attractor it belongs to and
	contains pointers to the next
	and last attractor nodes in
	the attractor.
*/
class Tools_Attractor_Node : public Asura_Attractor_Node_Data
{

public:

	Tools_Attractor_Node( class Tools_Attractor* const pxAttractor );
	~Tools_Attractor_Node();

	void SetPrevAndNext( Tools_Attractor_Node* const pxPrev, Tools_Attractor_Node* const pxNext );
	Tools_Attractor_Node* const GetPrev() { return m_pxPrev; }
	Tools_Attractor_Node* const GetNext() { return m_pxNext; }
	const Tools_Attractor_Node* const GetPrev() const { return m_pxPrev; }
	const Tools_Attractor_Node* const GetNext() const { return m_pxNext; }

	//Gets the previous/next nodes , looping round if needed (if it as a closed attractor)
	const Tools_Attractor_Node* GetPrevLooped() const;
	const Tools_Attractor_Node* GetNextLooped() const;
	

	class Tools_Object_Attractor_Node* const GetToolsNode() { return m_pxToolsNode; }
	class Tools_Object_Attractor_Node* const GetToolsNode() const { return m_pxToolsNode; }
	void SetToolsNode( class Tools_Object_Attractor_Node* const pxToolsNode ) { m_pxToolsNode = pxToolsNode; }

	class Tools_Attractor* GetAttractor() { return reinterpret_cast<class Tools_Attractor* const>( GetAttractorData() ); }
	const class Tools_Attractor* GetAttractor() const { return reinterpret_cast<const class Tools_Attractor* const>( GetAttractorData() ); }

	u_int GetID() const {return m_uID;}
	void SetID(u_int uID) {m_uID = uID;}

	const Asura_Vector_3& GetRelativePosition() const{return m_xRelativePosition;}
	void SetRelativePosition(const Asura_Vector_3& xPosition) {m_xRelativePosition = xPosition;}

	void ApplyChangesForTemplateInstance(class Tools_EntityTemplateInstance* pxInstance);

	virtual void Render() const;

private:

	Tools_Attractor_Node* m_pxPrev;
	Tools_Attractor_Node* m_pxNext;

	//Unique non-zero ID for this node , which in turn gets used to generate the IDs of the compiled attractors.
	u_int m_uID;

	//relative position is used if a parent entity has been assigned to the attractor
	Asura_Vector_3 m_xRelativePosition;

	class Tools_Object_Attractor_Node* m_pxToolsNode;
};


#endif // __TOOLS_ATTRACTOR_NODE_H__
