///////////////////////////////////////////////////////////////////////////////
//
// File   : AVP_Messages_Dropship.cpp
// Author : Sharon Galtzur
// Date   : 23-Sep-2008
//
// Copyright (C) 2008 Rebellion, All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
// Include files...
////////////////////////////////////////////////////////////////////////////////

#include "Core/Asura.h"

// This file's header...
#include "Entity/PhysicalObject/Actor/Vehicles/Dropship/AVP_Messages_Dropship.h"

// Asura independent header-files...
#include "Network/Asura_NetMsg.h"

// Asura platform header-files...

// Game independent header-files...
#include "Entity/AVP_Entity_Classification.h"
#include "Entity/AVP_Messages.h"
#include "Entity/PhysicalObject/Actor/Vehicles/Dropship/AVP_ServerVehicle_Dropship.h"


// Game platform header-files...

// Tools header-files...


////////////////////////////////////////////////////////////////////////////////
// Function     : AVP_Message_DropshipClientUpdate::FillDropship
////////////////////////////////////////////////////////////////////////////////

void AVP_Message_DropshipClientUpdate::FillDropship( const AVP_ServerVehicle_Dropship& xDropship )
{
	// Fill-in the base-class...
    FillActor(xDropship);

	m_bIsLaserOn = xDropship.GetLaserTarget(m_xLaserTarget);
	m_fVelocityFraction = xDropship.GetVeloictyFraction(); 
}

#ifdef ASURA_SUPPORT_NETMSG_SYSTEM
void AVP_Message_DropshipClientUpdate::RegisterFields(u_short usMsgID, u_short usEntityClassification)
{
	Asura_Assert(usMsgID == ASURA_MSG_CLIENTUPDATE, "invalid msg ID");
	Asura_Assert(!Asura_NetMsg::FindNetMsgObject(usMsgID, usEntityClassification), "already exists");
	Asura_Assert(usEntityClassification == AVP_ENTITYCLASS_DROPSHIP, "Unexpected entity classification.");
	
	u_char ucNumFields = GetNumFields();

	Asura_NetMsg* pxNetMsg = new Asura_NetMsg(usMsgID, usEntityClassification, ucNumFields, sizeof(AVP_Message_DropshipClientUpdate));
	RegisterFields(pxNetMsg);
	pxNetMsg->EndRegistration();
}


void AVP_Message_DropshipClientUpdate::RegisterFields(Asura_NetMsg* pxNetMsg)
{
	const AVP_Message_DropshipClientUpdate xDummy;
	AVP_Message_Actor_ClientUpdate::RegisterFields(pxNetMsg);

	Asura_NetMsg_RegisterField(pxNetMsg, xDummy, Asura_FieldType_uchar, m_bIsLaserOn, 1, Asura_Threshold_AnyChange, 0.0f);
	Asura_NetMsg_RegisterField(pxNetMsg, xDummy, Asura_FieldType_vector3, m_xLaserTarget, 1, Asura_Threshold_Magnitude , 0.1f);
	Asura_NetMsg_RegisterField(pxNetMsg, xDummy, Asura_FieldType_float, m_fVelocityFraction, 1, Asura_Threshold_Magnitude , 0.05f);
}

#endif//#ifdef ASURA_SUPPORT_NETMSG_SYSTEM

const char* AVP_Message_DropshipAttackMode::s_aszDropshipAttackMode[DSAM_MODES_COUNT] = 
{
	"None",
	"Machine gun",
	"Missiles",
	"Missiles (Miss)",
	"Machine gun & Missiles"	
};



