//////////////////////////////////////////////////////////////////////////////
//
// AVP_ClientEntity_InteractRetinalScanner.h
//
// Created by AJK 05/01/2009
//
// Copyright (c) 2009 Rebellion. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

#include "Entity/PhysicalObject/Interact/ToolReceptacle/RetinalScanner/AVP_ClientEntity_InteractRetinalScanner.h"

//ASURA
#include "Animation/Asura_AnimationController_Animation.h"
#include "Blueprint/Asura_Blueprint_System.h"
#include "Network/Asura_Message.h"

// AVP
#include "Entity/AVP_Entity_Classification.h"
#include "Entity/PhysicalObject/Actor/AVP_Actor_Messages.h"
#include "Entity/PhysicalObject/Actor/AVP_ClientEntity_Actor.h"
#include "Entity/PhysicalObject/Actor/Vertebrates/Predator/AVP_ServerActor_Predator.h"
#include "Entity/PhysicalObject/Interact/ToolReceptacle/RetinalScanner/AVP_Messages_InteractRetinalScanner.h"

Asura_Hashed_List<AVP_ClientEntity_InteractRetinalScanner> AVP_ClientEntity_InteractRetinalScanner::s_xList;

AVP_ClientEntity_InteractRetinalScanner::AVP_ClientEntity_InteractRetinalScanner()
: m_uPredatorUseHeadHUDAnimID( ASURA_HASH_ID_UNSET )
, m_uPredatorUseHeadTPAnimID ( ASURA_HASH_ID_UNSET )
, m_uVictimBlueprintHashID ( ASURA_HASH_ID_UNSET ) 
, m_uVictimBlueprintType ( ASURA_HASH_ID_UNSET )
{
	Classification = AVP_ENTITYCLASS_INTERACT_RETINAL_SCANNER;

	s_xList.AddToList( this );
}

AVP_ClientEntity_InteractRetinalScanner::~AVP_ClientEntity_InteractRetinalScanner() 
{
	s_xList.RemoveFromList( this );
}

void AVP_ClientEntity_InteractRetinalScanner::Create( const Asura_Message* pxMsg )
{
	Asura_Assert( pxMsg->GetMsgID() == ASURA_MSG_CLIENTCREATE, "" );
	Asura_Assert( pxMsg->GetEntityClassification() == AVP_ENTITYCLASS_INTERACT_RETINAL_SCANNER, "" );

	const AVP_Message_InteractRetinalScanner_ClientCreate* pxData = static_cast< const AVP_Message_InteractRetinalScanner_ClientCreate* >( pxMsg->GetData() );

	AVP_ClientEntity_InteractRetinalScanner* pxNew = new AVP_ClientEntity_InteractRetinalScanner();
	pxNew->ProcessClientCreate(  pxData, pxMsg->GetSentTime(), true );
}

void AVP_ClientEntity_InteractRetinalScanner::ProcessClientCreate( const AVP_Message_InteractRetinalScanner_ClientCreate* pxData, float fServerTime, bool bProcessPosAndOri )
{
	m_uVictimBlueprintHashID = pxData->GetVictimBlueprintHash();
	m_uVictimBlueprintType   = pxData->GetVictimBlueprintType();

	PARENT::ProcessClientCreate(pxData, fServerTime, bProcessPosAndOri);
}

void AVP_ClientEntity_InteractRetinalScanner::GetPredatorUseHeadAnimHashes( Asura_Hash_ID& uHUDAnimHash, Asura_Hash_ID& uTPAnimHash ) const
{
	uHUDAnimHash = m_uPredatorUseHeadHUDAnimID;
	uTPAnimHash  = m_uPredatorUseHeadTPAnimID;
}

void AVP_ClientEntity_InteractRetinalScanner::InitialiseFromBlueprint( const Asura_Blueprint& xBlueprint )
{
	PARENT::InitialiseFromBlueprint( xBlueprint );

	Asura_Value xValue;

	if ( xBlueprint.GetParameterValueByHashID( 0x98F72AC0, xValue ) )	//Asura_GetHashID( "Anim.Interaction.UseHead.Predator.HUD"); 
	{
		m_uPredatorUseHeadHUDAnimID = xValue.GetHashIDValue();
	}
	if ( xBlueprint.GetParameterValueByHashID( 0x788C1B93, xValue ) )	//Asura_GetHashID( "Anim.Interaction.UseHead.Predator.TP"); 
	{
		m_uPredatorUseHeadTPAnimID = xValue.GetHashIDValue();
	}
}

bool AVP_ClientEntity_InteractRetinalScanner::IsActorUsingRightInteractionItem(const AVP_ClientEntity_Actor& xActor) const
{
	return true;
}