
///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Messages_InteractObject.cpp
// Author : Will Plano
// Date   : 10/06/2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

#include "Entity/PhysicalObject/Interact/AVP_Messages_InteractObject.h"

#include "Core/Asura_Maths.h"
#include "Core/Asura_OrientedVolume.h"
#include "Network/Asura_NetMsg.h"

#include "Entity/PhysicalObject/Interact/AVP_ServerEntity_InteractObject.h"

void AVP_Message_InteractObject_ClientCreate::FillInteractionObject( const AVP_ServerEntity_InteractObject* pxObject )
{
	FillCreatePhysicalObject( pxObject );

	// Any data specific to this class would go here.
	m_uFlags = 0;

	const Asura_OrientedVolume* pxActorVolume = pxObject->GetActorVolume();
	const Asura_OBB* pxOnTargetVolume = pxObject->GetOnTargetVolume();
	const Asura_OBB* pxOffTargetVolume = pxObject->GetOffTargetVolume();
	m_bUseActorVolume = pxActorVolume != NULL;
	m_bUseOnTargetVolume = pxOnTargetVolume != NULL;
	m_bUseOffTargetVolume = pxOffTargetVolume != NULL;

	if ( pxActorVolume )
	{
		m_xActorVolumeMinBound	= pxActorVolume->m_xBox.GetMin();
		m_xActorVolumeMaxBound	= pxActorVolume->m_xBox.GetMax();
		m_xActorVolumeOrient	= pxActorVolume->m_xOrient;
	}

	if ( pxOnTargetVolume )
	{
		m_xOnTargetVolumeHalfExtents	= Asura_Vector_3( pxOnTargetVolume->GetHalfExtents() );
		m_xOnTargetVolumeCenter			= Asura_Vector_3( pxOnTargetVolume->GetCentre() );
		m_xOnTargetVolumeOrient.FromMatrix( pxOnTargetVolume->GetOrientation() );
	}

	if ( pxOffTargetVolume )
	{
		m_xOffTargetVolumeHalfExtents	= Asura_Vector_3( pxOffTargetVolume->GetHalfExtents() );
		m_xOffTargetVolumeCenter		= Asura_Vector_3( pxOffTargetVolume->GetCentre() );
		m_xOffTargetVolumeOrient.FromMatrix( pxOffTargetVolume->GetOrientation() );
	}

	m_bOn				= pxObject->IsOn();
	m_bEnabled			= pxObject->IsEnabled();
	m_bUseByAlien		= pxObject->IsUseByAlien();
	m_bUseByHuman		= pxObject->IsUseByHuman();
	m_bUseByPredator	= pxObject->IsUseByPredator();
}
