//////////////////////////////////////////////////////////////////////////////
//
// File: AVP_ClientEntity_PlayerObjective.cpp
//
//(AJK - 13.10.2008) Created
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
//////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h" 



// This file's header.
#include "Entity/ObjectiveSystem/PlayerObjective/AVP_ClientEntity_PlayerObjective.h"

// AVP
#include "Entity/AVP_Entity_Classification.h"
#include "Entity/ObjectiveSystem/PlayerObjective/AVP_PlayerObjective_Messages.h"


// Statics defintions
Asura_Hashed_List<AVP_ClientEntity_PlayerObjective> AVP_ClientEntity_PlayerObjective::s_xList(2);

AVP_ClientEntity_PlayerObjective::AVP_ClientEntity_PlayerObjective()
: m_xObjectiveText()
, m_uFlags(0)
{
	Classification = AVP_ENTITYCLASS_PLAYER_OBJECTIVE;  
	s_xList.AddToList(this);
}

AVP_ClientEntity_PlayerObjective::~AVP_ClientEntity_PlayerObjective( void ) 
{
	s_xList.RemoveFromList(this);
}

void AVP_ClientEntity_PlayerObjective::Create(const Asura_Message* pxMessage)
{
	if (pxMessage)
	{
		Asura_Assert(pxMessage->GetMsgID()                == ASURA_MSG_CLIENTCREATE, "Invalid message ID.");
		Asura_Assert(pxMessage->GetEntityClassification() == AVP_ENTITYCLASS_PLAYER_OBJECTIVE, "");

		AVP_ClientEntity_PlayerObjective* pxObject = new AVP_ClientEntity_PlayerObjective;
		pxObject->HandleMessage(pxMessage);
	}
}

bool AVP_ClientEntity_PlayerObjective::HandleMessage(const Asura_Message* pxMessage)
{
	if (pxMessage)
	{
		switch(pxMessage->GetMsgID())
		{
			case ASURA_MSG_CLIENTCREATE:
			{
				const AVP_Message_PlayerObjective_ClientCreate* const  pxData = static_cast<const AVP_Message_PlayerObjective_ClientCreate* const>(pxMessage->GetData());
				if (pxData)
				{
					pxData->Extract(this);
				}	
				return true;
			}
		}
	}
	return PARENT::HandleMessage(pxMessage);
}